6 * Copyright (c) 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_l2cap.h,v 1.2 2003/04/27 00:52:26 max Exp $
35 * This file contains everything that application needs to know about
36 * Link Layer Control and Adaptation Protocol (L2CAP). All information
37 * was obtained from Bluetooth Specification Book v1.1.
39 * This file can be included by both kernel and userland applications.
42 #ifndef _NETGRAPH_L2CAP_H_
43 #define _NETGRAPH_L2CAP_H_
45 /**************************************************************************
46 **************************************************************************
47 ** Netgraph node hook name, type name and type cookie and commands
48 **************************************************************************
49 **************************************************************************/
51 /* Netgraph node hook names */
52 #define NG_L2CAP_HOOK_HCI "hci" /* HCI <-> L2CAP */
53 #define NG_L2CAP_HOOK_L2C "l2c" /* L2CAP <-> Upper */
54 #define NG_L2CAP_HOOK_CTL "ctl" /* L2CAP <-> User */
56 /* Node type name and type cookie */
57 #define NG_L2CAP_NODE_TYPE "l2cap"
58 #define NGM_L2CAP_COOKIE 1000774185
60 /**************************************************************************
61 **************************************************************************
62 ** Common defines and types (L2CAP)
63 **************************************************************************
64 **************************************************************************/
67 * Channel IDs are assigned relative to the instance of L2CAP node, i.e.
68 * relative to the unit. So the total number of channels that unit can have
69 * open at the same time is 0xffff - 0x0040 = 0xffbf (65471). This number
70 * does not depend on number of connections.
73 #define NG_L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */
74 #define NG_L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */
75 #define NG_L2CAP_CLT_CID 0x0002 /* connectionless channel ID */
76 #define NG_L2CAP_A2MP_CID 0x0003
77 #define NG_L2CAP_ATT_CID 0x0004
78 #define NG_L2CAP_LESIGNAL_CID 0x0005
79 #define NG_L2CAP_SMP_CID 0x0006
80 /* 0x0007 - 0x003f Reserved */
81 #define NG_L2CAP_FIRST_CID 0x0040 /* dynamically alloc. (start) */
82 #define NG_L2CAP_LAST_CID 0xffff /* dynamically alloc. (end) */
83 #define NG_L2CAP_LELAST_CID 0x007f
87 #define NG_L2CAP_MTU_LE_MINIMAM 23
88 #define NG_L2CAP_MTU_MINIMUM 48
89 #define NG_L2CAP_MTU_DEFAULT 672
90 #define NG_L2CAP_MTU_MAXIMUM 0xffff
92 /* L2CAP flush and link timeouts */
93 #define NG_L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */
94 #define NG_L2CAP_LINK_TIMO_DEFAULT 0xffff
96 /* L2CAP Command Reject reasons */
97 #define NG_L2CAP_REJ_NOT_UNDERSTOOD 0x0000
98 #define NG_L2CAP_REJ_MTU_EXCEEDED 0x0001
99 #define NG_L2CAP_REJ_INVALID_CID 0x0002
100 /* 0x0003 - 0xffff - reserved for future use */
102 /* Protocol/Service Multioplexor (PSM) values */
103 #define NG_L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */
104 #define NG_L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */
105 #define NG_L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */
106 #define NG_L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */
107 /* 0x0006 - 0x1000 - reserved for future use */
109 /* L2CAP Connection response command result codes */
110 #define NG_L2CAP_SUCCESS 0x0000
111 #define NG_L2CAP_PENDING 0x0001
112 #define NG_L2CAP_PSM_NOT_SUPPORTED 0x0002
113 #define NG_L2CAP_SEQUIRY_BLOCK 0x0003
114 #define NG_L2CAP_NO_RESOURCES 0x0004
115 #define NG_L2CAP_TIMEOUT 0xeeee
116 #define NG_L2CAP_UNKNOWN 0xffff
117 /* 0x0005 - 0xffff - reserved for future use */
119 /* L2CAP Connection response status codes */
120 #define NG_L2CAP_NO_INFO 0x0000
121 #define NG_L2CAP_AUTH_PENDING 0x0001
122 #define NG_L2CAP_AUTZ_PENDING 0x0002
123 /* 0x0003 - 0xffff - reserved for future use */
125 /* L2CAP Configuration response result codes */
126 #define NG_L2CAP_UNACCEPTABLE_PARAMS 0x0001
127 #define NG_L2CAP_REJECT 0x0002
128 #define NG_L2CAP_UNKNOWN_OPTION 0x0003
129 /* 0x0003 - 0xffff - reserved for future use */
131 /* L2CAP Configuration options */
132 #define NG_L2CAP_OPT_CFLAG_BIT 0x0001
133 #define NG_L2CAP_OPT_CFLAG(flags) ((flags) & NG_L2CAP_OPT_CFLAG_BIT)
134 #define NG_L2CAP_OPT_HINT_BIT 0x80
135 #define NG_L2CAP_OPT_HINT(type) ((type) & NG_L2CAP_OPT_HINT_BIT)
136 #define NG_L2CAP_OPT_HINT_MASK 0x7f
137 #define NG_L2CAP_OPT_MTU 0x01
138 #define NG_L2CAP_OPT_MTU_SIZE sizeof(u_int16_t)
139 #define NG_L2CAP_OPT_FLUSH_TIMO 0x02
140 #define NG_L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(u_int16_t)
141 #define NG_L2CAP_OPT_QOS 0x03
142 #define NG_L2CAP_OPT_QOS_SIZE sizeof(ng_l2cap_flow_t)
143 /* 0x4 - 0xff - reserved for future use */
145 /* L2CAP Information request type codes */
146 #define NG_L2CAP_CONNLESS_MTU 0x0001
147 /* 0x0002 - 0xffff - reserved for future use */
149 /* L2CAP Information response codes */
150 #define NG_L2CAP_NOT_SUPPORTED 0x0001
151 /* 0x0002 - 0xffff - reserved for future use */
153 /* L2CAP flow control */
155 u_int8_t flags; /* reserved for future use */
156 u_int8_t service_type; /* service type */
157 u_int32_t token_rate; /* bytes per second */
158 u_int32_t token_bucket_size; /* bytes */
159 u_int32_t peak_bandwidth; /* bytes per second */
160 u_int32_t latency; /* microseconds */
161 u_int32_t delay_variation; /* microseconds */
162 } __attribute__ ((packed)) ng_l2cap_flow_t;
163 typedef ng_l2cap_flow_t * ng_l2cap_flow_p;
165 /**************************************************************************
166 **************************************************************************
167 ** Link level defines, headers and types
168 **************************************************************************
169 **************************************************************************/
173 u_int16_t length; /* payload size */
174 u_int16_t dcid; /* destination channel ID */
175 } __attribute__ ((packed)) ng_l2cap_hdr_t;
177 /* L2CAP ConnectionLess Traffic (CLT) (if destination cid == 0x2) */
179 u_int16_t psm; /* Protocol/Service Multiplexor */
180 } __attribute__ ((packed)) ng_l2cap_clt_hdr_t;
182 #define NG_L2CAP_CLT_MTU_MAXIMUM \
183 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_clt_hdr_t))
185 /* L2CAP command header */
187 u_int8_t code; /* command OpCode */
188 u_int8_t ident; /* identifier to match request and response */
189 u_int16_t length; /* command parameters length */
190 } __attribute__ ((packed)) ng_l2cap_cmd_hdr_t;
192 /* L2CAP Command Reject */
193 #define NG_L2CAP_CMD_REJ 0x01
195 u_int16_t reason; /* reason to reject command */
196 /* u_int8_t data[]; -- optional data (depends on reason) */
197 } __attribute__ ((packed)) ng_l2cap_cmd_rej_cp;
199 /* CommandReject data */
201 /* NG_L2CAP_REJ_MTU_EXCEEDED */
203 u_int16_t mtu; /* actual signaling MTU */
204 } __attribute__ ((packed)) mtu;
205 /* NG_L2CAP_REJ_INVALID_CID */
207 u_int16_t scid; /* local CID */
208 u_int16_t dcid; /* remote CID */
209 } __attribute__ ((packed)) cid;
210 } ng_l2cap_cmd_rej_data_t;
211 typedef ng_l2cap_cmd_rej_data_t * ng_l2cap_cmd_rej_data_p;
213 /* L2CAP Connection Request */
214 #define NG_L2CAP_CON_REQ 0x02
216 u_int16_t psm; /* Protocol/Service Multiplexor (PSM) */
217 u_int16_t scid; /* source channel ID */
218 } __attribute__ ((packed)) ng_l2cap_con_req_cp;
220 /* L2CAP Connection Response */
221 #define NG_L2CAP_CON_RSP 0x03
223 u_int16_t dcid; /* destination channel ID */
224 u_int16_t scid; /* source channel ID */
225 u_int16_t result; /* 0x00 - success */
226 u_int16_t status; /* more info if result != 0x00 */
227 } __attribute__ ((packed)) ng_l2cap_con_rsp_cp;
229 /* L2CAP Configuration Request */
230 #define NG_L2CAP_CFG_REQ 0x04
232 u_int16_t dcid; /* destination channel ID */
233 u_int16_t flags; /* flags */
234 /* u_int8_t options[] -- options */
235 } __attribute__ ((packed)) ng_l2cap_cfg_req_cp;
237 /* L2CAP Configuration Response */
238 #define NG_L2CAP_CFG_RSP 0x05
240 u_int16_t scid; /* source channel ID */
241 u_int16_t flags; /* flags */
242 u_int16_t result; /* 0x00 - success */
243 /* u_int8_t options[] -- options */
244 } __attribute__ ((packed)) ng_l2cap_cfg_rsp_cp;
246 /* L2CAP configuration option */
250 /* u_int8_t value[] -- option value (depends on type) */
251 } __attribute__ ((packed)) ng_l2cap_cfg_opt_t;
252 typedef ng_l2cap_cfg_opt_t * ng_l2cap_cfg_opt_p;
254 /* L2CAP configuration option value */
256 u_int16_t mtu; /* NG_L2CAP_OPT_MTU */
257 u_int16_t flush_timo; /* NG_L2CAP_OPT_FLUSH_TIMO */
258 ng_l2cap_flow_t flow; /* NG_L2CAP_OPT_QOS */
260 } ng_l2cap_cfg_opt_val_t;
261 typedef ng_l2cap_cfg_opt_val_t * ng_l2cap_cfg_opt_val_p;
263 /* L2CAP Disconnect Request */
264 #define NG_L2CAP_DISCON_REQ 0x06
266 u_int16_t dcid; /* destination channel ID */
267 u_int16_t scid; /* source channel ID */
268 } __attribute__ ((packed)) ng_l2cap_discon_req_cp;
270 /* L2CAP Disconnect Response */
271 #define NG_L2CAP_DISCON_RSP 0x07
272 typedef ng_l2cap_discon_req_cp ng_l2cap_discon_rsp_cp;
274 /* L2CAP Echo Request */
275 #define NG_L2CAP_ECHO_REQ 0x08
276 /* No command parameters, only optional data */
278 /* L2CAP Echo Response */
279 #define NG_L2CAP_ECHO_RSP 0x09
280 #define NG_L2CAP_MAX_ECHO_SIZE \
281 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_cmd_hdr_t))
282 /* No command parameters, only optional data */
284 /* L2CAP Information Request */
285 #define NG_L2CAP_INFO_REQ 0x0a
287 u_int16_t type; /* requested information type */
288 } __attribute__ ((packed)) ng_l2cap_info_req_cp;
290 /* L2CAP Information Response */
291 #define NG_L2CAP_INFO_RSP 0x0b
293 u_int16_t type; /* requested information type */
294 u_int16_t result; /* 0x00 - success */
295 /* u_int8_t info[] -- info data (depends on type)
297 * NG_L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
299 } __attribute__ ((packed)) ng_l2cap_info_rsp_cp;
301 /* NG_L2CAP_CONNLESS_MTU */
304 } __attribute__ ((packed)) mtu;
305 } ng_l2cap_info_rsp_data_t;
306 typedef ng_l2cap_info_rsp_data_t * ng_l2cap_info_rsp_data_p;
308 #define NG_L2CAP_CMD_PARAM_UPDATE_REQUEST 0x12
311 uint16_t interval_min;
312 uint16_t interval_max;
313 uint16_t slave_latency;
314 uint16_t timeout_mpl;
315 } __attribute__ ((packed)) ng_l2cap_param_update_req_cp;
317 #define NG_L2CAP_CMD_PARAM_UPDATE_RESPONSE 0x13
318 #define NG_L2CAP_UPDATE_PARAM_ACCEPT 0
319 #define NG_L2CAP_UPDATE_PARAM_REJECT 1
321 //typedef uint16_t update_response;
322 /**************************************************************************
323 **************************************************************************
324 ** Upper layer protocol interface. L2CA_xxx messages
325 **************************************************************************
326 **************************************************************************/
331 * Bluetooth specification says that L2CA_xxx request must block until
332 * response is ready. We are not allowed to block in Netgraph, so we
333 * need to queue request and save some information that can be used
334 * later and help match request and response.
336 * The idea is to use "token" field from Netgraph message header. The
337 * upper layer protocol _MUST_ populate "token". L2CAP will queue request
338 * (using L2CAP command descriptor) and start processing. Later, when
339 * response is ready or timeout has occur L2CAP layer will create new
340 * Netgraph message, set "token" and RESP flag and send the message to
341 * the upper layer protocol.
343 * L2CA_xxx_Ind messages _WILL_NOT_ populate "token" and _WILL_NOT_
344 * set RESP flag. There is no reason for this, because they are just
345 * notifications and do not require acknowlegment.
347 * NOTE: This is _NOT_ what NG_MKRESPONSE and NG_RESPOND_MSG do, however
348 * it is somewhat similar.
351 /* L2CA data packet header */
353 u_int32_t token; /* token to use in L2CAP_L2CA_WRITE */
354 u_int16_t length; /* length of the data */
355 u_int16_t lcid; /* local channel ID */
357 } __attribute__ ((packed)) ng_l2cap_l2ca_hdr_t;
358 #define NG_L2CAP_L2CA_IDTYPE_BREDR 0
359 #define NG_L2CAP_L2CA_IDTYPE_ATT 1
360 #define NG_L2CAP_L2CA_IDTYPE_LE 2
361 #define NG_L2CAP_L2CA_IDTYPE_SMP 3
363 #define NGM_L2CAP_L2CA_CON 0x80
366 u_int16_t psm; /* Protocol/Service Multiplexor */
367 bdaddr_t bdaddr; /* remote unit address */
370 } ng_l2cap_l2ca_con_ip;
374 u_int16_t lcid; /* local channel ID */
375 uint16_t idtype; /*ID type*/
376 u_int16_t result; /* 0x00 - success */
377 u_int16_t status; /* if result != 0x00 */
379 } ng_l2cap_l2ca_con_op;
381 /* L2CA_ConnectInd */
382 #define NGM_L2CAP_L2CA_CON_IND 0x81
385 bdaddr_t bdaddr; /* remote unit address */
386 u_int16_t lcid; /* local channel ID */
387 u_int16_t psm; /* Procotol/Service Multiplexor */
388 u_int8_t ident; /* identifier */
389 u_int8_t linktype; /* link type*/
390 } ng_l2cap_l2ca_con_ind_ip;
391 /* No output parameters */
393 /* L2CA_ConnectRsp */
394 #define NGM_L2CAP_L2CA_CON_RSP 0x82
397 bdaddr_t bdaddr; /* remote unit address */
398 u_int8_t ident; /* "ident" from L2CAP_ConnectInd event */
399 u_int8_t linktype; /*link type */
400 u_int16_t lcid; /* local channel ID */
401 u_int16_t result; /* 0x00 - success */
402 u_int16_t status; /* if response != 0x00 */
403 } ng_l2cap_l2ca_con_rsp_ip;
407 u_int16_t result; /* 0x00 - success */
408 } ng_l2cap_l2ca_con_rsp_op;
411 #define NGM_L2CAP_L2CA_CFG 0x83
414 u_int16_t lcid; /* local channel ID */
415 u_int16_t imtu; /* receiving MTU for the local channel */
416 ng_l2cap_flow_t oflow; /* out flow */
417 u_int16_t flush_timo; /* flush timeout (msec) */
418 u_int16_t link_timo; /* link timeout (msec) */
419 } ng_l2cap_l2ca_cfg_ip;
423 u_int16_t result; /* 0x00 - success */
424 u_int16_t imtu; /* sending MTU for the remote channel */
425 ng_l2cap_flow_t oflow; /* out flow */
426 u_int16_t flush_timo; /* flush timeout (msec) */
427 } ng_l2cap_l2ca_cfg_op;
430 #define NGM_L2CAP_L2CA_CFG_RSP 0x84
433 u_int16_t lcid; /* local channel ID */
434 u_int16_t omtu; /* sending MTU for the local channel */
435 ng_l2cap_flow_t iflow; /* in FLOW */
436 } ng_l2cap_l2ca_cfg_rsp_ip;
440 u_int16_t result; /* 0x00 - sucsess */
441 } ng_l2cap_l2ca_cfg_rsp_op;
444 #define NGM_L2CAP_L2CA_CFG_IND 0x85
447 u_int16_t lcid; /* local channel ID */
448 u_int16_t omtu; /* outgoing MTU for the local channel */
449 ng_l2cap_flow_t iflow; /* in flow */
450 u_int16_t flush_timo; /* flush timeout (msec) */
451 } ng_l2cap_l2ca_cfg_ind_ip;
452 /* No output parameters */
454 /* L2CA_QoSViolationInd */
455 #define NGM_L2CAP_L2CA_QOS_IND 0x86
458 bdaddr_t bdaddr; /* remote unit address */
459 } ng_l2cap_l2ca_qos_ind_ip;
460 /* No output parameters */
462 /* L2CA_Disconnect */
463 #define NGM_L2CAP_L2CA_DISCON 0x87
466 u_int16_t lcid; /* local channel ID */
468 } ng_l2cap_l2ca_discon_ip;
472 u_int16_t result; /* 0x00 - sucsess */
473 } ng_l2cap_l2ca_discon_op;
475 /* L2CA_DisconnectInd */
476 #define NGM_L2CAP_L2CA_DISCON_IND 0x88
478 typedef ng_l2cap_l2ca_discon_ip ng_l2cap_l2ca_discon_ind_ip;
479 /* No output parameters */
481 /* L2CA_Write response */
482 #define NGM_L2CAP_L2CA_WRITE 0x89
483 /* No input parameters */
487 int result; /* result (0x00 - success) */
488 u_int16_t length; /* amount of data written */
489 u_int16_t lcid; /* local channel ID */
491 } ng_l2cap_l2ca_write_op;
493 /* L2CA_GroupCreate */
494 #define NGM_L2CAP_L2CA_GRP_CREATE 0x8a
497 u_int16_t psm; /* Protocol/Service Multiplexor */
498 } ng_l2cap_l2ca_grp_create_ip;
502 u_int16_t lcid; /* local group channel ID */
503 } ng_l2cap_l2ca_grp_create_op;
505 /* L2CA_GroupClose */
506 #define NGM_L2CAP_L2CA_GRP_CLOSE 0x8b
509 u_int16_t lcid; /* local group channel ID */
510 } ng_l2cap_l2ca_grp_close_ip;
515 * u_int16_t result; /* 0x00 - success */
516 * } ng_l2cap_l2ca_grp_close_op;
519 /* L2CA_GroupAddMember */
520 #define NGM_L2CAP_L2CA_GRP_ADD_MEMBER 0x8c
523 u_int16_t lcid; /* local group channel ID */
524 bdaddr_t bdaddr; /* remote unit address */
525 } ng_l2cap_l2ca_grp_add_member_ip;
529 u_int16_t result; /* 0x00 - success */
530 } ng_l2cap_l2ca_grp_add_member_op;
532 /* L2CA_GroupRemoveMember */
533 #define NGM_L2CAP_L2CA_GRP_REM_MEMBER 0x8d
535 typedef ng_l2cap_l2ca_grp_add_member_ip ng_l2cap_l2ca_grp_rem_member_ip;
539 * typedef ng_l2cap_l2ca_grp_add_member_op ng_l2cap_l2ca_grp_rem_member_op;
542 /* L2CA_GroupMembeship */
543 #define NGM_L2CAP_L2CA_GRP_MEMBERSHIP 0x8e
546 u_int16_t lcid; /* local group channel ID */
547 } ng_l2cap_l2ca_grp_get_members_ip;
551 u_int16_t result; /* 0x00 - success */
552 u_int16_t nmembers; /* number of group members */
553 /* bdaddr_t members[] -- group memebers */
554 } ng_l2cap_l2ca_grp_get_members_op;
557 #define NGM_L2CAP_L2CA_PING 0x8f
560 bdaddr_t bdaddr; /* remote unit address */
561 u_int16_t echo_size; /* size of echo data in bytes */
562 /* u_int8_t echo_data[] -- echo data */
563 } ng_l2cap_l2ca_ping_ip;
567 u_int16_t result; /* 0x00 - success */
568 bdaddr_t bdaddr; /* remote unit address */
569 u_int16_t echo_size; /* size of echo data in bytes */
570 /* u_int8_t echo_data[] -- echo data */
571 } ng_l2cap_l2ca_ping_op;
574 #define NGM_L2CAP_L2CA_GET_INFO 0x90
577 bdaddr_t bdaddr; /* remote unit address */
578 u_int16_t info_type; /* info type */
581 } ng_l2cap_l2ca_get_info_ip;
585 u_int16_t result; /* 0x00 - success */
586 u_int16_t info_size; /* size of info data in bytes */
587 /* u_int8_t info_data[] -- info data */
588 } ng_l2cap_l2ca_get_info_op;
590 /* L2CA_EnableCLT/L2CA_DisableCLT */
591 #define NGM_L2CAP_L2CA_ENABLE_CLT 0x91
594 u_int16_t psm; /* Protocol/Service Multiplexor */
595 u_int16_t enable; /* 0x00 - disable */
596 } ng_l2cap_l2ca_enable_clt_ip;
601 * u_int16_t result; /* 0x00 - success */
602 * } ng_l2cap_l2ca_enable_clt_op;
604 #define NGM_L2CAP_L2CA_ENC_CHANGE 0x92
609 } ng_l2cap_l2ca_enc_chg_op;
611 /**************************************************************************
612 **************************************************************************
613 ** L2CAP node messages
614 **************************************************************************
615 **************************************************************************/
617 /* L2CAP connection states */
618 #define NG_L2CAP_CON_CLOSED 0 /* connection closed */
619 #define NG_L2CAP_W4_LP_CON_CFM 1 /* waiting... */
620 #define NG_L2CAP_CON_OPEN 2 /* connection open */
622 /* L2CAP channel states */
623 #define NG_L2CAP_CLOSED 0 /* channel closed */
624 #define NG_L2CAP_W4_L2CAP_CON_RSP 1 /* wait for L2CAP resp. */
625 #define NG_L2CAP_W4_L2CA_CON_RSP 2 /* wait for upper resp. */
626 #define NG_L2CAP_CONFIG 3 /* L2CAP configuration */
627 #define NG_L2CAP_OPEN 4 /* channel open */
628 #define NG_L2CAP_W4_L2CAP_DISCON_RSP 5 /* wait for L2CAP discon. */
629 #define NG_L2CAP_W4_L2CA_DISCON_RSP 6 /* wait for upper discon. */
632 #define NG_L2CAP_CLT_SDP_DISABLED (1 << 0) /* disable SDP CLT */
633 #define NG_L2CAP_CLT_RFCOMM_DISABLED (1 << 1) /* disable RFCOMM CLT */
634 #define NG_L2CAP_CLT_TCP_DISABLED (1 << 2) /* disable TCP CLT */
637 #define NG_L2CAP_ALERT_LEVEL 1
638 #define NG_L2CAP_ERR_LEVEL 2
639 #define NG_L2CAP_WARN_LEVEL 3
640 #define NG_L2CAP_INFO_LEVEL 4
642 /* Get node flags (see flags above) */
643 #define NGM_L2CAP_NODE_GET_FLAGS 0x400 /* L2CAP -> User */
644 typedef u_int16_t ng_l2cap_node_flags_ep;
646 /* Get/Set debug level (see levels above) */
647 #define NGM_L2CAP_NODE_GET_DEBUG 0x401 /* L2CAP -> User */
648 #define NGM_L2CAP_NODE_SET_DEBUG 0x402 /* User -> L2CAP */
649 typedef u_int16_t ng_l2cap_node_debug_ep;
651 #define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */
654 }ng_l2cap_node_hook_info_ep;
656 #define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */
658 u_int32_t num_connections; /* number of connections */
659 } ng_l2cap_node_con_list_ep;
661 /* Connection flags */
662 #define NG_L2CAP_CON_TX (1 << 0) /* sending data */
663 #define NG_L2CAP_CON_RX (1 << 1) /* receiving data */
664 #define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */
665 #define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */
666 #define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */
667 #define NG_L2CAP_CON_DYING (1 << 5) /* connection is dying */
670 u_int8_t state; /* connection state */
671 u_int8_t flags; /* flags */
672 int16_t pending; /* num. pending packets */
673 u_int16_t con_handle; /* connection handle */
674 bdaddr_t remote; /* remote bdaddr */
675 } ng_l2cap_node_con_ep;
677 #define NG_L2CAP_MAX_CON_NUM \
678 ((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep))
680 #define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */
682 u_int32_t num_channels; /* number of channels */
683 } ng_l2cap_node_chan_list_ep;
686 u_int32_t state; /* channel state */
688 u_int16_t scid; /* source (local) channel ID */
689 u_int16_t dcid; /* destination (remote) channel ID */
691 u_int16_t imtu; /* incoming MTU */
692 u_int16_t omtu; /* outgoing MTU */
694 u_int16_t psm; /* PSM */
695 bdaddr_t remote; /* remote bdaddr */
696 } ng_l2cap_node_chan_ep;
698 #define NG_L2CAP_MAX_CHAN_NUM \
699 ((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep))
701 #define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */
702 #define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */
703 typedef u_int16_t ng_l2cap_node_auto_discon_ep;
705 #endif /* ndef _NETGRAPH_L2CAP_H_ */