File: /usr/src/linux/include/net/irda/irda.h

1     /*********************************************************************
2      *                
3      * Filename:      irda.h
4      * Version:       1.0
5      * Description:   IrDA common include file for kernel internal use
6      * Status:        Stable
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>
11      * 
12      *     Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved.
13      *      
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.
18      *  
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.
22      *     
23      ********************************************************************/
24     
25     #ifndef NET_IRDA_H
26     #define NET_IRDA_H
27     
28     #include <linux/config.h>
29     #include <linux/skbuff.h>
30     #include <linux/kernel.h>
31     #include <linux/if.h>
32     #include <linux/irda.h>
33     
34     typedef __u32 magic_t;
35     
36     #include <net/irda/qos.h>
37     #include <net/irda/irqueue.h>
38     
39     #ifndef TRUE
40     #define TRUE 1
41     #endif
42     
43     #ifndef FALSE 
44     #define FALSE 0
45     #endif
46     
47     #ifndef IRDA_MIN /* Lets not mix this MIN with other header files */
48     #define IRDA_MIN(a, b) (((a) < (b)) ? (a) : (b))
49     #endif
50     
51     #ifndef ALIGN
52     #  define ALIGN __attribute__((aligned))
53     #endif
54     #ifndef PACK
55     #  define PACK __attribute__((packed))
56     #endif
57     
58     
59     #ifdef CONFIG_IRDA_DEBUG
60     
61     extern __u32 irda_debug;
62     
63     /* use 0 for production, 1 for verification, >2 for debug */
64     #define IRDA_DEBUG_LEVEL 0
65     
66     #define IRDA_DEBUG(n, args...) (irda_debug >= (n)) ? (printk(KERN_DEBUG args)) : 0
67     #define ASSERT(expr, func) \
68     if(!(expr)) { \
69             printk( "Assertion failed! %s:%s:%d %s\n", \
70             __FILE__,__FUNCTION__,__LINE__,(#expr));  \
71             func }
72     #else
73     #define IRDA_DEBUG(n, args...)
74     #define ASSERT(expr, func) \
75     if(!(expr)) do { \
76             func } while (0)
77     #endif /* CONFIG_IRDA_DEBUG */
78     
79     #define WARNING(args...) printk(KERN_WARNING args)
80     #define MESSAGE(args...) printk(KERN_INFO args)
81     #define ERROR(args...)   printk(KERN_ERR args)
82     
83     #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
84     
85     /*
86      *  Magic numbers used by Linux-IrDA. Random numbers which must be unique to 
87      *  give the best protection
88      */
89     
90     #define IRTTY_MAGIC        0x2357
91     #define LAP_MAGIC          0x1357
92     #define LMP_MAGIC          0x4321
93     #define LMP_LSAP_MAGIC     0x69333
94     #define LMP_LAP_MAGIC      0x3432
95     #define IRDA_DEVICE_MAGIC  0x63454
96     #define IAS_MAGIC          0x007
97     #define TTP_MAGIC          0x241169
98     #define TTP_TSAP_MAGIC     0x4345
99     #define IROBEX_MAGIC       0x341324
100     #define HB_MAGIC           0x64534
101     #define IRLAN_MAGIC        0x754
102     #define IAS_OBJECT_MAGIC   0x34234
103     #define IAS_ATTRIB_MAGIC   0x45232
104     #define IRDA_TASK_MAGIC    0x38423
105     
106     #define IAS_DEVICE_ID 0x0000 /* Defined by IrDA, IrLMP section 4.1 (page 68) */
107     #define IAS_PNP_ID    0xd342
108     #define IAS_OBEX_ID   0x34323
109     #define IAS_IRLAN_ID  0x34234
110     #define IAS_IRCOMM_ID 0x2343
111     #define IAS_IRLPT_ID  0x9876
112     
113     typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
114     
115     /* A few forward declarations (to make compiler happy) */
116     struct tsap_cb;		/* in <net/irda/irttp.h> */
117     struct lsap_cb;		/* in <net/irda/irlmp.h> */
118     struct iriap_cb;	/* in <net/irda/iriap.h> */
119     struct ias_value;	/* in <net/irda/irias_object.h> */
120     struct discovery_t;	/* in <net/irda/discovery.h> */
121     
122     /* IrDA Socket */
123     struct irda_sock {
124     	__u32 saddr;          /* my local address */
125     	__u32 daddr;          /* peer address */
126     
127     	struct lsap_cb *lsap; /* LSAP used by Ultra */
128     	__u8  pid;            /* Protocol IP (PID) used by Ultra */
129     
130     	struct tsap_cb *tsap; /* TSAP used by this connection */
131     	__u8 dtsap_sel;       /* remote TSAP address */
132     	__u8 stsap_sel;       /* local TSAP address */
133     	
134     	__u32 max_sdu_size_rx;
135     	__u32 max_sdu_size_tx;
136     	__u32 max_data_size;
137     	__u8  max_header_size;
138     	struct qos_info qos_tx;
139     
140     	__u16 mask;           /* Hint bits mask */
141     	__u16 hints;          /* Hint bits */
142     
143     	__u32 ckey;           /* IrLMP client handle */
144     	__u32 skey;           /* IrLMP service handle */
145     
146     	struct ias_object *ias_obj;   /* Our service name + lsap in IAS */
147     	struct iriap_cb *iriap;	      /* Used to query remote IAS */
148     	struct ias_value *ias_result; /* Result of remote IAS query */
149     
150     	hashbin_t *cachelog;		/* Result of discovery query */
151     	struct discovery_t *cachediscovery;	/* Result of selective discovery query */
152     
153     	int nslots;           /* Number of slots to use for discovery */
154     
155     	int errno;            /* status of the IAS query */
156     
157     	struct sock *sk;
158     	wait_queue_head_t query_wait;	/* Wait for the answer to a query */
159     	struct timer_list watchdog;	/* Timeout for discovery */
160     
161     	LOCAL_FLOW tx_flow;
162     	LOCAL_FLOW rx_flow;
163     };
164     
165     /*
166      *  This type is used by the protocols that transmit 16 bits words in 
167      *  little endian format. A little endian machine stores MSB of word in
168      *  byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] 
169      *  and LSB in byte[1].
170      */
171     typedef union {
172     	__u16 word;
173     	__u8  byte[2];
174     } __u16_host_order;
175     
176     /* 
177      * Per-packet information we need to hide inside sk_buff 
178      * (must not exceed 48 bytes, check with struct sk_buff) 
179      */
180     struct irda_skb_cb {
181     	magic_t magic;       /* Be sure that we can trust the information */
182     	__u32   next_speed;  /* The Speed to be set *after* this frame */
183     	__u16   mtt;         /* Minimum turn around time */
184     	__u16   xbofs;       /* Number of xbofs required, used by SIR mode */
185     	__u16   next_xbofs;  /* Number of xbofs required *after* this frame */
186     	void    *context;    /* May be used by drivers */
187     	void    (*destructor)(struct sk_buff *skb); /* Used for flow control */
188     	__u16   xbofs_delay; /* Number of xbofs used for generating the mtt */
189     	__u8    line;        /* Used by IrCOMM in IrLPT mode */
190     };
191     
192     /* Misc status information */
193     typedef enum {
194     	STATUS_OK,
195     	STATUS_ABORTED,
196     	STATUS_NO_ACTIVITY,
197     	STATUS_NOISY,
198     	STATUS_REMOTE,
199     } LINK_STATUS;
200     
201     typedef enum {
202     	LOCK_NO_CHANGE,
203     	LOCK_LOCKED,
204     	LOCK_UNLOCKED,
205     } LOCK_STATUS;
206     
207     typedef enum { /* FIXME check the two first reason codes */
208     	LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
209     	LAP_NO_RESPONSE,       /* To many retransmits without response */
210     	LAP_RESET_INDICATION,  /* To many retransmits, or invalid nr/ns */
211     	LAP_FOUND_NONE,        /* No devices were discovered */
212     	LAP_MEDIA_BUSY,
213     	LAP_PRIMARY_CONFLICT,
214     } LAP_REASON;
215     
216     /*  
217      *  IrLMP disconnect reasons. The order is very important, since they 
218      *  correspond to disconnect reasons sent in IrLMP disconnect frames, so
219      *  please do not touch :-)
220      */
221     typedef enum {
222     	LM_USER_REQUEST = 1,  /* User request */
223     	LM_LAP_DISCONNECT,    /* Unexpected IrLAP disconnect */
224     	LM_CONNECT_FAILURE,   /* Failed to establish IrLAP connection */
225     	LM_LAP_RESET,         /* IrLAP reset */
226     	LM_INIT_DISCONNECT,   /* Link Management initiated disconnect */
227     	LM_LSAP_NOTCONN,      /* Data delivered on unconnected LSAP */
228     	LM_NON_RESP_CLIENT,   /* Non responsive LM-MUX client */
229     	LM_NO_AVAIL_CLIENT,   /* No available LM-MUX client */
230     	LM_CONN_HALF_OPEN,    /* Connection is half open */
231     	LM_BAD_SOURCE_ADDR,   /* Illegal source address (i.e 0x00) */
232     } LM_REASON;
233     #define LM_UNKNOWN 0xff       /* Unspecified disconnect reason */
234     
235     /*
236      *  Notify structure used between transport and link management layers
237      */
238     typedef struct {
239     	int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
240     	int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
241     	void (*connect_confirm)(void *instance, void *sap, 
242     				struct qos_info *qos, __u32 max_sdu_size,
243     				__u8 max_header_size, struct sk_buff *skb);
244     	void (*connect_indication)(void *instance, void *sap, 
245     				   struct qos_info *qos, __u32 max_sdu_size, 
246     				   __u8 max_header_size, struct sk_buff *skb);
247     	void (*disconnect_indication)(void *instance, void *sap, 
248     				      LM_REASON reason, struct sk_buff *);
249     	void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
250     	void (*status_indication)(void *instance,
251     				  LINK_STATUS link, LOCK_STATUS lock);
252     	void *instance; /* Layer instance pointer */
253     	char name[16];  /* Name of layer */
254     } notify_t;
255     
256     #define NOTIFY_MAX_NAME 16
257     
258     #endif /* NET_IRDA_H */
259