diff options
author | Pablo Neira Ayuso <pablo@soleta.eu> | 2014-08-28 15:01:03 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@soleta.eu> | 2014-08-28 15:01:03 +0200 |
commit | d8947e37b09d4762161229324ad2bd35309b4d13 (patch) | |
tree | 18fb60ba8b74de6c661e3ca2f6ff0729ea5394ad /src/osmux.c | |
parent | 0b44016ef66788795dab051f4c9408cbc79d4978 (diff) |
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.
Diffstat (limited to 'src/osmux.c')
-rw-r--r-- | src/osmux.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/osmux.c b/src/osmux.c index 9288464..3705698 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -25,7 +25,7 @@ #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 /* 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"); - batch_msg = msgb_alloc(OSMUX_BATCH_MAX, "OSMUX"); + batch_msg = msgb_alloc(h->batch_size, "osmux"); if (batch_msg == NULL) { LOGP(DLMIB, LOGL_ERROR, "Not enough memory\n"); return NULL; @@ -326,7 +326,7 @@ void osmux_xfrm_input_deliver(struct osmux_in_handle *h) batch_msg = osmux_build_batch(h); h->deliver(batch_msg, h->data); 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) @@ -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 * 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; rtph = osmo_rtp_get_hdr(msg); @@ -549,18 +549,22 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h) { 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); if (batch == NULL) return; 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.data = h; h->internal_data = (void *)batch; + + LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n"); } void osmux_xfrm_input_fini(struct osmux_in_handle *h) |