Deleted Added
sdiff udiff text old ( 114878 ) new ( 139823 )
full compact
1/*
2 * ng_l2cap.h
3 *
4 * Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
15 *
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
26 * SUCH DAMAGE.
27 *
28 * $Id: ng_l2cap.h,v 1.2 2003/04/27 00:52:26 max Exp $
29 * $FreeBSD: head/sys/netgraph/bluetooth/include/ng_l2cap.h 114878 2003-05-10 21:44:42Z julian $
30 */
31
32/*
33 * This file contains everything that application needs to know about
34 * Link Layer Control and Adaptation Protocol (L2CAP). All information
35 * was obtained from Bluetooth Specification Book v1.1.
36 *
37 * This file can be included by both kernel and userland applications.
38 */
39
40#ifndef _NETGRAPH_L2CAP_H_
41#define _NETGRAPH_L2CAP_H_
42
43/**************************************************************************
44 **************************************************************************
45 ** Netgraph node hook name, type name and type cookie and commands
46 **************************************************************************
47 **************************************************************************/
48
49/* Netgraph node hook names */
50#define NG_L2CAP_HOOK_HCI "hci" /* HCI <-> L2CAP */
51#define NG_L2CAP_HOOK_L2C "l2c" /* L2CAP <-> Upper */
52#define NG_L2CAP_HOOK_CTL "ctl" /* L2CAP <-> User */
53
54/* Node type name and type cookie */
55#define NG_L2CAP_NODE_TYPE "l2cap"
56#define NGM_L2CAP_COOKIE 1000774185
57
58/**************************************************************************
59 **************************************************************************
60 ** Common defines and types (L2CAP)
61 **************************************************************************
62 **************************************************************************/
63
64/*
65 * Channel IDs are assigned relative to the instance of L2CAP node, i.e.
66 * relative to the unit. So the total number of channels that unit can have
67 * open at the same time is 0xffff - 0x0040 = 0xffbf (65471). This number
68 * does not depend on number of connections.
69 */
70
71#define NG_L2CAP_NULL_CID 0x0000 /* DO NOT USE THIS CID */
72#define NG_L2CAP_SIGNAL_CID 0x0001 /* signaling channel ID */
73#define NG_L2CAP_CLT_CID 0x0002 /* connectionless channel ID */
74 /* 0x0003 - 0x003f Reserved */
75#define NG_L2CAP_FIRST_CID 0x0040 /* dynamically alloc. (start) */
76#define NG_L2CAP_LAST_CID 0xffff /* dynamically alloc. (end) */
77
78/* L2CAP MTU */
79#define NG_L2CAP_MTU_MINIMUM 48
80#define NG_L2CAP_MTU_DEFAULT 672
81#define NG_L2CAP_MTU_MAXIMUM 0xffff
82
83/* L2CAP flush and link timeouts */
84#define NG_L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */
85#define NG_L2CAP_LINK_TIMO_DEFAULT 0xffff
86
87/* L2CAP Command Reject reasons */
88#define NG_L2CAP_REJ_NOT_UNDERSTOOD 0x0000
89#define NG_L2CAP_REJ_MTU_EXCEEDED 0x0001
90#define NG_L2CAP_REJ_INVALID_CID 0x0002
91/* 0x0003 - 0xffff - reserved for future use */
92
93/* Protocol/Service Multioplexor (PSM) values */
94#define NG_L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */
95#define NG_L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */
96#define NG_L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */
97#define NG_L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */
98/* 0x0006 - 0x1000 - reserved for future use */
99
100/* L2CAP Connection response command result codes */
101#define NG_L2CAP_SUCCESS 0x0000
102#define NG_L2CAP_PENDING 0x0001
103#define NG_L2CAP_PSM_NOT_SUPPORTED 0x0002
104#define NG_L2CAP_SEQUIRY_BLOCK 0x0003
105#define NG_L2CAP_NO_RESOURCES 0x0004
106#define NG_L2CAP_TIMEOUT 0xeeee
107#define NG_L2CAP_UNKNOWN 0xffff
108/* 0x0005 - 0xffff - reserved for future use */
109
110/* L2CAP Connection response status codes */
111#define NG_L2CAP_NO_INFO 0x0000
112#define NG_L2CAP_AUTH_PENDING 0x0001
113#define NG_L2CAP_AUTZ_PENDING 0x0002
114/* 0x0003 - 0xffff - reserved for future use */
115
116/* L2CAP Configuration response result codes */
117#define NG_L2CAP_UNACCEPTABLE_PARAMS 0x0001
118#define NG_L2CAP_REJECT 0x0002
119#define NG_L2CAP_UNKNOWN_OPTION 0x0003
120/* 0x0003 - 0xffff - reserved for future use */
121
122/* L2CAP Configuration options */
123#define NG_L2CAP_OPT_CFLAG_BIT 0x0001
124#define NG_L2CAP_OPT_CFLAG(flags) ((flags) & NG_L2CAP_OPT_CFLAG_BIT)
125#define NG_L2CAP_OPT_HINT_BIT 0x80
126#define NG_L2CAP_OPT_HINT(type) ((type) & NG_L2CAP_OPT_HINT_BIT)
127#define NG_L2CAP_OPT_HINT_MASK 0x7f
128#define NG_L2CAP_OPT_MTU 0x01
129#define NG_L2CAP_OPT_MTU_SIZE sizeof(u_int16_t)
130#define NG_L2CAP_OPT_FLUSH_TIMO 0x02
131#define NG_L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(u_int16_t)
132#define NG_L2CAP_OPT_QOS 0x03
133#define NG_L2CAP_OPT_QOS_SIZE sizeof(ng_l2cap_flow_t)
134/* 0x4 - 0xff - reserved for future use */
135
136/* L2CAP Information request type codes */
137#define NG_L2CAP_CONNLESS_MTU 0x0001
138/* 0x0002 - 0xffff - reserved for future use */
139
140/* L2CAP Information response codes */
141#define NG_L2CAP_NOT_SUPPORTED 0x0001
142/* 0x0002 - 0xffff - reserved for future use */
143
144/* L2CAP flow control */
145typedef struct {
146 u_int8_t flags; /* reserved for future use */
147 u_int8_t service_type; /* service type */
148 u_int32_t token_rate; /* bytes per second */
149 u_int32_t token_bucket_size; /* bytes */
150 u_int32_t peak_bandwidth; /* bytes per second */
151 u_int32_t latency; /* microseconds */
152 u_int32_t delay_variation; /* microseconds */
153} __attribute__ ((packed)) ng_l2cap_flow_t;
154typedef ng_l2cap_flow_t * ng_l2cap_flow_p;
155
156/**************************************************************************
157 **************************************************************************
158 ** Link level defines, headers and types
159 **************************************************************************
160 **************************************************************************/
161
162/* L2CAP header */
163typedef struct {
164 u_int16_t length; /* payload size */
165 u_int16_t dcid; /* destination channel ID */
166} __attribute__ ((packed)) ng_l2cap_hdr_t;
167
168/* L2CAP ConnectionLess Traffic (CLT) (if destination cid == 0x2) */
169typedef struct {
170 u_int16_t psm; /* Protocol/Service Multiplexor */
171} __attribute__ ((packed)) ng_l2cap_clt_hdr_t;
172
173#define NG_L2CAP_CLT_MTU_MAXIMUM \
174 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_clt_hdr_t))
175
176/* L2CAP command header */
177typedef struct {
178 u_int8_t code; /* command OpCode */
179 u_int8_t ident; /* identifier to match request and response */
180 u_int16_t length; /* command parameters length */
181} __attribute__ ((packed)) ng_l2cap_cmd_hdr_t;
182
183/* L2CAP Command Reject */
184#define NG_L2CAP_CMD_REJ 0x01
185typedef struct {
186 u_int16_t reason; /* reason to reject command */
187/* u_int8_t data[]; -- optional data (depends on reason) */
188} __attribute__ ((packed)) ng_l2cap_cmd_rej_cp;
189
190/* CommandReject data */
191typedef union {
192 /* NG_L2CAP_REJ_MTU_EXCEEDED */
193 struct {
194 u_int16_t mtu; /* actual signaling MTU */
195 } __attribute__ ((packed)) mtu;
196 /* NG_L2CAP_REJ_INVALID_CID */
197 struct {
198 u_int16_t scid; /* local CID */
199 u_int16_t dcid; /* remote CID */
200 } __attribute__ ((packed)) cid;
201} ng_l2cap_cmd_rej_data_t;
202typedef ng_l2cap_cmd_rej_data_t * ng_l2cap_cmd_rej_data_p;
203
204/* L2CAP Connection Request */
205#define NG_L2CAP_CON_REQ 0x02
206typedef struct {
207 u_int16_t psm; /* Protocol/Service Multiplexor (PSM) */
208 u_int16_t scid; /* source channel ID */
209} __attribute__ ((packed)) ng_l2cap_con_req_cp;
210
211/* L2CAP Connection Response */
212#define NG_L2CAP_CON_RSP 0x03
213typedef struct {
214 u_int16_t dcid; /* destination channel ID */
215 u_int16_t scid; /* source channel ID */
216 u_int16_t result; /* 0x00 - success */
217 u_int16_t status; /* more info if result != 0x00 */
218} __attribute__ ((packed)) ng_l2cap_con_rsp_cp;
219
220/* L2CAP Configuration Request */
221#define NG_L2CAP_CFG_REQ 0x04
222typedef struct {
223 u_int16_t dcid; /* destination channel ID */
224 u_int16_t flags; /* flags */
225/* u_int8_t options[] -- options */
226} __attribute__ ((packed)) ng_l2cap_cfg_req_cp;
227
228/* L2CAP Configuration Response */
229#define NG_L2CAP_CFG_RSP 0x05
230typedef struct {
231 u_int16_t scid; /* source channel ID */
232 u_int16_t flags; /* flags */
233 u_int16_t result; /* 0x00 - success */
234/* u_int8_t options[] -- options */
235} __attribute__ ((packed)) ng_l2cap_cfg_rsp_cp;
236
237/* L2CAP configuration option */
238typedef struct {
239 u_int8_t type;
240 u_int8_t length;
241/* u_int8_t value[] -- option value (depends on type) */
242} __attribute__ ((packed)) ng_l2cap_cfg_opt_t;
243typedef ng_l2cap_cfg_opt_t * ng_l2cap_cfg_opt_p;
244
245/* L2CAP configuration option value */
246typedef union {
247 u_int16_t mtu; /* NG_L2CAP_OPT_MTU */
248 u_int16_t flush_timo; /* NG_L2CAP_OPT_FLUSH_TIMO */
249 ng_l2cap_flow_t flow; /* NG_L2CAP_OPT_QOS */
250} ng_l2cap_cfg_opt_val_t;
251typedef ng_l2cap_cfg_opt_val_t * ng_l2cap_cfg_opt_val_p;
252
253/* L2CAP Disconnect Request */
254#define NG_L2CAP_DISCON_REQ 0x06
255typedef struct {
256 u_int16_t dcid; /* destination channel ID */
257 u_int16_t scid; /* source channel ID */
258} __attribute__ ((packed)) ng_l2cap_discon_req_cp;
259
260/* L2CAP Disconnect Response */
261#define NG_L2CAP_DISCON_RSP 0x07
262typedef ng_l2cap_discon_req_cp ng_l2cap_discon_rsp_cp;
263
264/* L2CAP Echo Request */
265#define NG_L2CAP_ECHO_REQ 0x08
266/* No command parameters, only optional data */
267
268/* L2CAP Echo Response */
269#define NG_L2CAP_ECHO_RSP 0x09
270#define NG_L2CAP_MAX_ECHO_SIZE \
271 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_cmd_hdr_t))
272/* No command parameters, only optional data */
273
274/* L2CAP Information Request */
275#define NG_L2CAP_INFO_REQ 0x0a
276typedef struct {
277 u_int16_t type; /* requested information type */
278} __attribute__ ((packed)) ng_l2cap_info_req_cp;
279
280/* L2CAP Information Response */
281#define NG_L2CAP_INFO_RSP 0x0b
282typedef struct {
283 u_int16_t type; /* requested information type */
284 u_int16_t result; /* 0x00 - success */
285/* u_int8_t info[] -- info data (depends on type)
286 *
287 * NG_L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
288 */
289} __attribute__ ((packed)) ng_l2cap_info_rsp_cp;
290
291typedef union {
292 /* NG_L2CAP_CONNLESS_MTU */
293 struct {
294 u_int16_t mtu;
295 } __attribute__ ((packed)) mtu;
296} ng_l2cap_info_rsp_data_t;
297typedef ng_l2cap_info_rsp_data_t * ng_l2cap_info_rsp_data_p;
298
299/**************************************************************************
300 **************************************************************************
301 ** Upper layer protocol interface. L2CA_xxx messages
302 **************************************************************************
303 **************************************************************************/
304
305/*
306 * NOTE! NOTE! NOTE!
307 *
308 * Bluetooth specification says that L2CA_xxx request must block until
309 * response is ready. We are not allowed to block in Netgraph, so we
310 * need to queue request and save some information that can be used
311 * later and help match request and response.
312 *
313 * The idea is to use "token" field from Netgraph message header. The
314 * upper layer protocol _MUST_ populate "token". L2CAP will queue request
315 * (using L2CAP command descriptor) and start processing. Later, when
316 * response is ready or timeout has occur L2CAP layer will create new
317 * Netgraph message, set "token" and RESP flag and send the message to
318 * the upper layer protocol.
319 *
320 * L2CA_xxx_Ind messages _WILL_NOT_ populate "token" and _WILL_NOT_
321 * set RESP flag. There is no reason for this, because they are just
322 * notifications and do not require acknowlegment.
323 *
324 * NOTE: This is _NOT_ what NG_MKRESPONSE and NG_RESPOND_MSG do, however
325 * it is somewhat similar.
326 */
327
328/* L2CA data packet header */
329typedef struct {
330 u_int32_t token; /* token to use in L2CAP_L2CA_WRITE */
331 u_int16_t length; /* length of the data */
332 u_int16_t lcid; /* local channel ID */
333} __attribute__ ((packed)) ng_l2cap_l2ca_hdr_t;
334
335/* L2CA_Connect */
336#define NGM_L2CAP_L2CA_CON 0x80
337/* Upper -> L2CAP */
338typedef struct {
339 u_int16_t psm; /* Protocol/Service Multiplexor */
340 bdaddr_t bdaddr; /* remote unit address */
341} ng_l2cap_l2ca_con_ip;
342
343/* L2CAP -> Upper */
344typedef struct {
345 u_int16_t lcid; /* local channel ID */
346 u_int16_t result; /* 0x00 - success */
347 u_int16_t status; /* if result != 0x00 */
348} ng_l2cap_l2ca_con_op;
349
350/* L2CA_ConnectInd */
351#define NGM_L2CAP_L2CA_CON_IND 0x81
352/* L2CAP -> Upper */
353typedef struct {
354 bdaddr_t bdaddr; /* remote unit address */
355 u_int16_t lcid; /* local channel ID */
356 u_int16_t psm; /* Procotol/Service Multiplexor */
357 u_int8_t ident; /* indentifier */
358 u_int8_t unused; /* place holder */
359} ng_l2cap_l2ca_con_ind_ip;
360/* No output parameters */
361
362/* L2CA_ConnectRsp */
363#define NGM_L2CAP_L2CA_CON_RSP 0x82
364/* Upper -> L2CAP */
365typedef struct {
366 bdaddr_t bdaddr; /* remote unit address */
367 u_int8_t ident; /* "ident" from L2CAP_ConnectInd event */
368 u_int8_t unused; /* place holder */
369 u_int16_t lcid; /* local channel ID */
370 u_int16_t result; /* 0x00 - success */
371 u_int16_t status; /* if response != 0x00 */
372} ng_l2cap_l2ca_con_rsp_ip;
373
374/* L2CAP -> Upper */
375typedef struct {
376 u_int16_t result; /* 0x00 - success */
377} ng_l2cap_l2ca_con_rsp_op;
378
379/* L2CA_Config */
380#define NGM_L2CAP_L2CA_CFG 0x83
381/* Upper -> L2CAP */
382typedef struct {
383 u_int16_t lcid; /* local channel ID */
384 u_int16_t imtu; /* receiving MTU for the local channel */
385 ng_l2cap_flow_t oflow; /* out flow */
386 u_int16_t flush_timo; /* flush timeout (msec) */
387 u_int16_t link_timo; /* link timeout (msec) */
388} ng_l2cap_l2ca_cfg_ip;
389
390/* L2CAP -> Upper */
391typedef struct {
392 u_int16_t result; /* 0x00 - success */
393 u_int16_t imtu; /* sending MTU for the remote channel */
394 ng_l2cap_flow_t oflow; /* out flow */
395 u_int16_t flush_timo; /* flush timeout (msec) */
396} ng_l2cap_l2ca_cfg_op;
397
398/* L2CA_ConfigRsp */
399#define NGM_L2CAP_L2CA_CFG_RSP 0x84
400/* Upper -> L2CAP */
401typedef struct {
402 u_int16_t lcid; /* local channel ID */
403 u_int16_t omtu; /* sending MTU for the local channel */
404 ng_l2cap_flow_t iflow; /* in FLOW */
405} ng_l2cap_l2ca_cfg_rsp_ip;
406
407/* L2CAP -> Upper */
408typedef struct {
409 u_int16_t result; /* 0x00 - sucsess */
410} ng_l2cap_l2ca_cfg_rsp_op;
411
412/* L2CA_ConfigInd */
413#define NGM_L2CAP_L2CA_CFG_IND 0x85
414/* L2CAP -> Upper */
415typedef struct {
416 u_int16_t lcid; /* local channel ID */
417 u_int16_t omtu; /* outgoing MTU for the local channel */
418 ng_l2cap_flow_t iflow; /* in flow */
419 u_int16_t flush_timo; /* flush timeout (msec) */
420} ng_l2cap_l2ca_cfg_ind_ip;
421/* No output parameters */
422
423/* L2CA_QoSViolationInd */
424#define NGM_L2CAP_L2CA_QOS_IND 0x86
425/* L2CAP -> Upper */
426typedef struct {
427 bdaddr_t bdaddr; /* remote unit address */
428} ng_l2cap_l2ca_qos_ind_ip;
429/* No output parameters */
430
431/* L2CA_Disconnect */
432#define NGM_L2CAP_L2CA_DISCON 0x87
433/* Upper -> L2CAP */
434typedef struct {
435 u_int16_t lcid; /* local channel ID */
436} ng_l2cap_l2ca_discon_ip;
437
438/* L2CAP -> Upper */
439typedef struct {
440 u_int16_t result; /* 0x00 - sucsess */
441} ng_l2cap_l2ca_discon_op;
442
443/* L2CA_DisconnectInd */
444#define NGM_L2CAP_L2CA_DISCON_IND 0x88
445/* L2CAP -> Upper */
446typedef ng_l2cap_l2ca_discon_ip ng_l2cap_l2ca_discon_ind_ip;
447/* No output parameters */
448
449/* L2CA_Write response */
450#define NGM_L2CAP_L2CA_WRITE 0x89
451/* No input parameters */
452
453/* L2CAP -> Upper */
454typedef struct {
455 int result; /* result (0x00 - success) */
456 u_int16_t length; /* amount of data written */
457 u_int16_t lcid; /* local channel ID */
458} ng_l2cap_l2ca_write_op;
459
460/* L2CA_GroupCreate */
461#define NGM_L2CAP_L2CA_GRP_CREATE 0x8a
462/* Upper -> L2CAP */
463typedef struct {
464 u_int16_t psm; /* Protocol/Service Multiplexor */
465} ng_l2cap_l2ca_grp_create_ip;
466
467/* L2CAP -> Upper */
468typedef struct {
469 u_int16_t lcid; /* local group channel ID */
470} ng_l2cap_l2ca_grp_create_op;
471
472/* L2CA_GroupClose */
473#define NGM_L2CAP_L2CA_GRP_CLOSE 0x8b
474/* Upper -> L2CAP */
475typedef struct {
476 u_int16_t lcid; /* local group channel ID */
477} ng_l2cap_l2ca_grp_close_ip;
478
479#if 0
480/* L2CAP -> Upper */
481 * typedef struct {
482 * u_int16_t result; /* 0x00 - success */
483 * } ng_l2cap_l2ca_grp_close_op;
484#endif
485
486/* L2CA_GroupAddMember */
487#define NGM_L2CAP_L2CA_GRP_ADD_MEMBER 0x8c
488/* Upper -> L2CAP */
489typedef struct {
490 u_int16_t lcid; /* local group channel ID */
491 bdaddr_t bdaddr; /* remote unit address */
492} ng_l2cap_l2ca_grp_add_member_ip;
493
494/* L2CAP -> Upper */
495typedef struct {
496 u_int16_t result; /* 0x00 - success */
497} ng_l2cap_l2ca_grp_add_member_op;
498
499/* L2CA_GroupRemoveMember */
500#define NGM_L2CAP_L2CA_GRP_REM_MEMBER 0x8d
501/* Upper -> L2CAP */
502typedef ng_l2cap_l2ca_grp_add_member_ip ng_l2cap_l2ca_grp_rem_member_ip;
503
504/* L2CAP -> Upper */
505#if 0
506 * typedef ng_l2cap_l2ca_grp_add_member_op ng_l2cap_l2ca_grp_rem_member_op;
507#endif
508
509/* L2CA_GroupMembeship */
510#define NGM_L2CAP_L2CA_GRP_MEMBERSHIP 0x8e
511/* Upper -> L2CAP */
512typedef struct {
513 u_int16_t lcid; /* local group channel ID */
514} ng_l2cap_l2ca_grp_get_members_ip;
515
516/* L2CAP -> Upper */
517typedef struct {
518 u_int16_t result; /* 0x00 - success */
519 u_int16_t nmembers; /* number of group members */
520/* bdaddr_t members[] -- group memebers */
521} ng_l2cap_l2ca_grp_get_members_op;
522
523/* L2CA_Ping */
524#define NGM_L2CAP_L2CA_PING 0x8f
525/* Upper -> L2CAP */
526typedef struct {
527 bdaddr_t bdaddr; /* remote unit address */
528 u_int16_t echo_size; /* size of echo data in bytes */
529/* u_int8_t echo_data[] -- echo data */
530} ng_l2cap_l2ca_ping_ip;
531
532/* L2CAP -> Upper */
533typedef struct {
534 u_int16_t result; /* 0x00 - success */
535 bdaddr_t bdaddr; /* remote unit address */
536 u_int16_t echo_size; /* size of echo data in bytes */
537/* u_int8_t echo_data[] -- echo data */
538} ng_l2cap_l2ca_ping_op;
539
540/* L2CA_GetInfo */
541#define NGM_L2CAP_L2CA_GET_INFO 0x90
542/* Upper -> L2CAP */
543typedef struct {
544 bdaddr_t bdaddr; /* remote unit address */
545 u_int16_t info_type; /* info type */
546} ng_l2cap_l2ca_get_info_ip;
547
548/* L2CAP -> Upper */
549typedef struct {
550 u_int16_t result; /* 0x00 - success */
551 u_int16_t info_size; /* size of info data in bytes */
552/* u_int8_t info_data[] -- info data */
553} ng_l2cap_l2ca_get_info_op;
554
555/* L2CA_EnableCLT/L2CA_DisableCLT */
556#define NGM_L2CAP_L2CA_ENABLE_CLT 0x91
557/* Upper -> L2CAP */
558typedef struct {
559 u_int16_t psm; /* Protocol/Service Multiplexor */
560 u_int16_t enable; /* 0x00 - disable */
561} ng_l2cap_l2ca_enable_clt_ip;
562
563#if 0
564/* L2CAP -> Upper */
565 * typedef struct {
566 * u_int16_t result; /* 0x00 - success */
567 * } ng_l2cap_l2ca_enable_clt_op;
568#endif
569
570/**************************************************************************
571 **************************************************************************
572 ** L2CAP node messages
573 **************************************************************************
574 **************************************************************************/
575
576/* L2CAP connection states */
577#define NG_L2CAP_CON_CLOSED 0 /* connection closed */
578#define NG_L2CAP_W4_LP_CON_CFM 1 /* waiting... */
579#define NG_L2CAP_CON_OPEN 2 /* connection open */
580
581/* L2CAP channel states */
582#define NG_L2CAP_CLOSED 0 /* channel closed */
583#define NG_L2CAP_W4_L2CAP_CON_RSP 1 /* wait for L2CAP resp. */
584#define NG_L2CAP_W4_L2CA_CON_RSP 2 /* wait for upper resp. */
585#define NG_L2CAP_CONFIG 3 /* L2CAP configuration */
586#define NG_L2CAP_OPEN 4 /* channel open */
587#define NG_L2CAP_W4_L2CAP_DISCON_RSP 5 /* wait for L2CAP discon. */
588#define NG_L2CAP_W4_L2CA_DISCON_RSP 6 /* wait for upper discon. */
589
590/* Node flags */
591#define NG_L2CAP_CLT_SDP_DISABLED (1 << 0) /* disable SDP CLT */
592#define NG_L2CAP_CLT_RFCOMM_DISABLED (1 << 1) /* disable RFCOMM CLT */
593#define NG_L2CAP_CLT_TCP_DISABLED (1 << 2) /* disable TCP CLT */
594
595/* Debug levels */
596#define NG_L2CAP_ALERT_LEVEL 1
597#define NG_L2CAP_ERR_LEVEL 2
598#define NG_L2CAP_WARN_LEVEL 3
599#define NG_L2CAP_INFO_LEVEL 4
600
601/* Get node flags (see flags above) */
602#define NGM_L2CAP_NODE_GET_FLAGS 0x400 /* L2CAP -> User */
603typedef u_int16_t ng_l2cap_node_flags_ep;
604
605/* Get/Set debug level (see levels above) */
606#define NGM_L2CAP_NODE_GET_DEBUG 0x401 /* L2CAP -> User */
607#define NGM_L2CAP_NODE_SET_DEBUG 0x402 /* User -> L2CAP */
608typedef u_int16_t ng_l2cap_node_debug_ep;
609
610#define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */
611/* bdaddr_t bdaddr; -- local (source BDADDR) */
612
613#define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */
614typedef struct {
615 u_int32_t num_connections; /* number of connections */
616} ng_l2cap_node_con_list_ep;
617
618/* Connection flags */
619#define NG_L2CAP_CON_TX (1 << 0) /* sending data */
620#define NG_L2CAP_CON_RX (1 << 1) /* receiving data */
621#define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */
622#define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */
623#define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */
624
625typedef struct {
626 u_int8_t state; /* connection state */
627 u_int8_t flags; /* flags */
628 int16_t pending; /* num. pending packets */
629 u_int16_t con_handle; /* connection handle */
630 bdaddr_t remote; /* remote bdaddr */
631} ng_l2cap_node_con_ep;
632
633#define NG_L2CAP_MAX_CON_NUM \
634 ((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep))
635
636#define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */
637typedef struct {
638 u_int32_t num_channels; /* number of channels */
639} ng_l2cap_node_chan_list_ep;
640
641typedef struct {
642 u_int32_t state; /* channel state */
643
644 u_int16_t scid; /* source (local) channel ID */
645 u_int16_t dcid; /* destination (remote) channel ID */
646
647 u_int16_t imtu; /* incomming MTU */
648 u_int16_t omtu; /* outgoing MTU */
649
650 u_int16_t psm; /* PSM */
651 bdaddr_t remote; /* remote bdaddr */
652} ng_l2cap_node_chan_ep;
653
654#define NG_L2CAP_MAX_CHAN_NUM \
655 ((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep))
656
657#define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */
658#define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */
659typedef u_int16_t ng_l2cap_node_auto_discon_ep;
660
661#endif /* ndef _NETGRAPH_L2CAP_H_ */
662