Go to the source code of this file.
Classes | |
struct | hdlc_rx_state_t |
struct | hdlc_rx_stats_t |
struct | hdlc_tx_state_t |
Defines | |
#define | _SPANDSP_HDLC_H_ |
#define | HDLC_MAXFRAME_LEN 400 |
Typedefs | |
typedef void(* | hdlc_frame_handler_t )(void *user_data, const uint8_t *pkt, int len, int ok) |
typedef void(* | hdlc_underflow_handler_t )(void *user_data) |
Functions | |
hdlc_rx_state_t * | hdlc_rx_init (hdlc_rx_state_t *s, int crc32, int report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data) |
Initialise an HDLC receiver context. | |
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. | |
void | hdlc_rx_set_octet_counting_report_interval (hdlc_rx_state_t *s, int interval) |
Set the octet counting report interval. | |
int | hdlc_rx_get_stats (hdlc_rx_state_t *s, hdlc_rx_stats_t *t) |
Get the current receive statistics. | |
void | hdlc_rx_put_bit (hdlc_rx_state_t *s, int new_bit) |
Put a single bit of data to an HDLC receiver. | |
void | hdlc_rx_put_byte (hdlc_rx_state_t *s, int new_byte) |
Put a byte of data to an HDLC receiver. | |
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. | |
hdlc_tx_state_t * | hdlc_tx_init (hdlc_tx_state_t *s, int crc32, int inter_frame_flags, int progressive, hdlc_underflow_handler_t handler, void *user_data) |
Initialise an HDLC transmitter context. | |
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. | |
int | hdlc_tx_frame (hdlc_tx_state_t *s, const uint8_t *frame, size_t len) |
Transmit a frame. | |
int | hdlc_tx_corrupt_frame (hdlc_tx_state_t *s) |
Corrupt the frame currently being transmitted, by giving it the wrong CRC. | |
int | hdlc_tx_flags (hdlc_tx_state_t *s, int len) |
Transmit a specified quantity of flag octets, typically as a preamble. | |
int | hdlc_tx_abort (hdlc_tx_state_t *s) |
Send an abort. | |
int | hdlc_tx_get_bit (hdlc_tx_state_t *s) |
Get the next bit for transmission. | |
int | hdlc_tx_get_byte (hdlc_tx_state_t *s) |
Get the next byte for transmission. | |
int | hdlc_tx_get (hdlc_tx_state_t *s, uint8_t buf[], size_t max_len) |
Get the next sequence of bytes for transmission. |
#define HDLC_MAXFRAME_LEN 400 |
HDLC_MAXFRAME_LEN is the maximum length of a stuffed HDLC frame, excluding the CRC.
Referenced by hdlc_tx_corrupt_frame(), hdlc_tx_frame(), hdlc_tx_get_byte(), hdlc_tx_init(), and hdlc_tx_set_max_frame_len().
int hdlc_rx_get_stats | ( | hdlc_rx_state_t * | s, | |
hdlc_rx_stats_t * | t | |||
) |
Get the current receive statistics.
s | A pointer to an HDLC receiver context. | |
t | A pointer to the buffer for the statistics. |
References hdlc_rx_stats_t::aborts, hdlc_rx_stats_t::bytes, hdlc_rx_stats_t::crc_errors, hdlc_rx_stats_t::good_frames, hdlc_rx_stats_t::length_errors, hdlc_rx_state_t::rx_aborts, hdlc_rx_state_t::rx_bytes, hdlc_rx_state_t::rx_crc_errors, hdlc_rx_state_t::rx_frames, and hdlc_rx_state_t::rx_length_errors.
hdlc_rx_state_t* hdlc_rx_init | ( | hdlc_rx_state_t * | s, | |
int | crc32, | |||
int | report_bad_frames, | |||
int | framing_ok_threshold, | |||
hdlc_frame_handler_t | handler, | |||
void * | user_data | |||
) |
Initialise an HDLC receiver context.
s | A pointer to an HDLC receiver context. | |
crc32 | TRUE to use ITU CRC32. FALSE to use ITU CRC16. | |
report_bad_frames | TRUE to request the reporting of bad frames. | |
framing_ok_threshold | The number of back-to-back flags needed to start the framing OK condition. This may be used where a series of flag octets is used as a preamble, such as in the T.30 protocol. | |
handler | The function to be called when a good HDLC frame is received. | |
user_data | An opaque parameter for the callback routine. |
References hdlc_rx_state_t::buffer, hdlc_rx_state_t::crc_bytes, hdlc_rx_state_t::frame_handler, hdlc_rx_state_t::framing_ok_threshold, hdlc_rx_state_t::max_frame_len, hdlc_rx_state_t::report_bad_frames, and hdlc_rx_state_t::user_data.
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.
s | A pointer to an HDLC receiver context. | |
buf | The buffer of data. | |
len | The length of the data in the buffer. |
References hdlc_rx_put_byte().
void hdlc_rx_put_bit | ( | hdlc_rx_state_t * | s, | |
int | new_bit | |||
) |
Put a single bit of data to an HDLC receiver.
s | A pointer to an HDLC receiver context. | |
new_bit | The bit. |
References hdlc_rx_state_t::raw_bit_stream.
Referenced by v42_rx_bit().
void hdlc_rx_put_byte | ( | hdlc_rx_state_t * | s, | |
int | new_byte | |||
) |
Put a byte of data to an HDLC receiver.
s | A pointer to an HDLC receiver context. | |
new_byte | The byte of data. |
References hdlc_rx_state_t::raw_bit_stream.
Referenced by hdlc_rx_put().
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.
s | A pointer to an HDLC receiver context. | |
max_len | The maximum permitted length of a frame. |
References hdlc_rx_state_t::buffer, hdlc_rx_state_t::crc_bytes, and hdlc_rx_state_t::max_frame_len.
void hdlc_rx_set_octet_counting_report_interval | ( | hdlc_rx_state_t * | s, | |
int | interval | |||
) |
Set the octet counting report interval.
s | A pointer to an HDLC receiver context. | |
interval | The interval, in octets. |
References hdlc_rx_state_t::octet_count_report_interval.
int hdlc_tx_abort | ( | hdlc_tx_state_t * | s | ) |
Send an abort.
s | A pointer to an HDLC transmitter context. |
References hdlc_tx_state_t::abort_octets, and hdlc_tx_state_t::flag_octets.
int hdlc_tx_corrupt_frame | ( | hdlc_tx_state_t * | s | ) |
Corrupt the frame currently being transmitted, by giving it the wrong CRC.
s | A pointer to an HDLC transmitter context. |
References hdlc_tx_state_t::buffer, hdlc_tx_state_t::crc, HDLC_MAXFRAME_LEN, and hdlc_tx_state_t::len.
int hdlc_tx_flags | ( | hdlc_tx_state_t * | s, | |
int | len | |||
) |
Transmit a specified quantity of flag octets, typically as a preamble.
s | A pointer to an HDLC transmitter context. | |
len | The length of the required period of flags, in flag octets. If len is zero this requests that HDLC transmission be terminated when the buffers have fully drained. |
References hdlc_tx_state_t::flag_octets, hdlc_tx_state_t::pos, hdlc_tx_state_t::report_flag_underflow, and hdlc_tx_state_t::tx_end.
int hdlc_tx_frame | ( | hdlc_tx_state_t * | s, | |
const uint8_t * | frame, | |||
size_t | len | |||
) |
Transmit a frame.
s | A pointer to an HDLC transmitter context. | |
frame | A pointer to the frame to be transmitted. | |
len | The length of the frame to be transmitted. |
References hdlc_tx_state_t::buffer, hdlc_tx_state_t::crc, hdlc_tx_state_t::crc_bytes, crc_itu16_calc(), crc_itu32_calc(), HDLC_MAXFRAME_LEN, hdlc_tx_state_t::len, hdlc_tx_state_t::max_frame_len, hdlc_tx_state_t::pos, hdlc_tx_state_t::progressive, and hdlc_tx_state_t::tx_end.
int hdlc_tx_get | ( | hdlc_tx_state_t * | s, | |
uint8_t | buf[], | |||
size_t | max_len | |||
) |
Get the next sequence of bytes for transmission.
s | A pointer to an HDLC transmitter context. | |
buf | The buffer for the data. | |
max_len | The number of bytes to get. |
References hdlc_tx_get_byte(), and SIG_STATUS_END_OF_DATA.
int hdlc_tx_get_bit | ( | hdlc_tx_state_t * | s | ) |
Get the next bit for transmission.
s | A pointer to an HDLC transmitter context. |
References hdlc_tx_state_t::bits, hdlc_tx_state_t::byte, and hdlc_tx_get_byte().
Referenced by v42_tx_bit().
int hdlc_tx_get_byte | ( | hdlc_tx_state_t * | s | ) |
Get the next byte for transmission.
s | A pointer to an HDLC transmitter context. |
References hdlc_tx_state_t::abort_octets, hdlc_tx_state_t::buffer, hdlc_tx_state_t::crc, hdlc_tx_state_t::crc_bytes, hdlc_tx_state_t::flag_octets, HDLC_MAXFRAME_LEN, hdlc_tx_state_t::idle_octet, hdlc_tx_state_t::inter_frame_flags, hdlc_tx_state_t::len, hdlc_tx_state_t::num_bits, hdlc_tx_state_t::octets_in_progress, hdlc_tx_state_t::pos, hdlc_tx_state_t::report_flag_underflow, SIG_STATUS_END_OF_DATA, hdlc_tx_state_t::tx_end, hdlc_tx_state_t::underflow_handler, and hdlc_tx_state_t::user_data.
Referenced by hdlc_tx_get(), and hdlc_tx_get_bit().
hdlc_tx_state_t* hdlc_tx_init | ( | hdlc_tx_state_t * | s, | |
int | crc32, | |||
int | inter_frame_flags, | |||
int | progressive, | |||
hdlc_underflow_handler_t | handler, | |||
void * | user_data | |||
) |
Initialise an HDLC transmitter context.
s | A pointer to an HDLC transmitter context. | |
crc32 | TRUE to use ITU CRC32. FALSE to use ITU CRC16. | |
inter_frame_flags | The minimum flag octets to insert between frames (usually one). | |
progressive | TRUE if frame creation works in progressive mode. | |
handler | The callback function called when the HDLC transmitter underflows. | |
user_data | An opaque parameter for the callback routine. |
References hdlc_tx_state_t::crc, hdlc_tx_state_t::crc_bytes, HDLC_MAXFRAME_LEN, hdlc_tx_state_t::idle_octet, hdlc_tx_state_t::inter_frame_flags, hdlc_tx_state_t::max_frame_len, hdlc_tx_state_t::progressive, hdlc_tx_state_t::underflow_handler, and hdlc_tx_state_t::user_data.
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.
s | A pointer to an HDLC transmitter context. | |
max_len | The maximum length. |
References HDLC_MAXFRAME_LEN, and hdlc_tx_state_t::max_frame_len.