File: /usr/src/linux/include/net/bluetooth/l2cap.h
1 /*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
23 */
24
25 /*
26 * $Id: l2cap.h,v 1.5 2001/06/14 21:28:26 maxk Exp $
27 */
28
29 #ifndef __L2CAP_H
30 #define __L2CAP_H
31
32 #include <asm/types.h>
33 #include <asm/byteorder.h>
34
35 /* L2CAP defaults */
36 #define L2CAP_DEFAULT_MTU 672
37 #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
38
39 #define L2CAP_CONN_TIMEOUT (HZ * 40)
40 #define L2CAP_DISCONN_TIMEOUT (HZ * 2)
41 #define L2CAP_CONN_IDLE_TIMEOUT (HZ * 60)
42
43 /* L2CAP socket address */
44 struct sockaddr_l2 {
45 sa_family_t l2_family;
46 unsigned short l2_psm;
47 bdaddr_t l2_bdaddr;
48 };
49
50 /* set/get sockopt defines */
51 #define L2CAP_OPTIONS 0x01
52 struct l2cap_options {
53 __u16 omtu;
54 __u16 imtu;
55 __u16 flush_to;
56 __u32 token_rate;
57 __u32 bucket_size;
58 __u32 pick_band;
59 __u32 latency;
60 __u32 delay_var;
61 };
62
63 #define L2CAP_CONNINFO 0x02
64 struct l2cap_conninfo {
65 __u16 hci_handle;
66 };
67
68 /* L2CAP command codes */
69 #define L2CAP_COMMAND_REJ 0x01
70 #define L2CAP_CONN_REQ 0x02
71 #define L2CAP_CONN_RSP 0x03
72 #define L2CAP_CONF_REQ 0x04
73 #define L2CAP_CONF_RSP 0x05
74 #define L2CAP_DISCONN_REQ 0x06
75 #define L2CAP_DISCONN_RSP 0x07
76 #define L2CAP_ECHO_REQ 0x08
77 #define L2CAP_ECHO_RSP 0x09
78 #define L2CAP_INFO_REQ 0x0a
79 #define L2CAP_INFO_RSP 0x0b
80
81 /* L2CAP structures */
82
83 typedef struct {
84 __u16 len;
85 __u16 cid;
86 } __attribute__ ((packed)) l2cap_hdr;
87 #define L2CAP_HDR_SIZE 4
88
89 typedef struct {
90 __u8 code;
91 __u8 ident;
92 __u16 len;
93 } __attribute__ ((packed)) l2cap_cmd_hdr;
94 #define L2CAP_CMD_HDR_SIZE 4
95
96 typedef struct {
97 __u16 reason;
98 } __attribute__ ((packed)) l2cap_cmd_rej;
99 #define L2CAP_CMD_REJ_SIZE 2
100
101 typedef struct {
102 __u16 psm;
103 __u16 scid;
104 } __attribute__ ((packed)) l2cap_conn_req;
105 #define L2CAP_CONN_REQ_SIZE 4
106
107 typedef struct {
108 __u16 dcid;
109 __u16 scid;
110 __u16 result;
111 __u16 status;
112 } __attribute__ ((packed)) l2cap_conn_rsp;
113 #define L2CAP_CONN_RSP_SIZE 8
114
115 #define L2CAP_CONN_SUCCESS 0x0000
116 #define L2CAP_CONN_PEND 0x0001
117 #define L2CAP_CONN_BAD_PSM 0x0002
118 #define L2CAP_CONN_SEC_BLOCK 0x0003
119 #define L2CAP_CONN_NO_MEM 0x0004
120
121 typedef struct {
122 __u16 dcid;
123 __u16 flags;
124 __u8 data[0];
125 } __attribute__ ((packed)) l2cap_conf_req;
126 #define L2CAP_CONF_REQ_SIZE 4
127
128 typedef struct {
129 __u16 scid;
130 __u16 flags;
131 __u16 result;
132 __u8 data[0];
133 } __attribute__ ((packed)) l2cap_conf_rsp;
134 #define L2CAP_CONF_RSP_SIZE 6
135
136 #define L2CAP_CONF_SUCCESS 0x00
137 #define L2CAP_CONF_UNACCEPT 0x01
138
139 typedef struct {
140 __u8 type;
141 __u8 len;
142 __u8 val[0];
143 } __attribute__ ((packed)) l2cap_conf_opt;
144 #define L2CAP_CONF_OPT_SIZE 2
145
146 #define L2CAP_CONF_MTU 0x01
147 #define L2CAP_CONF_FLUSH_TO 0x02
148 #define L2CAP_CONF_QOS 0x03
149
150 typedef struct {
151 __u16 dcid;
152 __u16 scid;
153 } __attribute__ ((packed)) l2cap_disconn_req;
154 #define L2CAP_DISCONN_REQ_SIZE 4
155
156 typedef struct {
157 __u16 dcid;
158 __u16 scid;
159 } __attribute__ ((packed)) l2cap_disconn_rsp;
160 #define L2CAP_DISCONN_RSP_SIZE 4
161
162 #endif /* __L2CAP_H */
163