1 /* $DragonFly: src/sys/netbt/bluetooth.h,v 1.2 2008/03/18 13:41:42 hasso Exp $ */
2 /* $OpenBSD: src/sys/netbt/bluetooth.h,v 1.5 2008/02/24 21:34:48 uwe Exp $ */
3 /* $NetBSD: bluetooth.h,v 1.6 2007/09/17 01:23:17 rillig Exp $ */
6 * Copyright (c) 2005 Iain Hibbert.
7 * Copyright (c) 2006 Itronix Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of Itronix Inc. may not be used to endorse
19 * or promote products derived from this software without specific
20 * prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _NETBT_BLUETOOTH_H_
36 #define _NETBT_BLUETOOTH_H_
38 #include <sys/socket.h>
39 #include <sys/types.h>
42 * Bluetooth Address Family Protocol Numbers
45 #define BTPROTO_L2CAP 2
46 #define BTPROTO_RFCOMM 3
49 /* All sizes are in bytes */
50 #define BLUETOOTH_BDADDR_SIZE 6
53 * Bluetooth device address
56 uint8_t b
[BLUETOOTH_BDADDR_SIZE
];
57 } __attribute__ ((packed
)) bdaddr_t
;
60 * bdaddr utility functions
63 bdaddr_same(const bdaddr_t
*a
, const bdaddr_t
*b
)
66 return (a
->b
[0] == b
->b
[0] && a
->b
[1] == b
->b
[1]
67 && a
->b
[2] == b
->b
[2] && a
->b
[3] == b
->b
[3]
68 && a
->b
[4] == b
->b
[4] && a
->b
[5] == b
->b
[5]);
72 bdaddr_any(const bdaddr_t
*a
)
75 return (a
->b
[0] == 0 && a
->b
[1] == 0 && a
->b
[2] == 0
76 && a
->b
[3] == 0 && a
->b
[4] == 0 && a
->b
[5] == 0);
80 bdaddr_copy(bdaddr_t
*d
, const bdaddr_t
*s
)
92 * Socket address used by Bluetooth protocols
96 sa_family_t bt_family
;
103 /* Note: this is actually 6 bytes including terminator */
104 #define BDADDR_ANY ((const bdaddr_t *) "\000\000\000\000\000")
107 #include <sys/malloc.h>
110 MALLOC_DECLARE(M_BLUETOOTH
);
113 * Bluetooth Protocol API callback methods
117 void (*connecting
)(void *);
118 void (*connected
)(void *);
119 void (*disconnected
)(void *, int);
120 void *(*newconn
)(void *, struct sockaddr_bt
*, struct sockaddr_bt
*);
121 void (*complete
)(void *, int);
122 void (*linkmode
)(void *, int);
123 void (*input
)(void *, struct mbuf
*);
129 #ifdef BLUETOOTH_DEBUG
130 extern int bluetooth_debug
;
131 # define DPRINTF(fmt, args...) do { \
132 if (bluetooth_debug) \
133 kprintf("%s: "fmt, __func__ , ##args); \
134 } while (/* CONSTCOND */0)
136 # define DPRINTFN(n, fmt, args...) do { \
137 if (bluetooth_debug > (n)) \
138 kprintf("%s: "fmt, __func__ , ##args); \
139 } while (/* CONSTCOND */0)
141 # define UNKNOWN(value) \
142 kprintf("%s: %s = %d unknown!\n", __func__, #value, (value));
144 # define DPRINTF(...) ((void)0)
145 # define DPRINTFN(...) ((void)0)
146 # define UNKNOWN(x) ((void)0)
147 #endif /* BLUETOOTH_DEBUG */
149 #define sbspace(sb) \
150 ((long) imin((int)((sb)->ssb_hiwat - (sb)->ssb_cc), \
151 (int)((sb)->ssb_mbmax - (sb)->ssb_mbcnt)))
154 #define letoh16(x) le16toh(x)
155 #define letoh32(x) le32toh(x)
157 #endif /* _NETBT_BLUETOOTH_H_ */