libosmoisdn 1.9.0.196-9975
Osmocom ISDN library
v110.c File Reference
#include <stdint.h>
#include <errno.h>
#include <osmocom/core/bits.h>
#include <osmocom/isdn/v110.h>

Data Structures

struct  osmo_v110_sync_ra1
 

Macros

#define F   1
 

Functions

int osmo_v110_decode_frame (struct osmo_v110_decoded_frame *fr, const ubit_t *ra_bits, size_t n_bits)
 Decode a 80-bit V.110 frame present as 80 ubits into a struct osmo_v110_decoded_frame. More...
 
int osmo_v110_encode_frame (ubit_t *ra_bits, size_t n_bits, const struct osmo_v110_decoded_frame *fr)
 Encode a struct osmo_v110_decoded_frame into an 80-bit V.110 frame as ubits. More...
 
void osmo_v110_ubit_dump (FILE *outf, const ubit_t *fr, size_t in_len)
 Print a encoded V.110 frame in the same table-like structure as the spec. More...
 
static int v110_adapt_600_to_IR8000 (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 6 synchronous 600bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR8000_to_600 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
static int v110_adapt_1200_to_IR8000 (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 12 synchronous 1200bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR8000_to_1200 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
static int v110_adapt_2400_to_IR8000 (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 24 synchronous 2400bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR8000_to_2400 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
static int v110_adapt_Nx3600_to_IR (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 36 synchronous N x 3600bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR_to_Nx3600 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
static int v110_adapt_Nx4800_to_IR (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 48 synchronous N x 4800bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR_to_Nx4800 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
static int v110_adapt_Nx12000_to_IR (struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 Adapt from 30 synchronous N x 12000bit/s input bits to a decoded V.110 frame. More...
 
static int v110_adapt_IR_to_Nx12000 (ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 
int osmo_v110_sync_ra1_get_user_data_chunk_bitlen (enum osmo_v100_sync_ra1_rate rate)
 obtain the size (in number of bits) of the user data bits in one V.110 frame for specified RA1 rate More...
 
int osmo_v110_sync_ra1_get_user_data_rate (enum osmo_v100_sync_ra1_rate rate)
 obtain the user data rate (in bits/s) for specified RA1 rate More...
 
int osmo_v110_sync_ra1_get_intermediate_rate (enum osmo_v100_sync_ra1_rate rate)
 obtain the intermediate rate (in bits/s) for specified RA1 rate More...
 
int osmo_v110_sync_ra1_user_to_ir (enum osmo_v100_sync_ra1_rate rate, struct osmo_v110_decoded_frame *fr, const ubit_t *d_in, size_t in_len)
 perform V.110 RA1 function in user rate -> intermediate rate direction. More...
 
int osmo_v110_sync_ra1_ir_to_user (enum osmo_v100_sync_ra1_rate rate, ubit_t *d_out, size_t out_len, const struct osmo_v110_decoded_frame *fr)
 perform V.110 RA1 function in intermediate rate -> user rate direction. More...
 

Variables

const ubit_t osmo_v110_e1e2e3 [_NUM_OSMO_V110_SYNC_RA1][3]
 E1/E2/E3 bit values as per Table 5/V.110. More...
 
static const struct osmo_v110_sync_ra1 osmo_v110_sync_ra1_def [_NUM_OSMO_V110_SYNC_RA1]
 

Macro Definition Documentation

◆ F

#define F   1

Function Documentation

◆ osmo_v110_decode_frame()

int osmo_v110_decode_frame ( struct osmo_v110_decoded_frame fr,
const ubit_t ra_bits,
size_t  n_bits 
)

Decode a 80-bit V.110 frame present as 80 ubits into a struct osmo_v110_decoded_frame.

Parameters
[out]frcaller-allocated output data structure, filled by this function
[in]ra_bitsOne V.110 frame as 80 unpacked bits.
[in]n_bitsnumber of unpacked bits provided in ra_bits
Returns
0 in case of success; negative on error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_decoded_frame::s_bits, and osmo_v110_decoded_frame::x_bits.

◆ osmo_v110_encode_frame()

int osmo_v110_encode_frame ( ubit_t ra_bits,
size_t  n_bits,
const struct osmo_v110_decoded_frame fr 
)

Encode a struct osmo_v110_decoded_frame into an 80-bit V.110 frame as ubits.

Parameters
[out]ra_bitscaller-provided output buffer at leat 80 ubits large
[in]n_bitslength of ra_bits. Must be at least 80.
[in]inputdata structure
Returns
number of bits written to ra_bits

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_decoded_frame::s_bits, and osmo_v110_decoded_frame::x_bits.

◆ osmo_v110_sync_ra1_get_intermediate_rate()

int osmo_v110_sync_ra1_get_intermediate_rate ( enum osmo_v100_sync_ra1_rate  rate)

obtain the intermediate rate (in bits/s) for specified RA1 rate

References _NUM_OSMO_V110_SYNC_RA1, osmo_v110_sync_ra1::intermediate_rate, and osmo_v110_sync_ra1_def.

◆ osmo_v110_sync_ra1_get_user_data_chunk_bitlen()

int osmo_v110_sync_ra1_get_user_data_chunk_bitlen ( enum osmo_v100_sync_ra1_rate  rate)

obtain the size (in number of bits) of the user data bits in one V.110 frame for specified RA1 rate

References _NUM_OSMO_V110_SYNC_RA1, osmo_v110_sync_ra1_def, and osmo_v110_sync_ra1::user_data_chunk_bits.

Referenced by v110_ta_build_frame(), and v110_ta_handle_frame().

◆ osmo_v110_sync_ra1_get_user_data_rate()

int osmo_v110_sync_ra1_get_user_data_rate ( enum osmo_v100_sync_ra1_rate  rate)

obtain the user data rate (in bits/s) for specified RA1 rate

References _NUM_OSMO_V110_SYNC_RA1, osmo_v110_sync_ra1::data_rate, and osmo_v110_sync_ra1_def.

◆ osmo_v110_sync_ra1_ir_to_user()

int osmo_v110_sync_ra1_ir_to_user ( enum osmo_v100_sync_ra1_rate  rate,
ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)

perform V.110 RA1 function in intermediate rate -> user rate direction.

Parameters
[in]ratespecification of the user bitrate
[out]d_outcaller-allocated output user data (unpacked bits)
[out]out_lenlength of d_out output buffer
[in]fr[decoded] V.110 frame used as input
Returns
number of unpacked bits written to d_out on success; negative in case of error

References _NUM_OSMO_V110_SYNC_RA1, osmo_v110_sync_ra1::adapt_ir_to_user, and osmo_v110_sync_ra1_def.

Referenced by v110_ta_handle_frame().

◆ osmo_v110_sync_ra1_user_to_ir()

int osmo_v110_sync_ra1_user_to_ir ( enum osmo_v100_sync_ra1_rate  rate,
struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)

perform V.110 RA1 function in user rate -> intermediate rate direction.

Parameters
[in]ratespecification of the user bitrate
[out]frcaller-allocated output buffer for the [decoded] V.110 frame generated
[in]d_ininput user data (unpacked bits)
[in]in_lenlength of user input data (in number of bits)
Returns
0 on success; negative in case of error

References _NUM_OSMO_V110_SYNC_RA1, osmo_v110_sync_ra1::adapt_user_to_ir, and osmo_v110_sync_ra1_def.

Referenced by v110_ta_build_frame().

◆ osmo_v110_ubit_dump()

void osmo_v110_ubit_dump ( FILE *  outf,
const ubit_t fr,
size_t  in_len 
)

Print a encoded V.110 frame in the same table-like structure as the spec.

Parameters
outfoutput FILE stream to which to dump
[in]frunpacked bits to dump
[in]in_lenlength of unpacked bits available at fr.

◆ v110_adapt_1200_to_IR8000()

static int v110_adapt_1200_to_IR8000 ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 12 synchronous 1200bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 12.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_1200.

◆ v110_adapt_2400_to_IR8000()

static int v110_adapt_2400_to_IR8000 ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 24 synchronous 2400bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 24.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_2400.

◆ v110_adapt_600_to_IR8000()

static int v110_adapt_600_to_IR8000 ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 6 synchronous 600bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 6.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_600.

◆ v110_adapt_IR8000_to_1200()

static int v110_adapt_IR8000_to_1200 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_IR8000_to_2400()

static int v110_adapt_IR8000_to_2400 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_IR8000_to_600()

static int v110_adapt_IR8000_to_600 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_IR_to_Nx12000()

static int v110_adapt_IR_to_Nx12000 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_IR_to_Nx3600()

static int v110_adapt_IR_to_Nx3600 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_IR_to_Nx4800()

static int v110_adapt_IR_to_Nx4800 ( ubit_t d_out,
size_t  out_len,
const struct osmo_v110_decoded_frame fr 
)
static

◆ v110_adapt_Nx12000_to_IR()

static int v110_adapt_Nx12000_to_IR ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 30 synchronous N x 12000bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 30.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, F, OSMO_ASSERT, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_12000.

◆ v110_adapt_Nx3600_to_IR()

static int v110_adapt_Nx3600_to_IR ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 36 synchronous N x 3600bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 36.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, F, OSMO_ASSERT, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_7200.

◆ v110_adapt_Nx4800_to_IR()

static int v110_adapt_Nx4800_to_IR ( struct osmo_v110_decoded_frame fr,
const ubit_t d_in,
size_t  in_len 
)
static

Adapt from 48 synchronous N x 4800bit/s input bits to a decoded V.110 frame.

Parameters
[out]frcaller-allocated output frame to which E+D bits are stored
[in]d_ininput user bits
[in]in_lennumber of bits in d_in. Must be 48.
Returns
0 on success; negative in case of error.

References osmo_v110_decoded_frame::d_bits, osmo_v110_decoded_frame::e_bits, osmo_v110_e1e2e3_set, and OSMO_V110_SYNC_RA1_4800.

Variable Documentation

◆ osmo_v110_e1e2e3

const ubit_t osmo_v110_e1e2e3[_NUM_OSMO_V110_SYNC_RA1][3]
Initial value:
= {
[OSMO_V110_SYNC_RA1_600] = { 1, 0, 0 },
[OSMO_V110_SYNC_RA1_1200] = { 0, 1, 0 },
[OSMO_V110_SYNC_RA1_2400] = { 1, 1, 0 },
[OSMO_V110_SYNC_RA1_4800] = { 0, 1, 1 },
[OSMO_V110_SYNC_RA1_7200] = { 1, 0, 1 },
[OSMO_V110_SYNC_RA1_9600] = { 0, 1, 1 },
[OSMO_V110_SYNC_RA1_12000] = { 0, 0, 1 },
[OSMO_V110_SYNC_RA1_14400] = { 1, 0, 1 },
[OSMO_V110_SYNC_RA1_19200] = { 0, 1, 1 },
[OSMO_V110_SYNC_RA1_24000] = { 0, 0, 1 },
[OSMO_V110_SYNC_RA1_28800] = { 1, 0, 1 },
[OSMO_V110_SYNC_RA1_38400] = { 0, 1, 1 },
}
@ OSMO_V110_SYNC_RA1_14400
Definition: v110.h:34
@ OSMO_V110_SYNC_RA1_9600
Definition: v110.h:32
@ OSMO_V110_SYNC_RA1_28800
Definition: v110.h:37
@ OSMO_V110_SYNC_RA1_1200
Definition: v110.h:28
@ OSMO_V110_SYNC_RA1_4800
Definition: v110.h:30
@ OSMO_V110_SYNC_RA1_2400
Definition: v110.h:29
@ OSMO_V110_SYNC_RA1_12000
Definition: v110.h:33
@ OSMO_V110_SYNC_RA1_7200
Definition: v110.h:31
@ OSMO_V110_SYNC_RA1_38400
Definition: v110.h:38
@ OSMO_V110_SYNC_RA1_600
Definition: v110.h:27
@ OSMO_V110_SYNC_RA1_19200
Definition: v110.h:35
@ OSMO_V110_SYNC_RA1_24000
Definition: v110.h:36

E1/E2/E3 bit values as per Table 5/V.110.

◆ osmo_v110_sync_ra1_def