6 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
8 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * $Id: ng_bluetooth.h,v 1.4 2003/04/26 22:32:34 max Exp $
36 #ifndef _NETGRAPH_BLUETOOTH_H_
37 #define _NETGRAPH_BLUETOOTH_H_
39 #include <sys/queue.h>
42 * Version of the stack
45 #define NG_BLUETOOTH_VERSION 1
48 * Declare the base of the Bluetooth sysctl hierarchy,
49 * but only if this file cares about sysctl's
53 SYSCTL_DECL(_net_bluetooth);
54 SYSCTL_DECL(_net_bluetooth_hci);
55 SYSCTL_DECL(_net_bluetooth_l2cap);
56 SYSCTL_DECL(_net_bluetooth_rfcomm);
57 SYSCTL_DECL(_net_bluetooth_sco);
58 #endif /* SYSCTL_DECL */
61 * Mbuf qeueue and useful mbufq macros. We do not use ifqueue because we
62 * do not need mutex and other locking stuff
68 struct mbuf *head; /* first item in the queue */
69 struct mbuf *tail; /* last item in the queue */
70 u_int32_t len; /* number of items in the queue */
71 u_int32_t maxlen; /* maximal number of items in the queue */
72 u_int32_t drops; /* number if dropped items */
74 typedef struct ng_bt_mbufq ng_bt_mbufq_t;
75 typedef struct ng_bt_mbufq * ng_bt_mbufq_p;
77 #define NG_BT_MBUFQ_INIT(q, _maxlen) \
82 (q)->maxlen = (_maxlen); \
86 #define NG_BT_MBUFQ_DESTROY(q) \
88 NG_BT_MBUFQ_DRAIN((q)); \
91 #define NG_BT_MBUFQ_FIRST(q) (q)->head
93 #define NG_BT_MBUFQ_LEN(q) (q)->len
95 #define NG_BT_MBUFQ_FULL(q) ((q)->len >= (q)->maxlen)
97 #define NG_BT_MBUFQ_DROP(q) (q)->drops ++
99 #define NG_BT_MBUFQ_ENQUEUE(q, i) \
101 (i)->m_nextpkt = NULL; \
103 if ((q)->tail == NULL) \
106 (q)->tail->m_nextpkt = (i); \
112 #define NG_BT_MBUFQ_DEQUEUE(q, i) \
116 (q)->head = (q)->head->m_nextpkt; \
117 if ((q)->head == NULL) \
121 (i)->m_nextpkt = NULL; \
125 #define NG_BT_MBUFQ_PREPEND(q, i) \
127 (i)->m_nextpkt = (q)->head; \
128 if ((q)->tail == NULL) \
135 #define NG_BT_MBUFQ_DRAIN(q) \
137 struct mbuf *m = NULL; \
140 NG_BT_MBUFQ_DEQUEUE((q), m); \
149 * Netgraph item queue and useful itemq macros
155 STAILQ_HEAD(, ng_item) queue; /* actually items queue */
156 u_int32_t len; /* number of items in the queue */
157 u_int32_t maxlen; /* maximal number of items in the queue */
158 u_int32_t drops; /* number if dropped items */
160 typedef struct ng_bt_itemq ng_bt_itemq_t;
161 typedef struct ng_bt_itemq * ng_bt_itemq_p;
163 #define NG_BT_ITEMQ_INIT(q, _maxlen) \
165 STAILQ_INIT(&(q)->queue); \
167 (q)->maxlen = (_maxlen); \
171 #define NG_BT_ITEMQ_DESTROY(q) \
173 NG_BT_ITEMQ_DRAIN((q)); \
176 #define NG_BT_ITEMQ_FIRST(q) STAILQ_FIRST(&(q)->queue)
178 #define NG_BT_ITEMQ_LEN(q) NG_BT_MBUFQ_LEN((q))
180 #define NG_BT_ITEMQ_FULL(q) NG_BT_MBUFQ_FULL((q))
182 #define NG_BT_ITEMQ_DROP(q) NG_BT_MBUFQ_DROP((q))
184 #define NG_BT_ITEMQ_ENQUEUE(q, i) \
186 STAILQ_INSERT_TAIL(&(q)->queue, (i), el_next); \
190 #define NG_BT_ITEMQ_DEQUEUE(q, i) \
192 (i) = STAILQ_FIRST(&(q)->queue); \
194 STAILQ_REMOVE_HEAD(&(q)->queue, el_next); \
199 #define NG_BT_ITEMQ_PREPEND(q, i) \
201 STAILQ_INSERT_HEAD(&(q)->queue, (i), el_next); \
205 #define NG_BT_ITEMQ_DRAIN(q) \
207 struct ng_item *i = NULL; \
210 NG_BT_ITEMQ_DEQUEUE((q), i); \
219 * Get Bluetooth stack sysctl globals
222 u_int32_t bluetooth_hci_command_timeout (void);
223 u_int32_t bluetooth_hci_connect_timeout (void);
224 u_int32_t bluetooth_hci_max_neighbor_age (void);
225 u_int32_t bluetooth_l2cap_rtx_timeout (void);
226 u_int32_t bluetooth_l2cap_ertx_timeout (void);
227 u_int32_t bluetooth_sco_rtx_timeout (void);
229 #define BDADDR_BREDR 0
230 #define BDADDR_LE_PUBLIC 1
231 #define BDADDR_LE_RANDOM 2
233 #endif /* _NETGRAPH_BLUETOOTH_H_ */