40 #if !defined(_SPANDSP_HDLC_H_) 41 #define _SPANDSP_HDLC_H_ 46 #define HDLC_MAXFRAME_LEN 400 48 typedef void (*hdlc_frame_handler_t)(
void *user_data,
const uint8_t *pkt,
int len,
int ok);
49 typedef void (*hdlc_underflow_handler_t)(
void *user_data);
79 #if defined(__cplusplus) 98 bool report_bad_frames,
99 int framing_ok_threshold,
100 hdlc_frame_handler_t handler,
192 hdlc_underflow_handler_t handler,
269 #if defined(__cplusplus) void hdlc_rx_set_max_frame_len(hdlc_rx_state_t *s, size_t max_len)
Set the maximum frame length for an HDLC receiver context.
Definition: hdlc.c:346
int inter_frame_flags
The minimum flag octets to insert between frames.
Definition: private/hdlc.h:100
int hdlc_tx_free(hdlc_tx_state_t *s)
Free an HDLC transmitter context.
Definition: hdlc.c:746
void hdlc_tx_set_max_frame_len(hdlc_tx_state_t *s, size_t max_len)
Set the maximum frame length for an HDLC transmitter context.
Definition: hdlc.c:676
int hdlc_tx_get_bit(hdlc_tx_state_t *s)
Get the next bit for transmission.
Definition: hdlc.c:641
void hdlc_rx_put_bit(hdlc_rx_state_t *s, int new_bit)
Put a single bit of data to an HDLC receiver.
Definition: hdlc.c:303
void * user_data
An opaque parameter passed to the callback routine.
Definition: private/hdlc.h:98
void hdlc_rx_put(hdlc_rx_state_t *s, const uint8_t buf[], int len)
Put a series of bytes of data to an HDLC receiver.
Definition: hdlc.c:336
int hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t len)
Transmit a frame.
Definition: hdlc.c:437
int hdlc_tx_get(hdlc_tx_state_t *s, uint8_t buf[], size_t max_len)
Get the next sequence of bytes for transmission.
Definition: hdlc.c:659
Definition: private/hdlc.h:91
void hdlc_rx_set_octet_counting_report_interval(hdlc_rx_state_t *s, int interval)
Set the octet counting report interval.
Definition: hdlc.c:353
int hdlc_rx_restart(hdlc_rx_state_t *s)
Re-initialise an HDLC receiver context.
Definition: hdlc.c:359
void(* span_modem_status_func_t)(void *user_data, int status)
Definition: async.h:131
unsigned long int aborts
The number of HDLC aborts received.
Definition: hdlc.h:70
unsigned long int crc_errors
The number of frames with CRC errors received.
Definition: hdlc.h:66
int hdlc_rx_free(hdlc_rx_state_t *s)
Free an HDLC receiver context.
Definition: hdlc.c:418
size_t len
The length of the message in the buffer.
Definition: private/hdlc.h:122
void hdlc_rx_set_frame_handler(hdlc_rx_state_t *s, hdlc_frame_handler_t handler, void *user_data)
Change the put_bit function associated with an HDLC receiver context.
Definition: hdlc.c:398
int hdlc_tx_flags(hdlc_tx_state_t *s, int len)
Transmit a specified quantity of flag octets, typically as a preamble.
Definition: hdlc.c:479
int hdlc_rx_get_stats(hdlc_rx_state_t *s, hdlc_rx_stats_t *t)
Get the current receive statistics.
Definition: hdlc.c:425
void hdlc_rx_set_status_handler(hdlc_rx_state_t *s, span_modem_status_func_t handler, void *user_data)
Change the status report function associated with an HDLC receiver context.
Definition: hdlc.c:405
int hdlc_tx_get_byte(hdlc_tx_state_t *s)
Get the next byte for transmission.
Definition: hdlc.c:521
int hdlc_rx_release(hdlc_rx_state_t *s)
Release an HDLC receiver context.
Definition: hdlc.c:412
int hdlc_tx_restart(hdlc_tx_state_t *s)
Re-initialise an HDLC transmitter context.
Definition: hdlc.c:682
int hdlc_tx_abort(hdlc_tx_state_t *s)
Send an abort.
Definition: hdlc.c:497
int hdlc_tx_corrupt_frame(hdlc_tx_state_t *s)
Corrupt the frame currently being transmitted, by giving it the wrong CRC.
Definition: hdlc.c:507
Definition: private/hdlc.h:32
hdlc_rx_state_t * hdlc_rx_init(hdlc_rx_state_t *s, bool crc32, bool report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data)
Initialise an HDLC receiver context.
Definition: hdlc.c:373
bool progressive
True if frame creation works in progressive mode.
Definition: private/hdlc.h:102
unsigned long int length_errors
The number of too short and too long frames received.
Definition: hdlc.h:68
void hdlc_rx_put_byte(hdlc_rx_state_t *s, int new_byte)
Put a byte of data to an HDLC receiver.
Definition: hdlc.c:316
int hdlc_tx_release(hdlc_tx_state_t *s)
Release an HDLC transmitter context.
Definition: hdlc.c:740
unsigned long int bytes
The number of bytes of good frames received (CRC not included).
Definition: hdlc.h:62
hdlc_tx_state_t * hdlc_tx_init(hdlc_tx_state_t *s, bool crc32, int inter_frame_flags, bool progressive, hdlc_underflow_handler_t handler, void *user_data)
Initialise an HDLC transmitter context.
Definition: hdlc.c:704
unsigned long int good_frames
The number of good frames received.
Definition: hdlc.h:64