From: Tom Hughes Date: Wed, 7 Mar 2012 11:22:42 +0000 (+0000) Subject: Add support for the HCIINQUIRY ioctl. X-Git-Tag: svn/VALGRIND_3_8_0~432 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e1da9ff3890c7fd032bb0c559ff9333f47f6373;p=thirdparty%2Fvalgrind.git Add support for the HCIINQUIRY ioctl. Patch from Andrew Brampton to fix BZ#283961. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12421 --- diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index e8fe844f73..2d62343de3 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -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)) { diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index cf0da7c2bd..f5d16c2c06 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -129,6 +129,14 @@ template 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 /*--------------------------------------------------------------------*/