Import 2.3.4pre3
[davej-history.git] / include / net / irda / irda.h
blobb0e67385b985840ac332208e63d3098992dac3d6
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 May 10 09:51:13 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 #define ALIGN __attribute__((aligned))
44 #define PACK __attribute__((packed))
47 #ifdef CONFIG_IRDA_DEBUG
49 extern __u32 irda_debug;
51 /* use 0 for production, 1 for verification, >2 for debug */
52 #define IRDA_DEBUG_LEVEL 0
54 #define DEBUG(n, args...) if (irda_debug >= (n)) printk(KERN_DEBUG args)
55 #define ASSERT(expr, func) \
56 if(!(expr)) { \
57 printk( "Assertion failed! %s,%s,%s,line=%d\n",\
58 #expr,__FILE__,__FUNCTION__,__LINE__); \
59 ##func}
60 #else
61 #define DEBUG(n, args...)
62 #define ASSERT(expr, func)
63 #endif /* CONFIG_IRDA_DEBUG */
65 #define WARNING(args...) printk(KERN_WARNING args)
66 #define MESSAGE(args...) printk(KERN_INFO args)
67 #define ERROR(args...) printk(KERN_ERR args)
69 #define MSECS_TO_JIFFIES(ms) (ms*HZ/1000)
72 * Magic numbers used by Linux/IR. Random numbers which must be unique to
73 * give the best protection
75 #define IRTTY_MAGIC 0x2357
76 #define LAP_MAGIC 0x1357
77 #define LMP_MAGIC 0x4321
78 #define LMP_LSAP_MAGIC 0x69333
79 #define LMP_LAP_MAGIC 0x3432
80 #define IRDA_DEVICE_MAGIC 0x63454
81 #define IAS_MAGIC 0x007
82 #define TTP_MAGIC 0x241169
83 #define TTP_TSAP_MAGIC 0x4345
84 #define IROBEX_MAGIC 0x341324
85 #define HB_MAGIC 0x64534
86 #define IRLAN_MAGIC 0x754
87 #define IAS_OBJECT_MAGIC 0x34234
88 #define IAS_ATTRIB_MAGIC 0x45232
90 #define IAS_DEVICE_ID 0x5342
91 #define IAS_PNP_ID 0xd342
92 #define IAS_OBEX_ID 0x34323
93 #define IAS_IRLAN_ID 0x34234
94 #define IAS_IRCOMM_ID 0x2343
95 #define IAS_IRLPT_ID 0x9876
97 typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
99 /* IrDA Socket */
100 struct tsap_cb;
101 struct irda_sock {
102 __u32 saddr; /* my local address */
103 __u32 daddr; /* peer address */
105 struct ias_object *ias_obj;
106 struct tsap_cb *tsap; /* TSAP used by this connection */
107 __u8 dtsap_sel; /* remote TSAP address */
108 __u8 stsap_sel; /* local TSAP address */
110 __u32 max_sdu_size_rx;
111 __u32 max_sdu_size_tx;
112 __u32 max_data_size;
113 __u8 max_header_size;
114 struct qos_info qos_tx;
116 __u16 mask; /* Hint bits mask */
117 __u16 hints; /* Hint bits */
119 __u32 ckey; /* IrLMP client handle */
120 __u32 skey; /* IrLMP service handle */
122 int nslots; /* Number of slots to use for discovery */
124 int errno;
126 struct sock *sk;
127 wait_queue_head_t ias_wait; /* Wait for LM-IAS answer */
129 LOCAL_FLOW tx_flow;
130 LOCAL_FLOW rx_flow;
134 * This type is used by the protocols that transmit 16 bits words in
135 * little endian format. A little endian machine stores MSB of word in
136 * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0]
137 * and LSB in byte[1].
139 typedef union {
140 __u16 word;
141 __u8 byte[2];
142 } __u16_host_order;
145 * Information monitored by some layers
147 struct irda_statistics
149 int rx_packets; /* total packets received */
150 int tx_packets; /* total packets transmitted */
151 int rx_errors; /* bad packets received */
152 int tx_errors; /* packet transmit problems */
153 int rx_dropped; /* no space in linux buffers */
154 int tx_dropped; /* no space available in linux */
155 int rx_compressed;
156 int tx_compressed;
157 int rx_bytes; /* total bytes received */
158 int tx_bytes; /* total bytes transmitted */
160 int multicast; /* multicast packets received */
161 int collisions;
163 /* detailed rx_errors: */
164 int rx_length_errors;
165 int rx_over_errors; /* receiver ring buff overflow */
166 int rx_crc_errors; /* recved pkt with crc error */
167 int rx_frame_errors; /* recv'd frame alignment error */
168 int rx_fifo_errors; /* recv'r fifo overrun */
169 int rx_missed_errors; /* receiver missed packet */
171 /* detailed tx_errors */
172 int tx_aborted_errors;
173 int tx_carrier_errors;
174 int tx_fifo_errors;
175 int tx_heartbeat_errors;
176 int tx_window_errors;
179 /* Misc status information */
180 typedef enum {
181 STATUS_OK,
182 STATUS_ABORTED,
183 STATUS_NO_ACTIVITY,
184 STATUS_NOISY,
185 STATUS_REMOTE,
186 } LINK_STATUS;
188 typedef enum {
189 LOCK_NO_CHANGE,
190 LOCK_LOCKED,
191 LOCK_UNLOCKED,
192 } LOCK_STATUS;
194 typedef enum { /* FIXME check the two first reason codes */
195 LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
196 LAP_NO_RESPONSE, /* To many retransmits without response */
197 LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */
198 LAP_FOUND_NONE, /* No devices were discovered */
199 LAP_MEDIA_BUSY,
200 LAP_PRIMARY_CONFLICT,
201 } LAP_REASON;
204 * IrLMP disconnect reasons. The order is very important, since they
205 * correspond to disconnect reasons sent in IrLMP disconnect frames, so
206 * please do not touch :-)
208 typedef enum {
209 LM_USER_REQUEST = 1, /* User request */
210 LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */
211 LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */
212 LM_LAP_RESET, /* IrLAP reset */
213 LM_INIT_DISCONNECT, /* Link Management initiated disconnect */
214 LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */
215 LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */
216 LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */
217 LM_CONN_HALF_OPEN, /* Connection is half open */
218 LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */
219 } LM_REASON;
220 #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */
223 * Notify structure used between transport and link management layers
225 struct notify_t {
226 int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
227 int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
228 void (*connect_confirm)(void *instance, void *sap,
229 struct qos_info *qos, __u32 max_sdu_size,
230 __u8 max_header_size, struct sk_buff *skb);
231 void (*connect_indication)(void *instance, void *sap,
232 struct qos_info *qos, __u32 max_sdu_size,
233 __u8 max_header_size, struct sk_buff *skb);
234 void (*disconnect_indication)(void *instance, void *sap,
235 LM_REASON reason, struct sk_buff *);
236 void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
237 void *instance; /* Layer instance pointer */
238 char name[16]; /* Name of layer */
241 #define NOTIFY_MAX_NAME 16
243 #endif /* NET_IRDA_H */