Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3063

to look at the new patch set (#2).

tests: osmo-pcap: Fix per packet timer

Before this commit, the gap time between 2 packets {n-1, n} was being
applied to {n, n+1}.

Change-Id: I715865c1edd1fc2ec9b024671d91eb72559cbdea
---
M tests/osmo-pcap-test/osmo_pcap.h
M tests/osmo-pcap-test/pcap.c
2 files changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/63/3063/2

diff --git a/tests/osmo-pcap-test/osmo_pcap.h b/tests/osmo-pcap-test/osmo_pcap.h
index cff638b..171360d 100644
--- a/tests/osmo-pcap-test/osmo_pcap.h
+++ b/tests/osmo-pcap-test/osmo_pcap.h
@@ -12,6 +12,7 @@
        pcap_t                  *h;
        struct osmo_timer_list  timer;
        struct timeval          last;
+       struct msgb             *deliver_msg;
 };
 
 pcap_t *osmo_pcap_test_open(const char *pcapfile);
diff --git a/tests/osmo-pcap-test/pcap.c b/tests/osmo-pcap-test/pcap.c
index 8fa8e0f..61408f8 100644
--- a/tests/osmo-pcap-test/pcap.c
+++ b/tests/osmo-pcap-test/pcap.c
@@ -39,7 +39,8 @@
 } osmo_pcap_test_stats;
 
 static int
-osmo_pcap_process_packet(const uint8_t *pkt, uint32_t pktlen,
+osmo_pcap_process_packet(struct msgb **msgptr,
+                        const uint8_t *pkt, uint32_t pktlen,
                         struct osmo_pcap_proto_l2l3 *l3h,
                         struct osmo_pcap_proto_l4 *l4h,
                         int (*cb)(struct msgb *msgb))
@@ -56,7 +57,7 @@
        /* This packet contains no data, skip it. */
        if (l4h->l4pkt_no_data(pkt + l3hdr_len + ETH_HLEN)) {
                osmo_pcap_test_stats.skip++;
-               return 0;
+               return -1;
        }
 
        /* get application layer data. */
@@ -72,11 +73,9 @@
        memcpy(msgb->data, pkt, pktlen);
        msgb_put(msgb, pktlen);
 
-       ret = cb(msgb);
+       *msgptr = msgb;
 
-       osmo_pcap_test_stats.processed++;
-
-       return ret;
+       return 0;
 }
 
 pcap_t *osmo_pcap_test_open(const char *pcapfile)
@@ -109,6 +108,12 @@
        struct timeval res;
        uint8_t l4protonum;
 
+       if (p->deliver_msg) {
+               if (cb(p->deliver_msg) == 0)
+                       osmo_pcap_test_stats.processed++;
+               p->deliver_msg = 0;
+       }
+
 retry:
        pkt = pcap_next(p->h, &pcaph);
        if (pkt == NULL)
@@ -140,7 +145,7 @@
                memcpy(&p->last, &pcaph.ts, sizeof(struct timeval));
 
        /* retry with next packet if this has been skipped. */
-       if (osmo_pcap_process_packet(pkt, pcaph.caplen, l3h, l4h, cb) < 0)
+       if (osmo_pcap_process_packet(&p->deliver_msg, pkt, pcaph.caplen, l3h, 
l4h, cb) < 0)
                goto retry;
 
        /* calculate waiting time */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I715865c1edd1fc2ec9b024671d91eb72559cbdea
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to