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_
38 * Version of the stack
41 #define NG_BLUETOOTH_VERSION 1
44 * Declare the base of the Bluetooth sysctl hierarchy,
45 * but only if this file cares about sysctl's
49 SYSCTL_DECL(_net_bluetooth);
50 SYSCTL_DECL(_net_bluetooth_hci);
51 SYSCTL_DECL(_net_bluetooth_l2cap);
52 SYSCTL_DECL(_net_bluetooth_rfcomm);
53 #endif /* SYSCTL_DECL */
56 * Mbuf qeueue and useful mbufq macros. We do not use ifqueue because we
57 * do not need mutex and other locking stuff
63 struct mbuf *head; /* first item in the queue */
64 struct mbuf *tail; /* last item in the queue */
65 u_int32_t len; /* number of items in the queue */
66 u_int32_t maxlen; /* maximal number of items in the queue */
67 u_int32_t drops; /* number if dropped items */
69 typedef struct ng_bt_mbufq ng_bt_mbufq_t;
70 typedef struct ng_bt_mbufq * ng_bt_mbufq_p;
72 #define NG_BT_MBUFQ_INIT(q, _maxlen) \
77 (q)->maxlen = (_maxlen); \
81 #define NG_BT_MBUFQ_DESTROY(q) \
83 NG_BT_MBUFQ_DRAIN((q)); \
86 #define NG_BT_MBUFQ_FIRST(q) (q)->head
88 #define NG_BT_MBUFQ_LEN(q) (q)->len
90 #define NG_BT_MBUFQ_FULL(q) ((q)->len >= (q)->maxlen)
92 #define NG_BT_MBUFQ_DROP(q) (q)->drops ++
94 #define NG_BT_MBUFQ_ENQUEUE(q, i) \
96 (i)->m_nextpkt = NULL; \
98 if ((q)->tail == NULL) \
101 (q)->tail->m_nextpkt = (i); \
107 #define NG_BT_MBUFQ_DEQUEUE(q, i) \
111 (q)->head = (q)->head->m_nextpkt; \
112 if ((q)->head == NULL) \
116 (i)->m_nextpkt = NULL; \
120 #define NG_BT_MBUFQ_PREPEND(q, i) \
122 (i)->m_nextpkt = (q)->head; \
123 if ((q)->tail == NULL) \
130 #define NG_BT_MBUFQ_DRAIN(q) \
132 struct mbuf *m = NULL; \
135 NG_BT_MBUFQ_DEQUEUE((q), m); \
144 * Netgraph item queue and useful itemq macros
150 struct ng_item *head; /* first item in the queue */
151 struct ng_item *tail; /* last item in the queue */
152 u_int32_t len; /* number of items in the queue */
153 u_int32_t maxlen; /* maximal number of items in the queue */
154 u_int32_t drops; /* number if dropped items */
156 typedef struct ng_bt_itemq ng_bt_itemq_t;
157 typedef struct ng_bt_itemq * ng_bt_itemq_p;
159 #define NG_BT_ITEMQ_INIT(q, _maxlen) NG_BT_MBUFQ_INIT((q), (_maxlen))
161 #define NG_BT_ITEMQ_DESTROY(q) \
163 NG_BT_ITEMQ_DRAIN((q)); \
166 #define NG_BT_ITEMQ_FIRST(q) NG_BT_MBUFQ_FIRST((q))
168 #define NG_BT_ITEMQ_LEN(q) NG_BT_MBUFQ_LEN((q))
170 #define NG_BT_ITEMQ_FULL(q) NG_BT_MBUFQ_FULL((q))
172 #define NG_BT_ITEMQ_DROP(q) NG_BT_MBUFQ_DROP((q))
174 #define NG_BT_ITEMQ_ENQUEUE(q, i) \
176 (i)->el_next = NULL; \
178 if ((q)->tail == NULL) \
181 (q)->tail->el_next = (i); \
187 #define NG_BT_ITEMQ_DEQUEUE(q, i) \
191 (q)->head = (q)->head->el_next; \
192 if ((q)->head == NULL) \
196 (i)->el_next = NULL; \
200 #define NG_BT_ITEMQ_PREPEND(q, i) \
202 (i)->el_next = (q)->head; \
203 if ((q)->tail == NULL) \
210 #define NG_BT_ITEMQ_DRAIN(q) \
212 struct ng_item *i = NULL; \
215 NG_BT_ITEMQ_DEQUEUE((q), i); \
224 * Get Bluetooth stack sysctl globals
227 u_int32_t bluetooth_hci_command_timeout (void);
228 u_int32_t bluetooth_hci_connect_timeout (void);
229 u_int32_t bluetooth_hci_max_neighbor_age (void);
230 u_int32_t bluetooth_l2cap_rtx_timeout (void);
231 u_int32_t bluetooth_l2cap_ertx_timeout (void);
233 #endif /* _NETGRAPH_BLUETOOTH_H_ */