#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include "spandsp/telephony.h"
#include "spandsp/logging.h"
#include "spandsp/async.h"
#include "spandsp/hdlc.h"
#include "spandsp/schedule.h"
#include "spandsp/queue.h"
#include "spandsp/v42.h"
Defines | |
#define | LAPM_FRAMETYPE_MASK 0x03 |
#define | LAPM_FRAMETYPE_I 0x00 |
#define | LAPM_FRAMETYPE_I_ALT 0x02 |
#define | LAPM_FRAMETYPE_S 0x01 |
#define | LAPM_FRAMETYPE_U 0x03 |
#define | T_WAIT_MIN 2000 |
#define | T_WAIT_MAX 10000 |
#define | T_400 750000 |
#define | T_401 1000000 |
#define | T_402 1000000 |
#define | T_403 10000000 |
#define | N_400 3 |
#define | N_401 128 |
#define | LAPM_DLCI_DTE_TO_DTE 0 |
#define | LAPM_DLCI_LAYER2_MANAGEMENT 63 |
Functions | |
void | lapm_reset (lapm_state_t *s) |
void | lapm_restart (lapm_state_t *s) |
const char * | lapm_status_to_str (int status) |
int | lapm_tx (lapm_state_t *s, const void *buf, int len) |
int | lapm_release (lapm_state_t *s) |
int | lapm_loopback (lapm_state_t *s, int enable) |
int | lapm_break (lapm_state_t *s, int enable) |
int | lapm_tx_iframe (lapm_state_t *s, const void *buf, int len, int cr) |
void | lapm_dump (lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx) |
void | lapm_receive (void *user_data, const uint8_t *frame, int len, int ok) |
void | v42_rx_bit (void *user_data, int bit) |
int | v42_tx_bit (void *user_data) |
void | v42_set_status_callback (v42_state_t *s, v42_status_func_t callback, void *user_data) |
void | v42_restart (v42_state_t *s) |
v42_state_t * | v42_init (v42_state_t *s, int caller, int detect, v42_frame_handler_t frame_handler, void *user_data) |
int | v42_release (v42_state_t *s) |
int lapm_break | ( | lapm_state_t * | s, | |
int | enable | |||
) |
Send a break over a LAP.M connection
References lapm_state_t::state.
void lapm_dump | ( | lapm_state_t * | s, | |
const uint8_t * | frame, | |||
int | len, | |||
int | showraw, | |||
int | txrx | |||
) |
Dump LAP.M frames in a raw and/or decoded forms
frame | The frame itself | |
len | The length of the frame, in octets | |
showraw | TRUE if the raw octets should be dumped | |
txrx | TRUE if tx, FALSE if rx. Used to highlight the packet's direction. |
References lapm_state_t::logging, span_log(), and span_log_buf().
Referenced by lapm_receive().
int lapm_loopback | ( | lapm_state_t * | s, | |
int | enable | |||
) |
Enable or disable loopback of a LAP.M connection
References lapm_state_t::state.
void lapm_receive | ( | void * | user_data, | |
const uint8_t * | buf, | |||
int | len, | |||
int | ok | |||
) |
Accept an HDLC packet
References lapm_state_t::busy, lapm_state_t::debug, lapm_state_t::iframe_receive, lapm_state_t::iframe_receive_user_data, lapm_dump(), lapm_state_t::last_frame_peer_acknowledged, lapm_state_t::last_frame_we_acknowledged, lapm_state_t::logging, lapm_state_t::next_expected_frame, lapm_state_t::next_tx_frame, lapm_state_t::peer_is_originator, lapm_state_t::sched, signal_status_to_str(), lapm_state_t::solicit_f_bit, span_log(), lapm_state_t::state, lapm_state_t::t401_timer, lapm_state_t::t403_timer, lapm_state_t::txqueue, lapm_state_t::we_are_originator, and lapm_state_t::window_size_k.
int lapm_release | ( | lapm_state_t * | s | ) |
Initiate an orderly release of a LAP.M connection
References lapm_state_t::state.
int lapm_tx | ( | lapm_state_t * | s, | |
const void * | buf, | |||
int | len | |||
) |
Transmit a LAP.M frame
References queue_write(), and lapm_state_t::tx_queue.
int lapm_tx_iframe | ( | lapm_state_t * | s, | |
const void * | buf, | |||
int | len, | |||
int | cr | |||
) |
Transmit a LAP.M information frame
References lapm_state_t::last_frame_we_acknowledged, lapm_state_t::logging, lapm_state_t::next_expected_frame, lapm_state_t::next_tx_frame, lapm_state_t::peer_is_originator, lapm_state_t::retransmissions, lapm_state_t::sched, span_log(), lapm_state_t::t401_timer, lapm_state_t::t403_timer, lapm_state_t::tx_last, and lapm_state_t::txqueue.
v42_state_t* v42_init | ( | v42_state_t * | s, | |
int | caller, | |||
int | detect, | |||
v42_frame_handler_t | frame_handler, | |||
void * | user_data | |||
) |
Initialise a V.42 context.
s | The V.42 context. | |
caller | TRUE if caller mode, else answerer mode. | |
frame_handler | A callback function to handle received frames of data. | |
user_data | An opaque pointer passed to the frame handler routine. |
References v42_state_t::caller, lapm_state_t::debug, v42_state_t::detect, lapm_state_t::iframe_receive, lapm_state_t::iframe_receive_user_data, v42_state_t::lapm, v42_state_t::logging, queue_init(), lapm_state_t::t401_timer, lapm_state_t::t402_timer, lapm_state_t::t403_timer, lapm_state_t::tx_queue, and v42_restart().
int v42_release | ( | v42_state_t * | s | ) |
Release a V.42 context.
s | The V.42 context. |
void v42_restart | ( | v42_state_t * | s | ) |
Restart a V.42 context.
s | The V.42 context. |
References v42_state_t::caller, v42_state_t::detect, v42_state_t::lapm, v42_state_t::odp_seen, v42_state_t::rx_negotiation_step, v42_state_t::rxbits, v42_state_t::rxoks, v42_state_t::rxstream, lapm_state_t::sched, lapm_state_t::state, v42_state_t::t400_timer, v42_state_t::txadps, v42_state_t::txbits, v42_state_t::txstream, and lapm_state_t::we_are_originator.
Referenced by v42_init().
void v42_rx_bit | ( | void * | user_data, | |
int | bit | |||
) |
Process a newly received bit for a V.42 context.
References lapm_state_t::hdlc_rx, hdlc_rx_put_bit(), v42_state_t::lapm, and lapm_state_t::state.
void v42_set_status_callback | ( | v42_state_t * | s, | |
v42_status_func_t | callback, | |||
void * | user_data | |||
) |
Assign or remove a callback routine used to deal with V.42 status changes.
References v42_state_t::lapm, lapm_state_t::status_callback, and lapm_state_t::status_callback_user_data.
int v42_tx_bit | ( | void * | user_data | ) |
Get the next transmit bit for a V.42 context.
References lapm_state_t::hdlc_tx, hdlc_tx_get_bit(), v42_state_t::lapm, and lapm_state_t::state.