Merge branch 'master' of /home/nchip/public_html/qemu into garage-push
[qemu] / bt-host.c
index 5d3e840..9a06578 100644 (file)
--- a/bt-host.c
+++ b/bt-host.c
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "qemu-common.h"
 #include "qemu-char.h"
 #include "sysemu.h"
 #include "net.h"
-
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#ifdef CONFIG_BLUEZ
-# include <bluetooth/bluetooth.h>
-# include <bluetooth/hci.h>
-# include <bluetooth/hci_lib.h>
-#else
-# include "hw/bt.h"
-# define HCI_MAX_FRAME_SIZE    1028
-#endif
+#include "bt-host.h"
+
+#ifndef _WIN32
+# include <errno.h>
+# include <sys/ioctl.h>
+# include <sys/uio.h>
+# ifdef CONFIG_BLUEZ
+#  include <bluetooth/bluetooth.h>
+#  include <bluetooth/hci.h>
+#  include <bluetooth/hci_lib.h>
+# else
+#  include "hw/bt.h"
+#  define HCI_MAX_FRAME_SIZE   1028
+# endif
 
 struct bt_host_hci_s {
     struct HCIInfo hci;
@@ -52,7 +53,7 @@ static void bt_host_send(struct HCIInfo *hci,
     struct iovec iv[2];
     int ret;
 
-    iv[0].iov_base = &pkt;
+    iv[0].iov_base = (void *)&pkt;
     iv[0].iov_len  = 1;
     iv[1].iov_base = (void *) data;
     iv[1].iov_len  = len;
@@ -154,7 +155,7 @@ struct HCIInfo *bt_host_hci(const char *id)
 {
     struct bt_host_hci_s *s;
     int fd = -1;
-#ifdef CONFIG_BLUEZ
+# ifdef CONFIG_BLUEZ
     int dev_id = hci_devid(id);
     struct hci_filter flt;
 
@@ -166,15 +167,15 @@ struct HCIInfo *bt_host_hci(const char *id)
     fd = hci_open_dev(dev_id);
 
     /* XXX: can we ensure nobody else has the device opened?  */
-#endif
+# endif
 
     if (fd < 0) {
         fprintf(stderr, "qemu: Can't open `%s': %s (%i)\n",
                         id, strerror(errno), errno);
-        return 0;
+        return NULL;
     }
 
-#ifdef CONFIG_BLUEZ
+# ifdef CONFIG_BLUEZ
     hci_filter_clear(&flt);
     hci_filter_all_ptypes(&flt);
     hci_filter_all_events(&flt);
@@ -183,7 +184,7 @@ struct HCIInfo *bt_host_hci(const char *id)
         fprintf(stderr, "qemu: Can't set HCI filter on socket (%i)\n", errno);
         return 0;
     }
-#endif
+# endif
 
     s = qemu_mallocz(sizeof(struct bt_host_hci_s));
     s->fd = fd;
@@ -192,7 +193,15 @@ struct HCIInfo *bt_host_hci(const char *id)
     s->hci.acl_send = bt_host_acl;
     s->hci.bdaddr_set = bt_host_bdaddr_set;
 
-    qemu_set_fd_handler2(s->fd, bt_host_read_poll, bt_host_read, 0, s);
+    qemu_set_fd_handler2(s->fd, bt_host_read_poll, bt_host_read, NULL, s);
 
     return &s->hci;
 }
+#else
+struct HCIInfo *bt_host_hci(const char *id)
+{
+    fprintf(stderr, "qemu: bluetooth passthrough not supported (yet)\n");
+
+    return 0;
+}
+#endif