--- zzzz-none-000/linux-2.4.17/include/net/bluetooth/l2cap.h 2001-09-07 16:28:38.000000000 +0000 +++ sangam-fb-401/linux-2.4.17/include/net/bluetooth/l2cap.h 2005-04-05 07:07:46.000000000 +0000 @@ -23,22 +23,17 @@ */ /* - * $Id: l2cap.h,v 1.5 2001/06/14 21:28:26 maxk Exp $ + * $Id: l2cap.h,v 1.1.1.1 2002/03/08 21:03:15 maxk Exp $ */ #ifndef __L2CAP_H #define __L2CAP_H -#include -#include - /* L2CAP defaults */ #define L2CAP_DEFAULT_MTU 672 #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF #define L2CAP_CONN_TIMEOUT (HZ * 40) -#define L2CAP_DISCONN_TIMEOUT (HZ * 2) -#define L2CAP_CONN_IDLE_TIMEOUT (HZ * 60) /* L2CAP socket address */ struct sockaddr_l2 { @@ -47,17 +42,12 @@ bdaddr_t l2_bdaddr; }; -/* set/get sockopt defines */ -#define L2CAP_OPTIONS 0x01 +/* Socket options */ +#define L2CAP_OPTIONS 0x01 struct l2cap_options { __u16 omtu; __u16 imtu; __u16 flush_to; - __u32 token_rate; - __u32 bucket_size; - __u32 pick_band; - __u32 latency; - __u32 delay_var; }; #define L2CAP_CONNINFO 0x02 @@ -65,6 +55,27 @@ __u16 hci_handle; }; +#define L2CAP_LM 0x03 +#define L2CAP_LM_MASTER 0x0001 +#define L2CAP_LM_AUTH 0x0002 +#define L2CAP_LM_ENCRYPT 0x0004 +#define L2CAP_LM_TRUSTED 0x0008 +#define L2CAP_LM_RELIABLE 0x0010 + +#define L2CAP_QOS 0x04 +struct l2cap_qos { + __u16 service_type; + __u32 token_rate; + __u32 token_bucket_size; + __u32 peak_bandwidth; + __u32 latency; + __u32 delay_variation; +}; + +#define L2CAP_SERV_NO_TRAFFIC 0x00 +#define L2CAP_SERV_BEST_EFFORT 0x01 +#define L2CAP_SERV_GUARANTEED 0x02 + /* L2CAP command codes */ #define L2CAP_COMMAND_REJ 0x01 #define L2CAP_CONN_REQ 0x02 @@ -79,7 +90,6 @@ #define L2CAP_INFO_RSP 0x0b /* L2CAP structures */ - typedef struct { __u16 len; __u16 cid; @@ -112,11 +122,17 @@ } __attribute__ ((packed)) l2cap_conn_rsp; #define L2CAP_CONN_RSP_SIZE 8 -#define L2CAP_CONN_SUCCESS 0x0000 -#define L2CAP_CONN_PEND 0x0001 -#define L2CAP_CONN_BAD_PSM 0x0002 -#define L2CAP_CONN_SEC_BLOCK 0x0003 -#define L2CAP_CONN_NO_MEM 0x0004 +/* connect result */ +#define L2CAP_CR_SUCCESS 0x0000 +#define L2CAP_CR_PEND 0x0001 +#define L2CAP_CR_BAD_PSM 0x0002 +#define L2CAP_CR_SEC_BLOCK 0x0003 +#define L2CAP_CR_NO_MEM 0x0004 + +/* connect status */ +#define L2CAP_CS_NO_INFO 0x0000 +#define L2CAP_CS_AUTHEN_PEND 0x0001 +#define L2CAP_CS_AUTHOR_PEND 0x0002 typedef struct { __u16 dcid; @@ -147,6 +163,8 @@ #define L2CAP_CONF_FLUSH_TO 0x02 #define L2CAP_CONF_QOS 0x03 +#define L2CAP_CONF_MAX_SIZE 22 + typedef struct { __u16 dcid; __u16 scid; @@ -159,4 +177,82 @@ } __attribute__ ((packed)) l2cap_disconn_rsp; #define L2CAP_DISCONN_RSP_SIZE 4 +typedef struct { + __u16 type; + __u8 data[0]; +} __attribute__ ((packed)) l2cap_info_req; +#define L2CAP_INFO_REQ_SIZE 2 + +typedef struct { + __u16 type; + __u16 result; + __u8 data[0]; +} __attribute__ ((packed)) l2cap_info_rsp; +#define L2CAP_INFO_RSP_SIZE 4 + +/* info type */ +#define L2CAP_IT_CL_MTU 0x0001 +#define L2CAP_IT_FEAT_MASK 0x0002 + +/* info result */ +#define L2CAP_IR_SUCCESS 0x0000 +#define L2CAP_IR_NOTSUPP 0x0001 + +/* ----- L2CAP connections ----- */ +struct l2cap_chan_list { + struct sock *head; + rwlock_t lock; + long num; +}; + +struct l2cap_conn { + struct hci_conn *hcon; + + bdaddr_t *dst; + bdaddr_t *src; + + unsigned int mtu; + + spinlock_t lock; + + struct sk_buff *rx_skb; + __u32 rx_len; + __u8 rx_ident; + __u8 tx_ident; + + struct l2cap_chan_list chan_list; +}; + +/* ----- L2CAP channel and socket info ----- */ +#define l2cap_pi(sk) ((struct l2cap_pinfo *) &sk->tp_pinfo) + +struct l2cap_pinfo { + __u16 psm; + __u16 dcid; + __u16 scid; + + __u16 imtu; + __u16 omtu; + __u16 flush_to; + + __u32 link_mode; + + __u8 conf_state; + __u8 conf_retry; + __u16 conf_mtu; + + __u8 ident; + + struct l2cap_conn *conn; + struct sock *next_c; + struct sock *prev_c; +}; + +#define L2CAP_CONF_REQ_SENT 0x01 +#define L2CAP_CONF_INPUT_DONE 0x02 +#define L2CAP_CONF_OUTPUT_DONE 0x04 +#define L2CAP_CONF_MAX_RETRIES 2 + +void l2cap_load(void); + #endif /* __L2CAP_H */