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$ 32 */ 33 34 /* 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. 38 * 39 * This file can be included by both kernel and userland applications. 40 */ 41 42 #ifndef _NETGRAPH_L2CAP_H_ 43 #define _NETGRAPH_L2CAP_H_ 44 45 /************************************************************************** 46 ************************************************************************** 47 ** Netgraph node hook name, type name and type cookie and commands 48 ************************************************************************** 49 **************************************************************************/ 50 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 */ 55 56 /* Node type name and type cookie */ 57 #define NG_L2CAP_NODE_TYPE "l2cap" 58 #define NGM_L2CAP_COOKIE 1000774185 59 60 /************************************************************************** 61 ************************************************************************** 62 ** Common defines and types (L2CAP) 63 ************************************************************************** 64 **************************************************************************/ 65 66 /* 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. 71 */ 72 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 84 85 86 /* L2CAP MTU */ 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 91 92 /* L2CAP flush and link timeouts */ 93 #define NG_L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */ 94 #define NG_L2CAP_LINK_TIMO_DEFAULT 0xffff 95 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 */ 101 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 */ 108 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 */ 118 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 */ 124 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 */ 130 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 */ 144 145 /* L2CAP Information request type codes */ 146 #define NG_L2CAP_CONNLESS_MTU 0x0001 147 /* 0x0002 - 0xffff - reserved for future use */ 148 149 /* L2CAP Information response codes */ 150 #define NG_L2CAP_NOT_SUPPORTED 0x0001 151 /* 0x0002 - 0xffff - reserved for future use */ 152 153 /* L2CAP flow control */ 154 typedef struct { 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; 164 165 /************************************************************************** 166 ************************************************************************** 167 ** Link level defines, headers and types 168 ************************************************************************** 169 **************************************************************************/ 170 171 /* L2CAP header */ 172 typedef struct { 173 u_int16_t length; /* payload size */ 174 u_int16_t dcid; /* destination channel ID */ 175 } __attribute__ ((packed)) ng_l2cap_hdr_t; 176 177 /* L2CAP ConnectionLess Traffic (CLT) (if destination cid == 0x2) */ 178 typedef struct { 179 u_int16_t psm; /* Protocol/Service Multiplexor */ 180 } __attribute__ ((packed)) ng_l2cap_clt_hdr_t; 181 182 #define NG_L2CAP_CLT_MTU_MAXIMUM \ 183 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_clt_hdr_t)) 184 185 /* L2CAP command header */ 186 typedef struct { 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; 191 192 /* L2CAP Command Reject */ 193 #define NG_L2CAP_CMD_REJ 0x01 194 typedef struct { 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; 198 199 /* CommandReject data */ 200 typedef union { 201 /* NG_L2CAP_REJ_MTU_EXCEEDED */ 202 struct { 203 u_int16_t mtu; /* actual signaling MTU */ 204 } __attribute__ ((packed)) mtu; 205 /* NG_L2CAP_REJ_INVALID_CID */ 206 struct { 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; 212 213 /* L2CAP Connection Request */ 214 #define NG_L2CAP_CON_REQ 0x02 215 typedef struct { 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; 219 220 /* L2CAP Connection Response */ 221 #define NG_L2CAP_CON_RSP 0x03 222 typedef struct { 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; 228 229 /* L2CAP Configuration Request */ 230 #define NG_L2CAP_CFG_REQ 0x04 231 typedef struct { 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; 236 237 /* L2CAP Configuration Response */ 238 #define NG_L2CAP_CFG_RSP 0x05 239 typedef struct { 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; 245 246 /* L2CAP configuration option */ 247 typedef struct { 248 u_int8_t type; 249 u_int8_t length; 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; 253 254 /* L2CAP configuration option value */ 255 typedef union { 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 */ 259 } ng_l2cap_cfg_opt_val_t; 260 typedef ng_l2cap_cfg_opt_val_t * ng_l2cap_cfg_opt_val_p; 261 262 /* L2CAP Disconnect Request */ 263 #define NG_L2CAP_DISCON_REQ 0x06 264 typedef struct { 265 u_int16_t dcid; /* destination channel ID */ 266 u_int16_t scid; /* source channel ID */ 267 } __attribute__ ((packed)) ng_l2cap_discon_req_cp; 268 269 /* L2CAP Disconnect Response */ 270 #define NG_L2CAP_DISCON_RSP 0x07 271 typedef ng_l2cap_discon_req_cp ng_l2cap_discon_rsp_cp; 272 273 /* L2CAP Echo Request */ 274 #define NG_L2CAP_ECHO_REQ 0x08 275 /* No command parameters, only optional data */ 276 277 /* L2CAP Echo Response */ 278 #define NG_L2CAP_ECHO_RSP 0x09 279 #define NG_L2CAP_MAX_ECHO_SIZE \ 280 (NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_cmd_hdr_t)) 281 /* No command parameters, only optional data */ 282 283 /* L2CAP Information Request */ 284 #define NG_L2CAP_INFO_REQ 0x0a 285 typedef struct { 286 u_int16_t type; /* requested information type */ 287 } __attribute__ ((packed)) ng_l2cap_info_req_cp; 288 289 /* L2CAP Information Response */ 290 #define NG_L2CAP_INFO_RSP 0x0b 291 typedef struct { 292 u_int16_t type; /* requested information type */ 293 u_int16_t result; /* 0x00 - success */ 294 /* u_int8_t info[] -- info data (depends on type) 295 * 296 * NG_L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU 297 */ 298 } __attribute__ ((packed)) ng_l2cap_info_rsp_cp; 299 typedef union { 300 /* NG_L2CAP_CONNLESS_MTU */ 301 struct { 302 u_int16_t mtu; 303 } __attribute__ ((packed)) mtu; 304 } ng_l2cap_info_rsp_data_t; 305 typedef ng_l2cap_info_rsp_data_t * ng_l2cap_info_rsp_data_p; 306 307 #define NG_L2CAP_CMD_PARAM_UPDATE_REQUEST 0x12 308 309 typedef struct { 310 uint16_t interval_min; 311 uint16_t interval_max; 312 uint16_t slave_latency; 313 uint16_t timeout_mpl; 314 } __attribute__ ((packed)) ng_l2cap_param_update_req_cp; 315 316 #define NG_L2CAP_CMD_PARAM_UPDATE_RESPONSE 0x13 317 #define NG_L2CAP_UPDATE_PARAM_ACCEPT 0 318 #define NG_L2CAP_UPDATE_PARAM_REJECT 1 319 320 //typedef uint16_t update_response; 321 /************************************************************************** 322 ************************************************************************** 323 ** Upper layer protocol interface. L2CA_xxx messages 324 ************************************************************************** 325 **************************************************************************/ 326 327 /* 328 * NOTE! NOTE! NOTE! 329 * 330 * Bluetooth specification says that L2CA_xxx request must block until 331 * response is ready. We are not allowed to block in Netgraph, so we 332 * need to queue request and save some information that can be used 333 * later and help match request and response. 334 * 335 * The idea is to use "token" field from Netgraph message header. The 336 * upper layer protocol _MUST_ populate "token". L2CAP will queue request 337 * (using L2CAP command descriptor) and start processing. Later, when 338 * response is ready or timeout has occur L2CAP layer will create new 339 * Netgraph message, set "token" and RESP flag and send the message to 340 * the upper layer protocol. 341 * 342 * L2CA_xxx_Ind messages _WILL_NOT_ populate "token" and _WILL_NOT_ 343 * set RESP flag. There is no reason for this, because they are just 344 * notifications and do not require acknowlegment. 345 * 346 * NOTE: This is _NOT_ what NG_MKRESPONSE and NG_RESPOND_MSG do, however 347 * it is somewhat similar. 348 */ 349 350 /* L2CA data packet header */ 351 typedef struct { 352 u_int32_t token; /* token to use in L2CAP_L2CA_WRITE */ 353 u_int16_t length; /* length of the data */ 354 u_int16_t lcid; /* local channel ID */ 355 uint16_t idtype; 356 } __attribute__ ((packed)) ng_l2cap_l2ca_hdr_t; 357 #define NG_L2CAP_L2CA_IDTYPE_BREDR 0 358 #define NG_L2CAP_L2CA_IDTYPE_ATT 1 359 #define NG_L2CAP_L2CA_IDTYPE_LE 2 360 /* L2CA_Connect */ 361 #define NGM_L2CAP_L2CA_CON 0x80 362 /* Upper -> L2CAP */ 363 typedef struct { 364 u_int16_t psm; /* Protocol/Service Multiplexor */ 365 bdaddr_t bdaddr; /* remote unit address */ 366 uint8_t linktype; 367 uint8_t idtype; 368 } ng_l2cap_l2ca_con_ip; 369 370 /* L2CAP -> Upper */ 371 typedef struct { 372 u_int16_t lcid; /* local channel ID */ 373 uint16_t idtype; /*ID type*/ 374 u_int16_t result; /* 0x00 - success */ 375 u_int16_t status; /* if result != 0x00 */ 376 } ng_l2cap_l2ca_con_op; 377 378 /* L2CA_ConnectInd */ 379 #define NGM_L2CAP_L2CA_CON_IND 0x81 380 /* L2CAP -> Upper */ 381 typedef struct { 382 bdaddr_t bdaddr; /* remote unit address */ 383 u_int16_t lcid; /* local channel ID */ 384 u_int16_t psm; /* Procotol/Service Multiplexor */ 385 u_int8_t ident; /* indentifier */ 386 u_int8_t linktype; /* link type*/ 387 } ng_l2cap_l2ca_con_ind_ip; 388 /* No output parameters */ 389 390 /* L2CA_ConnectRsp */ 391 #define NGM_L2CAP_L2CA_CON_RSP 0x82 392 /* Upper -> L2CAP */ 393 typedef struct { 394 bdaddr_t bdaddr; /* remote unit address */ 395 u_int8_t ident; /* "ident" from L2CAP_ConnectInd event */ 396 u_int8_t linktype; /*link type */ 397 u_int16_t lcid; /* local channel ID */ 398 u_int16_t result; /* 0x00 - success */ 399 u_int16_t status; /* if response != 0x00 */ 400 } ng_l2cap_l2ca_con_rsp_ip; 401 402 /* L2CAP -> Upper */ 403 typedef struct { 404 u_int16_t result; /* 0x00 - success */ 405 } ng_l2cap_l2ca_con_rsp_op; 406 407 /* L2CA_Config */ 408 #define NGM_L2CAP_L2CA_CFG 0x83 409 /* Upper -> L2CAP */ 410 typedef struct { 411 u_int16_t lcid; /* local channel ID */ 412 u_int16_t imtu; /* receiving MTU for the local channel */ 413 ng_l2cap_flow_t oflow; /* out flow */ 414 u_int16_t flush_timo; /* flush timeout (msec) */ 415 u_int16_t link_timo; /* link timeout (msec) */ 416 } ng_l2cap_l2ca_cfg_ip; 417 418 /* L2CAP -> Upper */ 419 typedef struct { 420 u_int16_t result; /* 0x00 - success */ 421 u_int16_t imtu; /* sending MTU for the remote channel */ 422 ng_l2cap_flow_t oflow; /* out flow */ 423 u_int16_t flush_timo; /* flush timeout (msec) */ 424 } ng_l2cap_l2ca_cfg_op; 425 426 /* L2CA_ConfigRsp */ 427 #define NGM_L2CAP_L2CA_CFG_RSP 0x84 428 /* Upper -> L2CAP */ 429 typedef struct { 430 u_int16_t lcid; /* local channel ID */ 431 u_int16_t omtu; /* sending MTU for the local channel */ 432 ng_l2cap_flow_t iflow; /* in FLOW */ 433 } ng_l2cap_l2ca_cfg_rsp_ip; 434 435 /* L2CAP -> Upper */ 436 typedef struct { 437 u_int16_t result; /* 0x00 - sucsess */ 438 } ng_l2cap_l2ca_cfg_rsp_op; 439 440 /* L2CA_ConfigInd */ 441 #define NGM_L2CAP_L2CA_CFG_IND 0x85 442 /* L2CAP -> Upper */ 443 typedef struct { 444 u_int16_t lcid; /* local channel ID */ 445 u_int16_t omtu; /* outgoing MTU for the local channel */ 446 ng_l2cap_flow_t iflow; /* in flow */ 447 u_int16_t flush_timo; /* flush timeout (msec) */ 448 } ng_l2cap_l2ca_cfg_ind_ip; 449 /* No output parameters */ 450 451 /* L2CA_QoSViolationInd */ 452 #define NGM_L2CAP_L2CA_QOS_IND 0x86 453 /* L2CAP -> Upper */ 454 typedef struct { 455 bdaddr_t bdaddr; /* remote unit address */ 456 } ng_l2cap_l2ca_qos_ind_ip; 457 /* No output parameters */ 458 459 /* L2CA_Disconnect */ 460 #define NGM_L2CAP_L2CA_DISCON 0x87 461 /* Upper -> L2CAP */ 462 typedef struct { 463 u_int16_t lcid; /* local channel ID */ 464 u_int16_t idtype; 465 } ng_l2cap_l2ca_discon_ip; 466 467 /* L2CAP -> Upper */ 468 typedef struct { 469 u_int16_t result; /* 0x00 - sucsess */ 470 } ng_l2cap_l2ca_discon_op; 471 472 /* L2CA_DisconnectInd */ 473 #define NGM_L2CAP_L2CA_DISCON_IND 0x88 474 /* L2CAP -> Upper */ 475 typedef ng_l2cap_l2ca_discon_ip ng_l2cap_l2ca_discon_ind_ip; 476 /* No output parameters */ 477 478 /* L2CA_Write response */ 479 #define NGM_L2CAP_L2CA_WRITE 0x89 480 /* No input parameters */ 481 482 /* L2CAP -> Upper */ 483 typedef struct { 484 int result; /* result (0x00 - success) */ 485 u_int16_t length; /* amount of data written */ 486 u_int16_t lcid; /* local channel ID */ 487 uint16_t idtype; 488 } ng_l2cap_l2ca_write_op; 489 490 /* L2CA_GroupCreate */ 491 #define NGM_L2CAP_L2CA_GRP_CREATE 0x8a 492 /* Upper -> L2CAP */ 493 typedef struct { 494 u_int16_t psm; /* Protocol/Service Multiplexor */ 495 } ng_l2cap_l2ca_grp_create_ip; 496 497 /* L2CAP -> Upper */ 498 typedef struct { 499 u_int16_t lcid; /* local group channel ID */ 500 } ng_l2cap_l2ca_grp_create_op; 501 502 /* L2CA_GroupClose */ 503 #define NGM_L2CAP_L2CA_GRP_CLOSE 0x8b 504 /* Upper -> L2CAP */ 505 typedef struct { 506 u_int16_t lcid; /* local group channel ID */ 507 } ng_l2cap_l2ca_grp_close_ip; 508 509 #if 0 510 /* L2CAP -> Upper */ 511 * typedef struct { 512 * u_int16_t result; /* 0x00 - success */ 513 * } ng_l2cap_l2ca_grp_close_op; 514 #endif 515 516 /* L2CA_GroupAddMember */ 517 #define NGM_L2CAP_L2CA_GRP_ADD_MEMBER 0x8c 518 /* Upper -> L2CAP */ 519 typedef struct { 520 u_int16_t lcid; /* local group channel ID */ 521 bdaddr_t bdaddr; /* remote unit address */ 522 } ng_l2cap_l2ca_grp_add_member_ip; 523 524 /* L2CAP -> Upper */ 525 typedef struct { 526 u_int16_t result; /* 0x00 - success */ 527 } ng_l2cap_l2ca_grp_add_member_op; 528 529 /* L2CA_GroupRemoveMember */ 530 #define NGM_L2CAP_L2CA_GRP_REM_MEMBER 0x8d 531 /* Upper -> L2CAP */ 532 typedef ng_l2cap_l2ca_grp_add_member_ip ng_l2cap_l2ca_grp_rem_member_ip; 533 534 /* L2CAP -> Upper */ 535 #if 0 536 * typedef ng_l2cap_l2ca_grp_add_member_op ng_l2cap_l2ca_grp_rem_member_op; 537 #endif 538 539 /* L2CA_GroupMembeship */ 540 #define NGM_L2CAP_L2CA_GRP_MEMBERSHIP 0x8e 541 /* Upper -> L2CAP */ 542 typedef struct { 543 u_int16_t lcid; /* local group channel ID */ 544 } ng_l2cap_l2ca_grp_get_members_ip; 545 546 /* L2CAP -> Upper */ 547 typedef struct { 548 u_int16_t result; /* 0x00 - success */ 549 u_int16_t nmembers; /* number of group members */ 550 /* bdaddr_t members[] -- group memebers */ 551 } ng_l2cap_l2ca_grp_get_members_op; 552 553 /* L2CA_Ping */ 554 #define NGM_L2CAP_L2CA_PING 0x8f 555 /* Upper -> L2CAP */ 556 typedef struct { 557 bdaddr_t bdaddr; /* remote unit address */ 558 u_int16_t echo_size; /* size of echo data in bytes */ 559 /* u_int8_t echo_data[] -- echo data */ 560 } ng_l2cap_l2ca_ping_ip; 561 562 /* L2CAP -> Upper */ 563 typedef struct { 564 u_int16_t result; /* 0x00 - success */ 565 bdaddr_t bdaddr; /* remote unit address */ 566 u_int16_t echo_size; /* size of echo data in bytes */ 567 /* u_int8_t echo_data[] -- echo data */ 568 } ng_l2cap_l2ca_ping_op; 569 570 /* L2CA_GetInfo */ 571 #define NGM_L2CAP_L2CA_GET_INFO 0x90 572 /* Upper -> L2CAP */ 573 typedef struct { 574 bdaddr_t bdaddr; /* remote unit address */ 575 u_int16_t info_type; /* info type */ 576 uint8_t linktype; 577 uint8_t unused; 578 } ng_l2cap_l2ca_get_info_ip; 579 580 /* L2CAP -> Upper */ 581 typedef struct { 582 u_int16_t result; /* 0x00 - success */ 583 u_int16_t info_size; /* size of info data in bytes */ 584 /* u_int8_t info_data[] -- info data */ 585 } ng_l2cap_l2ca_get_info_op; 586 587 /* L2CA_EnableCLT/L2CA_DisableCLT */ 588 #define NGM_L2CAP_L2CA_ENABLE_CLT 0x91 589 /* Upper -> L2CAP */ 590 typedef struct { 591 u_int16_t psm; /* Protocol/Service Multiplexor */ 592 u_int16_t enable; /* 0x00 - disable */ 593 } ng_l2cap_l2ca_enable_clt_ip; 594 595 #if 0 596 /* L2CAP -> Upper */ 597 * typedef struct { 598 * u_int16_t result; /* 0x00 - success */ 599 * } ng_l2cap_l2ca_enable_clt_op; 600 #endif 601 602 /************************************************************************** 603 ************************************************************************** 604 ** L2CAP node messages 605 ************************************************************************** 606 **************************************************************************/ 607 608 /* L2CAP connection states */ 609 #define NG_L2CAP_CON_CLOSED 0 /* connection closed */ 610 #define NG_L2CAP_W4_LP_CON_CFM 1 /* waiting... */ 611 #define NG_L2CAP_CON_OPEN 2 /* connection open */ 612 613 /* L2CAP channel states */ 614 #define NG_L2CAP_CLOSED 0 /* channel closed */ 615 #define NG_L2CAP_W4_L2CAP_CON_RSP 1 /* wait for L2CAP resp. */ 616 #define NG_L2CAP_W4_L2CA_CON_RSP 2 /* wait for upper resp. */ 617 #define NG_L2CAP_CONFIG 3 /* L2CAP configuration */ 618 #define NG_L2CAP_OPEN 4 /* channel open */ 619 #define NG_L2CAP_W4_L2CAP_DISCON_RSP 5 /* wait for L2CAP discon. */ 620 #define NG_L2CAP_W4_L2CA_DISCON_RSP 6 /* wait for upper discon. */ 621 622 /* Node flags */ 623 #define NG_L2CAP_CLT_SDP_DISABLED (1 << 0) /* disable SDP CLT */ 624 #define NG_L2CAP_CLT_RFCOMM_DISABLED (1 << 1) /* disable RFCOMM CLT */ 625 #define NG_L2CAP_CLT_TCP_DISABLED (1 << 2) /* disable TCP CLT */ 626 627 /* Debug levels */ 628 #define NG_L2CAP_ALERT_LEVEL 1 629 #define NG_L2CAP_ERR_LEVEL 2 630 #define NG_L2CAP_WARN_LEVEL 3 631 #define NG_L2CAP_INFO_LEVEL 4 632 633 /* Get node flags (see flags above) */ 634 #define NGM_L2CAP_NODE_GET_FLAGS 0x400 /* L2CAP -> User */ 635 typedef u_int16_t ng_l2cap_node_flags_ep; 636 637 /* Get/Set debug level (see levels above) */ 638 #define NGM_L2CAP_NODE_GET_DEBUG 0x401 /* L2CAP -> User */ 639 #define NGM_L2CAP_NODE_SET_DEBUG 0x402 /* User -> L2CAP */ 640 typedef u_int16_t ng_l2cap_node_debug_ep; 641 642 #define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */ 643 typedef struct { 644 bdaddr_t addr; 645 }ng_l2cap_node_hook_info_ep; 646 647 #define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */ 648 typedef struct { 649 u_int32_t num_connections; /* number of connections */ 650 } ng_l2cap_node_con_list_ep; 651 652 /* Connection flags */ 653 #define NG_L2CAP_CON_TX (1 << 0) /* sending data */ 654 #define NG_L2CAP_CON_RX (1 << 1) /* receiving data */ 655 #define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */ 656 #define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */ 657 #define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */ 658 #define NG_L2CAP_CON_DYING (1 << 5) /* connection is dying */ 659 660 typedef struct { 661 u_int8_t state; /* connection state */ 662 u_int8_t flags; /* flags */ 663 int16_t pending; /* num. pending packets */ 664 u_int16_t con_handle; /* connection handle */ 665 bdaddr_t remote; /* remote bdaddr */ 666 } ng_l2cap_node_con_ep; 667 668 #define NG_L2CAP_MAX_CON_NUM \ 669 ((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep)) 670 671 #define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */ 672 typedef struct { 673 u_int32_t num_channels; /* number of channels */ 674 } ng_l2cap_node_chan_list_ep; 675 676 typedef struct { 677 u_int32_t state; /* channel state */ 678 679 u_int16_t scid; /* source (local) channel ID */ 680 u_int16_t dcid; /* destination (remote) channel ID */ 681 682 u_int16_t imtu; /* incomming MTU */ 683 u_int16_t omtu; /* outgoing MTU */ 684 685 u_int16_t psm; /* PSM */ 686 bdaddr_t remote; /* remote bdaddr */ 687 } ng_l2cap_node_chan_ep; 688 689 #define NG_L2CAP_MAX_CHAN_NUM \ 690 ((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep)) 691 692 #define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */ 693 #define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */ 694 typedef u_int16_t ng_l2cap_node_auto_discon_ep; 695 696 #endif /* ndef _NETGRAPH_L2CAP_H_ */ 697 698