osmux: allow to specify the osmux frame size
This patch adds a new field to the struct osmux_in_handle that allows you to specify the osmux frame size. If not specified, the default size assumes your nic uses a mtu of 1500 bytes.
This commit is contained in:
parent
0b44016ef6
commit
d8947e37b0
|
@ -44,6 +44,7 @@ struct osmux_hdr {
|
||||||
struct osmux_in_handle {
|
struct osmux_in_handle {
|
||||||
uint8_t osmux_seq;
|
uint8_t osmux_seq;
|
||||||
uint8_t batch_factor;
|
uint8_t batch_factor;
|
||||||
|
uint16_t batch_size;
|
||||||
void (*deliver)(struct msgb *msg, void *data);
|
void (*deliver)(struct msgb *msg, void *data);
|
||||||
void *data;
|
void *data;
|
||||||
char *internal_data; /* internal data to store batch */
|
char *internal_data; /* internal data to store batch */
|
||||||
|
|
16
src/osmux.c
16
src/osmux.c
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#define DEBUG_TIMING 0
|
#define DEBUG_TIMING 0
|
||||||
|
|
||||||
/* XXX: MTU - iphdr (20 bytes) - udphdr (8 bytes) */
|
/* Default: MTU - iphdr (20 bytes) - udphdr (8 bytes) */
|
||||||
#define OSMUX_BATCH_MAX 1472
|
#define OSMUX_BATCH_MAX 1472
|
||||||
|
|
||||||
/* delta time between two RTP messages */
|
/* delta time between two RTP messages */
|
||||||
|
@ -277,7 +277,7 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h)
|
||||||
|
|
||||||
LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n");
|
LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n");
|
||||||
|
|
||||||
batch_msg = msgb_alloc(OSMUX_BATCH_MAX, "OSMUX");
|
batch_msg = msgb_alloc(h->batch_size, "osmux");
|
||||||
if (batch_msg == NULL) {
|
if (batch_msg == NULL) {
|
||||||
LOGP(DLMIB, LOGL_ERROR, "Not enough memory\n");
|
LOGP(DLMIB, LOGL_ERROR, "Not enough memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -326,7 +326,7 @@ void osmux_xfrm_input_deliver(struct osmux_in_handle *h)
|
||||||
batch_msg = osmux_build_batch(h);
|
batch_msg = osmux_build_batch(h);
|
||||||
h->deliver(batch_msg, h->data);
|
h->deliver(batch_msg, h->data);
|
||||||
osmo_timer_del(&batch->timer);
|
osmo_timer_del(&batch->timer);
|
||||||
batch->remaining_bytes = OSMUX_BATCH_MAX;
|
batch->remaining_bytes = h->batch_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osmux_batch_timer_expired(void *data)
|
static void osmux_batch_timer_expired(void *data)
|
||||||
|
@ -507,7 +507,7 @@ int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid)
|
||||||
/* Ignore too big RTP/RTCP messages, most likely forged. Sanity check
|
/* Ignore too big RTP/RTCP messages, most likely forged. Sanity check
|
||||||
* to avoid a possible forever loop in the caller.
|
* to avoid a possible forever loop in the caller.
|
||||||
*/
|
*/
|
||||||
if (msg->len > OSMUX_BATCH_MAX - sizeof(struct osmux_hdr))
|
if (msg->len > h->batch_size - sizeof(struct osmux_hdr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rtph = osmo_rtp_get_hdr(msg);
|
rtph = osmo_rtp_get_hdr(msg);
|
||||||
|
@ -549,18 +549,22 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h)
|
||||||
{
|
{
|
||||||
struct osmux_batch *batch;
|
struct osmux_batch *batch;
|
||||||
|
|
||||||
LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n");
|
/* Default to osmux packet size if not specified */
|
||||||
|
if (h->batch_size == 0)
|
||||||
|
h->batch_size = OSMUX_BATCH_MAX;
|
||||||
|
|
||||||
batch = talloc_zero(osmux_ctx, struct osmux_batch);
|
batch = talloc_zero(osmux_ctx, struct osmux_batch);
|
||||||
if (batch == NULL)
|
if (batch == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
INIT_LLIST_HEAD(&batch->node_list);
|
INIT_LLIST_HEAD(&batch->node_list);
|
||||||
batch->remaining_bytes = OSMUX_BATCH_MAX;
|
batch->remaining_bytes = h->batch_size;
|
||||||
batch->timer.cb = osmux_batch_timer_expired;
|
batch->timer.cb = osmux_batch_timer_expired;
|
||||||
batch->timer.data = h;
|
batch->timer.data = h;
|
||||||
|
|
||||||
h->internal_data = (void *)batch;
|
h->internal_data = (void *)batch;
|
||||||
|
|
||||||
|
LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void osmux_xfrm_input_fini(struct osmux_in_handle *h)
|
void osmux_xfrm_input_fini(struct osmux_in_handle *h)
|
||||||
|
|
Loading…
Reference in New Issue