mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
Bluetooth: Add basic constants for L2CAP ERTM support and use them
This adds the basic constants required to add support for L2CAP Enhanced Retransmission feature. Based on a patch from Nathan Holstein <nathan@lampreynetworks.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
af05b30bcb
commit
47ec1dcd69
2 changed files with 45 additions and 24 deletions
|
@ -26,8 +26,13 @@
|
||||||
#define __L2CAP_H
|
#define __L2CAP_H
|
||||||
|
|
||||||
/* L2CAP defaults */
|
/* L2CAP defaults */
|
||||||
#define L2CAP_DEFAULT_MTU 672
|
#define L2CAP_DEFAULT_MTU 672
|
||||||
#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
|
#define L2CAP_DEFAULT_FLUSH_TO 0xffff
|
||||||
|
#define L2CAP_DEFAULT_RX_WINDOW 1
|
||||||
|
#define L2CAP_DEFAULT_MAX_RECEIVE 1
|
||||||
|
#define L2CAP_DEFAULT_RETRANS_TO 300 /* 300 milliseconds */
|
||||||
|
#define L2CAP_DEFAULT_MONITOR_TO 1000 /* 1 second */
|
||||||
|
#define L2CAP_DEFAULT_MAX_RX_APDU 0xfff7
|
||||||
|
|
||||||
#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
|
#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
|
||||||
#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
|
#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
|
||||||
|
@ -64,17 +69,29 @@ struct l2cap_conninfo {
|
||||||
#define L2CAP_LM_SECURE 0x0020
|
#define L2CAP_LM_SECURE 0x0020
|
||||||
|
|
||||||
/* L2CAP command codes */
|
/* L2CAP command codes */
|
||||||
#define L2CAP_COMMAND_REJ 0x01
|
#define L2CAP_COMMAND_REJ 0x01
|
||||||
#define L2CAP_CONN_REQ 0x02
|
#define L2CAP_CONN_REQ 0x02
|
||||||
#define L2CAP_CONN_RSP 0x03
|
#define L2CAP_CONN_RSP 0x03
|
||||||
#define L2CAP_CONF_REQ 0x04
|
#define L2CAP_CONF_REQ 0x04
|
||||||
#define L2CAP_CONF_RSP 0x05
|
#define L2CAP_CONF_RSP 0x05
|
||||||
#define L2CAP_DISCONN_REQ 0x06
|
#define L2CAP_DISCONN_REQ 0x06
|
||||||
#define L2CAP_DISCONN_RSP 0x07
|
#define L2CAP_DISCONN_RSP 0x07
|
||||||
#define L2CAP_ECHO_REQ 0x08
|
#define L2CAP_ECHO_REQ 0x08
|
||||||
#define L2CAP_ECHO_RSP 0x09
|
#define L2CAP_ECHO_RSP 0x09
|
||||||
#define L2CAP_INFO_REQ 0x0a
|
#define L2CAP_INFO_REQ 0x0a
|
||||||
#define L2CAP_INFO_RSP 0x0b
|
#define L2CAP_INFO_RSP 0x0b
|
||||||
|
|
||||||
|
/* L2CAP feature mask */
|
||||||
|
#define L2CAP_FEAT_FLOWCTL 0x00000001
|
||||||
|
#define L2CAP_FEAT_RETRANS 0x00000002
|
||||||
|
#define L2CAP_FEAT_ERTM 0x00000008
|
||||||
|
#define L2CAP_FEAT_STREAMING 0x00000010
|
||||||
|
#define L2CAP_FEAT_FCS 0x00000020
|
||||||
|
#define L2CAP_FEAT_FIXED_CHAN 0x00000080
|
||||||
|
|
||||||
|
/* L2CAP checksum option */
|
||||||
|
#define L2CAP_FCS_NONE 0x00
|
||||||
|
#define L2CAP_FCS_CRC16 0x01
|
||||||
|
|
||||||
/* L2CAP structures */
|
/* L2CAP structures */
|
||||||
struct l2cap_hdr {
|
struct l2cap_hdr {
|
||||||
|
@ -113,16 +130,16 @@ struct l2cap_conn_rsp {
|
||||||
#define L2CAP_CID_DYN_END 0xffff
|
#define L2CAP_CID_DYN_END 0xffff
|
||||||
|
|
||||||
/* connect result */
|
/* connect result */
|
||||||
#define L2CAP_CR_SUCCESS 0x0000
|
#define L2CAP_CR_SUCCESS 0x0000
|
||||||
#define L2CAP_CR_PEND 0x0001
|
#define L2CAP_CR_PEND 0x0001
|
||||||
#define L2CAP_CR_BAD_PSM 0x0002
|
#define L2CAP_CR_BAD_PSM 0x0002
|
||||||
#define L2CAP_CR_SEC_BLOCK 0x0003
|
#define L2CAP_CR_SEC_BLOCK 0x0003
|
||||||
#define L2CAP_CR_NO_MEM 0x0004
|
#define L2CAP_CR_NO_MEM 0x0004
|
||||||
|
|
||||||
/* connect status */
|
/* connect status */
|
||||||
#define L2CAP_CS_NO_INFO 0x0000
|
#define L2CAP_CS_NO_INFO 0x0000
|
||||||
#define L2CAP_CS_AUTHEN_PEND 0x0001
|
#define L2CAP_CS_AUTHEN_PEND 0x0001
|
||||||
#define L2CAP_CS_AUTHOR_PEND 0x0002
|
#define L2CAP_CS_AUTHOR_PEND 0x0002
|
||||||
|
|
||||||
struct l2cap_conf_req {
|
struct l2cap_conf_req {
|
||||||
__le16 dcid;
|
__le16 dcid;
|
||||||
|
@ -150,11 +167,13 @@ struct l2cap_conf_opt {
|
||||||
#define L2CAP_CONF_OPT_SIZE 2
|
#define L2CAP_CONF_OPT_SIZE 2
|
||||||
|
|
||||||
#define L2CAP_CONF_HINT 0x80
|
#define L2CAP_CONF_HINT 0x80
|
||||||
|
#define L2CAP_CONF_MASK 0x7f
|
||||||
|
|
||||||
#define L2CAP_CONF_MTU 0x01
|
#define L2CAP_CONF_MTU 0x01
|
||||||
#define L2CAP_CONF_FLUSH_TO 0x02
|
#define L2CAP_CONF_FLUSH_TO 0x02
|
||||||
#define L2CAP_CONF_QOS 0x03
|
#define L2CAP_CONF_QOS 0x03
|
||||||
#define L2CAP_CONF_RFC 0x04
|
#define L2CAP_CONF_RFC 0x04
|
||||||
|
#define L2CAP_CONF_FCS 0x05
|
||||||
|
|
||||||
#define L2CAP_CONF_MAX_SIZE 22
|
#define L2CAP_CONF_MAX_SIZE 22
|
||||||
|
|
||||||
|
@ -170,6 +189,8 @@ struct l2cap_conf_rfc {
|
||||||
#define L2CAP_MODE_BASIC 0x00
|
#define L2CAP_MODE_BASIC 0x00
|
||||||
#define L2CAP_MODE_RETRANS 0x01
|
#define L2CAP_MODE_RETRANS 0x01
|
||||||
#define L2CAP_MODE_FLOWCTL 0x02
|
#define L2CAP_MODE_FLOWCTL 0x02
|
||||||
|
#define L2CAP_MODE_ERTM 0x03
|
||||||
|
#define L2CAP_MODE_STREAM 0x04
|
||||||
|
|
||||||
struct l2cap_disconn_req {
|
struct l2cap_disconn_req {
|
||||||
__le16 dcid;
|
__le16 dcid;
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
#define VERSION "2.13"
|
#define VERSION "2.13"
|
||||||
|
|
||||||
static u32 l2cap_feat_mask = 0x0080;
|
static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN;
|
||||||
static u8 l2cap_fixed_chan[8] = { 0x02, };
|
static u8 l2cap_fixed_chan[8] = { 0x02, };
|
||||||
|
|
||||||
static const struct proto_ops l2cap_sock_ops;
|
static const struct proto_ops l2cap_sock_ops;
|
||||||
|
@ -1747,7 +1747,7 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data)
|
||||||
len -= l2cap_get_conf_opt(&req, &type, &olen, &val);
|
len -= l2cap_get_conf_opt(&req, &type, &olen, &val);
|
||||||
|
|
||||||
hint = type & L2CAP_CONF_HINT;
|
hint = type & L2CAP_CONF_HINT;
|
||||||
type &= 0x7f;
|
type &= L2CAP_CONF_MASK;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case L2CAP_CONF_MTU:
|
case L2CAP_CONF_MTU:
|
||||||
|
@ -2244,7 +2244,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
|
||||||
if (type == L2CAP_IT_FEAT_MASK) {
|
if (type == L2CAP_IT_FEAT_MASK) {
|
||||||
conn->feat_mask = get_unaligned_le32(rsp->data);
|
conn->feat_mask = get_unaligned_le32(rsp->data);
|
||||||
|
|
||||||
if (conn->feat_mask & 0x0080) {
|
if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) {
|
||||||
struct l2cap_info_req req;
|
struct l2cap_info_req req;
|
||||||
req.type = cpu_to_le16(L2CAP_IT_FIXED_CHAN);
|
req.type = cpu_to_le16(L2CAP_IT_FIXED_CHAN);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue