pespin has uploaded this change for review.

View Change

osmux: Allow specifying extra headroom & tailroom in generated rtp msgb

This is useful for users of the API whic need to keep forwarding the
msgb to lower layers which may need prepending a new header to the msgb,
like osmo-bts with l1sap.

Related: OS#5987
Change-Id: I632654221826340423e1e97b0f8ed9a2baf6c6c3
---
M include/osmocom/netif/osmux.h
M src/osmux.c
2 files changed, 16 insertions(+), 4 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/60/29260/1
diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index 8742797..7b561fe 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -86,6 +86,8 @@
struct llist_head list;
void (*tx_cb)(struct msgb *msg, void *data); /* Used defined rtp tx callback */
void *data; /* User defined opaque data structure */
+ unsigned int rtp_msgb_headroom;
+ unsigned int rtp_msgb_tailroom;
};

static inline uint8_t *osmux_get_payload(struct osmux_hdr *osmuxh)
@@ -112,6 +114,7 @@
void osmux_xfrm_output_init2(struct osmux_out_handle *h, uint32_t rtp_ssrc, uint8_t rtp_payload_type) OSMO_DEPRECATED("Use osmux_xfrm_output_alloc() and osmux_xfrm_output_set_rtp_*() instead");
void osmux_xfrm_output_set_rtp_ssrc(struct osmux_out_handle *h, uint32_t rtp_ssrc);
void osmux_xfrm_output_set_rtp_pl_type(struct osmux_out_handle *h, uint32_t rtp_payload_type);
+void osmux_xfrm_output_set_rtp_msgb_extra_room(struct osmux_out_handle *h, unsigned int headroom, unsigned int tailroom);
void osmux_xfrm_output_set_tx_cb(struct osmux_out_handle *h, void (*tx_cb)(struct msgb *msg, void *data), void *data);
int osmux_xfrm_output_sched(struct osmux_out_handle *h, struct osmux_hdr *osmuxh);
void osmux_xfrm_output_flush(struct osmux_out_handle *h);
diff --git a/src/osmux.c b/src/osmux.c
index 49cc368..7f0bca3 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -128,10 +128,13 @@
struct amr_hdr *amrh;
struct timespec delta = { .tv_sec = 0, .tv_nsec = DELTA_RTP_MSG*1000 };

- out_msg = msgb_alloc(sizeof(struct rtp_hdr) +
- sizeof(struct amr_hdr) +
- osmo_amr_bytes(osmuxh->amr_ft),
- "OSMUX test");
+ out_msg = msgb_alloc_headroom(h->rtp_msgb_headroom +
+ sizeof(struct rtp_hdr) +
+ sizeof(struct amr_hdr) +
+ osmo_amr_bytes(osmuxh->amr_ft) +
+ h->rtp_msgb_tailroom,
+ h->rtp_msgb_headroom,
+ "osmux-rtp");
if (out_msg == NULL)
return NULL;

@@ -934,6 +937,12 @@
h->rtp_payload_type = rtp_payload_type;
}

+void osmux_xfrm_output_set_rtp_msgb_extra_room(struct osmux_out_handle *h, unsigned int headroom, unsigned int tailroom)
+{
+ h->rtp_msgb_headroom = headroom;
+ h->rtp_msgb_tailroom = tailroom;
+}
+
#define SNPRINTF_BUFFER_SIZE(ret, remain, offset) \
if (ret < 0) \
ret = 0; \

To view, visit change 29260. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I632654221826340423e1e97b0f8ed9a2baf6c6c3
Gerrit-Change-Number: 29260
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange