* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / include / net / irda / irlap.h
blobf21365188ba0a1efb46a64bf1a0d3ae0dbb6fb51
1 /*********************************************************************
2 *
3 * Filename: irlap.h
4 * Version: 0.8
5 * Description: An IrDA LAP driver for Linux
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Mon Aug 4 20:40:53 1997
9 * Modified at: Mon Sep 20 10:14:47 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
13 * All Rights Reserved.
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.
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.
24 ********************************************************************/
26 #ifndef IRLAP_H
27 #define IRLAP_H
29 #include <linux/config.h>
30 #include <linux/types.h>
31 #include <linux/skbuff.h>
32 #include <linux/netdevice.h>
33 #include <linux/ppp_defs.h>
34 #include <linux/ppp-comp.h>
35 #include <linux/timer.h>
37 #include <net/irda/irlap_event.h>
39 #define LAP_RELIABLE 1
40 #define LAP_UNRELIABLE 0
42 #define LAP_ADDR_HEADER 1 /* IrLAP Address Header */
43 #define LAP_CTRL_HEADER 1 /* IrLAP Control Header */
44 #define LAP_COMP_HEADER 1 /* IrLAP Compression Header */
46 #ifdef CONFIG_IRDA_COMPRESSION
47 # define LAP_MAX_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER + LAP_COMP_HEADER)
48 # define IRDA_COMPRESSED 1
49 # define IRDA_NORMAL 0
50 #else
51 #define LAP_MAX_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER)
52 #endif
54 #define BROADCAST 0xffffffff /* Broadcast device address */
55 #define CBROADCAST 0xfe /* Connection broadcast address */
56 #define XID_FORMAT 0x01 /* Discovery XID format */
58 #define LAP_WINDOW_SIZE 8
59 #define LAP_MAX_QUEUE 10
61 #define NR_EXPECTED 1
62 #define NR_UNEXPECTED 0
63 #define NR_INVALID -1
65 #define NS_EXPECTED 1
66 #define NS_UNEXPECTED 0
67 #define NS_INVALID -1
69 #ifdef CONFIG_IRDA_COMPRESSION
70 /*
71 * Just some shortcuts (may give you strange compiler errors if you change
72 * them :-)
74 #define irda_compress (*self->compessor.cp->compress)
75 #define irda_comp_free (*self->compressor.cp->comp_free)
76 #define irda_decompress (*self->decompressor.cp->decompress)
77 #define irda_decomp_free (*self->decompressor.cp->decomp_free)
78 #define irda_incomp (*self->decompressor.cp->incomp)
80 struct irda_compressor {
81 QUEUE queue;
83 struct compressor *cp;
84 void *state; /* Not used by IrDA */
86 #endif
88 /* Main structure of IrLAP */
89 struct irlap_cb {
90 QUEUE q; /* Must be first */
91 magic_t magic;
93 struct net_device *netdev;
95 /* Connection state */
96 volatile IRLAP_STATE state; /* Current state */
98 /* Timers used by IrLAP */
99 struct timer_list query_timer;
100 struct timer_list slot_timer;
101 struct timer_list discovery_timer;
102 struct timer_list final_timer;
103 struct timer_list poll_timer;
104 struct timer_list wd_timer;
105 struct timer_list backoff_timer;
107 /* Timeouts which will be different with different turn time */
108 int slot_timeout;
109 int poll_timeout;
110 int final_timeout;
111 int wd_timeout;
113 struct sk_buff_head tx_list; /* Frames to be transmitted */
115 __u8 caddr; /* Connection address */
116 __u32 saddr; /* Source device address */
117 __u32 daddr; /* Destination device address */
119 int retry_count; /* Times tried to establish connection */
120 int add_wait; /* True if we are waiting for frame */
122 __u8 connect_pending;
123 __u8 disconnect_pending;
125 /* To send a faster RR if tx queue empty */
126 #ifdef CONFIG_IRDA_FAST_RR
127 int fast_RR_timeout;
128 int fast_RR;
129 #endif
131 int N1; /* N1 * F-timer = Negitiated link disconnect warning threshold */
132 int N2; /* N2 * F-timer = Negitiated link disconnect time */
133 int N3; /* Connection retry count */
135 int local_busy;
136 int remote_busy;
137 int xmitflag;
139 __u8 vs; /* Next frame to be sent */
140 __u8 vr; /* Next frame to be received */
141 __u8 va; /* Last frame acked */
142 int window; /* Nr of I-frames allowed to send */
143 int window_size; /* Current negotiated window size */
144 __u32 window_bytes; /* Number of bytes allowed to send */
145 __u32 bytes_left; /* Number of bytes allowed to transmit */
147 struct sk_buff_head wx_list;
149 __u8 ack_required;
151 /* XID parameters */
152 __u8 S; /* Number of slots */
153 __u8 slot; /* Random chosen slot */
154 __u8 s; /* Current slot */
155 int frame_sent; /* Have we sent reply? */
157 hashbin_t *discovery_log;
158 discovery_t *discovery_cmd;
160 struct qos_info qos_tx; /* QoS requested by peer */
161 struct qos_info qos_rx; /* QoS requested by self */
163 notify_t notify; /* Callbacks to IrLMP */
165 int mtt_required; /* Minumum turnaround time required */
166 int xbofs_delay; /* Nr of XBOF's used to MTT */
167 int bofs_count; /* Negotiated extra BOFs */
169 struct irda_statistics stats;
171 #ifdef CONFIG_IRDA_COMPRESSION
172 struct irda_compressor compressor;
173 struct irda_compressor decompressor;
174 #endif
177 extern hashbin_t *irlap;
180 * Function prototypes
182 int irlap_init(void);
183 void irlap_cleanup(void);
185 struct irlap_cb *irlap_open(struct net_device *dev);
186 void irlap_close(struct irlap_cb *self);
188 void irlap_connect_request(struct irlap_cb *self, __u32 daddr,
189 struct qos_info *qos, int sniff);
190 void irlap_connect_response(struct irlap_cb *self, struct sk_buff *skb);
191 void irlap_connect_indication(struct irlap_cb *self, struct sk_buff *skb);
192 void irlap_connect_confirm(struct irlap_cb *, struct sk_buff *skb);
194 inline void irlap_data_indication(struct irlap_cb *, struct sk_buff *);
195 inline void irlap_unit_data_indication(struct irlap_cb *, struct sk_buff *);
196 inline void irlap_data_request(struct irlap_cb *, struct sk_buff *,
197 int reliable);
199 void irlap_disconnect_request(struct irlap_cb *);
200 void irlap_disconnect_indication(struct irlap_cb *, LAP_REASON reason);
202 void irlap_status_indication(int quality_of_link);
204 void irlap_test_request(__u8 *info, int len);
206 void irlap_discovery_request(struct irlap_cb *, discovery_t *discovery);
207 void irlap_discovery_confirm(struct irlap_cb *, hashbin_t *discovery_log);
208 void irlap_discovery_indication(struct irlap_cb *, discovery_t *discovery);
210 void irlap_reset_indication(struct irlap_cb *self);
211 void irlap_reset_confirm(void);
213 void irlap_update_nr_received(struct irlap_cb *, int nr);
214 int irlap_validate_nr_received(struct irlap_cb *, int nr);
215 int irlap_validate_ns_received(struct irlap_cb *, int ns);
217 int irlap_generate_rand_time_slot(int S, int s);
218 void irlap_initiate_connection_state(struct irlap_cb *);
219 void irlap_flush_all_queues(struct irlap_cb *);
220 void irlap_change_speed(struct irlap_cb *self, __u32 speed);
221 void irlap_wait_min_turn_around(struct irlap_cb *, struct qos_info *);
223 void irlap_init_qos_capabilities(struct irlap_cb *, struct qos_info *);
224 void irlap_apply_default_connection_parameters(struct irlap_cb *self);
225 void irlap_apply_connection_parameters(struct irlap_cb *, struct qos_info *);
226 void irlap_set_local_busy(struct irlap_cb *self, int status);
228 extern inline __u8 irlap_get_header_size(struct irlap_cb *self)
230 return 2;
233 extern inline int irlap_get_tx_queue_len(struct irlap_cb *self)
235 return skb_queue_len(&self->tx_list);
238 #endif