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