Review at  https://gerrit.osmocom.org/7776

tests: jibuf_tool: Add OSMUX support

Change-Id: I0f02da0329e6739ff340d31113161bb520b1b760
---
M tests/jibuf/jibuf_tool.c
1 file changed, 42 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/76/7776/1

diff --git a/tests/jibuf/jibuf_tool.c b/tests/jibuf/jibuf_tool.c
index c2461ec..faa6e38 100644
--- a/tests/jibuf/jibuf_tool.c
+++ b/tests/jibuf/jibuf_tool.c
@@ -25,6 +25,7 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/netif/jibuf.h>
 #include <osmocom/netif/rtp.h>
+#include <osmocom/netif/osmux.h>
 
 #include "../osmo-pcap-test/osmo_pcap.h"
 
@@ -53,6 +54,7 @@
 static bool opt_test_rand;
 static bool opt_debug_human;
 static bool opt_debug_table;
+static bool opt_osmux;
 static char* opt_pcap_file;
 /* ----------------------------- */
 
@@ -102,6 +104,8 @@
 /* Used for test pcap: */
 static struct osmo_pcap osmo_pcap;
 static bool pcap_finished;
+static struct osmux_out_handle pcap_osmux_h;
+static struct llist_head osmux_list;
 /* ----------------------------- */
 
 static void sigalarm_handler(int foo)
@@ -304,7 +308,7 @@
        return cb->data;
 }
 
-void send_rtp_packet()
+void rand_send_rtp_packet()
 {
 
        struct rtp_pkt_info *pinfo;
@@ -362,7 +366,7 @@
        if (!packets_sent)
                gettimeofday(&last_generated, NULL);
 
-       send_rtp_packet();
+       rand_send_rtp_packet();
        packets_sent++;
 
        timeradd(&last_generated, &time_rate, &sched_ts);
@@ -395,9 +399,33 @@
        return 0;
 }
 
+void glue_cb(struct msgb *msg, void *data)
+{
+       pcap_generate_pkt_cb(msg);
+}
+
+int pcap_read_osmux(struct msgb *msg)
+{
+       struct osmux_hdr *osmuxh;
+
+       /* This code below belongs to the osmux receiver */
+       while((osmuxh = osmux_xfrm_output_pull(msg)) != NULL) {
+               osmux_xfrm_output(osmuxh, &pcap_osmux_h, &osmux_list);
+               osmux_tx_sched(&osmux_list, glue_cb, NULL);
+       }
+       msgb_free(msg);
+       return 0;
+}
+
 void pcap_pkt_timer_cb(void *data)
 {
-       if (osmo_pcap_test_run(&osmo_pcap, IPPROTO_UDP, pcap_generate_pkt_cb) < 
0) {
+       int (*mycb)(struct msgb *msgb);
+       if(opt_osmux)
+               mycb = pcap_read_osmux;
+       else
+               mycb = pcap_generate_pkt_cb;
+
+       if (osmo_pcap_test_run(&osmo_pcap, IPPROTO_UDP, mycb) < 0) {
                osmo_pcap_stats_printf();
                osmo_pcap_test_close(osmo_pcap.h);
                pcap_finished=true;
@@ -462,6 +490,11 @@
 
        osmo_pcap.timer.cb = pcap_pkt_timer_cb;
 
+       if(opt_osmux) {
+               INIT_LLIST_HEAD(&osmux_list);
+               osmux_xfrm_output_init(&pcap_osmux_h, 0);
+       }
+
        jb = osmo_jibuf_alloc(NULL);
        osmo_jibuf_set_dequeue_cb(jb, dequeue_cb, NULL);
        osmo_jibuf_set_min_delay(jb, 60);
@@ -480,10 +513,11 @@
 
 static void print_help(void)
 {
-       printf("jibuf_test [-r] [-p pcap] [-d] [-g]\n");
+       printf("jibuf_test [-r] [-p pcap] [-o] [-d] [-g]\n");
        printf(" -h Print this help message\n");
        printf(" -r Run test with randomly generated jitter\n");
        printf(" -p Run test with specified pcap file\n");
+       printf(" -o The pcap contains OSMUX packets isntead of RTP\n");
        printf(" -d Enable packet trace debug suitable for humans\n");
        printf(" -t Enable packet trace debug suitable for gnuplot\n");
 }
@@ -492,7 +526,7 @@
 {
        int opt;
 
-       while ((opt = getopt(argc, argv, "hdtrp:")) != -1) {
+       while ((opt = getopt(argc, argv, "hdtrop:")) != -1) {
                switch (opt) {
                case 'h':
                        print_help();
@@ -506,6 +540,9 @@
                case 'r':
                        opt_test_rand = true;
                        break;
+               case 'o':
+                       opt_osmux = true;
+                       break;
                case 'p':
                        opt_pcap_file = strdup(optarg);
                        break;

-- 
To view, visit https://gerrit.osmocom.org/7776
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f02da0329e6739ff340d31113161bb520b1b760
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to