Commit | Line | Data |
---|---|---|
74ba9207 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
1da177e4 | 2 | /* |
6bd4bcd3 | 3 | * hdlc.h -- General purpose ISDN HDLC decoder. |
1da177e4 LT |
4 | * |
5 | * Implementation of a HDLC decoder/encoder in software. | |
25985edc | 6 | * Necessary because some ISDN devices don't have HDLC |
6bd4bcd3 | 7 | * controllers. |
1da177e4 | 8 | * |
6bd4bcd3 | 9 | * Copyright (C) |
c38fc3bc | 10 | * 2009 Karsten Keil <keil@b1-systems.de> |
6bd4bcd3 KK |
11 | * 2002 Wolfgang Mües <wolfgang@iksw-muees.de> |
12 | * 2001 Frode Isaksen <fisaksen@bewan.com> | |
13 | * 2001 Kai Germaschewski <kai.germaschewski@gmx.de> | |
1da177e4 LT |
14 | */ |
15 | ||
16 | #ifndef __ISDNHDLC_H__ | |
17 | #define __ISDNHDLC_H__ | |
18 | ||
19 | struct isdnhdlc_vars { | |
20 | int bit_shift; | |
21 | int hdlc_bits1; | |
22 | int data_bits; | |
6bd4bcd3 | 23 | int ffbit_shift; /* encoding only */ |
1da177e4 LT |
24 | int state; |
25 | int dstpos; | |
26 | ||
6bd4bcd3 | 27 | u16 crc; |
1da177e4 | 28 | |
6bd4bcd3 KK |
29 | u8 cbin; |
30 | u8 shift_reg; | |
31 | u8 ffvalue; | |
1da177e4 | 32 | |
6bd4bcd3 KK |
33 | /* set if transferring data */ |
34 | u32 data_received:1; | |
35 | /* set if D channel (send idle instead of flags) */ | |
36 | u32 dchannel:1; | |
37 | /* set if 56K adaptation */ | |
38 | u32 do_adapt56:1; | |
39 | /* set if in closing phase (need to send CRC + flag) */ | |
40 | u32 do_closing:1; | |
c38fc3bc KK |
41 | /* set if data is bitreverse */ |
42 | u32 do_bitreverse:1; | |
1da177e4 LT |
43 | }; |
44 | ||
c38fc3bc KK |
45 | /* Feature Flags */ |
46 | #define HDLC_56KBIT 0x01 | |
47 | #define HDLC_DCHANNEL 0x02 | |
48 | #define HDLC_BITREVERSE 0x04 | |
1da177e4 LT |
49 | |
50 | /* | |
51 | The return value from isdnhdlc_decode is | |
52 | the frame length, 0 if no complete frame was decoded, | |
53 | or a negative error number | |
54 | */ | |
55 | #define HDLC_FRAMING_ERROR 1 | |
56 | #define HDLC_CRC_ERROR 2 | |
57 | #define HDLC_LENGTH_ERROR 3 | |
58 | ||
c38fc3bc | 59 | extern void isdnhdlc_rcv_init(struct isdnhdlc_vars *hdlc, u32 features); |
1da177e4 | 60 | |
6bd4bcd3 KK |
61 | extern int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, |
62 | int slen, int *count, u8 *dst, int dsize); | |
1da177e4 | 63 | |
c38fc3bc | 64 | extern void isdnhdlc_out_init(struct isdnhdlc_vars *hdlc, u32 features); |
1da177e4 | 65 | |
6bd4bcd3 KK |
66 | extern int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, |
67 | u16 slen, int *count, u8 *dst, int dsize); | |
1da177e4 LT |
68 | |
69 | #endif /* __ISDNHDLC_H__ */ |