libosmo-netif/include/osmocom/netif/osmux.h

84 lines
2.2 KiB
C
Raw Normal View History

2012-07-09 17:39:55 +00:00
#ifndef _OSMUX_H_
#define _OSMUX_H_
/* OSmux header:
*
* ft (3 bits): 0=signalling, 1=voice
* ctr (3 bits): Number of batched AMR payloads (starting 0)
* amr_f (1 bit): AMR F field (RFC3267)
* amr_q (1 bit): AMR Q field (RFC3267)
* seq (8 bits): Combination of RTP timestamp and seq. number
* circuit_id (8 bits): Circuit ID, ie. Call identifier.
* amr_ft (4 bits): AMR FT field (RFC3267)
* amr_cmr (4 bits): AMR CMT field (RFC3267)
2012-07-09 17:39:55 +00:00
*/
#define OSMUX_FT_SIGNAL 0
#define OSMUX_FT_VOICE_AMR 1
struct osmux_hdr {
#if __BYTE_ORDER == __BIG_ENDIAN
uint8_t ft:3,
ctr:3,
amr_f:1,
amr_q:1;
2012-07-09 17:39:55 +00:00
#elif __BYTE_ORDER == __LITTLE_ENDIAN
uint8_t amr_q:1,
amr_f:1,
ctr:3,
ft:3;
2012-07-09 17:39:55 +00:00
#endif
uint8_t seq;
#define OSMUX_CID_MAX 255 /* determined by circuit_id */
uint8_t circuit_id;
2012-07-09 17:39:55 +00:00
#if __BYTE_ORDER == __BIG_ENDIAN
uint8_t amr_ft:4,
amr_cmr:4;
2012-07-09 17:39:55 +00:00
#elif __BYTE_ORDER == __LITTLE_ENDIAN
uint8_t amr_cmr:4,
amr_ft:4;
2012-07-09 17:39:55 +00:00
#endif
} __attribute__((packed));
/* one to handle all existing RTP flows */
struct osmux_in_handle {
uint8_t osmux_seq;
uint8_t batch_factor;
uint16_t batch_size;
void (*deliver)(struct msgb *msg, void *data);
void *data;
char *internal_data; /* internal data to store batch */
2012-07-09 17:39:55 +00:00
};
#define OSMUX_MAX_CONCURRENT_CALLS 8
2012-07-09 17:39:55 +00:00
/* one per OSmux circuit_id, ie. one per RTP flow. */
struct osmux_out_handle {
uint16_t rtp_seq;
uint32_t rtp_timestamp;
uint32_t rtp_ssrc;
2012-07-09 17:39:55 +00:00
};
struct osmux_hdr *osmux_get_hdr(struct msgb *msg);
static inline uint8_t *osmux_get_payload(struct osmux_hdr *osmuxh)
2012-07-09 17:39:55 +00:00
{
return (uint8_t *)osmuxh + sizeof(struct osmux_hdr);
}
int osmux_snprintf(char *buf, size_t size, struct msgb *msg);
2012-07-09 17:39:55 +00:00
void osmux_xfrm_input_init(struct osmux_in_handle *h);
void osmux_xfrm_input_fini(struct osmux_in_handle *h);
int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid);
2012-07-09 17:39:55 +00:00
void osmux_xfrm_input_deliver(struct osmux_in_handle *h);
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc);
int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct llist_head *list);
2012-07-09 17:39:55 +00:00
struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg);
void osmux_tx_sched(struct llist_head *list, void (*tx_cb)(struct msgb *msg, void *data), void *data);
2012-07-09 17:39:55 +00:00
#endif