aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@soleta.eu>2014-08-28 15:01:03 +0200
committerPablo Neira Ayuso <pablo@soleta.eu>2014-08-28 15:01:03 +0200
commitd8947e37b09d4762161229324ad2bd35309b4d13 (patch)
tree18fb60ba8b74de6c661e3ca2f6ff0729ea5394ad
parent0b44016ef66788795dab051f4c9408cbc79d4978 (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.
-rw-r--r--include/osmocom/netif/osmux.h1
-rw-r--r--src/osmux.c16
2 files changed, 11 insertions, 6 deletions
diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index 4754089..2ee845c 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -44,6 +44,7 @@ struct osmux_hdr {
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 */
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)