Loading...
Searching...
No Matches
v110_ta.h File Reference
`#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.
void | osmo_v110_ta_free (struct osmo_v110_ta *ta)
| Release memory taken by the given V.110 TA instance.
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.
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.
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.
int | osmo_v110_ta_sync_ind (struct osmo_v110_ta *ta)
| Indicate a synchronization establishment event.
int | osmo_v110_ta_desync_ind (struct osmo_v110_ta *ta)
| Indicate a synchronization loss event.
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]).
static const char * | osmo_v110_ta_circuit_desc (enum osmo_v110_ta_circuit circuit)
| Get a brief description of the given TA's circuit.
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.
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.
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.

## Variables

const struct value_string | osmo_v110_ta_circuit_names []
const struct value_string | osmo_v110_ta_circuit_descs []

## Enumeration Type Documentation

## osmo_v110_local_flow_ctrl_mode

enum osmo_v110_local_flow_ctrl_mode

V.110 5.4.1 Local flow control (DTE-DCE or TE-TA) mode.

Enumerator
OSMO_V110_LOCAL_FLOW_CTRL_NONE | No local flow control.
OSMO_V110_LOCAL_FLOW_CTRL_133_106 | 5.4.1.1 133/106 operation
OSMO_V110_LOCAL_FLOW_CTRL_105_106 | 5.4.1.2 105/106 operation
OSMO_V110_LOCAL_FLOW_CTRL_XON_XOFF | 5.4.1.3 XON/XOFF operation

## osmo_v110_ta_circuit

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.

Enumerator
OSMO_V110_TA_C_105 | DTE->DCE | RTS (Request to Send)
OSMO_V110_TA_C_106 | DTE<-DCE | CTS (Clear to Send)
OSMO_V110_TA_C_107 | DTE<-DCE | DSR (Data Set Ready)
OSMO_V110_TA_C_108 | DTE->DCE | DTR (Data Terminal Ready)
OSMO_V110_TA_C_109 | DTE<-DCE | DCD (Data Carrier Detect)
OSMO_V110_TA_C_133 | DTE->DCE | Ready for receiving.

## osmo_v110_ta_timer

enum osmo_v110_ta_timer

Various timers for a V.110 TA instance.

Enumerator
OSMO_V110_TA_TIMER_X1 | 7.1.5 Loss of frame synchronization: sync recovery timer. T-number is not assigned in V.110, so we call it X1.
OSMO_V110_TA_TIMER_T1 | 7.1.2 Connect TA to line: sync establishment timer
OSMO_V110_TA_TIMER_T2 | 7.1.4 Disconnect mode: disconnect confirmation timer

## Function Documentation

## osmo_v110_ta_alloc()

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.

Parameters

  [in] | ctx | parent talloc context.
  [in] | name | name of the TA instance.
  [in] | cfg | initial configuration of the TA instance.

Returns
  pointer to allocated TA instance; NULL on error.

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, 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.

## osmo_v110_ta_circuit_desc()

static const char * osmo_v110_ta_circuit_desc | ( | enum osmo_v110_ta_circuit | circuit | ) |

inline static

Get a brief description of the given TA's circuit.

References get_value_string(), and osmo_v110_ta_circuit_descs.

## osmo_v110_ta_circuit_name()

static const char * osmo_v110_ta_circuit_name | ( | enum osmo_v110_ta_circuit | circuit | ) |

inline static

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().

## osmo_v110_ta_desync_ind()

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.

Parameters

  [in] | ta | TA instance to indicate the event to.

Returns
  0 in case of success; negative on error.

References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_DESYNC_IND.

## osmo_v110_ta_frame_in()

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'.

Parameters

  [in] | ta | TA instance to feed the given frame into.
  [in] | in | pointer to a [decoded] V.110 frame.

Returns
  0 in case of success; negative on error.

References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_RX_FRAME_IND.

## osmo_v110_ta_frame_out()

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 data transfer mode, the user bits are obtained from the upper layer (application) via the configured .tx_cb(), and then passed to the bit rate adaption function RA1, which generates bits D1..D48.
- In other modes, bits D1..D48 are all set to binary '0' or '1'.

Parameters

  [in] | ta | TA instance to pull a frame from.
  [out] | out | where to store a [decoded] V.110 frame.

Returns
  0 in case of success; negative on error.

References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_TX_FRAME_RTS.

## osmo_v110_ta_free()

void osmo_v110_ta_free | ( | struct osmo_v110_ta * | ta | ) |

Release memory taken by the given V.110 TA instance.

Parameters

  [in] | ta | TA instance to be free()d.

References osmo_v110_ta::fi, and osmo_fsm_inst_free().

## osmo_v110_ta_get_circuit()

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.

Parameters

  [in] | ta | TA instance to get the circuit state.
  [in] | circuit | a V.24 circuit, one of OSMO_V110_TA_C_*.

Returns
  circuit state: active (true) or inactive (false).

References osmo_v110_ta::state, V24_FLAGMASK_IS_ON, and v110_ta_state::v24_flags.

## osmo_v110_ta_get_status()

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.

Parameters

  [in] | ta | TA instance to get the circuit bit-mask.

Returns
  bitmask of OSMO_V110_TA_C_*.

References osmo_v110_ta::state, and v110_ta_state::v24_flags.

## osmo_v110_ta_set_circuit()

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.

Parameters

  [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.

Returns
  0 on success; negative on error.

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.

## osmo_v110_ta_set_timer_val_ms()

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.

Parameters

  [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).

Returns
  0 in case of success; negative on error.

References OSMO_TDEF_MS, osmo_tdef_set(), and osmo_v110_ta::Tdefs.

## osmo_v110_ta_sync_ind()

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.

Parameters

  [in] | ta | TA instance to indicate the event to.

Returns
  0 in case of success; negative on error.

References osmo_v110_ta::fi, osmo_fsm_inst_dispatch, and V110_TA_EV_SYNC_IND.

## Variable Documentation

## osmo_v110_ta_circuit_descs

const struct value_string osmo_v110_ta_circuit_descs[]

extern

Referenced by osmo_v110_ta_circuit_desc().

## osmo_v110_ta_circuit_names

const struct value_string osmo_v110_ta_circuit_names[]

extern

Referenced by osmo_v110_ta_circuit_name().