1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#ifndef IRLMP_H
28#define IRLMP_H
29
30#include <asm/param.h>
31
32#include <linux/config.h>
33#include <linux/types.h>
34
35#include <net/irda/irda.h>
36#include <net/irda/qos.h>
37#include <net/irda/irlap.h>
38#include <net/irda/irlmp_event.h>
39#include <net/irda/irqueue.h>
40#include <net/irda/discovery.h>
41
42
43#define LSAP_MASK 0x7f
44#define LSAP_IAS 0x00
45#define LSAP_ANY 0xff
46#define LSAP_MAX 0x6f
47#define LSAP_CONNLESS 0x70
48
49#define DEV_ADDR_ANY 0xffffffff
50
51#define LMP_HEADER 2
52#define LMP_CONTROL_HEADER 4
53#define LMP_PID_HEADER 1
54#define LMP_MAX_HEADER (LMP_CONTROL_HEADER+LAP_MAX_HEADER)
55
56#define LM_MAX_CONNECTIONS 10
57
58#define LM_IDLE_TIMEOUT 2*HZ
59
60typedef enum {
61 S_PNP = 0,
62 S_PDA,
63 S_COMPUTER,
64 S_PRINTER,
65 S_MODEM,
66 S_FAX,
67 S_LAN,
68 S_TELEPHONY,
69 S_COMM,
70 S_OBEX,
71 S_ANY,
72 S_END,
73} SERVICE;
74
75
76typedef void (*DISCOVERY_CALLBACK1) (discinfo_t *, DISCOVERY_MODE, void *);
77
78typedef void (*DISCOVERY_CALLBACK2) (discinfo_t *, DISCOVERY_MODE, void *);
79
80typedef struct {
81 irda_queue_t queue;
82
83 __u16_host_order hints;
84} irlmp_service_t;
85
86typedef struct {
87 irda_queue_t queue;
88
89 __u16_host_order hint_mask;
90
91 DISCOVERY_CALLBACK1 disco_callback;
92 DISCOVERY_CALLBACK2 expir_callback;
93 void *priv;
94} irlmp_client_t;
95
96
97
98
99struct lsap_cb {
100 irda_queue_t queue;
101 magic_t magic;
102
103 unsigned long connected;
104 int persistent;
105
106 __u8 slsap_sel;
107 __u8 dlsap_sel;
108#ifdef CONFIG_IRDA_ULTRA
109 __u8 pid;
110#endif
111 struct sk_buff *conn_skb;
112
113 struct timer_list watchdog_timer;
114
115 IRLMP_STATE lsap_state;
116 notify_t notify;
117 struct qos_info qos;
118
119 struct lap_cb *lap;
120};
121
122
123
124
125
126
127
128
129typedef struct {
130 int valid;
131
132 __u8 slsap_sel;
133 __u8 dlsap_sel;
134 struct lsap_cb *lsap;
135} CACHE_ENTRY;
136
137
138
139
140struct lap_cb {
141 irda_queue_t queue;
142 magic_t magic;
143
144 int reason;
145
146 IRLMP_STATE lap_state;
147
148 struct irlap_cb *irlap;
149 hashbin_t *lsaps;
150 struct lsap_cb *flow_next;
151
152 __u8 caddr;
153 __u32 saddr;
154 __u32 daddr;
155
156 struct qos_info *qos;
157 struct timer_list idle_timer;
158
159#ifdef CONFIG_IRDA_CACHE_LAST_LSAP
160
161
162
163 CACHE_ENTRY cache;
164#endif
165};
166
167
168
169
170struct irlmp_cb {
171 magic_t magic;
172
173 __u8 conflict_flag;
174
175 discovery_t discovery_cmd;
176 discovery_t discovery_rsp;
177
178
179 int last_lsap_sel;
180
181 struct timer_list discovery_timer;
182
183 hashbin_t *links;
184 hashbin_t *unconnected_lsaps;
185 hashbin_t *clients;
186 hashbin_t *services;
187
188 hashbin_t *cachelog;
189
190 int running;
191
192 __u16_host_order hints;
193};
194
195
196int irlmp_init(void);
197void irlmp_cleanup(void);
198struct lsap_cb *irlmp_open_lsap(__u8 slsap, notify_t *notify, __u8 pid);
199void irlmp_close_lsap( struct lsap_cb *self);
200
201__u16 irlmp_service_to_hint(int service);
202void *irlmp_register_service(__u16 hints);
203int irlmp_unregister_service(void *handle);
204void *irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 disco_clb,
205 DISCOVERY_CALLBACK2 expir_clb, void *priv);
206int irlmp_unregister_client(void *handle);
207int irlmp_update_client(void *handle, __u16 hint_mask,
208 DISCOVERY_CALLBACK1 disco_clb,
209 DISCOVERY_CALLBACK2 expir_clb, void *priv);
210
211void irlmp_register_link(struct irlap_cb *, __u32 saddr, notify_t *);
212void irlmp_unregister_link(__u32 saddr);
213
214int irlmp_connect_request(struct lsap_cb *, __u8 dlsap_sel,
215 __u32 saddr, __u32 daddr,
216 struct qos_info *, struct sk_buff *);
217void irlmp_connect_indication(struct lsap_cb *self, struct sk_buff *skb);
218int irlmp_connect_response(struct lsap_cb *, struct sk_buff *);
219void irlmp_connect_confirm(struct lsap_cb *, struct sk_buff *);
220struct lsap_cb *irlmp_dup(struct lsap_cb *self, void *instance);
221
222void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason,
223 struct sk_buff *userdata);
224int irlmp_disconnect_request(struct lsap_cb *, struct sk_buff *userdata);
225
226void irlmp_discovery_confirm(hashbin_t *discovery_log, DISCOVERY_MODE mode);
227void irlmp_discovery_request(int nslots);
228discinfo_t *irlmp_get_discoveries(int *pn, __u16 mask, int nslots);
229void irlmp_do_expiry(void);
230void irlmp_do_discovery(int nslots);
231discovery_t *irlmp_get_discovery_response(void);
232void irlmp_discovery_expiry(discinfo_t *expiry, int number);
233
234int irlmp_data_request(struct lsap_cb *, struct sk_buff *);
235void irlmp_data_indication(struct lsap_cb *, struct sk_buff *);
236
237int irlmp_udata_request(struct lsap_cb *, struct sk_buff *);
238void irlmp_udata_indication(struct lsap_cb *, struct sk_buff *);
239
240#ifdef CONFIG_IRDA_ULTRA
241int irlmp_connless_data_request(struct lsap_cb *, struct sk_buff *, __u8);
242void irlmp_connless_data_indication(struct lsap_cb *, struct sk_buff *);
243#endif
244
245void irlmp_status_indication(struct lap_cb *, LINK_STATUS link, LOCK_STATUS lock);
246void irlmp_flow_indication(struct lap_cb *self, LOCAL_FLOW flow);
247
248LM_REASON irlmp_convert_lap_reason(LAP_REASON);
249
250static inline __u32 irlmp_get_saddr(const struct lsap_cb *self)
251{
252 return (self && self->lap) ? self->lap->saddr : 0;
253}
254
255static inline __u32 irlmp_get_daddr(const struct lsap_cb *self)
256{
257 return (self && self->lap) ? self->lap->daddr : 0;
258}
259
260extern const char *irlmp_reasons[];
261extern int sysctl_discovery_timeout;
262extern int sysctl_discovery_slots;
263extern int sysctl_discovery;
264extern int sysctl_lap_keepalive_time;
265extern struct irlmp_cb *irlmp;
266
267
268
269static inline int irlmp_lap_tx_queue_full(struct lsap_cb *self)
270{
271 if (self == NULL)
272 return 0;
273 if (self->lap == NULL)
274 return 0;
275 if (self->lap->irlap == NULL)
276 return 0;
277
278 return(IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD);
279}
280
281
282
283
284
285
286static inline void irlmp_listen(struct lsap_cb *self)
287{
288 self->dlsap_sel = LSAP_ANY;
289 self->lap = NULL;
290 self->lsap_state = LSAP_DISCONNECTED;
291
292 del_timer(&self->watchdog_timer);
293}
294
295#endif
296