Annotation of sys/netbt/bluetooth.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: bluetooth.h,v 1.4 2007/05/30 03:42:53 uwe Exp $ */
2: /* $NetBSD: bluetooth.h,v 1.5 2007/04/21 06:15:22 plunky Exp $ */
3:
4: /*-
5: * Copyright (c) 2005 Iain Hibbert.
6: * Copyright (c) 2006 Itronix Inc.
7: * All rights reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. The name of Itronix Inc. may not be used to endorse
18: * or promote products derived from this software without specific
19: * prior written permission.
20: *
21: * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
22: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28: * ON ANY THEORY OF LIABILITY, WHETHER IN
29: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31: * POSSIBILITY OF SUCH DAMAGE.
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: * Bluetooth Address Family Protocol Numbers
42: */
43: #define BTPROTO_HCI 1
44: #define BTPROTO_L2CAP 2
45: #define BTPROTO_RFCOMM 3
46: #define BTPROTO_SCO 4
47:
48: /* All sizes are in bytes */
49: #define BLUETOOTH_BDADDR_SIZE 6
50:
51: /*
52: * Bluetooth device address
53: */
54: typedef struct {
55: uint8_t b[BLUETOOTH_BDADDR_SIZE];
56: } __attribute__ ((packed)) bdaddr_t;
57:
58: /*
59: * bdaddr utility functions
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: * Socket address used by Bluetooth protocols
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: /* Note: this is actually 6 bytes including terminator */
103: #define BDADDR_ANY ((const bdaddr_t *) "\000\000\000\000\000")
104:
105: #ifdef _KERNEL
106:
107: /*
108: * Bluetooth Protocol API callback methods
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: * Debugging stuff
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 (/* CONSTCOND */0)
132:
133: # define DPRINTFN(n, fmt, args...) do { \
134: if (bluetooth_debug > (n)) \
135: printf("%s: "fmt, __func__ , ##args); \
136: } while (/* CONSTCOND */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 /* BLUETOOTH_DEBUG */
145:
146: #endif /* _KERNEL */
147:
148: #endif /* _NETBT_BLUETOOTH_H_ */
CVSweb