1 /*********************************************************************
5 * Description: IrDA common include file for kernel internal use
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Tue Dec 9 21:13:12 1997
9 * Modified at: Fri Jan 28 13:16:32 2000
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
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.
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.
24 ********************************************************************/
29 #include <linux/config.h>
30 #include <linux/skbuff.h>
31 #include <linux/kernel.h>
33 #include <linux/irda.h>
35 typedef __u32 magic_t;
37 #include <net/irda/qos.h>
38 #include <net/irda/irqueue.h>
48 /* Hack to do small backoff when setting media busy in IrLAP */
53 #ifndef IRDA_MIN /* Lets not mix this MIN with other header files */
54 #define IRDA_MIN(a, b) (((a) < (b)) ? (a) : (b))
58 # define ALIGN __attribute__((aligned))
61 # define PACK __attribute__((packed))
65 #ifdef CONFIG_IRDA_DEBUG
67 extern __u32 irda_debug;
69 /* use 0 for production, 1 for verification, >2 for debug */
70 #define IRDA_DEBUG_LEVEL 0
72 #define IRDA_DEBUG(n, args...) (irda_debug >= (n)) ? (printk(KERN_DEBUG args)) : 0
73 #define ASSERT(expr, func) \
75 printk( "Assertion failed! %s:%s:%d %s\n", \
76 __FILE__,__FUNCTION__,__LINE__,(#expr)); \
79 #define IRDA_DEBUG(n, args...)
80 #define ASSERT(expr, func) \
83 #endif /* CONFIG_IRDA_DEBUG */
85 #define WARNING(args...) printk(KERN_WARNING args)
86 #define MESSAGE(args...) printk(KERN_INFO args)
87 #define ERROR(args...) printk(KERN_ERR args)
89 #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
92 * Magic numbers used by Linux-IrDA. Random numbers which must be unique to
93 * give the best protection
96 #define IRTTY_MAGIC 0x2357
97 #define LAP_MAGIC 0x1357
98 #define LMP_MAGIC 0x4321
99 #define LMP_LSAP_MAGIC 0x69333
100 #define LMP_LAP_MAGIC 0x3432
101 #define IRDA_DEVICE_MAGIC 0x63454
102 #define IAS_MAGIC 0x007
103 #define TTP_MAGIC 0x241169
104 #define TTP_TSAP_MAGIC 0x4345
105 #define IROBEX_MAGIC 0x341324
106 #define HB_MAGIC 0x64534
107 #define IRLAN_MAGIC 0x754
108 #define IAS_OBJECT_MAGIC 0x34234
109 #define IAS_ATTRIB_MAGIC 0x45232
110 #define IRDA_TASK_MAGIC 0x38423
112 #define IAS_DEVICE_ID 0x0000 /* Defined by IrDA, IrLMP section 4.1 (page 68) */
113 #define IAS_PNP_ID 0xd342
114 #define IAS_OBEX_ID 0x34323
115 #define IAS_IRLAN_ID 0x34234
116 #define IAS_IRCOMM_ID 0x2343
117 #define IAS_IRLPT_ID 0x9876
119 typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
121 /* A few forward declarations (to make compiler happy) */
122 struct tsap_cb; /* in <net/irda/irttp.h> */
123 struct lsap_cb; /* in <net/irda/irlmp.h> */
124 struct iriap_cb; /* in <net/irda/iriap.h> */
125 struct ias_value; /* in <net/irda/irias_object.h> */
126 struct discovery_t; /* in <net/irda/discovery.h> */
130 __u32 saddr; /* my local address */
131 __u32 daddr; /* peer address */
133 struct lsap_cb *lsap; /* LSAP used by Ultra */
134 __u8 pid; /* Protocol IP (PID) used by Ultra */
136 struct tsap_cb *tsap; /* TSAP used by this connection */
137 __u8 dtsap_sel; /* remote TSAP address */
138 __u8 stsap_sel; /* local TSAP address */
140 __u32 max_sdu_size_rx;
141 __u32 max_sdu_size_tx;
143 __u8 max_header_size;
144 struct qos_info qos_tx;
146 __u16 mask; /* Hint bits mask */
147 __u16 hints; /* Hint bits */
149 __u32 ckey; /* IrLMP client handle */
150 __u32 skey; /* IrLMP service handle */
152 struct ias_object *ias_obj; /* Our service name + lsap in IAS */
153 struct iriap_cb *iriap; /* Used to query remote IAS */
154 struct ias_value *ias_result; /* Result of remote IAS query */
156 hashbin_t *cachelog; /* Result of discovery query */
157 struct discovery_t *cachediscovery; /* Result of selective discovery query */
159 int nslots; /* Number of slots to use for discovery */
161 int errno; /* status of the IAS query */
164 wait_queue_head_t query_wait; /* Wait for the answer to a query */
165 struct timer_list watchdog; /* Timeout for discovery */
172 * This type is used by the protocols that transmit 16 bits words in
173 * little endian format. A little endian machine stores MSB of word in
174 * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0]
175 * and LSB in byte[1].
183 * Per-packet information we need to hide inside sk_buff
184 * (must not exceed 48 bytes, check with struct sk_buff)
187 magic_t magic; /* Be sure that we can trust the information */
188 __u32 next_speed; /* The Speed to be set *after* this frame */
189 __u16 mtt; /* Minimum turn around time */
190 __u16 xbofs; /* Number of xbofs required, used by SIR mode */
191 __u16 next_xbofs; /* Number of xbofs required *after* this frame */
192 void *context; /* May be used by drivers */
193 void (*destructor)(struct sk_buff *skb); /* Used for flow control */
194 __u16 xbofs_delay; /* Number of xbofs used for generating the mtt */
195 __u8 line; /* Used by IrCOMM in IrLPT mode */
198 /* Misc status information */
213 typedef enum { /* FIXME check the two first reason codes */
214 LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
215 LAP_NO_RESPONSE, /* To many retransmits without response */
216 LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */
217 LAP_FOUND_NONE, /* No devices were discovered */
219 LAP_PRIMARY_CONFLICT,
223 * IrLMP disconnect reasons. The order is very important, since they
224 * correspond to disconnect reasons sent in IrLMP disconnect frames, so
225 * please do not touch :-)
228 LM_USER_REQUEST = 1, /* User request */
229 LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */
230 LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */
231 LM_LAP_RESET, /* IrLAP reset */
232 LM_INIT_DISCONNECT, /* Link Management initiated disconnect */
233 LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */
234 LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */
235 LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */
236 LM_CONN_HALF_OPEN, /* Connection is half open */
237 LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */
239 #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */
242 * Notify structure used between transport and link management layers
245 int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
246 int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
247 void (*connect_confirm)(void *instance, void *sap,
248 struct qos_info *qos, __u32 max_sdu_size,
249 __u8 max_header_size, struct sk_buff *skb);
250 void (*connect_indication)(void *instance, void *sap,
251 struct qos_info *qos, __u32 max_sdu_size,
252 __u8 max_header_size, struct sk_buff *skb);
253 void (*disconnect_indication)(void *instance, void *sap,
254 LM_REASON reason, struct sk_buff *);
255 void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
256 void (*status_indication)(void *instance,
257 LINK_STATUS link, LOCK_STATUS lock);
258 void *instance; /* Layer instance pointer */
259 char name[16]; /* Name of layer */
262 #define NOTIFY_MAX_NAME 16
264 #endif /* NET_IRDA_H */