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 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com> 14 * 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. 19 * 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. 23 * 24 ********************************************************************/ 25 26 #ifndef NET_IRDA_H 27 #define NET_IRDA_H 28 29 #include <linux/config.h> 30 #include <linux/skbuff.h> 31 #include <linux/kernel.h> 32 #include <linux/if.h> 33 #include <linux/irda.h> 34 35 typedef __u32 magic_t; 36 37 #include <net/irda/qos.h> 38 #include <net/irda/irqueue.h> 39 40 #ifndef TRUE 41 #define TRUE 1 42 #endif 43 44 #ifndef FALSE 45 #define FALSE 0 46 #endif 47 48 /* Hack to do small backoff when setting media busy in IrLAP */ 49 #ifndef SMALL 50 #define SMALL 5 51 #endif 52 53 #ifndef IRDA_MIN /* Lets not mix this MIN with other header files */ 54 #define IRDA_MIN(a, b) (((a) < (b)) ? (a) : (b)) 55 #endif 56 57 #ifndef ALIGN 58 # define ALIGN __attribute__((aligned)) 59 #endif 60 #ifndef PACK 61 # define PACK __attribute__((packed)) 62 #endif 63 64 65 #ifdef CONFIG_IRDA_DEBUG 66 67 extern __u32 irda_debug; 68 69 /* use 0 for production, 1 for verification, >2 for debug */ 70 #define IRDA_DEBUG_LEVEL 0 71 72 #define IRDA_DEBUG(n, args...) (irda_debug >= (n)) ? (printk(KERN_DEBUG args)) : 0 73 #define ASSERT(expr, func) \ 74 if(!(expr)) { \ 75 printk( "Assertion failed! %s:%s:%d %s\n", \ 76 __FILE__,__FUNCTION__,__LINE__,(#expr)); \ 77 func } 78 #else 79 #define IRDA_DEBUG(n, args...) 80 #define ASSERT(expr, func) \ 81 if(!(expr)) do { \ 82 func } while (0) 83 #endif /* CONFIG_IRDA_DEBUG */ 84 85 #define WARNING(args...) printk(KERN_WARNING args) 86 #define MESSAGE(args...) printk(KERN_INFO args) 87 #define ERROR(args...) printk(KERN_ERR args) 88 89 #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000) 90 91 /* 92 * Magic numbers used by Linux-IrDA. Random numbers which must be unique to 93 * give the best protection 94 */ 95 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 111 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 118 119 typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW; 120 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> */ 127 128 /* IrDA Socket */ 129 struct irda_sock { 130 __u32 saddr; /* my local address */ 131 __u32 daddr; /* peer address */ 132 133 struct lsap_cb *lsap; /* LSAP used by Ultra */ 134 __u8 pid; /* Protocol IP (PID) used by Ultra */ 135 136 struct tsap_cb *tsap; /* TSAP used by this connection */ 137 __u8 dtsap_sel; /* remote TSAP address */ 138 __u8 stsap_sel; /* local TSAP address */ 139 140 __u32 max_sdu_size_rx; 141 __u32 max_sdu_size_tx; 142 __u32 max_data_size; 143 __u8 max_header_size; 144 struct qos_info qos_tx; 145 146 __u16 mask; /* Hint bits mask */ 147 __u16 hints; /* Hint bits */ 148 149 __u32 ckey; /* IrLMP client handle */ 150 __u32 skey; /* IrLMP service handle */ 151 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 */ 155 156 hashbin_t *cachelog; /* Result of discovery query */ 157 struct discovery_t *cachediscovery; /* Result of selective discovery query */ 158 159 int nslots; /* Number of slots to use for discovery */ 160 161 int errno; /* status of the IAS query */ 162 163 struct sock *sk; 164 wait_queue_head_t query_wait; /* Wait for the answer to a query */ 165 struct timer_list watchdog; /* Timeout for discovery */ 166 167 LOCAL_FLOW tx_flow; 168 LOCAL_FLOW rx_flow; 169 }; 170 171 /* 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]. 176 */ 177 typedef union { 178 __u16 word; 179 __u8 byte[2]; 180 } __u16_host_order; 181 182 /* 183 * Per-packet information we need to hide inside sk_buff 184 * (must not exceed 48 bytes, check with struct sk_buff) 185 */ 186 struct irda_skb_cb { 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 */ 196 }; 197 198 /* Misc status information */ 199 typedef enum { 200 STATUS_OK, 201 STATUS_ABORTED, 202 STATUS_NO_ACTIVITY, 203 STATUS_NOISY, 204 STATUS_REMOTE, 205 } LINK_STATUS; 206 207 typedef enum { 208 LOCK_NO_CHANGE, 209 LOCK_LOCKED, 210 LOCK_UNLOCKED, 211 } LOCK_STATUS; 212 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 */ 218 LAP_MEDIA_BUSY, 219 LAP_PRIMARY_CONFLICT, 220 } LAP_REASON; 221 222 /* 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 :-) 226 */ 227 typedef enum { 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) */ 238 } LM_REASON; 239 #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */ 240 241 /* 242 * Notify structure used between transport and link management layers 243 */ 244 typedef struct { 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 */ 260 } notify_t; 261 262 #define NOTIFY_MAX_NAME 16 263 264 #endif /* NET_IRDA_H */ 265