5 #include <sys/socket.h>
6 #include "../../memcheck.h"
8 /* user space headers might not be there, define things ourselves. */
11 } __attribute__((packed
)) vui_bdaddr_t
;
13 struct vui_sockaddr_rc
{
14 sa_family_t rc_family
;
15 vui_bdaddr_t rc_bdaddr
;
19 #define VUI_AF_BLUETOOTH 31
20 #define VUI_BTPROTO_RFCOMM 3
22 #define VUI_BDADDR_ANY (&(vui_bdaddr_t) {{0, 0, 0, 0, 0, 0}})
25 main (int argc
, char **argv
)
29 nSocket
= socket(VUI_AF_BLUETOOTH
, SOCK_STREAM
, VUI_BTPROTO_RFCOMM
);
33 // Not supported, nothing to test...
37 struct vui_sockaddr_rc aAddr
;
39 // Store correct values in aAddr but marking it undefined
40 // so as to generate errors. We need to have deterministic
41 // undefined values to have a reproducible test.
42 aAddr
.rc_family
= VUI_AF_BLUETOOTH
;
43 aAddr
.rc_bdaddr
= *VUI_BDADDR_ANY
;
45 VALGRIND_MAKE_MEM_UNDEFINED(&aAddr
, sizeof(aAddr
));
46 // We re-assign below each piece one by one, so as to
47 // have the piece marked initialised.
50 // Ignore return values.
52 // Everything uninit (family, ...)
53 bind(nSocket
, (struct sockaddr
*) &aAddr
, sizeof(aAddr
));
55 // Same but with an unknown family (we hope :)
56 aAddr
.rc_family
= 12345;
57 // (reset everything to uninit)
58 VALGRIND_MAKE_MEM_UNDEFINED(&aAddr
, sizeof(aAddr
));
59 bind(nSocket
, (struct sockaddr
*) &aAddr
, sizeof(aAddr
));
61 aAddr
.rc_family
= VUI_AF_BLUETOOTH
;
62 // uninit bdaddr and channel.
63 bind(nSocket
, (struct sockaddr
*) &aAddr
, sizeof(aAddr
));
65 aAddr
.rc_bdaddr
= *VUI_BDADDR_ANY
;
67 bind(nSocket
, (struct sockaddr
*) &aAddr
, sizeof(aAddr
));
70 // Everything correctly init.
71 bind(nSocket
, (struct sockaddr
*) &aAddr
, sizeof(aAddr
));