* better
[mascara-docs.git] / i386 / linux-2.3.21 / include / net / irda / irda.h
blob5e00eec7ac359ebcb587d7a3dd35811183667558
1 /*********************************************************************
2 *
3 * Filename: irda.h
4 * Version:
5 * Description:
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Tue Dec 9 21:13:12 1997
9 * Modified at: Mon Sep 27 11:13:18 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * Neither Dag Brattli nor University of Tromsø admit liability nor
20 * provide warranty for any of this software. This material is
21 * provided "AS-IS" and at no charge.
23 ********************************************************************/
25 #ifndef NET_IRDA_H
26 #define NET_IRDA_H
28 #include <linux/config.h>
29 #include <linux/skbuff.h>
30 #include <linux/kernel.h>
32 #include <net/irda/qos.h>
33 #include <net/irda/irqueue.h>
35 #ifndef TRUE
36 #define TRUE 1
37 #endif
39 #ifndef FALSE
40 #define FALSE 0
41 #endif
43 #ifndef MIN
44 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
45 #endif
47 #define ALIGN __attribute__((aligned))
48 #define PACK __attribute__((packed))
51 #ifdef CONFIG_IRDA_DEBUG
53 extern __u32 irda_debug;
55 /* use 0 for production, 1 for verification, >2 for debug */
56 #define IRDA_DEBUG_LEVEL 0
58 #define DEBUG(n, args...) (irda_debug >= (n)) ? (printk(KERN_DEBUG args)) : 0
59 #define ASSERT(expr, func) \
60 if(!(expr)) { \
61 printk( "Assertion failed! %s,%s,%s,line=%d\n",\
62 #expr,__FILE__,__FUNCTION__,__LINE__); \
63 ##func}
64 #else
65 #define DEBUG(n, args...)
66 #define ASSERT(expr, func)
67 #endif /* CONFIG_IRDA_DEBUG */
69 #define WARNING(args...) printk(KERN_WARNING args)
70 #define MESSAGE(args...) printk(KERN_INFO args)
71 #define ERROR(args...) printk(KERN_ERR args)
73 #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
76 * Magic numbers used by Linux-IrDA. Random numbers which must be unique to
77 * give the best protection
79 typedef __u32 magic_t;
81 #define IRTTY_MAGIC 0x2357
82 #define LAP_MAGIC 0x1357
83 #define LMP_MAGIC 0x4321
84 #define LMP_LSAP_MAGIC 0x69333
85 #define LMP_LAP_MAGIC 0x3432
86 #define IRDA_DEVICE_MAGIC 0x63454
87 #define IAS_MAGIC 0x007
88 #define TTP_MAGIC 0x241169
89 #define TTP_TSAP_MAGIC 0x4345
90 #define IROBEX_MAGIC 0x341324
91 #define HB_MAGIC 0x64534
92 #define IRLAN_MAGIC 0x754
93 #define IAS_OBJECT_MAGIC 0x34234
94 #define IAS_ATTRIB_MAGIC 0x45232
96 #define IAS_DEVICE_ID 0x5342
97 #define IAS_PNP_ID 0xd342
98 #define IAS_OBEX_ID 0x34323
99 #define IAS_IRLAN_ID 0x34234
100 #define IAS_IRCOMM_ID 0x2343
101 #define IAS_IRLPT_ID 0x9876
103 typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
105 /* IrDA Socket */
106 struct tsap_cb;
107 struct irda_sock {
108 __u32 saddr; /* my local address */
109 __u32 daddr; /* peer address */
111 struct ias_object *ias_obj;
112 struct tsap_cb *tsap; /* TSAP used by this connection */
113 __u8 dtsap_sel; /* remote TSAP address */
114 __u8 stsap_sel; /* local TSAP address */
116 __u32 max_sdu_size_rx;
117 __u32 max_sdu_size_tx;
118 __u32 max_data_size;
119 __u8 max_header_size;
120 struct qos_info qos_tx;
122 __u16 mask; /* Hint bits mask */
123 __u16 hints; /* Hint bits */
125 __u32 ckey; /* IrLMP client handle */
126 __u32 skey; /* IrLMP service handle */
128 int nslots; /* Number of slots to use for discovery */
130 int errno;
132 struct sock *sk;
133 wait_queue_head_t ias_wait; /* Wait for LM-IAS answer */
135 LOCAL_FLOW tx_flow;
136 LOCAL_FLOW rx_flow;
140 * This type is used by the protocols that transmit 16 bits words in
141 * little endian format. A little endian machine stores MSB of word in
142 * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0]
143 * and LSB in byte[1].
145 typedef union {
146 __u16 word;
147 __u8 byte[2];
148 } __u16_host_order;
150 /* Per-packet information we need to hide inside sk_buff */
151 struct irda_skb_cb {
152 magic_t magic; /* Be sure that we can trust the information */
153 int mtt; /* minimum turn around time */
154 int xbofs; /* number of xbofs required, used by SIR mode */
155 int line; /* Used by IrCOMM in IrLPT mode */
156 void *instance; /* Used by IrTTP */
157 void (*destructor)(struct sk_buff *skb); /* Used for flow control */
161 * Information monitored by some layers
163 struct irda_statistics
165 int rx_packets; /* total packets received */
166 int tx_packets; /* total packets transmitted */
167 int rx_errors; /* bad packets received */
168 int tx_errors; /* packet transmit problems */
169 int rx_dropped; /* no space in linux buffers */
170 int tx_dropped; /* no space available in linux */
171 int rx_compressed;
172 int tx_compressed;
173 int rx_bytes; /* total bytes received */
174 int tx_bytes; /* total bytes transmitted */
176 int multicast; /* multicast packets received */
177 int collisions;
179 /* detailed rx_errors: */
180 int rx_length_errors;
181 int rx_over_errors; /* receiver ring buff overflow */
182 int rx_crc_errors; /* recved pkt with crc error */
183 int rx_frame_errors; /* recv'd frame alignment error */
184 int rx_fifo_errors; /* recv'r fifo overrun */
185 int rx_missed_errors; /* receiver missed packet */
187 /* detailed tx_errors */
188 int tx_aborted_errors;
189 int tx_carrier_errors;
190 int tx_fifo_errors;
191 int tx_heartbeat_errors;
192 int tx_window_errors;
195 /* Misc status information */
196 typedef enum {
197 STATUS_OK,
198 STATUS_ABORTED,
199 STATUS_NO_ACTIVITY,
200 STATUS_NOISY,
201 STATUS_REMOTE,
202 } LINK_STATUS;
204 typedef enum {
205 LOCK_NO_CHANGE,
206 LOCK_LOCKED,
207 LOCK_UNLOCKED,
208 } LOCK_STATUS;
210 typedef enum { /* FIXME check the two first reason codes */
211 LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
212 LAP_NO_RESPONSE, /* To many retransmits without response */
213 LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */
214 LAP_FOUND_NONE, /* No devices were discovered */
215 LAP_MEDIA_BUSY,
216 LAP_PRIMARY_CONFLICT,
217 } LAP_REASON;
220 * IrLMP disconnect reasons. The order is very important, since they
221 * correspond to disconnect reasons sent in IrLMP disconnect frames, so
222 * please do not touch :-)
224 typedef enum {
225 LM_USER_REQUEST = 1, /* User request */
226 LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */
227 LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */
228 LM_LAP_RESET, /* IrLAP reset */
229 LM_INIT_DISCONNECT, /* Link Management initiated disconnect */
230 LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */
231 LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */
232 LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */
233 LM_CONN_HALF_OPEN, /* Connection is half open */
234 LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */
235 } LM_REASON;
236 #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */
239 * Notify structure used between transport and link management layers
241 typedef struct {
242 int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
243 int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
244 void (*connect_confirm)(void *instance, void *sap,
245 struct qos_info *qos, __u32 max_sdu_size,
246 __u8 max_header_size, struct sk_buff *skb);
247 void (*connect_indication)(void *instance, void *sap,
248 struct qos_info *qos, __u32 max_sdu_size,
249 __u8 max_header_size, struct sk_buff *skb);
250 void (*disconnect_indication)(void *instance, void *sap,
251 LM_REASON reason, struct sk_buff *);
252 void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
253 void *instance; /* Layer instance pointer */
254 char name[16]; /* Name of layer */
255 } notify_t;
257 #define NOTIFY_MAX_NAME 16
259 #endif /* NET_IRDA_H */