Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

net/irda/irda.h

Go to the documentation of this file.
00001 /*********************************************************************
00002  *                
00003  * Filename:      irda.h
00004  * Version:       1.0
00005  * Description:   IrDA common include file for kernel internal use
00006  * Status:        Stable
00007  * Author:        Dag Brattli <dagb@cs.uit.no>
00008  * Created at:    Tue Dec  9 21:13:12 1997
00009  * Modified at:   Sat Dec 25 18:58:49 1999
00010  * Modified by:   Dag Brattli <dagb@cs.uit.no>
00011  * 
00012  *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
00013  *      
00014  *     This program is free software; you can redistribute it and/or 
00015  *     modify it under the terms of the GNU General Public License as 
00016  *     published by the Free Software Foundation; either version 2 of 
00017  *     the License, or (at your option) any later version.
00018  *  
00019  *     Neither Dag Brattli nor University of Tromsų admit liability nor
00020  *     provide warranty for any of this software. This material is 
00021  *     provided "AS-IS" and at no charge.
00022  *     
00023  ********************************************************************/
00024 
00025 #ifndef NET_IRDA_H
00026 #define NET_IRDA_H
00027 
00028 #include <linux/config.h>
00029 #include <linux/skbuff.h>
00030 #include <linux/kernel.h>
00031 #include <linux/if.h>
00032 #include <linux/irda.h>
00033 
00034 typedef __u32 magic_t;
00035 
00036 #include <net/irda/qos.h>
00037 #include <net/irda/irqueue.h>
00038 
00039 #ifndef TRUE
00040 #define TRUE 1
00041 #endif
00042 
00043 #ifndef FALSE 
00044 #define FALSE 0
00045 #endif
00046 
00047 #ifndef IRDA_MIN /* Lets not mix this MIN with other header files */
00048 #define IRDA_MIN(a, b) (((a) < (b)) ? (a) : (b))
00049 #endif
00050 
00051 #ifndef ALIGN
00052 #  define ALIGN __attribute__((aligned))
00053 #endif
00054 #ifndef PACK
00055 #  define PACK __attribute__((packed))
00056 #endif
00057 
00058 
00059 #ifdef CONFIG_IRDA_DEBUG
00060 
00061 extern __u32 irda_debug;
00062 
00063 /* use 0 for production, 1 for verification, >2 for debug */
00064 #define IRDA_DEBUG_LEVEL 0
00065 
00066 #define IRDA_DEBUG(n, args...) (irda_debug >= (n)) ? (printk(KERN_DEBUG args)) : 0
00067 #define ASSERT(expr, func) \
00068 if(!(expr)) { \
00069         printk( "Assertion failed! %s,%s,%s,line=%d\n",\
00070         #expr,__FILE__,__FUNCTION__,__LINE__); \
00071         ##func}
00072 #else
00073 #define IRDA_DEBUG(n, args...)
00074 #define ASSERT(expr, func)
00075 #endif /* CONFIG_IRDA_DEBUG */
00076 
00077 #define WARNING(args...) printk(KERN_WARNING args)
00078 #define MESSAGE(args...) printk(KERN_INFO args)
00079 #define ERROR(args...)   printk(KERN_ERR args)
00080 
00081 #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
00082 
00083 /*
00084  *  Magic numbers used by Linux-IrDA. Random numbers which must be unique to 
00085  *  give the best protection
00086  */
00087 
00088 #define IRTTY_MAGIC        0x2357
00089 #define LAP_MAGIC          0x1357
00090 #define LMP_MAGIC          0x4321
00091 #define LMP_LSAP_MAGIC     0x69333
00092 #define LMP_LAP_MAGIC      0x3432
00093 #define IRDA_DEVICE_MAGIC  0x63454
00094 #define IAS_MAGIC          0x007
00095 #define TTP_MAGIC          0x241169
00096 #define TTP_TSAP_MAGIC     0x4345
00097 #define IROBEX_MAGIC       0x341324
00098 #define HB_MAGIC           0x64534
00099 #define IRLAN_MAGIC        0x754
00100 #define IAS_OBJECT_MAGIC   0x34234
00101 #define IAS_ATTRIB_MAGIC   0x45232
00102 #define IRDA_TASK_MAGIC    0x38423
00103 
00104 #define IAS_DEVICE_ID 0x0000 /* Defined by IrDA, IrLMP section 4.1 (page 68) */
00105 #define IAS_PNP_ID    0xd342
00106 #define IAS_OBEX_ID   0x34323
00107 #define IAS_IRLAN_ID  0x34234
00108 #define IAS_IRCOMM_ID 0x2343
00109 #define IAS_IRLPT_ID  0x9876
00110 
00111 typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW;
00112 
00113 /* IrDA Socket */
00114 struct tsap_cb;
00115 struct irda_sock {
00116         __u32 saddr;          /* my local address */
00117         __u32 daddr;          /* peer address */
00118 
00119         struct lsap_cb *lsap; /* LSAP used by Ultra */
00120         __u8  pid;            /* Protocol IP (PID) used by Ultra */
00121 
00122         struct tsap_cb *tsap; /* TSAP used by this connection */
00123         __u8 dtsap_sel;       /* remote TSAP address */
00124         __u8 stsap_sel;       /* local TSAP address */
00125         
00126         __u32 max_sdu_size_rx;
00127         __u32 max_sdu_size_tx;
00128         __u32 max_data_size;
00129         __u8  max_header_size;
00130         struct qos_info qos_tx;
00131 
00132         __u16 mask;           /* Hint bits mask */
00133         __u16 hints;          /* Hint bits */
00134 
00135         __u32 ckey;           /* IrLMP client handle */
00136         __u32 skey;           /* IrLMP service handle */
00137 
00138         struct ias_object *ias_obj;   /* Our service name + lsap in IAS */
00139         struct iriap_cb *iriap;       /* Used to query remote IAS */
00140         struct ias_value *ias_result; /* Used by getsockopt(IRLMP_IAS_QUERY) */
00141 
00142         int nslots;           /* Number of slots to use for discovery */
00143 
00144         int errno;            /* status of the IAS query */
00145 
00146         struct sock *sk;
00147         struct wait_queue *ias_wait;       /* Wait for LM-IAS answer */
00148 
00149         LOCAL_FLOW tx_flow;
00150         LOCAL_FLOW rx_flow;
00151 };
00152 
00153 /*
00154  *  This type is used by the protocols that transmit 16 bits words in 
00155  *  little endian format. A little endian machine stores MSB of word in
00156  *  byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] 
00157  *  and LSB in byte[1].
00158  */
00159 typedef union {
00160         __u16 word;
00161         __u8  byte[2];
00162 } __u16_host_order;
00163 
00164 /* 
00165  * Per-packet information we need to hide inside sk_buff 
00166  * (must not exceed 48 bytes, check with struct sk_buff) 
00167  */
00168 struct irda_skb_cb {
00169         magic_t magic;     /* Be sure that we can trust the information */
00170         __u32   speed;     /* The Speed this frame should be sent with */
00171         __u16     mtt;     /* Minimum turn around time */
00172         int     xbofs;     /* Number of xbofs required, used by SIR mode */
00173         __u8     line;     /* Used by IrCOMM in IrLPT mode */
00174         void (*destructor)(struct sk_buff *skb); /* Used for flow control */
00175 };
00176 
00177 /* Misc status information */
00178 typedef enum {
00179         STATUS_OK,
00180         STATUS_ABORTED,
00181         STATUS_NO_ACTIVITY,
00182         STATUS_NOISY,
00183         STATUS_REMOTE,
00184 } LINK_STATUS;
00185 
00186 typedef enum {
00187         LOCK_NO_CHANGE,
00188         LOCK_LOCKED,
00189         LOCK_UNLOCKED,
00190 } LOCK_STATUS;
00191 
00192 typedef enum { /* FIXME check the two first reason codes */
00193         LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */
00194         LAP_NO_RESPONSE,       /* To many retransmits without response */
00195         LAP_RESET_INDICATION,  /* To many retransmits, or invalid nr/ns */
00196         LAP_FOUND_NONE,        /* No devices were discovered */
00197         LAP_MEDIA_BUSY,
00198         LAP_PRIMARY_CONFLICT,
00199 } LAP_REASON;
00200 
00201 /*  
00202  *  IrLMP disconnect reasons. The order is very important, since they 
00203  *  correspond to disconnect reasons sent in IrLMP disconnect frames, so
00204  *  please do not touch :-)
00205  */
00206 typedef enum {
00207         LM_USER_REQUEST = 1,  /* User request */
00208         LM_LAP_DISCONNECT,    /* Unexpected IrLAP disconnect */
00209         LM_CONNECT_FAILURE,   /* Failed to establish IrLAP connection */
00210         LM_LAP_RESET,         /* IrLAP reset */
00211         LM_INIT_DISCONNECT,   /* Link Management initiated disconnect */
00212         LM_LSAP_NOTCONN,      /* Data delivered on unconnected LSAP */
00213         LM_NON_RESP_CLIENT,   /* Non responsive LM-MUX client */
00214         LM_NO_AVAIL_CLIENT,   /* No available LM-MUX client */
00215         LM_CONN_HALF_OPEN,    /* Connection is half open */
00216         LM_BAD_SOURCE_ADDR,   /* Illegal source address (i.e 0x00) */
00217 } LM_REASON;
00218 #define LM_UNKNOWN 0xff       /* Unspecified disconnect reason */
00219 
00220 /*
00221  *  Notify structure used between transport and link management layers
00222  */
00223 typedef struct {
00224         int (*data_indication)(void *priv, void *sap, struct sk_buff *skb);
00225         int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb);
00226         void (*connect_confirm)(void *instance, void *sap, 
00227                                 struct qos_info *qos, __u32 max_sdu_size,
00228                                 __u8 max_header_size, struct sk_buff *skb);
00229         void (*connect_indication)(void *instance, void *sap, 
00230                                    struct qos_info *qos, __u32 max_sdu_size, 
00231                                    __u8 max_header_size, struct sk_buff *skb);
00232         void (*disconnect_indication)(void *instance, void *sap, 
00233                                       LM_REASON reason, struct sk_buff *);
00234         void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow);
00235         void *instance; /* Layer instance pointer */
00236         char name[16];  /* Name of layer */
00237 } notify_t;
00238 
00239 #define NOTIFY_MAX_NAME 16
00240 
00241 #endif /* NET_IRDA_H */