00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef IRLAP_H
00027 #define IRLAP_H
00028
00029 #include <linux/config.h>
00030 #include <linux/types.h>
00031 #include <linux/skbuff.h>
00032 #include <linux/netdevice.h>
00033 #include <linux/ppp_defs.h>
00034 #include <linux/ppp-comp.h>
00035 #include <linux/timer.h>
00036
00037 #include <net/irda/irlap_event.h>
00038
00039 #define CONFIG_IRDA_DYNAMIC_WINDOW 1
00040
00041 #define LAP_RELIABLE 1
00042 #define LAP_UNRELIABLE 0
00043
00044 #define LAP_ADDR_HEADER 1
00045 #define LAP_CTRL_HEADER 1
00046 #define LAP_COMP_HEADER 1
00047
00048 #ifdef CONFIG_IRDA_COMPRESSION
00049 # define LAP_MAX_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER + LAP_COMP_HEADER)
00050 # define IRDA_COMPRESSED 1
00051 # define IRDA_NORMAL 0
00052 #else
00053 #define LAP_MAX_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER)
00054 #endif
00055
00056 #define BROADCAST 0xffffffff
00057 #define CBROADCAST 0xfe
00058 #define XID_FORMAT 0x01
00059
00060 #define LAP_WINDOW_SIZE 8
00061 #define LAP_MAX_QUEUE 10
00062
00063 #define NR_EXPECTED 1
00064 #define NR_UNEXPECTED 0
00065 #define NR_INVALID -1
00066
00067 #define NS_EXPECTED 1
00068 #define NS_UNEXPECTED 0
00069 #define NS_INVALID -1
00070
00071 #ifdef CONFIG_IRDA_COMPRESSION
00072
00073
00074
00075
00076
00077 #define irda_compress (*self->compessor.cp->compress)
00078 #define irda_comp_free (*self->compressor.cp->comp_free)
00079 #define irda_decompress (*self->decompressor.cp->decompress)
00080 #define irda_decomp_free (*self->decompressor.cp->decomp_free)
00081 #define irda_incomp (*self->decompressor.cp->incomp)
00082
00083 struct irda_compressor {
00084 queue_t q;
00085
00086 struct compressor *cp;
00087 void *state;
00088 };
00089 #endif
00090
00091
00092 struct irlap_cb {
00093 queue_t q;
00094 magic_t magic;
00095
00096 struct device *netdev;
00097
00098
00099 volatile IRLAP_STATE state;
00100
00101
00102 struct timer_list query_timer;
00103 struct timer_list slot_timer;
00104 struct timer_list discovery_timer;
00105 struct timer_list final_timer;
00106 struct timer_list poll_timer;
00107 struct timer_list wd_timer;
00108 struct timer_list backoff_timer;
00109
00110
00111 struct timer_list media_busy_timer;
00112 int media_busy;
00113
00114
00115 int slot_timeout;
00116 int poll_timeout;
00117 int final_timeout;
00118 int wd_timeout;
00119
00120 struct sk_buff_head txq;
00121 struct sk_buff_head txq_ultra;
00122
00123 __u8 caddr;
00124 __u32 saddr;
00125 __u32 daddr;
00126
00127 int retry_count;
00128 int add_wait;
00129
00130 __u8 connect_pending;
00131 __u8 disconnect_pending;
00132
00133
00134 #ifdef CONFIG_IRDA_FAST_RR
00135 int fast_RR_timeout;
00136 int fast_RR;
00137 #endif
00138
00139 int N1;
00140 int N2;
00141 int N3;
00142
00143 int local_busy;
00144 int remote_busy;
00145 int xmitflag;
00146
00147 __u8 vs;
00148 __u8 vr;
00149 __u8 va;
00150 int window;
00151 int window_size;
00152
00153 #ifdef CONFIG_IRDA_DYNAMIC_WINDOW
00154 __u32 line_capacity;
00155 __u32 bytes_left;
00156 #endif
00157
00158 struct sk_buff_head wx_list;
00159
00160 __u8 ack_required;
00161
00162
00163 __u8 S;
00164 __u8 slot;
00165 __u8 s;
00166 int frame_sent;
00167
00168 hashbin_t *discovery_log;
00169 discovery_t *discovery_cmd;
00170
00171 __u32 speed;
00172
00173 struct qos_info qos_tx;
00174 struct qos_info qos_rx;
00175 struct qos_info *qos_dev;
00176
00177 notify_t notify;
00178
00179 int mtt_required;
00180 int xbofs_delay;
00181 int bofs_count;
00182
00183 #ifdef CONFIG_IRDA_COMPRESSION
00184 struct irda_compressor compressor;
00185 struct irda_compressor decompressor;
00186 #endif
00187 };
00188
00189 extern hashbin_t *irlap;
00190
00191
00192
00193
00194 int irlap_init(void);
00195 void irlap_cleanup(void);
00196
00197 struct irlap_cb *irlap_open(struct device *dev, struct qos_info *qos);
00198 void irlap_close(struct irlap_cb *self);
00199
00200 void irlap_connect_request(struct irlap_cb *self, __u32 daddr,
00201 struct qos_info *qos, int sniff);
00202 void irlap_connect_response(struct irlap_cb *self, struct sk_buff *skb);
00203 void irlap_connect_indication(struct irlap_cb *self, struct sk_buff *skb);
00204 void irlap_connect_confirm(struct irlap_cb *, struct sk_buff *skb);
00205
00206 void irlap_data_indication(struct irlap_cb *, struct sk_buff *, int unreliable);
00207 void irlap_data_request(struct irlap_cb *, struct sk_buff *, int unreliable);
00208
00209 #ifdef CONFIG_IRDA_ULTRA
00210 void irlap_unitdata_request(struct irlap_cb *, struct sk_buff *);
00211 void irlap_unitdata_indication(struct irlap_cb *, struct sk_buff *);
00212 #endif
00213
00214 void irlap_disconnect_request(struct irlap_cb *);
00215 void irlap_disconnect_indication(struct irlap_cb *, LAP_REASON reason);
00216
00217 void irlap_status_indication(int quality_of_link);
00218
00219 void irlap_test_request(__u8 *info, int len);
00220
00221 void irlap_discovery_request(struct irlap_cb *, discovery_t *discovery);
00222 void irlap_discovery_confirm(struct irlap_cb *, hashbin_t *discovery_log);
00223 void irlap_discovery_indication(struct irlap_cb *, discovery_t *discovery);
00224
00225 void irlap_reset_indication(struct irlap_cb *self);
00226 void irlap_reset_confirm(void);
00227
00228 void irlap_update_nr_received(struct irlap_cb *, int nr);
00229 int irlap_validate_nr_received(struct irlap_cb *, int nr);
00230 int irlap_validate_ns_received(struct irlap_cb *, int ns);
00231
00232 int irlap_generate_rand_time_slot(int S, int s);
00233 void irlap_initiate_connection_state(struct irlap_cb *);
00234 void irlap_flush_all_queues(struct irlap_cb *);
00235 void irlap_change_speed(struct irlap_cb *self, __u32 speed, int now);
00236 void irlap_wait_min_turn_around(struct irlap_cb *, struct qos_info *);
00237
00238 void irlap_init_qos_capabilities(struct irlap_cb *, struct qos_info *);
00239 void irlap_apply_default_connection_parameters(struct irlap_cb *self);
00240 void irlap_apply_connection_parameters(struct irlap_cb *self);
00241 void irlap_set_local_busy(struct irlap_cb *self, int status);
00242
00243 #define IRLAP_GET_HEADER_SIZE(self) 2
00244 #define IRLAP_GET_TX_QUEUE_LEN(self) skb_queue_len(&self->txq)
00245
00246 #endif