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.c,v 1.3 2003/04/26 22:37:31 max Exp $
31 * $FreeBSD: src/sys/netgraph/bluetooth/common/ng_bluetooth.c,v 1.7 2007/06/04 18:25:07 dwmalone Exp $
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/errno.h>
37 #include <sys/kernel.h>
38 #include <sys/module.h>
39 #include <sys/sysctl.h>
41 #include <netgraph/bluetooth/include/ng_bluetooth.h>
44 * Bluetooth stack sysctl globals
47 static u_int32_t bluetooth_hci_command_timeout_value = 5; /* sec */
48 static u_int32_t bluetooth_hci_connect_timeout_value = 60; /* sec */
49 static u_int32_t bluetooth_hci_max_neighbor_age_value = 600; /* sec */
50 static u_int32_t bluetooth_l2cap_rtx_timeout_value = 60; /* sec */
51 static u_int32_t bluetooth_l2cap_ertx_timeout_value = 300; /* sec */
54 * Define sysctl tree that shared by other parts of Bluetooth stack
57 SYSCTL_NODE(_net, OID_AUTO, bluetooth, CTLFLAG_RW, 0, "Bluetooth family");
58 SYSCTL_INT(_net_bluetooth, OID_AUTO, version,
59 CTLFLAG_RD, 0, NG_BLUETOOTH_VERSION, "");
65 SYSCTL_NODE(_net_bluetooth, OID_AUTO, hci, CTLFLAG_RW,
66 0, "Bluetooth HCI family");
69 bluetooth_set_hci_command_timeout_value(SYSCTL_HANDLER_ARGS)
74 value = bluetooth_hci_command_timeout_value;
75 error = sysctl_handle_int(oidp, &value, 0, req);
76 if (error == 0 && req->newptr != NULL) {
78 bluetooth_hci_command_timeout_value = value;
84 } /* bluetooth_set_hci_command_timeout_value */
86 SYSCTL_PROC(_net_bluetooth_hci, OID_AUTO, command_timeout,
87 CTLTYPE_INT | CTLFLAG_RW,
88 &bluetooth_hci_command_timeout_value, 5,
89 bluetooth_set_hci_command_timeout_value,
90 "I", "HCI command timeout (sec)");
93 bluetooth_set_hci_connect_timeout_value(SYSCTL_HANDLER_ARGS)
98 value = bluetooth_hci_connect_timeout_value;
99 error = sysctl_handle_int(oidp, &value, 0, req);
100 if (error == 0 && req->newptr != NULL) {
101 if (0 < value && value <= bluetooth_l2cap_rtx_timeout_value)
102 bluetooth_hci_connect_timeout_value = value;
108 } /* bluetooth_set_hci_connect_timeout_value */
110 SYSCTL_PROC(_net_bluetooth_hci, OID_AUTO, connection_timeout,
111 CTLTYPE_INT | CTLFLAG_RW,
112 &bluetooth_hci_connect_timeout_value, 60,
113 bluetooth_set_hci_connect_timeout_value,
114 "I", "HCI connect timeout (sec)");
116 SYSCTL_INT(_net_bluetooth_hci, OID_AUTO, max_neighbor_age, CTLFLAG_RW,
117 &bluetooth_hci_max_neighbor_age_value, 600,
118 "Maximal HCI neighbor cache entry age (sec)");
124 SYSCTL_NODE(_net_bluetooth, OID_AUTO, l2cap, CTLFLAG_RW,
125 0, "Bluetooth L2CAP family");
128 bluetooth_set_l2cap_rtx_timeout_value(SYSCTL_HANDLER_ARGS)
133 value = bluetooth_l2cap_rtx_timeout_value;
134 error = sysctl_handle_int(oidp, &value, 0, req);
135 if (error == 0 && req->newptr != NULL) {
136 if (bluetooth_hci_connect_timeout_value <= value &&
137 value <= bluetooth_l2cap_ertx_timeout_value)
138 bluetooth_l2cap_rtx_timeout_value = value;
144 } /* bluetooth_set_l2cap_rtx_timeout_value */
146 SYSCTL_PROC(_net_bluetooth_l2cap, OID_AUTO, rtx_timeout,
147 CTLTYPE_INT | CTLFLAG_RW,
148 &bluetooth_l2cap_rtx_timeout_value, 60,
149 bluetooth_set_l2cap_rtx_timeout_value,
150 "I", "L2CAP RTX timeout (sec)");
153 bluetooth_set_l2cap_ertx_timeout_value(SYSCTL_HANDLER_ARGS)
158 value = bluetooth_l2cap_ertx_timeout_value;
159 error = sysctl_handle_int(oidp, &value, 0, req);
160 if (error == 0 && req->newptr != NULL) {
161 if (value >= bluetooth_l2cap_rtx_timeout_value)
162 bluetooth_l2cap_ertx_timeout_value = value;
168 } /* bluetooth_set_l2cap_ertx_timeout_value */
170 SYSCTL_PROC(_net_bluetooth_l2cap, OID_AUTO, ertx_timeout,
171 CTLTYPE_INT | CTLFLAG_RW,
172 &bluetooth_l2cap_ertx_timeout_value, 300,
173 bluetooth_set_l2cap_ertx_timeout_value,
174 "I", "L2CAP ERTX timeout (sec)");
177 * Return various sysctl values
181 bluetooth_hci_command_timeout(void)
183 return (bluetooth_hci_command_timeout_value * hz);
184 } /* bluetooth_hci_command_timeout */
187 bluetooth_hci_connect_timeout(void)
189 return (bluetooth_hci_connect_timeout_value * hz);
190 } /* bluetooth_hci_connect_timeout */
193 bluetooth_hci_max_neighbor_age(void)
195 return (bluetooth_hci_max_neighbor_age_value);
196 } /* bluetooth_hci_max_neighbor_age */
199 bluetooth_l2cap_rtx_timeout(void)
201 return (bluetooth_l2cap_rtx_timeout_value * hz);
202 } /* bluetooth_l2cap_rtx_timeout */
205 bluetooth_l2cap_ertx_timeout(void)
207 return (bluetooth_l2cap_ertx_timeout_value * hz);
208 } /* bluetooth_l2cap_ertx_timeout */
214 SYSCTL_NODE(_net_bluetooth, OID_AUTO, rfcomm, CTLFLAG_RW,
215 0, "Bluetooth RFCOMM family");
218 * Handle loading and unloading for this code.
222 bluetooth_modevent(module_t mod, int event, void *data)
239 } /* bluetooth_modevent */
245 static moduledata_t bluetooth_mod = {
251 DECLARE_MODULE(ng_bluetooth, bluetooth_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
252 MODULE_VERSION(ng_bluetooth, NG_BLUETOOTH_VERSION);