This source file includes following definitions.
- bdaddr_t
- bdaddr_same
- bdaddr_any
- bdaddr_copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _NETBT_BLUETOOTH_H_
35 #define _NETBT_BLUETOOTH_H_
36
37 #include <sys/socket.h>
38 #include <sys/types.h>
39
40
41
42
43 #define BTPROTO_HCI 1
44 #define BTPROTO_L2CAP 2
45 #define BTPROTO_RFCOMM 3
46 #define BTPROTO_SCO 4
47
48
49 #define BLUETOOTH_BDADDR_SIZE 6
50
51
52
53
54 typedef struct {
55 uint8_t b[BLUETOOTH_BDADDR_SIZE];
56 } __attribute__ ((packed)) bdaddr_t;
57
58
59
60
61 static __inline int
62 bdaddr_same(const bdaddr_t *a, const bdaddr_t *b)
63 {
64
65 return (a->b[0] == b->b[0] && a->b[1] == b->b[1]
66 && a->b[2] == b->b[2] && a->b[3] == b->b[3]
67 && a->b[4] == b->b[4] && a->b[5] == b->b[5]);
68 }
69
70 static __inline int
71 bdaddr_any(const bdaddr_t *a)
72 {
73
74 return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0
75 && a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0);
76 }
77
78 static __inline void
79 bdaddr_copy(bdaddr_t *d, const bdaddr_t *s)
80 {
81
82 d->b[0] = s->b[0];
83 d->b[1] = s->b[1];
84 d->b[2] = s->b[2];
85 d->b[3] = s->b[3];
86 d->b[4] = s->b[4];
87 d->b[5] = s->b[5];
88 }
89
90
91
92
93 struct sockaddr_bt {
94 uint8_t bt_len;
95 sa_family_t bt_family;
96 bdaddr_t bt_bdaddr;
97 uint16_t bt_psm;
98 uint8_t bt_channel;
99 uint8_t bt_zero[5];
100 };
101
102
103 #define BDADDR_ANY ((const bdaddr_t *) "\000\000\000\000\000")
104
105 #ifdef _KERNEL
106
107
108
109
110 struct mbuf;
111 struct btproto {
112 void (*connecting)(void *);
113 void (*connected)(void *);
114 void (*disconnected)(void *, int);
115 void *(*newconn)(void *, struct sockaddr_bt *, struct sockaddr_bt *);
116 void (*complete)(void *, int);
117 void (*linkmode)(void *, int);
118 void (*input)(void *, struct mbuf *);
119 };
120
121
122
123
124
125 #define BLUETOOTH_DEBUG
126 #ifdef BLUETOOTH_DEBUG
127 extern int bluetooth_debug;
128 # define DPRINTF(fmt, args...) do { \
129 if (bluetooth_debug) \
130 printf("%s: "fmt, __func__ , ##args); \
131 } while (0)
132
133 # define DPRINTFN(n, fmt, args...) do { \
134 if (bluetooth_debug > (n)) \
135 printf("%s: "fmt, __func__ , ##args); \
136 } while (0)
137
138 # define UNKNOWN(value) \
139 printf("%s: %s = %d unknown!\n", __func__, #value, (value));
140 #else
141 # define DPRINTF(...)
142 # define DPRINTFN(...)
143 # define UNKNOWN(x)
144 #endif
145
146 #endif
147
148 #endif