libosmo-netif  0.2.0.4.7839
Osmocom network interface library
Osmocom Multiplex Protocol

Files

file  osmux.h
 
file  osmux.c
 Osmocom multiplex protocol helpers.
 

Data Structures

struct  osmux_hdr
 
struct  osmux_in_handle
 
struct  osmux_out_handle
 
struct  osmux_batch
 
struct  osmux_circuit
 
struct  osmux_input_state
 
struct  osmux_tx_handle
 

Macros

#define OSMUX_FT_SIGNAL   0
 
#define OSMUX_FT_VOICE_AMR   1
 
#define OSMUX_FT_DUMMY   2
 
#define OSMUX_MAX_CONCURRENT_CALLS   8
 
#define OSMUX_BATCH_DEFAULT_MAX   1472
 
#define DELTA_RTP_MSG   20000
 
#define DELTA_RTP_TIMESTAMP   160
 
#define SNPRINTF_BUFFER_SIZE(ret, remain, offset)
 

Functions

struct osmux_hdr __attribute__ ((packed))
 
static uint8_t * osmux_get_payload (struct osmux_hdr *osmuxh)
 
int osmux_snprintf (char *buf, size_t size, struct msgb *msg)
 
void osmux_xfrm_input_init (struct osmux_in_handle *h)
 
void osmux_xfrm_input_fini (struct osmux_in_handle *h)
 
int osmux_xfrm_input_open_circuit (struct osmux_in_handle *h, int ccid, int dummy)
 
void osmux_xfrm_input_close_circuit (struct osmux_in_handle *h, int ccid)
 
int osmux_xfrm_input (struct osmux_in_handle *h, struct msgb *msg, int ccid)
 
void osmux_xfrm_input_deliver (struct osmux_in_handle *h)
 
void osmux_xfrm_output_init (struct osmux_out_handle *h, uint32_t rtp_ssrc)
 
void osmux_xfrm_output_set_tx_cb (struct osmux_out_handle *h, void(*tx_cb)(struct msgb *msg, void *data), void *data)
 Set transmission callback to call when a generated RTP packet is to be transmitted. More...
 
int osmux_xfrm_output (struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct llist_head *list) OSMO_DEPRECATED("Use osmux_xfrm_output_sched() instead")
 
int osmux_xfrm_output_sched (struct osmux_out_handle *h, struct osmux_hdr *osmuxh)
 Generate RTP packets from osmux frame AMR payload set and schedule them for transmission at appropiate time. More...
 
void osmux_xfrm_output_flush (struct osmux_out_handle *h)
 Flush all scheduled RTP packets still pending to be transmitted. More...
 
struct osmux_hdrosmux_xfrm_output_pull (struct msgb *msg)
 
void osmux_tx_sched (struct llist_head *list, void(*tx_cb)(struct msgb *msg, void *data), void *data) OSMO_DEPRECATED("Use osmux_xfrm_output_set_tx_cb() instead")
 
static uint32_t osmux_get_payload_len (struct osmux_hdr *osmuxh)
 
static uint32_t osmux_ft_dummy_size (uint8_t amr_ft, uint8_t batch_factor)
 
static struct msgb * osmux_rebuild_rtp (struct osmux_out_handle *h, struct osmux_hdr *osmuxh, void *payload, int payload_len, bool first_pkt)
 
static void osmux_xfrm_output_trigger (void *data)
 
static int osmux_batch_enqueue (struct msgb *msg, struct osmux_circuit *circuit, uint8_t batch_factor)
 
static void osmux_batch_dequeue (struct msgb *msg, struct osmux_circuit *circuit)
 
static void osmux_circuit_del_msgs (struct osmux_batch *batch, struct osmux_circuit *circuit)
 
static int osmux_batch_put (struct osmux_batch *batch, struct osmux_input_state *state)
 
static int osmux_xfrm_encode_amr (struct osmux_batch *batch, struct osmux_input_state *state)
 
static void osmux_encode_dummy (struct osmux_batch *batch, uint8_t batch_factor, struct osmux_input_state *state)
 
static struct msgb * osmux_build_batch (struct osmux_batch *batch, uint32_t batch_size, uint8_t batch_factor)
 
static void osmux_batch_timer_expired (void *data)
 
static int osmux_rtp_amr_payload_len (struct msgb *msg, struct rtp_hdr *rtph)
 
static void osmux_replay_lost_packets (struct osmux_circuit *circuit, struct rtp_hdr *cur_rtph, int batch_factor)
 
static struct osmux_circuitosmux_batch_find_circuit (struct osmux_batch *batch, int ccid)
 
static struct osmux_circuitosmux_batch_add_circuit (struct osmux_batch *batch, int ccid, int dummy, uint8_t batch_factor)
 
static void osmux_batch_del_circuit (struct osmux_batch *batch, struct osmux_circuit *circuit)
 
static int osmux_batch_add (struct osmux_batch *batch, uint32_t batch_factor, struct msgb *msg, struct rtp_hdr *rtph, int ccid)
 
static void osmux_tx_cb (void *data)
 
static void osmux_tx (struct msgb *msg, struct timeval *when, void(*tx_cb)(struct msgb *msg, void *data), void *data)
 
static int osmux_snprintf_header (char *buf, size_t size, struct osmux_hdr *osmuxh)
 
static int osmux_snprintf_payload (char *buf, size_t size, const uint8_t *payload, int payload_len)
 

Variables

struct osmux_in_handle __attribute__
 
static void * osmux_ctx
 

Detailed Description

This code implements a variety of utility functions related to the OSMUX user-plane multiplexing protocol, an efficient alternative to plain UDP/RTP streams for voice transport in back-haul of cellular networks.

For information about the OSMUX protocol design, please see the OSMUX reference manual at http://ftp.osmocom.org/docs/latest/osmux-reference.pdf

Macro Definition Documentation

#define SNPRINTF_BUFFER_SIZE (   ret,
  remain,
  offset 
)
Value:
if (ret < 0) \
ret = 0; \
offset += ret; \
if (ret > remain) \
ret = remain; \
remain -= ret;

Function Documentation

int osmux_snprintf ( char *  buf,
size_t  size,
struct msgb *  msg 
)

Print osmux header fields and payload from msg into buffer buf.

Parameters
[out]bufbuffer to store the output into
[in]lenlength of buf in bytes
[in]msgbmessage buffer containing one or more osmux frames
Returns
the number of characters printed (excluding the null byte used to end output to strings).

If the output was truncated due to this limit, then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available.

int osmux_xfrm_input ( struct osmux_in_handle h,
struct msgb *  msg,
int  ccid 
)

osmux_xfrm_input - add RTP message to OSmux batch

Parameters
msgRTP message that you want to batch into one OSmux message

If 0 is returned, this indicates that the message has been batched or that an error occured and we have skipped the message. If 1 is returned, you have to invoke osmux_xfrm_input_deliver and try again.

The function takes care of releasing the messages in case of error and when building the batch.

void osmux_xfrm_output_flush ( struct osmux_out_handle h)

Flush all scheduled RTP packets still pending to be transmitted.

Parameters
[in]hthe osmux out handle to flush

This function will immediately call the transmit callback for all queued RTP packets, making sure the list ends up empty. It will also stop all internal timers to make sure the osmux_out_handle can be dropped or re-used by calling osmux_xfrm_output on it.

int osmux_xfrm_output_sched ( struct osmux_out_handle h,
struct osmux_hdr osmuxh 
)

Generate RTP packets from osmux frame AMR payload set and schedule them for transmission at appropiate time.

Parameters
[in]hthe osmux out handle handling a specific CID
[in]osmuxhBuffer pointing to osmux frame header structure and AMR payload
Returns
Number of generated RTP packets

The osmux frame passed to this function must be of the type OSMUX_FT_VOICE_AMR. The generated RTP packets are kept into h's internal list and sent to the callback configured through osmux_xfrm_output_set_tx_cb when are ready to be transmitted according to schedule.

void osmux_xfrm_output_set_tx_cb ( struct osmux_out_handle h,
void(*)(struct msgb *msg, void *data)  tx_cb,
void *  data 
)

Set transmission callback to call when a generated RTP packet is to be transmitted.

Parameters
[in]hthe osmux out handle handling a specific CID
[in]osmuxhBuffer pointing to osmux frame header structure and AMR payload
Returns
Number of generated RTP packets

This Function sets the callback called by the interal timer set by osmux_xfrm_out_sched function.