Add support for the HCIINQUIRY ioctl.
authortom <tom@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 7 Mar 2012 11:22:42 +0000 (11:22 +0000)
committertom <tom@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Wed, 7 Mar 2012 11:22:42 +0000 (11:22 +0000)
Patch from Andrew Brampton to fix BZ#283961.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12421 a5019735-40e9-0310-863c-91ae7b9d1cf9

coregrind/m_syswrap/syswrap-linux.c
include/vki/vki-linux.h

index e8fe844f73e1334d4ca20c2f9743274fa7256c90..2d62343de3e2fca533d01ab498ef256c3d076a6b 100644 (file)
@@ -5374,6 +5374,17 @@ PRE(sys_ioctl)
        break;
 #  endif /* defined(VGPV_arm_linux_android) */
 
+   case VKI_HCIINQUIRY:
+      if (ARG3) {
+         struct vki_hci_inquiry_req* ir = (struct vki_hci_inquiry_req*)ARG3;
+         PRE_MEM_READ("ioctl(HCIINQUIRY)",
+                      (Addr)ARG3, sizeof(struct vki_hci_inquiry_req));
+         PRE_MEM_WRITE("ioctl(HCIINQUIRY)",
+                       (Addr)ARG3 + sizeof(struct vki_hci_inquiry_req),
+                       ir->num_rsp * sizeof(struct vki_inquiry_info));
+      }
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
@@ -6348,6 +6359,14 @@ POST(sys_ioctl)
        break;
 #  endif /* defined(VGPV_arm_linux_android) */
 
+   case VKI_HCIINQUIRY:
+      if (ARG3) {
+        struct vki_hci_inquiry_req* ir = (struct vki_hci_inquiry_req*)ARG3;
+        POST_MEM_WRITE((Addr)ARG3 + sizeof(struct vki_hci_inquiry_req),
+                       ir->num_rsp * sizeof(struct vki_inquiry_info));
+      }
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
index cf0da7c2bde3c6b8b6f835af0332f90e4d84735c..f5d16c2c06acf6b77fbca66dd783ccc8a42f7799 100644 (file)
@@ -129,6 +129,14 @@ template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
 
 # define __user
 
+//----------------------------------------------------------------------
+// From linux/include/linux/compiler-gcc.h
+//----------------------------------------------------------------------
+
+#ifdef __GNUC__
+#define __vki_packed                   __attribute__((packed))
+#endif
+
 //----------------------------------------------------------------------
 // From linux-2.6.8.1/include/linux/posix_types.h
 //----------------------------------------------------------------------
@@ -218,6 +226,8 @@ typedef             __vki_u8        vki_uint8_t;
 typedef                __vki_u16       vki_uint16_t;
 typedef                __vki_u32       vki_uint32_t;
 
+typedef                __vki_u16       __vki_le16;
+
 //----------------------------------------------------------------------
 // From linux-2.6.8.1/include/linux/limits.h
 //----------------------------------------------------------------------
@@ -2881,6 +2891,61 @@ struct vki_binder_version {
 
 #endif /* defined(VGPV_arm_linux_android) */
 
+//----------------------------------------------------------------------
+// From linux-3.0.4/include/net/bluetooth/bluetooth.h
+//----------------------------------------------------------------------
+
+typedef struct {
+   __vki_u8 b[6];
+} __vki_packed vki_bdaddr_t;
+
+//----------------------------------------------------------------------
+// From linux-3.0.4/include/net/bluetooth/hci.h
+//----------------------------------------------------------------------
+
+#define VKI_HCIDEVUP        _VKI_IOW('H', 201, int)
+#define VKI_HCIDEVDOWN      _VKI_IOW('H', 202, int)
+#define VKI_HCIDEVRESET     _VKI_IOW('H', 203, int)
+#define VKI_HCIDEVRESTAT    _VKI_IOW('H', 204, int)
+
+#define VKI_HCIGETDEVLIST   _VKI_IOR('H', 210, int)
+#define VKI_HCIGETDEVINFO   _VKI_IOR('H', 211, int)
+#define VKI_HCIGETCONNLIST  _VKI_IOR('H', 212, int)
+#define VKI_HCIGETCONNINFO  _VKI_IOR('H', 213, int)
+#define VKI_HCIGETAUTHINFO  _VKI_IOR('H', 215, int)
+
+#define VKI_HCISETRAW       _VKI_IOW('H', 220, int)
+#define VKI_HCISETSCAN      _VKI_IOW('H', 221, int)
+#define VKI_HCISETAUTH      _VKI_IOW('H', 222, int)
+#define VKI_HCISETENCRYPT   _VKI_IOW('H', 223, int)
+#define VKI_HCISETPTYPE     _VKI_IOW('H', 224, int)
+#define VKI_HCISETLINKPOL   _VKI_IOW('H', 225, int)
+#define VKI_HCISETLINKMODE  _VKI_IOW('H', 226, int)
+#define VKI_HCISETACLMTU    _VKI_IOW('H', 227, int)
+#define VKI_HCISETSCOMTU    _VKI_IOW('H', 228, int)
+
+#define VKI_HCIBLOCKADDR    _VKI_IOW('H', 230, int)
+#define VKI_HCIUNBLOCKADDR  _VKI_IOW('H', 231, int)
+
+#define VKI_HCIINQUIRY      _VKI_IOR('H', 240, int)
+
+struct vki_inquiry_info {
+   vki_bdaddr_t bdaddr;
+   __vki_u8     pscan_rep_mode;
+   __vki_u8     pscan_period_mode;
+   __vki_u8     pscan_mode;
+   __vki_u8     dev_class[3];
+   __vki_le16   clock_offset;
+} __vki_packed;
+
+struct vki_hci_inquiry_req {
+   __vki_u16 dev_id;
+   __vki_u16 flags;
+   __vki_u8  lap[3];
+   __vki_u8  length;
+   __vki_u8  num_rsp;
+};
+
 #endif // __VKI_LINUX_H
 
 /*--------------------------------------------------------------------*/