Path: blob/main/sys/netgraph/bluetooth/include/ng_l2cap.h
34814 views
/*1* ng_l2cap.h2*/34/*-5* SPDX-License-Identifier: BSD-2-Clause6*7* Copyright (c) Maksim Yevmenkin <[email protected]>8* All rights reserved.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer.15* 2. Redistributions in binary form must reproduce the above copyright16* notice, this list of conditions and the following disclaimer in the17* documentation and/or other materials provided with the distribution.18*19* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*31* $Id: ng_l2cap.h,v 1.2 2003/04/27 00:52:26 max Exp $32*/3334/*35* This file contains everything that application needs to know about36* Link Layer Control and Adaptation Protocol (L2CAP). All information37* was obtained from Bluetooth Specification Book v1.1.38*39* This file can be included by both kernel and userland applications.40*/4142#ifndef _NETGRAPH_L2CAP_H_43#define _NETGRAPH_L2CAP_H_4445/**************************************************************************46**************************************************************************47** Netgraph node hook name, type name and type cookie and commands48**************************************************************************49**************************************************************************/5051/* 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 */5556/* Node type name and type cookie */57#define NG_L2CAP_NODE_TYPE "l2cap"58#define NGM_L2CAP_COOKIE 10007741855960/**************************************************************************61**************************************************************************62** Common defines and types (L2CAP)63**************************************************************************64**************************************************************************/6566/*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 have69* open at the same time is 0xffff - 0x0040 = 0xffbf (65471). This number70* does not depend on number of connections.71*/7273#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 0x000377#define NG_L2CAP_ATT_CID 0x000478#define NG_L2CAP_LESIGNAL_CID 0x000579#define NG_L2CAP_SMP_CID 0x000680/* 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 0x007f8485/* L2CAP MTU */86#define NG_L2CAP_MTU_LE_MINIMAM 2387#define NG_L2CAP_MTU_MINIMUM 4888#define NG_L2CAP_MTU_DEFAULT 67289#define NG_L2CAP_MTU_MAXIMUM 0xffff9091/* L2CAP flush and link timeouts */92#define NG_L2CAP_FLUSH_TIMO_DEFAULT 0xffff /* always retransmit */93#define NG_L2CAP_LINK_TIMO_DEFAULT 0xffff9495/* L2CAP Command Reject reasons */96#define NG_L2CAP_REJ_NOT_UNDERSTOOD 0x000097#define NG_L2CAP_REJ_MTU_EXCEEDED 0x000198#define NG_L2CAP_REJ_INVALID_CID 0x000299/* 0x0003 - 0xffff - reserved for future use */100101/* Protocol/Service Multioplexor (PSM) values */102#define NG_L2CAP_PSM_ANY 0x0000 /* Any/Invalid PSM */103#define NG_L2CAP_PSM_SDP 0x0001 /* Service Discovery Protocol */104#define NG_L2CAP_PSM_RFCOMM 0x0003 /* RFCOMM protocol */105#define NG_L2CAP_PSM_TCP 0x0005 /* Telephony Control Protocol */106/* 0x0006 - 0x1000 - reserved for future use */107108/* L2CAP Connection response command result codes */109#define NG_L2CAP_SUCCESS 0x0000110#define NG_L2CAP_PENDING 0x0001111#define NG_L2CAP_PSM_NOT_SUPPORTED 0x0002112#define NG_L2CAP_SEQUIRY_BLOCK 0x0003113#define NG_L2CAP_NO_RESOURCES 0x0004114#define NG_L2CAP_TIMEOUT 0xeeee115#define NG_L2CAP_UNKNOWN 0xffff116/* 0x0005 - 0xffff - reserved for future use */117118/* L2CAP Connection response status codes */119#define NG_L2CAP_NO_INFO 0x0000120#define NG_L2CAP_AUTH_PENDING 0x0001121#define NG_L2CAP_AUTZ_PENDING 0x0002122/* 0x0003 - 0xffff - reserved for future use */123124/* L2CAP Configuration response result codes */125#define NG_L2CAP_UNACCEPTABLE_PARAMS 0x0001126#define NG_L2CAP_REJECT 0x0002127#define NG_L2CAP_UNKNOWN_OPTION 0x0003128/* 0x0003 - 0xffff - reserved for future use */129130/* L2CAP Configuration options */131#define NG_L2CAP_OPT_CFLAG_BIT 0x0001132#define NG_L2CAP_OPT_CFLAG(flags) ((flags) & NG_L2CAP_OPT_CFLAG_BIT)133#define NG_L2CAP_OPT_HINT_BIT 0x80134#define NG_L2CAP_OPT_HINT(type) ((type) & NG_L2CAP_OPT_HINT_BIT)135#define NG_L2CAP_OPT_HINT_MASK 0x7f136#define NG_L2CAP_OPT_MTU 0x01137#define NG_L2CAP_OPT_MTU_SIZE sizeof(u_int16_t)138#define NG_L2CAP_OPT_FLUSH_TIMO 0x02139#define NG_L2CAP_OPT_FLUSH_TIMO_SIZE sizeof(u_int16_t)140#define NG_L2CAP_OPT_QOS 0x03141#define NG_L2CAP_OPT_QOS_SIZE sizeof(ng_l2cap_flow_t)142/* 0x4 - 0xff - reserved for future use */143144/* L2CAP Information request type codes */145#define NG_L2CAP_CONNLESS_MTU 0x0001146/* 0x0002 - 0xffff - reserved for future use */147148/* L2CAP Information response codes */149#define NG_L2CAP_NOT_SUPPORTED 0x0001150/* 0x0002 - 0xffff - reserved for future use */151152/* L2CAP flow control */153typedef struct {154u_int8_t flags; /* reserved for future use */155u_int8_t service_type; /* service type */156u_int32_t token_rate; /* bytes per second */157u_int32_t token_bucket_size; /* bytes */158u_int32_t peak_bandwidth; /* bytes per second */159u_int32_t latency; /* microseconds */160u_int32_t delay_variation; /* microseconds */161} __attribute__ ((packed)) ng_l2cap_flow_t;162typedef ng_l2cap_flow_t * ng_l2cap_flow_p;163164/**************************************************************************165**************************************************************************166** Link level defines, headers and types167**************************************************************************168**************************************************************************/169170/* L2CAP header */171typedef struct {172u_int16_t length; /* payload size */173u_int16_t dcid; /* destination channel ID */174} __attribute__ ((packed)) ng_l2cap_hdr_t;175176/* L2CAP ConnectionLess Traffic (CLT) (if destination cid == 0x2) */177typedef struct {178u_int16_t psm; /* Protocol/Service Multiplexor */179} __attribute__ ((packed)) ng_l2cap_clt_hdr_t;180181#define NG_L2CAP_CLT_MTU_MAXIMUM \182(NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_clt_hdr_t))183184/* L2CAP command header */185typedef struct {186u_int8_t code; /* command OpCode */187u_int8_t ident; /* identifier to match request and response */188u_int16_t length; /* command parameters length */189} __attribute__ ((packed)) ng_l2cap_cmd_hdr_t;190191/* L2CAP Command Reject */192#define NG_L2CAP_CMD_REJ 0x01193typedef struct {194u_int16_t reason; /* reason to reject command */195/* u_int8_t data[]; -- optional data (depends on reason) */196} __attribute__ ((packed)) ng_l2cap_cmd_rej_cp;197198/* CommandReject data */199typedef union {200/* NG_L2CAP_REJ_MTU_EXCEEDED */201struct {202u_int16_t mtu; /* actual signaling MTU */203} __attribute__ ((packed)) mtu;204/* NG_L2CAP_REJ_INVALID_CID */205struct {206u_int16_t scid; /* local CID */207u_int16_t dcid; /* remote CID */208} __attribute__ ((packed)) cid;209} ng_l2cap_cmd_rej_data_t;210typedef ng_l2cap_cmd_rej_data_t * ng_l2cap_cmd_rej_data_p;211212/* L2CAP Connection Request */213#define NG_L2CAP_CON_REQ 0x02214typedef struct {215u_int16_t psm; /* Protocol/Service Multiplexor (PSM) */216u_int16_t scid; /* source channel ID */217} __attribute__ ((packed)) ng_l2cap_con_req_cp;218219/* L2CAP Connection Response */220#define NG_L2CAP_CON_RSP 0x03221typedef struct {222u_int16_t dcid; /* destination channel ID */223u_int16_t scid; /* source channel ID */224u_int16_t result; /* 0x00 - success */225u_int16_t status; /* more info if result != 0x00 */226} __attribute__ ((packed)) ng_l2cap_con_rsp_cp;227228/* L2CAP Configuration Request */229#define NG_L2CAP_CFG_REQ 0x04230typedef struct {231u_int16_t dcid; /* destination channel ID */232u_int16_t flags; /* flags */233/* u_int8_t options[] -- options */234} __attribute__ ((packed)) ng_l2cap_cfg_req_cp;235236/* L2CAP Configuration Response */237#define NG_L2CAP_CFG_RSP 0x05238typedef struct {239u_int16_t scid; /* source channel ID */240u_int16_t flags; /* flags */241u_int16_t result; /* 0x00 - success */242/* u_int8_t options[] -- options */243} __attribute__ ((packed)) ng_l2cap_cfg_rsp_cp;244245/* L2CAP configuration option */246typedef struct {247u_int8_t type;248u_int8_t length;249/* u_int8_t value[] -- option value (depends on type) */250} __attribute__ ((packed)) ng_l2cap_cfg_opt_t;251typedef ng_l2cap_cfg_opt_t * ng_l2cap_cfg_opt_p;252253/* L2CAP configuration option value */254typedef union {255u_int16_t mtu; /* NG_L2CAP_OPT_MTU */256u_int16_t flush_timo; /* NG_L2CAP_OPT_FLUSH_TIMO */257ng_l2cap_flow_t flow; /* NG_L2CAP_OPT_QOS */258uint16_t encryption;259} ng_l2cap_cfg_opt_val_t;260typedef ng_l2cap_cfg_opt_val_t * ng_l2cap_cfg_opt_val_p;261262/* L2CAP Disconnect Request */263#define NG_L2CAP_DISCON_REQ 0x06264typedef struct {265u_int16_t dcid; /* destination channel ID */266u_int16_t scid; /* source channel ID */267} __attribute__ ((packed)) ng_l2cap_discon_req_cp;268269/* L2CAP Disconnect Response */270#define NG_L2CAP_DISCON_RSP 0x07271typedef ng_l2cap_discon_req_cp ng_l2cap_discon_rsp_cp;272273/* L2CAP Echo Request */274#define NG_L2CAP_ECHO_REQ 0x08275/* No command parameters, only optional data */276277/* L2CAP Echo Response */278#define NG_L2CAP_ECHO_RSP 0x09279#define NG_L2CAP_MAX_ECHO_SIZE \280(NG_L2CAP_MTU_MAXIMUM - sizeof(ng_l2cap_cmd_hdr_t))281/* No command parameters, only optional data */282283/* L2CAP Information Request */284#define NG_L2CAP_INFO_REQ 0x0a285typedef struct {286u_int16_t type; /* requested information type */287} __attribute__ ((packed)) ng_l2cap_info_req_cp;288289/* L2CAP Information Response */290#define NG_L2CAP_INFO_RSP 0x0b291typedef struct {292u_int16_t type; /* requested information type */293u_int16_t result; /* 0x00 - success */294/* u_int8_t info[] -- info data (depends on type)295*296* NG_L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU297*/298} __attribute__ ((packed)) ng_l2cap_info_rsp_cp;299typedef union {300/* NG_L2CAP_CONNLESS_MTU */301struct {302u_int16_t mtu;303} __attribute__ ((packed)) mtu;304} ng_l2cap_info_rsp_data_t;305typedef ng_l2cap_info_rsp_data_t * ng_l2cap_info_rsp_data_p;306307#define NG_L2CAP_CMD_PARAM_UPDATE_REQUEST 0x12308309typedef struct {310uint16_t interval_min;311uint16_t interval_max;312uint16_t slave_latency;313uint16_t timeout_mpl;314} __attribute__ ((packed)) ng_l2cap_param_update_req_cp;315316#define NG_L2CAP_CMD_PARAM_UPDATE_RESPONSE 0x13317#define NG_L2CAP_UPDATE_PARAM_ACCEPT 0318#define NG_L2CAP_UPDATE_PARAM_REJECT 1319320//typedef uint16_t update_response;321/**************************************************************************322**************************************************************************323** Upper layer protocol interface. L2CA_xxx messages324**************************************************************************325**************************************************************************/326327/*328* NOTE! NOTE! NOTE!329*330* Bluetooth specification says that L2CA_xxx request must block until331* response is ready. We are not allowed to block in Netgraph, so we332* need to queue request and save some information that can be used333* later and help match request and response.334*335* The idea is to use "token" field from Netgraph message header. The336* upper layer protocol _MUST_ populate "token". L2CAP will queue request337* (using L2CAP command descriptor) and start processing. Later, when338* response is ready or timeout has occur L2CAP layer will create new339* Netgraph message, set "token" and RESP flag and send the message to340* 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 just344* notifications and do not require acknowlegment.345*346* NOTE: This is _NOT_ what NG_MKRESPONSE and NG_RESPOND_MSG do, however347* it is somewhat similar.348*/349350/* L2CA data packet header */351typedef struct {352u_int32_t token; /* token to use in L2CAP_L2CA_WRITE */353u_int16_t length; /* length of the data */354u_int16_t lcid; /* local channel ID */355uint16_t idtype;356} __attribute__ ((packed)) ng_l2cap_l2ca_hdr_t;357#define NG_L2CAP_L2CA_IDTYPE_BREDR 0358#define NG_L2CAP_L2CA_IDTYPE_ATT 1359#define NG_L2CAP_L2CA_IDTYPE_LE 2360#define NG_L2CAP_L2CA_IDTYPE_SMP 3361/* L2CA_Connect */362#define NGM_L2CAP_L2CA_CON 0x80363/* Upper -> L2CAP */364typedef struct {365u_int16_t psm; /* Protocol/Service Multiplexor */366bdaddr_t bdaddr; /* remote unit address */367uint8_t linktype;368uint8_t idtype;369} ng_l2cap_l2ca_con_ip;370371/* L2CAP -> Upper */372typedef struct {373u_int16_t lcid; /* local channel ID */374uint16_t idtype; /*ID type*/375u_int16_t result; /* 0x00 - success */376u_int16_t status; /* if result != 0x00 */377uint8_t encryption;378} ng_l2cap_l2ca_con_op;379380/* L2CA_ConnectInd */381#define NGM_L2CAP_L2CA_CON_IND 0x81382/* L2CAP -> Upper */383typedef struct {384bdaddr_t bdaddr; /* remote unit address */385u_int16_t lcid; /* local channel ID */386u_int16_t psm; /* Procotol/Service Multiplexor */387u_int8_t ident; /* identifier */388u_int8_t linktype; /* link type*/389} ng_l2cap_l2ca_con_ind_ip;390/* No output parameters */391392/* L2CA_ConnectRsp */393#define NGM_L2CAP_L2CA_CON_RSP 0x82394/* Upper -> L2CAP */395typedef struct {396bdaddr_t bdaddr; /* remote unit address */397u_int8_t ident; /* "ident" from L2CAP_ConnectInd event */398u_int8_t linktype; /*link type */399u_int16_t lcid; /* local channel ID */400u_int16_t result; /* 0x00 - success */401u_int16_t status; /* if response != 0x00 */402} ng_l2cap_l2ca_con_rsp_ip;403404/* L2CAP -> Upper */405typedef struct {406u_int16_t result; /* 0x00 - success */407} ng_l2cap_l2ca_con_rsp_op;408409/* L2CA_Config */410#define NGM_L2CAP_L2CA_CFG 0x83411/* Upper -> L2CAP */412typedef struct {413u_int16_t lcid; /* local channel ID */414u_int16_t imtu; /* receiving MTU for the local channel */415ng_l2cap_flow_t oflow; /* out flow */416u_int16_t flush_timo; /* flush timeout (msec) */417u_int16_t link_timo; /* link timeout (msec) */418} ng_l2cap_l2ca_cfg_ip;419420/* L2CAP -> Upper */421typedef struct {422u_int16_t result; /* 0x00 - success */423u_int16_t imtu; /* sending MTU for the remote channel */424ng_l2cap_flow_t oflow; /* out flow */425u_int16_t flush_timo; /* flush timeout (msec) */426} ng_l2cap_l2ca_cfg_op;427428/* L2CA_ConfigRsp */429#define NGM_L2CAP_L2CA_CFG_RSP 0x84430/* Upper -> L2CAP */431typedef struct {432u_int16_t lcid; /* local channel ID */433u_int16_t omtu; /* sending MTU for the local channel */434ng_l2cap_flow_t iflow; /* in FLOW */435} ng_l2cap_l2ca_cfg_rsp_ip;436437/* L2CAP -> Upper */438typedef struct {439u_int16_t result; /* 0x00 - sucsess */440} ng_l2cap_l2ca_cfg_rsp_op;441442/* L2CA_ConfigInd */443#define NGM_L2CAP_L2CA_CFG_IND 0x85444/* L2CAP -> Upper */445typedef struct {446u_int16_t lcid; /* local channel ID */447u_int16_t omtu; /* outgoing MTU for the local channel */448ng_l2cap_flow_t iflow; /* in flow */449u_int16_t flush_timo; /* flush timeout (msec) */450} ng_l2cap_l2ca_cfg_ind_ip;451/* No output parameters */452453/* L2CA_QoSViolationInd */454#define NGM_L2CAP_L2CA_QOS_IND 0x86455/* L2CAP -> Upper */456typedef struct {457bdaddr_t bdaddr; /* remote unit address */458} ng_l2cap_l2ca_qos_ind_ip;459/* No output parameters */460461/* L2CA_Disconnect */462#define NGM_L2CAP_L2CA_DISCON 0x87463/* Upper -> L2CAP */464typedef struct {465u_int16_t lcid; /* local channel ID */466u_int16_t idtype;467} ng_l2cap_l2ca_discon_ip;468469/* L2CAP -> Upper */470typedef struct {471u_int16_t result; /* 0x00 - sucsess */472} ng_l2cap_l2ca_discon_op;473474/* L2CA_DisconnectInd */475#define NGM_L2CAP_L2CA_DISCON_IND 0x88476/* L2CAP -> Upper */477typedef ng_l2cap_l2ca_discon_ip ng_l2cap_l2ca_discon_ind_ip;478/* No output parameters */479480/* L2CA_Write response */481#define NGM_L2CAP_L2CA_WRITE 0x89482/* No input parameters */483484/* L2CAP -> Upper */485typedef struct {486int result; /* result (0x00 - success) */487u_int16_t length; /* amount of data written */488u_int16_t lcid; /* local channel ID */489uint16_t idtype;490} ng_l2cap_l2ca_write_op;491492/* L2CA_GroupCreate */493#define NGM_L2CAP_L2CA_GRP_CREATE 0x8a494/* Upper -> L2CAP */495typedef struct {496u_int16_t psm; /* Protocol/Service Multiplexor */497} ng_l2cap_l2ca_grp_create_ip;498499/* L2CAP -> Upper */500typedef struct {501u_int16_t lcid; /* local group channel ID */502} ng_l2cap_l2ca_grp_create_op;503504/* L2CA_GroupClose */505#define NGM_L2CAP_L2CA_GRP_CLOSE 0x8b506/* Upper -> L2CAP */507typedef struct {508u_int16_t lcid; /* local group channel ID */509} ng_l2cap_l2ca_grp_close_ip;510511#if 0512/* L2CAP -> Upper */513* typedef struct {514* u_int16_t result; /* 0x00 - success */515* } ng_l2cap_l2ca_grp_close_op;516#endif517518/* L2CA_GroupAddMember */519#define NGM_L2CAP_L2CA_GRP_ADD_MEMBER 0x8c520/* Upper -> L2CAP */521typedef struct {522u_int16_t lcid; /* local group channel ID */523bdaddr_t bdaddr; /* remote unit address */524} ng_l2cap_l2ca_grp_add_member_ip;525526/* L2CAP -> Upper */527typedef struct {528u_int16_t result; /* 0x00 - success */529} ng_l2cap_l2ca_grp_add_member_op;530531/* L2CA_GroupRemoveMember */532#define NGM_L2CAP_L2CA_GRP_REM_MEMBER 0x8d533/* Upper -> L2CAP */534typedef ng_l2cap_l2ca_grp_add_member_ip ng_l2cap_l2ca_grp_rem_member_ip;535536/* L2CAP -> Upper */537#if 0538* typedef ng_l2cap_l2ca_grp_add_member_op ng_l2cap_l2ca_grp_rem_member_op;539#endif540541/* L2CA_GroupMembeship */542#define NGM_L2CAP_L2CA_GRP_MEMBERSHIP 0x8e543/* Upper -> L2CAP */544typedef struct {545u_int16_t lcid; /* local group channel ID */546} ng_l2cap_l2ca_grp_get_members_ip;547548/* L2CAP -> Upper */549typedef struct {550u_int16_t result; /* 0x00 - success */551u_int16_t nmembers; /* number of group members */552/* bdaddr_t members[] -- group memebers */553} ng_l2cap_l2ca_grp_get_members_op;554555/* L2CA_Ping */556#define NGM_L2CAP_L2CA_PING 0x8f557/* Upper -> L2CAP */558typedef struct {559bdaddr_t bdaddr; /* remote unit address */560u_int16_t echo_size; /* size of echo data in bytes */561/* u_int8_t echo_data[] -- echo data */562} ng_l2cap_l2ca_ping_ip;563564/* L2CAP -> Upper */565typedef struct {566u_int16_t result; /* 0x00 - success */567bdaddr_t bdaddr; /* remote unit address */568u_int16_t echo_size; /* size of echo data in bytes */569/* u_int8_t echo_data[] -- echo data */570} ng_l2cap_l2ca_ping_op;571572/* L2CA_GetInfo */573#define NGM_L2CAP_L2CA_GET_INFO 0x90574/* Upper -> L2CAP */575typedef struct {576bdaddr_t bdaddr; /* remote unit address */577u_int16_t info_type; /* info type */578uint8_t linktype;579uint8_t unused;580} ng_l2cap_l2ca_get_info_ip;581582/* L2CAP -> Upper */583typedef struct {584u_int16_t result; /* 0x00 - success */585u_int16_t info_size; /* size of info data in bytes */586/* u_int8_t info_data[] -- info data */587} ng_l2cap_l2ca_get_info_op;588589/* L2CA_EnableCLT/L2CA_DisableCLT */590#define NGM_L2CAP_L2CA_ENABLE_CLT 0x91591/* Upper -> L2CAP */592typedef struct {593u_int16_t psm; /* Protocol/Service Multiplexor */594u_int16_t enable; /* 0x00 - disable */595} ng_l2cap_l2ca_enable_clt_ip;596597#if 0598/* L2CAP -> Upper */599* typedef struct {600* u_int16_t result; /* 0x00 - success */601* } ng_l2cap_l2ca_enable_clt_op;602#endif603#define NGM_L2CAP_L2CA_ENC_CHANGE 0x92604typedef struct {605uint16_t lcid;606uint16_t result;607uint8_t idtype;608} ng_l2cap_l2ca_enc_chg_op;609610/**************************************************************************611**************************************************************************612** L2CAP node messages613**************************************************************************614**************************************************************************/615616/* L2CAP connection states */617#define NG_L2CAP_CON_CLOSED 0 /* connection closed */618#define NG_L2CAP_W4_LP_CON_CFM 1 /* waiting... */619#define NG_L2CAP_CON_OPEN 2 /* connection open */620621/* L2CAP channel states */622#define NG_L2CAP_CLOSED 0 /* channel closed */623#define NG_L2CAP_W4_L2CAP_CON_RSP 1 /* wait for L2CAP resp. */624#define NG_L2CAP_W4_L2CA_CON_RSP 2 /* wait for upper resp. */625#define NG_L2CAP_CONFIG 3 /* L2CAP configuration */626#define NG_L2CAP_OPEN 4 /* channel open */627#define NG_L2CAP_W4_L2CAP_DISCON_RSP 5 /* wait for L2CAP discon. */628#define NG_L2CAP_W4_L2CA_DISCON_RSP 6 /* wait for upper discon. */629630/* Node flags */631#define NG_L2CAP_CLT_SDP_DISABLED (1 << 0) /* disable SDP CLT */632#define NG_L2CAP_CLT_RFCOMM_DISABLED (1 << 1) /* disable RFCOMM CLT */633#define NG_L2CAP_CLT_TCP_DISABLED (1 << 2) /* disable TCP CLT */634635/* Debug levels */636#define NG_L2CAP_ALERT_LEVEL 1637#define NG_L2CAP_ERR_LEVEL 2638#define NG_L2CAP_WARN_LEVEL 3639#define NG_L2CAP_INFO_LEVEL 4640641/* Get node flags (see flags above) */642#define NGM_L2CAP_NODE_GET_FLAGS 0x400 /* L2CAP -> User */643typedef u_int16_t ng_l2cap_node_flags_ep;644645/* Get/Set debug level (see levels above) */646#define NGM_L2CAP_NODE_GET_DEBUG 0x401 /* L2CAP -> User */647#define NGM_L2CAP_NODE_SET_DEBUG 0x402 /* User -> L2CAP */648typedef u_int16_t ng_l2cap_node_debug_ep;649650#define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */651typedef struct {652bdaddr_t addr;653}ng_l2cap_node_hook_info_ep;654655#define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */656typedef struct {657u_int32_t num_connections; /* number of connections */658} ng_l2cap_node_con_list_ep;659660/* Connection flags */661#define NG_L2CAP_CON_TX (1 << 0) /* sending data */662#define NG_L2CAP_CON_RX (1 << 1) /* receiving data */663#define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */664#define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */665#define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */666#define NG_L2CAP_CON_DYING (1 << 5) /* connection is dying */667668typedef struct {669u_int8_t state; /* connection state */670u_int8_t flags; /* flags */671int16_t pending; /* num. pending packets */672u_int16_t con_handle; /* connection handle */673bdaddr_t remote; /* remote bdaddr */674} ng_l2cap_node_con_ep;675676#define NG_L2CAP_MAX_CON_NUM \677((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep))678679#define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */680typedef struct {681u_int32_t num_channels; /* number of channels */682} ng_l2cap_node_chan_list_ep;683684typedef struct {685u_int32_t state; /* channel state */686687u_int16_t scid; /* source (local) channel ID */688u_int16_t dcid; /* destination (remote) channel ID */689690u_int16_t imtu; /* incoming MTU */691u_int16_t omtu; /* outgoing MTU */692693u_int16_t psm; /* PSM */694bdaddr_t remote; /* remote bdaddr */695} ng_l2cap_node_chan_ep;696697#define NG_L2CAP_MAX_CHAN_NUM \698((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep))699700#define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */701#define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */702typedef u_int16_t ng_l2cap_node_auto_discon_ep;703704#endif /* ndef _NETGRAPH_L2CAP_H_ */705706707