1 /*********************************************************************
2 *
3 * Filename: irlmp.h
4 * Version: 0.9
5 * Description: IrDA Link Management Protocol (LMP) layer
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sun Aug 17 20:54:32 1997
9 * Modified at: Fri Dec 10 13:23:01 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
13 * All Rights Reserved.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * Neither Dag Brattli nor University of Tromsų admit liability nor
21 * provide warranty for any of this software. This material is
22 * provided "AS-IS" and at no charge.
23 *
24 ********************************************************************/
25
26 #ifndef IRLMP_H
27 #define IRLMP_H
28
29 #include <asm/param.h> /* for HZ */
30
31 #include <linux/config.h>
32 #include <linux/types.h>
33
34 #include <net/irda/irda.h>
35 #include <net/irda/qos.h>
36 #include <net/irda/irlap.h>
37 #include <net/irda/irlmp_event.h>
38 #include <net/irda/irqueue.h>
39 #include <net/irda/discovery.h>
40
41 /* LSAP-SEL's */
42 #define LSAP_MASK 0x7f
43 #define LSAP_IAS 0x00
44 #define LSAP_ANY 0xff
45 #define LSAP_MAX 0x6f /* 0x70-0x7f are reserved */
46 #define LSAP_CONNLESS 0x70 /* Connectionless LSAP, mostly used for Ultra */
47
48 #define DEV_ADDR_ANY 0xffffffff
49
50 #define LMP_HEADER 2 /* Dest LSAP + Source LSAP */
51 #define LMP_CONTROL_HEADER 4
52 #define LMP_PID_HEADER 1 /* Used by Ultra */
53 #define LMP_MAX_HEADER (LMP_CONTROL_HEADER+LAP_MAX_HEADER)
54
55 #define LM_MAX_CONNECTIONS 10
56
57 #define LM_IDLE_TIMEOUT 2*HZ /* 2 seconds for now */
58
59 typedef enum {
60 S_PNP,
61 S_PDA,
62 S_COMPUTER,
63 S_PRINTER,
64 S_MODEM,
65 S_FAX,
66 S_LAN,
67 S_TELEPHONY,
68 S_COMM,
69 S_OBEX,
70 S_ANY,
71 S_END,
72 } SERVICE;
73
74 typedef void (*DISCOVERY_CALLBACK1) (discovery_t *, void *);
75 typedef void (*DISCOVERY_CALLBACK2) (hashbin_t *, void *);
76
77 typedef struct {
78 irda_queue_t queue; /* Must be first */
79
80 __u16 hints; /* Hint bits */
81 } irlmp_service_t;
82
83 typedef struct {
84 irda_queue_t queue; /* Must be first */
85
86 __u16 hint_mask;
87
88 DISCOVERY_CALLBACK1 disco_callback; /* Selective discovery */
89 DISCOVERY_CALLBACK1 expir_callback; /* Selective expiration */
90 void *priv; /* Used to identify client */
91 } irlmp_client_t;
92
93 struct lap_cb; /* Forward decl. */
94
95 /*
96 * Information about each logical LSAP connection
97 */
98 struct lsap_cb {
99 irda_queue_t queue; /* Must be first */
100 magic_t magic;
101
102 int connected;
103 int persistent;
104
105 __u8 slsap_sel; /* Source (this) LSAP address */
106 __u8 dlsap_sel; /* Destination LSAP address (if connected) */
107 #ifdef CONFIG_IRDA_ULTRA
108 __u8 pid; /* Used by connectionless LSAP */
109 #endif /* CONFIG_IRDA_ULTRA */
110 struct sk_buff *conn_skb; /* Store skb here while connecting */
111
112 struct timer_list watchdog_timer;
113
114 IRLMP_STATE lsap_state; /* Connection state */
115 notify_t notify; /* Indication/Confirm entry points */
116 struct qos_info qos; /* QoS for this connection */
117
118 struct lap_cb *lap; /* Pointer to LAP connection structure */
119 };
120
121 /*
122 * Information about each registred IrLAP layer
123 */
124 struct lap_cb {
125 irda_queue_t queue; /* Must be first */
126 magic_t magic;
127
128 int reason; /* LAP disconnect reason */
129
130 IRLMP_STATE lap_state;
131
132 struct irlap_cb *irlap; /* Instance of IrLAP layer */
133 hashbin_t *lsaps; /* LSAP associated with this link */
134 int refcount;
135
136 __u8 caddr; /* Connection address */
137 __u32 saddr; /* Source device address */
138 __u32 daddr; /* Destination device address */
139
140 struct qos_info *qos; /* LAP QoS for this session */
141 struct timer_list idle_timer;
142 };
143
144 /*
145 * Used for caching the last slsap->dlsap->handle mapping
146 */
147 typedef struct {
148 int valid;
149
150 __u8 slsap_sel;
151 __u8 dlsap_sel;
152 struct lsap_cb *lsap;
153 } CACHE_ENTRY;
154
155 /*
156 * Main structure for IrLMP
157 */
158 struct irlmp_cb {
159 magic_t magic;
160
161 __u8 conflict_flag;
162
163 discovery_t discovery_cmd; /* Discovery command to use by IrLAP */
164 discovery_t discovery_rsp; /* Discovery response to use by IrLAP */
165
166 int free_lsap_sel;
167
168 #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
169 CACHE_ENTRY cache; /* Caching last slsap->dlsap->handle mapping */
170 #endif
171 struct timer_list discovery_timer;
172
173 hashbin_t *links; /* IrLAP connection table */
174 hashbin_t *unconnected_lsaps;
175 hashbin_t *clients;
176 hashbin_t *services;
177
178 hashbin_t *cachelog; /* Current discovery log */
179 spinlock_t log_lock; /* discovery log spinlock */
180
181 int running;
182
183 __u16_host_order hints; /* Hint bits */
184 };
185
186 /* Prototype declarations */
187 int irlmp_init(void);
188 void irlmp_cleanup(void);
189 struct lsap_cb *irlmp_open_lsap(__u8 slsap, notify_t *notify, __u8 pid);
190 void irlmp_close_lsap( struct lsap_cb *self);
191
192 __u16 irlmp_service_to_hint(int service);
193 __u32 irlmp_register_service(__u16 hints);
194 int irlmp_unregister_service(__u32 handle);
195 __u32 irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 disco_clb,
196 DISCOVERY_CALLBACK1 expir_clb, void *priv);
197 int irlmp_unregister_client(__u32 handle);
198 int irlmp_update_client(__u32 handle, __u16 hint_mask,
199 DISCOVERY_CALLBACK1 disco_clb,
200 DISCOVERY_CALLBACK1 expir_clb, void *priv);
201
202 void irlmp_register_link(struct irlap_cb *, __u32 saddr, notify_t *);
203 void irlmp_unregister_link(__u32 saddr);
204
205 int irlmp_connect_request(struct lsap_cb *, __u8 dlsap_sel,
206 __u32 saddr, __u32 daddr,
207 struct qos_info *, struct sk_buff *);
208 void irlmp_connect_indication(struct lsap_cb *self, struct sk_buff *skb);
209 int irlmp_connect_response(struct lsap_cb *, struct sk_buff *);
210 void irlmp_connect_confirm(struct lsap_cb *, struct sk_buff *);
211 struct lsap_cb *irlmp_dup(struct lsap_cb *self, void *instance);
212
213 void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason,
214 struct sk_buff *userdata);
215 int irlmp_disconnect_request(struct lsap_cb *, struct sk_buff *userdata);
216
217 void irlmp_discovery_confirm(hashbin_t *discovery_log);
218 void irlmp_discovery_request(int nslots);
219 struct irda_device_info *irlmp_get_discoveries(int *pn, __u16 mask);
220 void irlmp_do_discovery(int nslots);
221 discovery_t *irlmp_get_discovery_response(void);
222 void irlmp_discovery_expiry(discovery_t *expiry);
223
224 int irlmp_data_request(struct lsap_cb *, struct sk_buff *);
225 void irlmp_data_indication(struct lsap_cb *, struct sk_buff *);
226
227 int irlmp_udata_request(struct lsap_cb *, struct sk_buff *);
228 void irlmp_udata_indication(struct lsap_cb *, struct sk_buff *);
229
230 #ifdef CONFIG_IRDA_ULTRA
231 int irlmp_connless_data_request(struct lsap_cb *, struct sk_buff *);
232 void irlmp_connless_data_indication(struct lsap_cb *, struct sk_buff *);
233 #endif /* CONFIG_IRDA_ULTRA */
234
235 void irlmp_status_request(void);
236 void irlmp_status_indication(struct lap_cb *, LINK_STATUS link, LOCK_STATUS lock);
237
238 int irlmp_slsap_inuse(__u8 slsap);
239 __u8 irlmp_find_free_slsap(void);
240 LM_REASON irlmp_convert_lap_reason(LAP_REASON);
241
242 __u32 irlmp_get_saddr(struct lsap_cb *self);
243 __u32 irlmp_get_daddr(struct lsap_cb *self);
244
245 extern char *lmp_reasons[];
246 extern int sysctl_discovery_timeout;
247 extern int sysctl_discovery_slots;
248 extern int sysctl_discovery;
249 extern struct irlmp_cb *irlmp;
250
251 static inline hashbin_t *irlmp_get_cachelog(void) { return irlmp->cachelog; }
252
253 static inline int irlmp_get_lap_tx_queue_len(struct lsap_cb *self)
254 {
255 if (self == NULL)
256 return 0;
257 if (self->lap == NULL)
258 return 0;
259 if (self->lap->irlap == NULL)
260 return 0;
261
262 return IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap);
263 }
264
265 #endif
266
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.