OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [net/] [bluetooth/] [l2cap.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
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.1.1.1 2004-04-15 02:34:40 phoenix Exp $
27
 */
28
 
29
#ifndef __L2CAP_H
30
#define __L2CAP_H
31
 
32
/* L2CAP defaults */
33
#define L2CAP_DEFAULT_MTU       672
34
#define L2CAP_DEFAULT_FLUSH_TO  0xFFFF
35
 
36
#define L2CAP_CONN_TIMEOUT      (HZ * 40)
37
 
38
/* L2CAP socket address */
39
struct sockaddr_l2 {
40
        sa_family_t     l2_family;
41
        unsigned short  l2_psm;
42
        bdaddr_t        l2_bdaddr;
43
};
44
 
45
/* Socket options */
46
#define L2CAP_OPTIONS   0x01
47
struct l2cap_options {
48
        __u16 omtu;
49
        __u16 imtu;
50
        __u16 flush_to;
51
};
52
 
53
#define L2CAP_CONNINFO  0x02
54
struct l2cap_conninfo {
55
        __u16 hci_handle;
56
};
57
 
58
#define L2CAP_LM        0x03
59
#define L2CAP_LM_MASTER         0x0001
60
#define L2CAP_LM_AUTH           0x0002
61
#define L2CAP_LM_ENCRYPT        0x0004
62
#define L2CAP_LM_TRUSTED        0x0008
63
#define L2CAP_LM_RELIABLE       0x0010
64
 
65
#define L2CAP_QOS       0x04
66
struct l2cap_qos {
67
        __u16 service_type;
68
        __u32 token_rate;
69
        __u32 token_bucket_size;
70
        __u32 peak_bandwidth;
71
        __u32 latency;
72
        __u32 delay_variation;
73
};
74
 
75
#define L2CAP_SERV_NO_TRAFFIC   0x00
76
#define L2CAP_SERV_BEST_EFFORT  0x01
77
#define L2CAP_SERV_GUARANTEED   0x02
78
 
79
/* L2CAP command codes */
80
#define L2CAP_COMMAND_REJ 0x01
81
#define L2CAP_CONN_REQ    0x02
82
#define L2CAP_CONN_RSP    0x03
83
#define L2CAP_CONF_REQ    0x04
84
#define L2CAP_CONF_RSP    0x05
85
#define L2CAP_DISCONN_REQ 0x06
86
#define L2CAP_DISCONN_RSP 0x07
87
#define L2CAP_ECHO_REQ    0x08
88
#define L2CAP_ECHO_RSP    0x09
89
#define L2CAP_INFO_REQ    0x0a
90
#define L2CAP_INFO_RSP    0x0b
91
 
92
/* L2CAP structures */
93
typedef struct {
94
        __u16      len;
95
        __u16      cid;
96
} __attribute__ ((packed))      l2cap_hdr;
97
#define L2CAP_HDR_SIZE          4
98
 
99
typedef struct {
100
        __u8       code;
101
        __u8       ident;
102
        __u16      len;
103
} __attribute__ ((packed))      l2cap_cmd_hdr;
104
#define L2CAP_CMD_HDR_SIZE      4
105
 
106
typedef struct {
107
        __u16      reason;
108
} __attribute__ ((packed))      l2cap_cmd_rej;
109
#define L2CAP_CMD_REJ_SIZE      2
110
 
111
typedef struct {
112
        __u16      psm;
113
        __u16      scid;
114
} __attribute__ ((packed))      l2cap_conn_req;
115
#define L2CAP_CONN_REQ_SIZE     4
116
 
117
typedef struct {
118
        __u16      dcid;
119
        __u16      scid;
120
        __u16      result;
121
        __u16      status;
122
} __attribute__ ((packed))      l2cap_conn_rsp;
123
#define L2CAP_CONN_RSP_SIZE     8
124
 
125
/* connect result */
126
#define L2CAP_CR_SUCCESS    0x0000
127
#define L2CAP_CR_PEND       0x0001
128
#define L2CAP_CR_BAD_PSM    0x0002
129
#define L2CAP_CR_SEC_BLOCK  0x0003
130
#define L2CAP_CR_NO_MEM     0x0004
131
 
132
/* connect status */
133
#define L2CAP_CS_NO_INFO      0x0000
134
#define L2CAP_CS_AUTHEN_PEND  0x0001
135
#define L2CAP_CS_AUTHOR_PEND  0x0002
136
 
137
typedef struct {
138
        __u16      dcid;
139
        __u16      flags;
140
        __u8       data[0];
141
} __attribute__ ((packed))      l2cap_conf_req;
142
#define L2CAP_CONF_REQ_SIZE     4
143
 
144
typedef struct {
145
        __u16      scid;
146
        __u16      flags;
147
        __u16      result;
148
        __u8       data[0];
149
} __attribute__ ((packed))      l2cap_conf_rsp;
150
#define L2CAP_CONF_RSP_SIZE     6
151
 
152
#define L2CAP_CONF_SUCCESS      0x00
153
#define L2CAP_CONF_UNACCEPT     0x01
154
 
155
typedef struct {
156
        __u8       type;
157
        __u8       len;
158
        __u8       val[0];
159
} __attribute__ ((packed))      l2cap_conf_opt;
160
#define L2CAP_CONF_OPT_SIZE     2
161
 
162
#define L2CAP_CONF_MTU          0x01
163
#define L2CAP_CONF_FLUSH_TO     0x02
164
#define L2CAP_CONF_QOS          0x03
165
 
166
#define L2CAP_CONF_MAX_SIZE     22
167
 
168
typedef struct {
169
        __u16      dcid;
170
        __u16      scid;
171
} __attribute__ ((packed))      l2cap_disconn_req;
172
#define L2CAP_DISCONN_REQ_SIZE  4
173
 
174
typedef struct {
175
        __u16      dcid;
176
        __u16      scid;
177
} __attribute__ ((packed))      l2cap_disconn_rsp;
178
#define L2CAP_DISCONN_RSP_SIZE  4
179
 
180
typedef struct {
181
        __u16       type;
182
        __u8        data[0];
183
} __attribute__ ((packed))      l2cap_info_req;
184
#define L2CAP_INFO_REQ_SIZE     2
185
 
186
typedef struct {
187
        __u16       type;
188
        __u16       result;
189
        __u8        data[0];
190
} __attribute__ ((packed))      l2cap_info_rsp;
191
#define L2CAP_INFO_RSP_SIZE     4
192
 
193
/* ----- L2CAP connections ----- */
194
struct l2cap_chan_list {
195
        struct sock     *head;
196
        rwlock_t        lock;
197
        long            num;
198
};
199
 
200
struct l2cap_conn {
201
        struct hci_conn *hcon;
202
 
203
        bdaddr_t        *dst;
204
        bdaddr_t        *src;
205
 
206
        unsigned int    mtu;
207
 
208
        spinlock_t      lock;
209
 
210
        struct sk_buff *rx_skb;
211
        __u32           rx_len;
212
        __u8            rx_ident;
213
        __u8            tx_ident;
214
 
215
        struct l2cap_chan_list chan_list;
216
};
217
 
218
/* ----- L2CAP channel and socket info ----- */
219
#define l2cap_pi(sk)   ((struct l2cap_pinfo *) &sk->tp_pinfo)
220
 
221
struct l2cap_pinfo {
222
        __u16           psm;
223
        __u16           dcid;
224
        __u16           scid;
225
 
226
        __u16           imtu;
227
        __u16           omtu;
228
        __u16           flush_to;
229
 
230
        __u32           link_mode;
231
 
232
        __u8            conf_state;
233
        __u8            conf_retry;
234
        __u16           conf_mtu;
235
 
236
        __u8            ident;
237
 
238
        struct l2cap_conn       *conn;
239
        struct sock             *next_c;
240
        struct sock             *prev_c;
241
};
242
 
243
#define L2CAP_CONF_REQ_SENT    0x01
244
#define L2CAP_CONF_INPUT_DONE  0x02
245
#define L2CAP_CONF_OUTPUT_DONE 0x04
246
#define L2CAP_CONF_MAX_RETRIES 2
247
 
248
void l2cap_load(void);
249
 
250
#endif /* __L2CAP_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.