libosmoisdn 1.10.0.58-6cd7a
Osmocom ISDN library
|
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
#include <osmocom/isdn/v110.h>
Go to the source code of this file.
Data Structures | |
struct | osmo_v110_ta_cfg |
Configuration for a V.110 TA instance. More... | |
Enumerations | |
enum | osmo_v110_local_flow_ctrl_mode { OSMO_V110_LOCAL_FLOW_CTRL_NONE , OSMO_V110_LOCAL_FLOW_CTRL_133_106 , OSMO_V110_LOCAL_FLOW_CTRL_105_106 , OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF } |
V.110 5.4.1 Local flow control (DTE-DCE or TE-TA) mode. More... | |
enum | osmo_v110_ta_timer { OSMO_V110_TA_TIMER_X1 = -1 , OSMO_V110_TA_TIMER_T1 = 1 , OSMO_V110_TA_TIMER_T2 = 2 } |
Various timers for a V.110 TA instance. More... | |
enum | osmo_v110_ta_circuit { OSMO_V110_TA_C_105 , OSMO_V110_TA_C_106 , OSMO_V110_TA_C_107 , OSMO_V110_TA_C_108 , OSMO_V110_TA_C_109 , OSMO_V110_TA_C_133 } |
ITU-T Table 9 "Interchange circuit" (see also ITU-T V.24 Chapter 3). More... | |
Functions | |
struct osmo_v110_ta * | osmo_v110_ta_alloc (void *ctx, const char *name, const struct osmo_v110_ta_cfg *cfg) |
Allocate a V.110 TA (Terminal Adapter) instance. More... | |
void | osmo_v110_ta_free (struct osmo_v110_ta *ta) |
Release memory taken by the given V.110 TA instance. More... | |
int | osmo_v110_ta_set_timer_val_ms (struct osmo_v110_ta *ta, enum osmo_v110_ta_timer timer, unsigned long val_ms) |
Configure a timer of the given V.110 TA instance. More... | |
int | osmo_v110_ta_frame_in (struct osmo_v110_ta *ta, const struct osmo_v110_decoded_frame *in) |
Feed a [decoded] V.110 frame into the given TA instance. More... | |
int | osmo_v110_ta_frame_out (struct osmo_v110_ta *ta, struct osmo_v110_decoded_frame *out) |
Pull a [decoded] V.110 frame out of the given TA instance. More... | |
int | osmo_v110_ta_sync_ind (struct osmo_v110_ta *ta) |
Indicate a synchronization establishment event. More... | |
int | osmo_v110_ta_desync_ind (struct osmo_v110_ta *ta) |
Indicate a synchronization loss event. More... | |
static const char * | osmo_v110_ta_circuit_name (enum osmo_v110_ta_circuit circuit) |
Get a short name of the given TA's circuit (format: NNN[/ABBR]). More... | |
static const char * | osmo_v110_ta_circuit_desc (enum osmo_v110_ta_circuit circuit) |
Get a brief description of the given TA's circuit. More... | |
unsigned int | osmo_v110_ta_get_status (const struct osmo_v110_ta *ta) |
Get the V.24 status bit-mask of the given TA instance. More... | |
bool | osmo_v110_ta_get_circuit (const struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit) |
Get state of a V.24 circuit of the given TA instance. More... | |
int | osmo_v110_ta_set_circuit (struct osmo_v110_ta *ta, enum osmo_v110_ta_circuit circuit, bool active) |
Activate/deactivate a V.24 circuit of the given TA instance. More... | |
Variables | |
const struct value_string | osmo_v110_ta_circuit_names [] |
const struct value_string | osmo_v110_ta_circuit_descs [] |
V.110 5.4.1 Local flow control (DTE-DCE or TE-TA) mode.
enum osmo_v110_ta_circuit |
ITU-T Table 9 "Interchange circuit" (see also ITU-T V.24 Chapter 3).
XXX: Not all circuits are present here, only those which we actually use. TODO: add human-friendly abbreviated circuit names.
enum osmo_v110_ta_timer |
Various timers for a V.110 TA instance.
struct osmo_v110_ta * osmo_v110_ta_alloc | ( | void * | ctx, |
const char * | name, | ||
const struct osmo_v110_ta_cfg * | cfg | ||
) |
Allocate a V.110 TA (Terminal Adapter) instance.
[in] | ctx | parent talloc context. |
[in] | name | name of the TA instance. |
[in] | cfg | initial configuration of the TA instance. |
References osmo_v110_ta::cfg, DLGLOBAL, osmo_v110_ta::fi, osmo_v110_ta_cfg::flow_ctrl, osmo_v110_ta_cfg::local, LOGL_DEBUG, LOGL_ERROR, LOGP, name, osmo_v110_ta::name, OSMO_ASSERT, osmo_fsm_inst_alloc(), osmo_fsm_inst_free(), osmo_fsm_inst_state_chg, osmo_tdefs_reset(), OSMO_V110_LOCAL_FLOW_CTRL_NONE, osmo_v110_ta_fsm, osmo_v110_ta_cfg::rx_cb, osmo_v110_ta::Tdefs, osmo_v110_ta_cfg::tx_cb, V110_TA_ST_IDLE_READY, and v110_ta_tdef.
|
inlinestatic |
Get a brief description of the given TA's circuit.
References get_value_string(), and osmo_v110_ta_circuit_descs.
|
inlinestatic |
Get a short name of the given TA's circuit (format: NNN[/ABBR]).
References get_value_string(), and osmo_v110_ta_circuit_names.
Referenced by osmo_v110_ta_set_circuit().
int osmo_v110_ta_desync_ind | ( | struct osmo_v110_ta * | ta | ) |
Indicate a synchronization loss event.
This function is intended to be called when the lower layer experiences a loss of synchronization with the frame clock.
[in] | ta | TA instance to indicate the event to. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_DESYNC_IND.
int osmo_v110_ta_frame_in | ( | struct osmo_v110_ta * | ta, |
const struct osmo_v110_decoded_frame * | in | ||
) |
Feed a [decoded] V.110 frame into the given TA instance.
This function, like its out counterpart, is intended to be used by the lower layers receiving V.110 frames over some medium. The caller of this function is responsible for finding the synchronization pattern (if needed), aligning to the frame boundaries, and decoding frames using osmo_v110_decode_frame() or osmo_csd*_decode_frame().
Bits E1/E2/E3 are expected to be set by the caller (if not being transmitted over the medium) in accordance with the configured synchronous user rate.
Bits D1..D48 are passed to the bit rate adaption function RA1. The resulting output is then passed to the upper layer (application) via the configured .rx_cb(). Though, in certain states of the TA's FSM, bits D1..D48 are ignored and the upper layer gets a sequence of binary '0' or '1'.
[in] | ta | TA instance to feed the given frame into. |
[in] | in | pointer to a [decoded] V.110 frame. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_RX_FRAME_IND.
int osmo_v110_ta_frame_out | ( | struct osmo_v110_ta * | ta, |
struct osmo_v110_decoded_frame * | out | ||
) |
Pull a [decoded] V.110 frame out of the given TA instance.
This function, like its in counterpart, is intended to be used by the lower layers transmitting V.110 frames over some medium. The caller of this function is responsible for encoding the output frame using osmo_v110_encode_frame() or osmo_csd*_encode_frame().
Bits E1/E2/E3 are set in accordance with the configured synchronous user rate. Bits E4/E5/E6/E7 are unconditionally set to binary '1'.
Bits D1..D48 are set depending on the state of TA's FSM:
[in] | ta | TA instance to pull a frame from. |
[out] | out | where to store a [decoded] V.110 frame. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_TX_FRAME_RTS.
void osmo_v110_ta_free | ( | struct osmo_v110_ta * | ta | ) |
Release memory taken by the given V.110 TA instance.
[in] | ta | TA instance to be free()d. |
References osmo_v110_ta::fi, and osmo_fsm_inst_free().
bool osmo_v110_ta_get_circuit | ( | const struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_circuit | circuit | ||
) |
Get state of a V.24 circuit of the given TA instance.
[in] | ta | TA instance to get the circuit state. |
[in] | circuit | a V.24 circuit, one of OSMO_V110_TA_C_*. |
References osmo_v110_ta::state, V24_FLAGMASK_IS_ON, and v110_ta_state::v24_flags.
unsigned int osmo_v110_ta_get_status | ( | const struct osmo_v110_ta * | ta | ) |
Get the V.24 status bit-mask of the given TA instance.
[in] | ta | TA instance to get the circuit bit-mask. |
References osmo_v110_ta::state, and v110_ta_state::v24_flags.
int osmo_v110_ta_set_circuit | ( | struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_circuit | circuit, | ||
bool | active | ||
) |
Activate/deactivate a V.24 circuit of the given TA instance.
[in] | ta | TA instance to update the circuit state. |
[in] | circuit | a V.24 circuit, one of OSMO_V110_TA_C_* (DTE->DCE). |
[in] | active | activate (true) or deactivate (false) the circuit. |
References osmo_v110_ta::fi, LOGL_ERROR, LOGPFSML, OSMO_V110_TA_C_105, OSMO_V110_TA_C_108, OSMO_V110_TA_C_133, osmo_v110_ta_circuit_name(), osmo_v110_ta::state, v110_ta_set_status(), V24_FLAGMASK_SET_OFF, V24_FLAGMASK_SET_ON, and v110_ta_state::v24_flags.
int osmo_v110_ta_set_timer_val_ms | ( | struct osmo_v110_ta * | ta, |
enum osmo_v110_ta_timer | timer, | ||
unsigned long | val_ms | ||
) |
Configure a timer of the given V.110 TA instance.
[in] | ta | TA instance to be configured. |
[in] | timer | a timer to be configured. |
[in] | val_ms | the new timeout value to set (in milliseconds). |
References OSMO_TDEF_MS, osmo_tdef_set(), and osmo_v110_ta::Tdefs.
int osmo_v110_ta_sync_ind | ( | struct osmo_v110_ta * | ta | ) |
Indicate a synchronization establishment event.
This function is intended to be called when the lower layer achieves synchronization to the frame clock.
[in] | ta | TA instance to indicate the event to. |
References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_SYNC_IND.
|
extern |
Referenced by osmo_v110_ta_circuit_desc().
|
extern |
Referenced by osmo_v110_ta_circuit_name().