1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * hdlc.h -- General purpose ISDN HDLC decoder.
5 * Implementation of a HDLC decoder/encoder in software.
6 * Necessary because some ISDN devices don't have HDLC
10 * 2009 Karsten Keil <keil@b1-systems.de>
11 * 2002 Wolfgang Mües <wolfgang@iksw-muees.de>
12 * 2001 Frode Isaksen <fisaksen@bewan.com>
13 * 2001 Kai Germaschewski <kai.germaschewski@gmx.de>
16 #ifndef __ISDNHDLC_H__
17 #define __ISDNHDLC_H__
19 struct isdnhdlc_vars
{
23 int ffbit_shift
; /* encoding only */
33 /* set if transferring data */
35 /* set if D channel (send idle instead of flags) */
37 /* set if 56K adaptation */
39 /* set if in closing phase (need to send CRC + flag) */
41 /* set if data is bitreverse */
46 #define HDLC_56KBIT 0x01
47 #define HDLC_DCHANNEL 0x02
48 #define HDLC_BITREVERSE 0x04
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
55 #define HDLC_FRAMING_ERROR 1
56 #define HDLC_CRC_ERROR 2
57 #define HDLC_LENGTH_ERROR 3
59 extern void isdnhdlc_rcv_init(struct isdnhdlc_vars
*hdlc
, u32 features
);
61 extern int isdnhdlc_decode(struct isdnhdlc_vars
*hdlc
, const u8
*src
,
62 int slen
, int *count
, u8
*dst
, int dsize
);
64 extern void isdnhdlc_out_init(struct isdnhdlc_vars
*hdlc
, u32 features
);
66 extern int isdnhdlc_encode(struct isdnhdlc_vars
*hdlc
, const u8
*src
,
67 u16 slen
, int *count
, u8
*dst
, int dsize
);
69 #endif /* __ISDNHDLC_H__ */