ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / isdn / hisax / st5481_hdlc.h
1 /*
2  * Driver for ST5481 USB ISDN modem
3  *
4  * Author       Frode Isaksen
5  * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
6  *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
7  * 
8  * This software may be used and distributed according to the terms
9  * of the GNU General Public License, incorporated herein by reference.
10  *
11  */
12
13 #ifndef __ST5481_HDLC_H__
14 #define __ST5481_HDLC_H__
15
16 struct hdlc_vars {
17         int bit_shift; 
18         int hdlc_bits1;
19         int data_bits;
20         int ffbit_shift; // encoding only
21         int state;
22         int dstpos;
23
24         int data_received:1; // set if transferring data
25         int dchannel:1; // set if D channel (send idle instead of flags)
26         int do_adapt56:1; // set if 56K adaptation
27         int do_closing:1; // set if in closing phase (need to send CRC + flag
28
29         unsigned short crc;
30
31         unsigned char cbin; 
32         unsigned char shift_reg;
33         unsigned char ffvalue;
34         
35 };
36
37
38 /*
39   The return value from hdlc_decode is
40   the frame length, 0 if no complete frame was decoded,
41   or a negative error number
42 */
43
44 #define HDLC_FRAMING_ERROR     1
45 #define HDLC_CRC_ERROR         2
46 #define HDLC_LENGTH_ERROR      3
47
48 void 
49 hdlc_rcv_init(struct hdlc_vars *hdlc, int do_adapt56);
50
51 int
52 hdlc_decode(struct hdlc_vars *hdlc, const unsigned char *src, int slen,int *count, 
53             unsigned char *dst, int dsize);
54
55 void 
56 hdlc_out_init(struct hdlc_vars *hdlc,int is_d_channel,int do_adapt56);
57
58 int 
59 hdlc_encode(struct hdlc_vars *hdlc,const unsigned char *src,unsigned short slen,int *count,
60             unsigned char *dst,int dsize);
61
62 #endif