aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-08-06 20:15:46 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-08-06 21:04:25 +0200
commit72a0aae500de36ef3fa528a9ce2e32a8ddde5080 (patch)
tree295a512f9809226398b65241e3fc72392ee46530
parentb9cf903bbe0cd9b84a1226c345e68f0e826034e9 (diff)
osmux: support two concurrent calls in output path
-rw-r--r--include/osmocom/netif/osmux.h5
-rw-r--r--src/osmux.c20
-rw-r--r--tests/osmo-pcap-test/osmux_test.c6
3 files changed, 20 insertions, 11 deletions
diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index 58ec40d..dd89973 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -49,8 +49,8 @@ struct osmux_in_handle {
/* one per OSmux circuit_id, ie. one per RTP flow. */
struct osmux_out_handle {
- uint16_t rtp_seq;
- uint32_t rtp_timestamp;
+ uint16_t rtp_seq[8];
+ uint32_t rtp_timestamp[8];
};
static inline uint8_t *osmux_get_payload(struct osmux_hdr *osmuxh)
@@ -65,6 +65,7 @@ void osmux_xfrm_input_register_ccid(struct osmux_in_handle *h, uint32_t ssrc);
int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg);
void osmux_xfrm_input_deliver(struct osmux_in_handle *h);
+void osmux_xfrm_output_init(struct osmux_out_handle *h);
int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct llist_head *list);
struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg);
diff --git a/src/osmux.c b/src/osmux.c
index 508f01c..ad18c36 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -75,8 +75,8 @@ osmux_rebuild_rtp(struct osmux_out_handle *h,
rtph->version = RTP_VERSION;
rtph->payload_type = 98;
/* ... emulate timestamp and ssrc */
- rtph->timestamp = htonl(h->rtp_timestamp);
- rtph->sequence = htons(h->rtp_seq);
+ rtph->timestamp = htonl(h->rtp_timestamp[osmuxh->circuit_id]);
+ rtph->sequence = htons(h->rtp_seq[osmuxh->circuit_id]);
rtph->ssrc = htonl(ssrc_from_ccid);
msgb_put(out_msg, sizeof(struct rtp_hdr));
@@ -95,8 +95,8 @@ osmux_rebuild_rtp(struct osmux_out_handle *h,
msgb_put(out_msg, payload_len);
/* bump last RTP sequence number and timestamp that has been used */
- h->rtp_seq++;
- h->rtp_timestamp++;
+ h->rtp_seq[osmuxh->circuit_id]++;
+ h->rtp_timestamp[osmuxh->circuit_id]++;
osmo_rtp_snprintf(buf, sizeof(buf), out_msg);
LOGP(DOSMUX, LOGL_DEBUG, "%s\n", buf);
@@ -134,7 +134,7 @@ struct osmux_batch {
struct llist_head msgb_list;
unsigned int remaining_bytes;
uint8_t seq;
- int64_t ccid[8];
+ int64_t ccid[OSMUX_MAX_CONCURRENT_CALLS];
};
static int
@@ -507,3 +507,13 @@ int osmux_xfrm_input_get_ccid(struct osmux_in_handle *h, uint32_t ssrc)
return found ? i : -1;
}
+
+void osmux_xfrm_output_init(struct osmux_out_handle *h)
+{
+ int i;
+
+ for (i=0; i<8; i++) {
+ h->rtp_seq[i] = (uint16_t)random();
+ h->rtp_timestamp[i] = (uint32_t)random();
+ }
+}
diff --git a/tests/osmo-pcap-test/osmux_test.c b/tests/osmo-pcap-test/osmux_test.c
index 8dab1bf..541665a 100644
--- a/tests/osmo-pcap-test/osmux_test.c
+++ b/tests/osmo-pcap-test/osmux_test.c
@@ -35,10 +35,7 @@
* This is the output handle for osmux, it stores last RTP sequence and
* timestamp that has been used. There should be one per circuit ID.
*/
-static struct osmux_out_handle h_output = {
- .rtp_seq = 1000,
- .rtp_timestamp = 10,
-};
+static struct osmux_out_handle h_output;
static void tx_cb(struct msgb *msg, void *data)
{
@@ -154,6 +151,7 @@ int main(int argc, char *argv[])
osmo_pcap.timer.cb = osmo_pcap_pkt_timer_cb;
osmux_xfrm_input_init(&h_input);
+ osmux_xfrm_output_init(&h_output);
/* first run */
osmo_pcap_pkt_timer_cb(NULL);