1 .\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $Id: ng_btsocket.4,v 1.7 2003/05/21 19:37:35 max Exp $
33 .Nd Bluetooth sockets layer
38 .In netgraph/bluetooth/include/ng_hci.h
39 .In netgraph/bluetooth/include/ng_l2cap.h
40 .In netgraph/bluetooth/include/ng_btsocket.h
44 module implements three Netgraph node types.
45 Each type in its turn implements one protocol within
48 .Sh Dv BLUETOOTH_PROTO_HCI Sh protocol
49 .Ss Dv SOCK_RAW Ss HCI sockets
53 Raw HCI sockets allow sending of raw HCI command datagrams
54 only to correspondents named in
57 Raw HCI datagrams (HCI commands, events and data) are generally received with
59 which returns the next datagram with its return address.
60 Raw HCI sockets can also be used to control HCI nodes.
62 The Bluetooth raw HCI socket address is defined as follows:
63 .Bd -literal -offset indent
64 /* Bluetooth version of struct sockaddr for raw HCI sockets */
66 u_char hci_len; /* total length */
67 u_char hci_family; /* address family */
68 char hci_node[32]; /* address (size == NG_NODESIZ ) */
72 Raw HCI sockets support a number of
76 .It Dv SIOC_HCI_RAW_NODE_GET_STATE
77 Returns current state for the HCI node.
78 .It Dv SIOC_HCI_RAW_NODE_INIT
82 .It Dv SIOC_HCI_RAW_NODE_GET_DEBUG
83 Returns current debug level for the HCI node.
84 .It Dv SIOC_HCI_RAW_NODE_SET_DEBUG
85 Sets current debug level for the HCI node.
86 .It Dv SIOC_HCI_RAW_NODE_GET_BUFFER
87 Returns current state of data buffers for the HCI node.
88 .It Dv SIOC_HCI_RAW_NODE_GET_BDADDR
89 Returns BD_ADDR for the HCI node.
90 .It Dv SIOC_HCI_RAW_NODE_GET_FEATURES
91 Returns the list of features supported by hardware for the HCI node.
92 .It Dv SIOC_HCI_RAW_NODE_GET_STAT
93 Returns various statistic counters for the HCI node.
94 .It Dv SIOC_HCI_RAW_NODE_RESET_STAT
95 Resets all statistic counters for the HCI node to zero.
96 .It Dv SIOC_HCI_RAW_NODE_FLUSH_NEIGHBOR_CACHE
97 Remove all neighbor cache entries for the HCI node.
98 .It Dv SIOC_HCI_RAW_NODE_GET_NEIGHBOR_CACHE
99 Returns content of the neighbor cache for the HCI node.
100 .It Dv SIOC_HCI_RAW_NODE_GET_CON_LIST
101 Returns list of active baseband connections (i.e., ACL and SCO links) for
103 .It SIOC_HCI_RAW_NODE_GET_LINK_POLICY_MASK
104 Returns current link policy settings mask for the HCI node.
105 .It SIOC_HCI_RAW_NODE_SET_LINK_POLICY_MASK
106 Sets current link policy settings mask for the HCI node.
107 .It SIOC_HCI_RAW_NODE_GET_PACKET_MASK
108 Returns current packet mask for the HCI node.
109 .It SIOC_HCI_RAW_NODE_SET_PACKET_MASK
110 Sets current packet mask for the HCI node.
111 .It SIOC_HCI_RAW_NODE_GET_ROLE_SWITCH
112 Returns current value of the role switch parameter for the HCI node.
113 .It SIOC_HCI_RAW_NODE_SET_ROLE_SWITCH
114 Sets new value of the role switch parameter for the HCI node.
118 .Va net.bluetooth.hci.sockets.raw.ioctl_timeout
119 variable, that can be examined and set via
121 controls the control request timeout (in seconds) for raw HCI sockets.
123 Raw HCI sockets support filters.
124 The application can filter certain HCI datagram types.
125 For HCI event datagrams the application can set additional filter.
126 The raw HCI socket filter defined as follows:
127 .Bd -literal -offset indent
129 * Raw HCI socket filter.
131 * For packet mask use (1 << (HCI packet indicator - 1))
132 * For event mask use (1 << (Event - 1))
135 struct ng_btsocket_hci_raw_filter {
136 bitstr_t bit_decl(packet_mask, 32);
137 bitstr_t bit_decl(event_mask, (NG_HCI_EVENT_MASK_SIZE * 8));
142 .Dv SO_HCI_RAW_FILTER
145 level can be used to obtain via
149 raw HCI socket's filter.
150 .Sh Dv BLUETOOTH_PROTO_L2CAP Sh protocol
151 The Bluetooth L2CAP socket address is defined as follows:
152 .Bd -literal -offset indent
153 /* Bluetooth version of struct sockaddr for L2CAP sockets */
154 struct sockaddr_l2cap {
155 u_char l2cap_len; /* total length */
156 u_char l2cap_family; /* address family */
157 uint16_t l2cap_psm; /* Protocol/Service Multiplexor */
158 bdaddr_t l2cap_bdaddr; /* address */
161 .Ss Dv SOCK_RAW Ss L2CAP sockets
165 Raw L2CAP sockets do not provide access to raw L2CAP datagrams.
167 sockets used to control L2CAP nodes and to issue special L2CAP requests
174 Raw L2CAP sockets support number of
178 .It Dv SIOC_L2CAP_NODE_GET_FLAGS
179 Returns current state for the L2CAP node.
180 .It Dv SIOC_L2CAP_NODE_GET_DEBUG
181 Returns current debug level for the L2CAP node.
182 .It Dv SIOC_L2CAP_NODE_SET_DEBUG
183 Sets current debug level for the L2CAP node.
184 .It Dv SIOC_L2CAP_NODE_GET_CON_LIST
185 Returns list of active baseband connections (i.e., ACL links) for the L2CAP
187 .It Dv SIOC_L2CAP_NODE_GET_CHAN_LIST
188 Returns list of active channels for the L2CAP node.
189 .It Dv SIOC_L2CAP_NODE_GET_AUTO_DISCON_TIMO
190 Returns current value of the auto disconnect timeout for the L2CAP node.
191 .It Dv SIOC_L2CAP_NODE_SET_AUTO_DISCON_TIMO
192 Sets current value of the auto disconnect timeout for the L2CAP node.
193 .It Dv SIOC_L2CAP_L2CA_PING
196 .It Dv SIOC_L2CAP_L2CA_GET_INFO
203 .Va net.bluetooth.l2cap.sockets.raw.ioctl_timeout
204 variable, that can be examined and set via
206 controls the control request timeout (in seconds) for raw L2CAP sockets.
207 .Ss Dv SOCK_SEQPACKET Ss L2CAP sockets
211 L2CAP sockets are either
215 Active sockets initiate connections to passive sockets.
216 By default, L2CAP sockets are created active; to create a passive socket, the
218 system call must be used after binding the socket with the
221 Only passive sockets may use the
223 call to accept incoming connections.
224 Only active sockets may use the
226 call to initiate connections.
228 L2CAP sockets support
229 .Dq "wildcard addressing" .
230 In this case, socket must be bound to
231 .Dv NG_HCI_BDADDR_ANY
233 Note that PSM (Protocol/Service Multiplexor) field is always required.
234 Once a connection has been established, the socket's address is
235 fixed by the peer entity's location.
236 The address assigned to the socket is
237 the address associated with the Bluetooth device through which packets are
238 being transmitted and received, and PSM (Protocol/Service Multiplexor).
240 L2CAP sockets support number of options defined at
242 level which can be set with
248 Get (set) maximum payload size the local socket is capable of accepting.
250 Get maximum payload size the remote socket is capable of accepting.
251 .It Dv SO_L2CAP_IFLOW
252 Get incoming flow specification for the socket.
256 .It Dv SO_L2CAP_OFLOW
257 Get (set) outgoing flow specification for the socket.
261 .It Dv SO_L2CAP_FLUSH
262 Get (set) value of the flush timeout.
267 .Sh Dv BLUETOOTH_PROTO_RFCOMM Sh protocol
268 The Bluetooth RFCOMM socket address is defined as follows:
269 .Bd -literal -offset indent
270 /* Bluetooth version of struct sockaddr for RFCOMM sockets */
271 struct sockaddr_rfcomm {
272 u_char rfcomm_len; /* total length */
273 u_char rfcomm_family; /* address family */
274 bdaddr_t rfcomm_bdaddr; /* address */
275 uint8_t rfcomm_channel; /* channel */
278 .Ss Dv SOCK_STREAM Ss RFCOMM sockets
279 Note that RFCOMM sockets do not have associated Netgraph node type.
280 RFCOMM sockets are implemented as additional layer on top of L2CAP sockets.
281 RFCOMM sockets are either
285 Active sockets initiate connections to passive sockets.
286 By default, RFCOMM sockets are created active; to create a passive socket, the
288 system call must be used after binding the socket with the
291 Only passive sockets may use the
293 call to accept incoming connections.
294 Only active sockets may use the
296 call to initiate connections.
298 RFCOMM sockets support
299 .Dq "wildcard addressing" .
300 In this case, socket must be bound to
301 .Dv NG_HCI_BDADDR_ANY
303 Note that RFCOMM channel field is always required.
304 Once a connection has been established, the socket's address is fixed by the
305 peer entity's location.
306 The address assigned to the socket is the address associated with the
307 Bluetooth device through which packets are being transmitted and received,
310 The following options, which can be tested with
314 level for RFCOMM sockets:
317 Returns the maximum transfer unit size (in bytes) for the underlying RFCOMM
319 Note that application still can write/read bigger chunks to/from the socket.
320 .It Dv SO_RFCOMM_FC_INFO
321 Return the flow control information for the underlying RFCOMM channel.
325 .Va net.bluetooth.rfcomm.sockets.stream.timeout
326 variable, that can be examined and set via
328 controls the connection timeout (in seconds) for RFCOMM sockets.
330 These node types support hooks with arbitrary names (as long as they are
331 unique) and always accept hook connection requests.
332 .Sh NETGRAPH CONTROL MESSAGES
333 These node types support the generic control messages.
335 These nodes are persistent and cannot be shut down.
348 module was implemented in
351 .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com
354 Please report if found.