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