libosmocore
UNKNOWN
Osmocom core library
Toggle main menu visibility
Loading...
Searching...
No Matches
isdnhdlc.h
Go to the documentation of this file.
1
/*
2
* isdnhdlc.h -- General purpose ISDN HDLC decoder.
3
*
4
* Implementation of a HDLC decoder/encoder in software.
5
* Necessary because some ISDN devices don't have HDLC
6
* controllers.
7
*
8
* Copyright (C)
9
* 2009 Karsten Keil <keil@b1-systems.de>
10
* 2002 Wolfgang Mües <wolfgang@iksw-muees.de>
11
* 2001 Frode Isaksen <fisaksen@bewan.com>
12
* 2001 Kai Germaschewski <kai.germaschewski@gmx.de>
13
*
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2 of the License, or
17
* (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*/
24
25
#pragma once
26
27
#include <stdint.h>
28
29
struct
osmo_isdnhdlc_vars
{
30
int
bit_shift
;
31
int
hdlc_bits1
;
32
int
data_bits
;
33
int
ffbit_shift
;
/* encoding only */
34
int
state
;
35
int
dstpos
;
36
37
uint16_t
crc
;
38
39
uint8_t
cbin
;
40
uint8_t
shift_reg
;
41
uint8_t
ffvalue
;
42
43
/* set if transferring data */
44
uint32_t
data_received
:1;
45
/* set if D channel (send idle instead of flags) */
46
uint32_t
dchannel
:1;
47
/* set if 56K adaptation */
48
uint32_t
do_adapt56
:1;
49
/* set if in closing phase (need to send CRC + flag) */
50
uint32_t
do_closing
:1;
51
/* set if data is bitreverse */
52
uint32_t
do_bitreverse
:1;
53
};
54
55
/* Feature Flags */
56
#define OSMO_HDLC_F_56KBIT 0x01
57
#define OSMO_HDLC_F_DCHANNEL 0x02
58
#define OSMO_HDLC_F_BITREVERSE 0x04
59
60
/*
61
The return value from isdnhdlc_decode is
62
the frame length, 0 if no complete frame was decoded,
63
or a negative error number
64
*/
65
#define OSMO_HDLC_FRAMING_ERROR 1
66
#define OSMO_HDLC_CRC_ERROR 2
67
#define OSMO_HDLC_LENGTH_ERROR 3
68
69
extern
void
osmo_isdnhdlc_rcv_init
(
struct
osmo_isdnhdlc_vars
*hdlc, uint32_t features);
70
71
extern
int
osmo_isdnhdlc_decode
(
struct
osmo_isdnhdlc_vars
*hdlc,
const
uint8_t *src,
72
int
slen,
int
*count, uint8_t *dst,
int
dsize);
73
74
extern
void
osmo_isdnhdlc_out_init
(
struct
osmo_isdnhdlc_vars
*hdlc, uint32_t features);
75
76
extern
int
osmo_isdnhdlc_encode
(
struct
osmo_isdnhdlc_vars
*hdlc,
const
uint8_t *src,
77
uint16_t slen,
int
*count, uint8_t *dst,
int
dsize);
osmo_isdnhdlc_encode
int osmo_isdnhdlc_encode(struct osmo_isdnhdlc_vars *hdlc, const uint8_t *src, uint16_t slen, int *count, uint8_t *dst, int dsize)
encodes HDLC frames to a transparent bit stream.
Definition
isdnhdlc.c:337
osmo_isdnhdlc_decode
int osmo_isdnhdlc_decode(struct osmo_isdnhdlc_vars *hdlc, const uint8_t *src, int slen, int *count, uint8_t *dst, int dsize)
decodes HDLC frames from a transparent bit stream.
Definition
isdnhdlc.c:116
osmo_isdnhdlc_rcv_init
void osmo_isdnhdlc_rcv_init(struct osmo_isdnhdlc_vars *hdlc, uint32_t features)
Definition
isdnhdlc.c:43
osmo_isdnhdlc_out_init
void osmo_isdnhdlc_out_init(struct osmo_isdnhdlc_vars *hdlc, uint32_t features)
Definition
isdnhdlc.c:53
osmo_isdnhdlc_vars
Definition
isdnhdlc.h:29
osmo_isdnhdlc_vars::do_adapt56
uint32_t do_adapt56
Definition
isdnhdlc.h:48
osmo_isdnhdlc_vars::crc
uint16_t crc
Definition
isdnhdlc.h:37
osmo_isdnhdlc_vars::hdlc_bits1
int hdlc_bits1
Definition
isdnhdlc.h:31
osmo_isdnhdlc_vars::dstpos
int dstpos
Definition
isdnhdlc.h:35
osmo_isdnhdlc_vars::ffbit_shift
int ffbit_shift
Definition
isdnhdlc.h:33
osmo_isdnhdlc_vars::data_received
uint32_t data_received
Definition
isdnhdlc.h:44
osmo_isdnhdlc_vars::do_closing
uint32_t do_closing
Definition
isdnhdlc.h:50
osmo_isdnhdlc_vars::cbin
uint8_t cbin
Definition
isdnhdlc.h:39
osmo_isdnhdlc_vars::ffvalue
uint8_t ffvalue
Definition
isdnhdlc.h:41
osmo_isdnhdlc_vars::shift_reg
uint8_t shift_reg
Definition
isdnhdlc.h:40
osmo_isdnhdlc_vars::bit_shift
int bit_shift
Definition
isdnhdlc.h:30
osmo_isdnhdlc_vars::dchannel
uint32_t dchannel
Definition
isdnhdlc.h:46
osmo_isdnhdlc_vars::do_bitreverse
uint32_t do_bitreverse
Definition
isdnhdlc.h:52
osmo_isdnhdlc_vars::state
int state
Definition
isdnhdlc.h:34
osmo_isdnhdlc_vars::data_bits
int data_bits
Definition
isdnhdlc.h:32
include
osmocom
core
isdnhdlc.h
Generated by
1.17.0