6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $Id: ng_bluetooth.h,v 1.4 2003/04/26 22:32:34 max Exp $
34 #ifndef _NETGRAPH_BLUETOOTH_H_
35 #define _NETGRAPH_BLUETOOTH_H_
37 #include <sys/queue.h>
40 * Version of the stack
43 #define NG_BLUETOOTH_VERSION 1
46 * Declare the base of the Bluetooth sysctl hierarchy,
47 * but only if this file cares about sysctl's
51 SYSCTL_DECL(_net_bluetooth);
52 SYSCTL_DECL(_net_bluetooth_hci);
53 SYSCTL_DECL(_net_bluetooth_l2cap);
54 SYSCTL_DECL(_net_bluetooth_rfcomm);
55 SYSCTL_DECL(_net_bluetooth_sco);
56 #endif /* SYSCTL_DECL */
59 * Mbuf qeueue and useful mbufq macros. We do not use ifqueue because we
60 * do not need mutex and other locking stuff
66 struct mbuf *head; /* first item in the queue */
67 struct mbuf *tail; /* last item in the queue */
68 u_int32_t len; /* number of items in the queue */
69 u_int32_t maxlen; /* maximal number of items in the queue */
70 u_int32_t drops; /* number if dropped items */
72 typedef struct ng_bt_mbufq ng_bt_mbufq_t;
73 typedef struct ng_bt_mbufq * ng_bt_mbufq_p;
75 #define NG_BT_MBUFQ_INIT(q, _maxlen) \
80 (q)->maxlen = (_maxlen); \
84 #define NG_BT_MBUFQ_DESTROY(q) \
86 NG_BT_MBUFQ_DRAIN((q)); \
89 #define NG_BT_MBUFQ_FIRST(q) (q)->head
91 #define NG_BT_MBUFQ_LEN(q) (q)->len
93 #define NG_BT_MBUFQ_FULL(q) ((q)->len >= (q)->maxlen)
95 #define NG_BT_MBUFQ_DROP(q) (q)->drops ++
97 #define NG_BT_MBUFQ_ENQUEUE(q, i) \
99 (i)->m_nextpkt = NULL; \
101 if ((q)->tail == NULL) \
104 (q)->tail->m_nextpkt = (i); \
110 #define NG_BT_MBUFQ_DEQUEUE(q, i) \
114 (q)->head = (q)->head->m_nextpkt; \
115 if ((q)->head == NULL) \
119 (i)->m_nextpkt = NULL; \
123 #define NG_BT_MBUFQ_PREPEND(q, i) \
125 (i)->m_nextpkt = (q)->head; \
126 if ((q)->tail == NULL) \
133 #define NG_BT_MBUFQ_DRAIN(q) \
135 struct mbuf *m = NULL; \
138 NG_BT_MBUFQ_DEQUEUE((q), m); \
147 * Netgraph item queue and useful itemq macros
153 STAILQ_HEAD(, ng_item) queue; /* actually items queue */
154 u_int32_t len; /* number of items in the queue */
155 u_int32_t maxlen; /* maximal number of items in the queue */
156 u_int32_t drops; /* number if dropped items */
158 typedef struct ng_bt_itemq ng_bt_itemq_t;
159 typedef struct ng_bt_itemq * ng_bt_itemq_p;
161 #define NG_BT_ITEMQ_INIT(q, _maxlen) \
163 STAILQ_INIT(&(q)->queue); \
165 (q)->maxlen = (_maxlen); \
169 #define NG_BT_ITEMQ_DESTROY(q) \
171 NG_BT_ITEMQ_DRAIN((q)); \
174 #define NG_BT_ITEMQ_FIRST(q) STAILQ_FIRST(&(q)->queue)
176 #define NG_BT_ITEMQ_LEN(q) NG_BT_MBUFQ_LEN((q))
178 #define NG_BT_ITEMQ_FULL(q) NG_BT_MBUFQ_FULL((q))
180 #define NG_BT_ITEMQ_DROP(q) NG_BT_MBUFQ_DROP((q))
182 #define NG_BT_ITEMQ_ENQUEUE(q, i) \
184 STAILQ_INSERT_TAIL(&(q)->queue, (i), el_next); \
188 #define NG_BT_ITEMQ_DEQUEUE(q, i) \
190 (i) = STAILQ_FIRST(&(q)->queue); \
192 STAILQ_REMOVE_HEAD(&(q)->queue, el_next); \
197 #define NG_BT_ITEMQ_PREPEND(q, i) \
199 STAILQ_INSERT_HEAD(&(q)->queue, (i), el_next); \
203 #define NG_BT_ITEMQ_DRAIN(q) \
205 struct ng_item *i = NULL; \
208 NG_BT_ITEMQ_DEQUEUE((q), i); \
217 * Get Bluetooth stack sysctl globals
220 u_int32_t bluetooth_hci_command_timeout (void);
221 u_int32_t bluetooth_hci_connect_timeout (void);
222 u_int32_t bluetooth_hci_max_neighbor_age (void);
223 u_int32_t bluetooth_l2cap_rtx_timeout (void);
224 u_int32_t bluetooth_l2cap_ertx_timeout (void);
225 u_int32_t bluetooth_sco_rtx_timeout (void);
227 #define BDADDR_BREDR 0
228 #define BDADDR_LE_PUBLIC 1
229 #define BDADDR_LE_RANDOM 2
231 #endif /* _NETGRAPH_BLUETOOTH_H_ */