6 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
8 * Copyright (c) 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_l2cap.h,v 1.2 2003/04/27 00:52:26 max Exp $
37 * This file contains everything that application needs to know about
38 * Link Layer Control and Adaptation Protocol (L2CAP). All information
39 * was obtained from Bluetooth Specification Book v1.1.
41 * This file can be included by both kernel and userland applications.
44 #ifndef _NETGRAPH_L2CAP_H_
45 #define _NETGRAPH_L2CAP_H_
47 /**************************************************************************
48 **************************************************************************
49 ** Netgraph node hook name, type name and type cookie and commands
50 **************************************************************************
51 **************************************************************************/
53 /* Netgraph node hook names */
54 #define NG_L2CAP_HOOK_HCI "hci" /* HCI <-> L2CAP */
55 #define NG_L2CAP_HOOK_L2C "l2c" /* L2CAP <-> Upper */
56 #define NG_L2CAP_HOOK_CTL "ctl" /* L2CAP <-> User */
58 /* Node type name and type cookie */
59 #define NG_L2CAP_NODE_TYPE "l2cap"
60 #define NGM_L2CAP_COOKIE 1000774185
62 /**************************************************************************
63 **************************************************************************
64 ** Common defines and types (L2CAP)
65 **************************************************************************
66 **************************************************************************/
69 * Channel IDs are assigned relative to the instance of L2CAP node, i.e.
70 * relative to the unit. So the total number of channels that unit can have
71 * open at the same time is 0xffff - 0x0040 = 0xffbf (65471). This number
72 * does not depend on number of connections.
75 #define NG_L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */
76 #define NG_L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */
77 #define NG_L2CAP_CLT_CID 0x0002 /* connectionless channel ID */
78 #define NG_L2CAP_A2MP_CID 0x0003
79 #define NG_L2CAP_ATT_CID 0x0004
80 #define NG_L2CAP_LESIGNAL_CID 0x0005
81 #define NG_L2CAP_SMP_CID 0x0006
82 /* 0x0007 - 0x003f Reserved */
83 #define NG_L2CAP_FIRST_CID 0x0040 /* dynamically alloc. (start) */
84 #define NG_L2CAP_LAST_CID 0xffff /* dynamically alloc. (end) */
85 #define NG_L2CAP_LELAST_CID 0x007f
89 #define NG_L2CAP_MTU_LE_MINIMAM 23
90 #define NG_L2CAP_MTU_MINIMUM 48
91 #define NG_L2CAP_MTU_DEFAULT 672
92 #define NG_L2CAP_MTU_MAXIMUM 0xffff
94 /* L2CAP flush and link timeouts */
95 #define NG_L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */
96 #define NG_L2CAP_LINK_TIMO_DEFAULT 0xffff
98 /* L2CAP Command Reject reasons */
99 #define NG_L2CAP_REJ_NOT_UNDERSTOOD 0x0000
100 #define NG_L2CAP_REJ_MTU_EXCEEDED 0x0001
101 #define NG_L2CAP_REJ_INVALID_CID 0x0002
102 /* 0x0003 - 0xffff - reserved for future use */
104 /* Protocol/Service Multioplexor (PSM) values */
105 #define NG_L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */
106 #define NG_L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */
107 #define NG_L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */
108 #define NG_L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */
109 /* 0x0006 - 0x1000 - reserved for future use */
111 /* L2CAP Connection response command result codes */
112 #define NG_L2CAP_SUCCESS 0x0000
113 #define NG_L2CAP_PENDING 0x0001
114 #define NG_L2CAP_PSM_NOT_SUPPORTED 0x0002
115 #define NG_L2CAP_SEQUIRY_BLOCK 0x0003
116 #define NG_L2CAP_NO_RESOURCES 0x0004
117 #define NG_L2CAP_TIMEOUT 0xeeee
118 #define NG_L2CAP_UNKNOWN 0xffff
119 /* 0x0005 - 0xffff - reserved for future use */
121 /* L2CAP Connection response status codes */
122 #define NG_L2CAP_NO_INFO 0x0000
123 #define NG_L2CAP_AUTH_PENDING 0x0001
124 #define NG_L2CAP_AUTZ_PENDING 0x0002
125 /* 0x0003 - 0xffff - reserved for future use */
127 /* L2CAP Configuration response result codes */
128 #define NG_L2CAP_UNACCEPTABLE_PARAMS 0x0001
129 #define NG_L2CAP_REJECT 0x0002
130 #define NG_L2CAP_UNKNOWN_OPTION 0x0003
131 /* 0x0003 - 0xffff - reserved for future use */
133 /* L2CAP Configuration options */
134 #define NG_L2CAP_OPT_CFLAG_BIT 0x0001
135 #define NG_L2CAP_OPT_CFLAG(flags) ((flags) & NG_L2CAP_OPT_CFLAG_BIT)
136 #define NG_L2CAP_OPT_HINT_BIT 0x80
137 #define NG_L2CAP_OPT_HINT(type) ((type) & NG_L2CAP_OPT_HINT_BIT)
138 #define NG_L2CAP_OPT_HINT_MASK 0x7f
139 #define NG_L2CAP_OPT_MTU 0x01
140 #define NG_L2CAP_OPT_MTU_SIZE sizeof(u_int16_t)
141 #define NG_L2CAP_OPT_FLUSH_TIMO 0x02
142 #define NG_L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(u_int16_t)
143 #define NG_L2CAP_OPT_QOS 0x03
144 #define NG_L2CAP_OPT_QOS_SIZE sizeof(ng_l2cap_flow_t)
145 /* 0x4 - 0xff - reserved for future use */
147 /* L2CAP Information request type codes */
148 #define NG_L2CAP_CONNLESS_MTU 0x0001
149 /* 0x0002 - 0xffff - reserved for future use */
151 /* L2CAP Information response codes */
152 #define NG_L2CAP_NOT_SUPPORTED 0x0001
153 /* 0x0002 - 0xffff - reserved for future use */
155 /* L2CAP flow control */
157 u_int8_t flags; /* reserved for future use */
158 u_int8_t service_type; /* service type */
159 u_int32_t token_rate; /* bytes per second */
160 u_int32_t token_bucket_size; /* bytes */
161 u_int32_t peak_bandwidth; /* bytes per second */
162 u_int32_t latency; /* microseconds */
163 u_int32_t delay_variation; /* microseconds */
164 } __attribute__ ((packed)) ng_l2cap_flow_t;
165 typedef ng_l2cap_flow_t * ng_l2cap_flow_p;
167 /**************************************************************************
168 **************************************************************************
169 ** Link level defines, headers and types
170 **************************************************************************
171 **************************************************************************/
175 u_int16_t length; /* payload size */
176 u_int16_t dcid; /* destination channel ID */
177 } __attribute__ ((packed)) ng_l2cap_hdr_t;
179 /* L2CAP ConnectionLess Traffic (CLT) (if destination cid == 0x2) */
181 u_int16_t psm; /* Protocol/Service Multiplexor */
182 } __attribute__ ((packed)) ng_l2cap_clt_hdr_t;
184 #define NG_L2CAP_CLT_MTU_MAXIMUM \
185 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_clt_hdr_t))
187 /* L2CAP command header */
189 u_int8_t code; /* command OpCode */
190 u_int8_t ident; /* identifier to match request and response */
191 u_int16_t length; /* command parameters length */
192 } __attribute__ ((packed)) ng_l2cap_cmd_hdr_t;
194 /* L2CAP Command Reject */
195 #define NG_L2CAP_CMD_REJ 0x01
197 u_int16_t reason; /* reason to reject command */
198 /* u_int8_t data[]; -- optional data (depends on reason) */
199 } __attribute__ ((packed)) ng_l2cap_cmd_rej_cp;
201 /* CommandReject data */
203 /* NG_L2CAP_REJ_MTU_EXCEEDED */
205 u_int16_t mtu; /* actual signaling MTU */
206 } __attribute__ ((packed)) mtu;
207 /* NG_L2CAP_REJ_INVALID_CID */
209 u_int16_t scid; /* local CID */
210 u_int16_t dcid; /* remote CID */
211 } __attribute__ ((packed)) cid;
212 } ng_l2cap_cmd_rej_data_t;
213 typedef ng_l2cap_cmd_rej_data_t * ng_l2cap_cmd_rej_data_p;
215 /* L2CAP Connection Request */
216 #define NG_L2CAP_CON_REQ 0x02
218 u_int16_t psm; /* Protocol/Service Multiplexor (PSM) */
219 u_int16_t scid; /* source channel ID */
220 } __attribute__ ((packed)) ng_l2cap_con_req_cp;
222 /* L2CAP Connection Response */
223 #define NG_L2CAP_CON_RSP 0x03
225 u_int16_t dcid; /* destination channel ID */
226 u_int16_t scid; /* source channel ID */
227 u_int16_t result; /* 0x00 - success */
228 u_int16_t status; /* more info if result != 0x00 */
229 } __attribute__ ((packed)) ng_l2cap_con_rsp_cp;
231 /* L2CAP Configuration Request */
232 #define NG_L2CAP_CFG_REQ 0x04
234 u_int16_t dcid; /* destination channel ID */
235 u_int16_t flags; /* flags */
236 /* u_int8_t options[] -- options */
237 } __attribute__ ((packed)) ng_l2cap_cfg_req_cp;
239 /* L2CAP Configuration Response */
240 #define NG_L2CAP_CFG_RSP 0x05
242 u_int16_t scid; /* source channel ID */
243 u_int16_t flags; /* flags */
244 u_int16_t result; /* 0x00 - success */
245 /* u_int8_t options[] -- options */
246 } __attribute__ ((packed)) ng_l2cap_cfg_rsp_cp;
248 /* L2CAP configuration option */
252 /* u_int8_t value[] -- option value (depends on type) */
253 } __attribute__ ((packed)) ng_l2cap_cfg_opt_t;
254 typedef ng_l2cap_cfg_opt_t * ng_l2cap_cfg_opt_p;
256 /* L2CAP configuration option value */
258 u_int16_t mtu; /* NG_L2CAP_OPT_MTU */
259 u_int16_t flush_timo; /* NG_L2CAP_OPT_FLUSH_TIMO */
260 ng_l2cap_flow_t flow; /* NG_L2CAP_OPT_QOS */
262 } ng_l2cap_cfg_opt_val_t;
263 typedef ng_l2cap_cfg_opt_val_t * ng_l2cap_cfg_opt_val_p;
265 /* L2CAP Disconnect Request */
266 #define NG_L2CAP_DISCON_REQ 0x06
268 u_int16_t dcid; /* destination channel ID */
269 u_int16_t scid; /* source channel ID */
270 } __attribute__ ((packed)) ng_l2cap_discon_req_cp;
272 /* L2CAP Disconnect Response */
273 #define NG_L2CAP_DISCON_RSP 0x07
274 typedef ng_l2cap_discon_req_cp ng_l2cap_discon_rsp_cp;
276 /* L2CAP Echo Request */
277 #define NG_L2CAP_ECHO_REQ 0x08
278 /* No command parameters, only optional data */
280 /* L2CAP Echo Response */
281 #define NG_L2CAP_ECHO_RSP 0x09
282 #define NG_L2CAP_MAX_ECHO_SIZE \
283 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_cmd_hdr_t))
284 /* No command parameters, only optional data */
286 /* L2CAP Information Request */
287 #define NG_L2CAP_INFO_REQ 0x0a
289 u_int16_t type; /* requested information type */
290 } __attribute__ ((packed)) ng_l2cap_info_req_cp;
292 /* L2CAP Information Response */
293 #define NG_L2CAP_INFO_RSP 0x0b
295 u_int16_t type; /* requested information type */
296 u_int16_t result; /* 0x00 - success */
297 /* u_int8_t info[] -- info data (depends on type)
299 * NG_L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
301 } __attribute__ ((packed)) ng_l2cap_info_rsp_cp;
303 /* NG_L2CAP_CONNLESS_MTU */
306 } __attribute__ ((packed)) mtu;
307 } ng_l2cap_info_rsp_data_t;
308 typedef ng_l2cap_info_rsp_data_t * ng_l2cap_info_rsp_data_p;
310 #define NG_L2CAP_CMD_PARAM_UPDATE_REQUEST 0x12
313 uint16_t interval_min;
314 uint16_t interval_max;
315 uint16_t slave_latency;
316 uint16_t timeout_mpl;
317 } __attribute__ ((packed)) ng_l2cap_param_update_req_cp;
319 #define NG_L2CAP_CMD_PARAM_UPDATE_RESPONSE 0x13
320 #define NG_L2CAP_UPDATE_PARAM_ACCEPT 0
321 #define NG_L2CAP_UPDATE_PARAM_REJECT 1
323 //typedef uint16_t update_response;
324 /**************************************************************************
325 **************************************************************************
326 ** Upper layer protocol interface. L2CA_xxx messages
327 **************************************************************************
328 **************************************************************************/
333 * Bluetooth specification says that L2CA_xxx request must block until
334 * response is ready. We are not allowed to block in Netgraph, so we
335 * need to queue request and save some information that can be used
336 * later and help match request and response.
338 * The idea is to use "token" field from Netgraph message header. The
339 * upper layer protocol _MUST_ populate "token". L2CAP will queue request
340 * (using L2CAP command descriptor) and start processing. Later, when
341 * response is ready or timeout has occur L2CAP layer will create new
342 * Netgraph message, set "token" and RESP flag and send the message to
343 * the upper layer protocol.
345 * L2CA_xxx_Ind messages _WILL_NOT_ populate "token" and _WILL_NOT_
346 * set RESP flag. There is no reason for this, because they are just
347 * notifications and do not require acknowlegment.
349 * NOTE: This is _NOT_ what NG_MKRESPONSE and NG_RESPOND_MSG do, however
350 * it is somewhat similar.
353 /* L2CA data packet header */
355 u_int32_t token; /* token to use in L2CAP_L2CA_WRITE */
356 u_int16_t length; /* length of the data */
357 u_int16_t lcid; /* local channel ID */
359 } __attribute__ ((packed)) ng_l2cap_l2ca_hdr_t;
360 #define NG_L2CAP_L2CA_IDTYPE_BREDR 0
361 #define NG_L2CAP_L2CA_IDTYPE_ATT 1
362 #define NG_L2CAP_L2CA_IDTYPE_LE 2
363 #define NG_L2CAP_L2CA_IDTYPE_SMP 3
365 #define NGM_L2CAP_L2CA_CON 0x80
368 u_int16_t psm; /* Protocol/Service Multiplexor */
369 bdaddr_t bdaddr; /* remote unit address */
372 } ng_l2cap_l2ca_con_ip;
376 u_int16_t lcid; /* local channel ID */
377 uint16_t idtype; /*ID type*/
378 u_int16_t result; /* 0x00 - success */
379 u_int16_t status; /* if result != 0x00 */
381 } ng_l2cap_l2ca_con_op;
383 /* L2CA_ConnectInd */
384 #define NGM_L2CAP_L2CA_CON_IND 0x81
387 bdaddr_t bdaddr; /* remote unit address */
388 u_int16_t lcid; /* local channel ID */
389 u_int16_t psm; /* Procotol/Service Multiplexor */
390 u_int8_t ident; /* identifier */
391 u_int8_t linktype; /* link type*/
392 } ng_l2cap_l2ca_con_ind_ip;
393 /* No output parameters */
395 /* L2CA_ConnectRsp */
396 #define NGM_L2CAP_L2CA_CON_RSP 0x82
399 bdaddr_t bdaddr; /* remote unit address */
400 u_int8_t ident; /* "ident" from L2CAP_ConnectInd event */
401 u_int8_t linktype; /*link type */
402 u_int16_t lcid; /* local channel ID */
403 u_int16_t result; /* 0x00 - success */
404 u_int16_t status; /* if response != 0x00 */
405 } ng_l2cap_l2ca_con_rsp_ip;
409 u_int16_t result; /* 0x00 - success */
410 } ng_l2cap_l2ca_con_rsp_op;
413 #define NGM_L2CAP_L2CA_CFG 0x83
416 u_int16_t lcid; /* local channel ID */
417 u_int16_t imtu; /* receiving MTU for the local channel */
418 ng_l2cap_flow_t oflow; /* out flow */
419 u_int16_t flush_timo; /* flush timeout (msec) */
420 u_int16_t link_timo; /* link timeout (msec) */
421 } ng_l2cap_l2ca_cfg_ip;
425 u_int16_t result; /* 0x00 - success */
426 u_int16_t imtu; /* sending MTU for the remote channel */
427 ng_l2cap_flow_t oflow; /* out flow */
428 u_int16_t flush_timo; /* flush timeout (msec) */
429 } ng_l2cap_l2ca_cfg_op;
432 #define NGM_L2CAP_L2CA_CFG_RSP 0x84
435 u_int16_t lcid; /* local channel ID */
436 u_int16_t omtu; /* sending MTU for the local channel */
437 ng_l2cap_flow_t iflow; /* in FLOW */
438 } ng_l2cap_l2ca_cfg_rsp_ip;
442 u_int16_t result; /* 0x00 - sucsess */
443 } ng_l2cap_l2ca_cfg_rsp_op;
446 #define NGM_L2CAP_L2CA_CFG_IND 0x85
449 u_int16_t lcid; /* local channel ID */
450 u_int16_t omtu; /* outgoing MTU for the local channel */
451 ng_l2cap_flow_t iflow; /* in flow */
452 u_int16_t flush_timo; /* flush timeout (msec) */
453 } ng_l2cap_l2ca_cfg_ind_ip;
454 /* No output parameters */
456 /* L2CA_QoSViolationInd */
457 #define NGM_L2CAP_L2CA_QOS_IND 0x86
460 bdaddr_t bdaddr; /* remote unit address */
461 } ng_l2cap_l2ca_qos_ind_ip;
462 /* No output parameters */
464 /* L2CA_Disconnect */
465 #define NGM_L2CAP_L2CA_DISCON 0x87
468 u_int16_t lcid; /* local channel ID */
470 } ng_l2cap_l2ca_discon_ip;
474 u_int16_t result; /* 0x00 - sucsess */
475 } ng_l2cap_l2ca_discon_op;
477 /* L2CA_DisconnectInd */
478 #define NGM_L2CAP_L2CA_DISCON_IND 0x88
480 typedef ng_l2cap_l2ca_discon_ip ng_l2cap_l2ca_discon_ind_ip;
481 /* No output parameters */
483 /* L2CA_Write response */
484 #define NGM_L2CAP_L2CA_WRITE 0x89
485 /* No input parameters */
489 int result; /* result (0x00 - success) */
490 u_int16_t length; /* amount of data written */
491 u_int16_t lcid; /* local channel ID */
493 } ng_l2cap_l2ca_write_op;
495 /* L2CA_GroupCreate */
496 #define NGM_L2CAP_L2CA_GRP_CREATE 0x8a
499 u_int16_t psm; /* Protocol/Service Multiplexor */
500 } ng_l2cap_l2ca_grp_create_ip;
504 u_int16_t lcid; /* local group channel ID */
505 } ng_l2cap_l2ca_grp_create_op;
507 /* L2CA_GroupClose */
508 #define NGM_L2CAP_L2CA_GRP_CLOSE 0x8b
511 u_int16_t lcid; /* local group channel ID */
512 } ng_l2cap_l2ca_grp_close_ip;
517 * u_int16_t result; /* 0x00 - success */
518 * } ng_l2cap_l2ca_grp_close_op;
521 /* L2CA_GroupAddMember */
522 #define NGM_L2CAP_L2CA_GRP_ADD_MEMBER 0x8c
525 u_int16_t lcid; /* local group channel ID */
526 bdaddr_t bdaddr; /* remote unit address */
527 } ng_l2cap_l2ca_grp_add_member_ip;
531 u_int16_t result; /* 0x00 - success */
532 } ng_l2cap_l2ca_grp_add_member_op;
534 /* L2CA_GroupRemoveMember */
535 #define NGM_L2CAP_L2CA_GRP_REM_MEMBER 0x8d
537 typedef ng_l2cap_l2ca_grp_add_member_ip ng_l2cap_l2ca_grp_rem_member_ip;
541 * typedef ng_l2cap_l2ca_grp_add_member_op ng_l2cap_l2ca_grp_rem_member_op;
544 /* L2CA_GroupMembeship */
545 #define NGM_L2CAP_L2CA_GRP_MEMBERSHIP 0x8e
548 u_int16_t lcid; /* local group channel ID */
549 } ng_l2cap_l2ca_grp_get_members_ip;
553 u_int16_t result; /* 0x00 - success */
554 u_int16_t nmembers; /* number of group members */
555 /* bdaddr_t members[] -- group memebers */
556 } ng_l2cap_l2ca_grp_get_members_op;
559 #define NGM_L2CAP_L2CA_PING 0x8f
562 bdaddr_t bdaddr; /* remote unit address */
563 u_int16_t echo_size; /* size of echo data in bytes */
564 /* u_int8_t echo_data[] -- echo data */
565 } ng_l2cap_l2ca_ping_ip;
569 u_int16_t result; /* 0x00 - success */
570 bdaddr_t bdaddr; /* remote unit address */
571 u_int16_t echo_size; /* size of echo data in bytes */
572 /* u_int8_t echo_data[] -- echo data */
573 } ng_l2cap_l2ca_ping_op;
576 #define NGM_L2CAP_L2CA_GET_INFO 0x90
579 bdaddr_t bdaddr; /* remote unit address */
580 u_int16_t info_type; /* info type */
583 } ng_l2cap_l2ca_get_info_ip;
587 u_int16_t result; /* 0x00 - success */
588 u_int16_t info_size; /* size of info data in bytes */
589 /* u_int8_t info_data[] -- info data */
590 } ng_l2cap_l2ca_get_info_op;
592 /* L2CA_EnableCLT/L2CA_DisableCLT */
593 #define NGM_L2CAP_L2CA_ENABLE_CLT 0x91
596 u_int16_t psm; /* Protocol/Service Multiplexor */
597 u_int16_t enable; /* 0x00 - disable */
598 } ng_l2cap_l2ca_enable_clt_ip;
603 * u_int16_t result; /* 0x00 - success */
604 * } ng_l2cap_l2ca_enable_clt_op;
606 #define NGM_L2CAP_L2CA_ENC_CHANGE 0x92
611 } ng_l2cap_l2ca_enc_chg_op;
613 /**************************************************************************
614 **************************************************************************
615 ** L2CAP node messages
616 **************************************************************************
617 **************************************************************************/
619 /* L2CAP connection states */
620 #define NG_L2CAP_CON_CLOSED 0 /* connection closed */
621 #define NG_L2CAP_W4_LP_CON_CFM 1 /* waiting... */
622 #define NG_L2CAP_CON_OPEN 2 /* connection open */
624 /* L2CAP channel states */
625 #define NG_L2CAP_CLOSED 0 /* channel closed */
626 #define NG_L2CAP_W4_L2CAP_CON_RSP 1 /* wait for L2CAP resp. */
627 #define NG_L2CAP_W4_L2CA_CON_RSP 2 /* wait for upper resp. */
628 #define NG_L2CAP_CONFIG 3 /* L2CAP configuration */
629 #define NG_L2CAP_OPEN 4 /* channel open */
630 #define NG_L2CAP_W4_L2CAP_DISCON_RSP 5 /* wait for L2CAP discon. */
631 #define NG_L2CAP_W4_L2CA_DISCON_RSP 6 /* wait for upper discon. */
634 #define NG_L2CAP_CLT_SDP_DISABLED (1 << 0) /* disable SDP CLT */
635 #define NG_L2CAP_CLT_RFCOMM_DISABLED (1 << 1) /* disable RFCOMM CLT */
636 #define NG_L2CAP_CLT_TCP_DISABLED (1 << 2) /* disable TCP CLT */
639 #define NG_L2CAP_ALERT_LEVEL 1
640 #define NG_L2CAP_ERR_LEVEL 2
641 #define NG_L2CAP_WARN_LEVEL 3
642 #define NG_L2CAP_INFO_LEVEL 4
644 /* Get node flags (see flags above) */
645 #define NGM_L2CAP_NODE_GET_FLAGS 0x400 /* L2CAP -> User */
646 typedef u_int16_t ng_l2cap_node_flags_ep;
648 /* Get/Set debug level (see levels above) */
649 #define NGM_L2CAP_NODE_GET_DEBUG 0x401 /* L2CAP -> User */
650 #define NGM_L2CAP_NODE_SET_DEBUG 0x402 /* User -> L2CAP */
651 typedef u_int16_t ng_l2cap_node_debug_ep;
653 #define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */
656 }ng_l2cap_node_hook_info_ep;
658 #define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */
660 u_int32_t num_connections; /* number of connections */
661 } ng_l2cap_node_con_list_ep;
663 /* Connection flags */
664 #define NG_L2CAP_CON_TX (1 << 0) /* sending data */
665 #define NG_L2CAP_CON_RX (1 << 1) /* receiving data */
666 #define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */
667 #define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */
668 #define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */
669 #define NG_L2CAP_CON_DYING (1 << 5) /* connection is dying */
672 u_int8_t state; /* connection state */
673 u_int8_t flags; /* flags */
674 int16_t pending; /* num. pending packets */
675 u_int16_t con_handle; /* connection handle */
676 bdaddr_t remote; /* remote bdaddr */
677 } ng_l2cap_node_con_ep;
679 #define NG_L2CAP_MAX_CON_NUM \
680 ((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep))
682 #define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */
684 u_int32_t num_channels; /* number of channels */
685 } ng_l2cap_node_chan_list_ep;
688 u_int32_t state; /* channel state */
690 u_int16_t scid; /* source (local) channel ID */
691 u_int16_t dcid; /* destination (remote) channel ID */
693 u_int16_t imtu; /* incoming MTU */
694 u_int16_t omtu; /* outgoing MTU */
696 u_int16_t psm; /* PSM */
697 bdaddr_t remote; /* remote bdaddr */
698 } ng_l2cap_node_chan_ep;
700 #define NG_L2CAP_MAX_CHAN_NUM \
701 ((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep))
703 #define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */
704 #define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */
705 typedef u_int16_t ng_l2cap_node_auto_discon_ep;
707 #endif /* ndef _NETGRAPH_L2CAP_H_ */