4 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $Id: ng_bluetooth.c,v 1.3 2003/04/26 22:37:31 max Exp $
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/errno.h>
35 #include <sys/kernel.h>
36 #include <sys/sysctl.h>
38 #include "ng_bluetooth.h"
41 * Bluetooth stack sysctl globals
44 static u_int32_t bluetooth_hci_command_timeout_value = 5; /* sec */
45 static u_int32_t bluetooth_hci_connect_timeout_value = 60; /* sec */
46 static u_int32_t bluetooth_hci_max_neighbor_age_value = 600; /* sec */
47 static u_int32_t bluetooth_l2cap_rtx_timeout_value = 60; /* sec */
48 static u_int32_t bluetooth_l2cap_ertx_timeout_value = 300; /* sec */
51 * Define sysctl tree that shared by other parts of Bluetooth stack
54 SYSCTL_NODE(_net, OID_AUTO, bluetooth, CTLFLAG_RW, 0, "Bluetooth family");
55 SYSCTL_INT(_net_bluetooth, OID_AUTO, version,
56 CTLFLAG_RD, 0, NG_BLUETOOTH_VERSION, "");
62 SYSCTL_NODE(_net_bluetooth, OID_AUTO, hci, CTLFLAG_RW,
63 0, "Bluetooth HCI family");
66 bluetooth_set_hci_command_timeout_value(SYSCTL_HANDLER_ARGS)
71 value = bluetooth_hci_command_timeout_value;
72 error = sysctl_handle_int(oidp, &value, sizeof(value), req);
73 if (error == 0 && req->newptr != NULL) {
75 bluetooth_hci_command_timeout_value = value;
81 } /* bluetooth_set_hci_command_timeout_value */
83 SYSCTL_PROC(_net_bluetooth_hci, OID_AUTO, command_timeout,
84 CTLTYPE_INT | CTLFLAG_RW,
85 &bluetooth_hci_command_timeout_value, 5,
86 bluetooth_set_hci_command_timeout_value,
87 "I", "HCI command timeout (sec)");
90 bluetooth_set_hci_connect_timeout_value(SYSCTL_HANDLER_ARGS)
95 value = bluetooth_hci_connect_timeout_value;
96 error = sysctl_handle_int(oidp, &value, sizeof(value), req);
97 if (error == 0 && req->newptr != NULL) {
98 if (0 < value && value <= bluetooth_l2cap_rtx_timeout_value)
99 bluetooth_hci_connect_timeout_value = value;
105 } /* bluetooth_set_hci_connect_timeout_value */
107 SYSCTL_PROC(_net_bluetooth_hci, OID_AUTO, connection_timeout,
108 CTLTYPE_INT | CTLFLAG_RW,
109 &bluetooth_hci_connect_timeout_value, 60,
110 bluetooth_set_hci_connect_timeout_value,
111 "I", "HCI connect timeout (sec)");
113 SYSCTL_INT(_net_bluetooth_hci, OID_AUTO, max_neighbor_age, CTLFLAG_RW,
114 &bluetooth_hci_max_neighbor_age_value, 600,
115 "Maximal HCI neighbor cache entry age (sec)");
121 SYSCTL_NODE(_net_bluetooth, OID_AUTO, l2cap, CTLFLAG_RW,
122 0, "Bluetooth L2CAP family");
125 bluetooth_set_l2cap_rtx_timeout_value(SYSCTL_HANDLER_ARGS)
130 value = bluetooth_l2cap_rtx_timeout_value;
131 error = sysctl_handle_int(oidp, &value, sizeof(value), req);
132 if (error == 0 && req->newptr != NULL) {
133 if (bluetooth_hci_connect_timeout_value <= value &&
134 value <= bluetooth_l2cap_ertx_timeout_value)
135 bluetooth_l2cap_rtx_timeout_value = value;
141 } /* bluetooth_set_l2cap_rtx_timeout_value */
143 SYSCTL_PROC(_net_bluetooth_l2cap, OID_AUTO, rtx_timeout,
144 CTLTYPE_INT | CTLFLAG_RW,
145 &bluetooth_l2cap_rtx_timeout_value, 60,
146 bluetooth_set_l2cap_rtx_timeout_value,
147 "I", "L2CAP RTX timeout (sec)");
150 bluetooth_set_l2cap_ertx_timeout_value(SYSCTL_HANDLER_ARGS)
155 value = bluetooth_l2cap_ertx_timeout_value;
156 error = sysctl_handle_int(oidp, &value, sizeof(value), req);
157 if (error == 0 && req->newptr != NULL) {
158 if (value >= bluetooth_l2cap_rtx_timeout_value)
159 bluetooth_l2cap_ertx_timeout_value = value;
165 } /* bluetooth_set_l2cap_ertx_timeout_value */
167 SYSCTL_PROC(_net_bluetooth_l2cap, OID_AUTO, ertx_timeout,
168 CTLTYPE_INT | CTLFLAG_RW,
169 &bluetooth_l2cap_ertx_timeout_value, 300,
170 bluetooth_set_l2cap_ertx_timeout_value,
171 "I", "L2CAP ERTX timeout (sec)");
174 * Return various sysctl values
178 bluetooth_hci_command_timeout(void)
180 return (bluetooth_hci_command_timeout_value * hz);
181 } /* bluetooth_hci_command_timeout */
184 bluetooth_hci_connect_timeout(void)
186 return (bluetooth_hci_connect_timeout_value * hz);
187 } /* bluetooth_hci_connect_timeout */
190 bluetooth_hci_max_neighbor_age(void)
192 return (bluetooth_hci_max_neighbor_age_value);
193 } /* bluetooth_hci_max_neighbor_age */
196 bluetooth_l2cap_rtx_timeout(void)
198 return (bluetooth_l2cap_rtx_timeout_value * hz);
199 } /* bluetooth_l2cap_rtx_timeout */
202 bluetooth_l2cap_ertx_timeout(void)
204 return (bluetooth_l2cap_ertx_timeout_value * hz);
205 } /* bluetooth_l2cap_ertx_timeout */
211 SYSCTL_NODE(_net_bluetooth, OID_AUTO, rfcomm, CTLFLAG_RW,
212 0, "Bluetooth RFCOMM family");
215 * Handle loading and unloading for this code.
219 bluetooth_modevent(module_t mod, int event, void *data)
236 } /* bluetooth_modevent */
242 static moduledata_t bluetooth_mod = {
248 DECLARE_MODULE(ng_bluetooth, bluetooth_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
249 MODULE_VERSION(ng_bluetooth, NG_BLUETOOTH_VERSION);