aboutsummaryrefslogtreecommitdiffstats
path: root/tests/osmo-pcap-test/l4_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/osmo-pcap-test/l4_udp.c')
-rw-r--r--tests/osmo-pcap-test/l4_udp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/osmo-pcap-test/l4_udp.c b/tests/osmo-pcap-test/l4_udp.c
new file mode 100644
index 0000000..0a4266e
--- /dev/null
+++ b/tests/osmo-pcap-test/l4_udp.c
@@ -0,0 +1,38 @@
+/*
+ * (C) 2012 by Pablo Neira Ayuso <pablo@gnumonks.org>
+ * (C) 2012 by On Waves ehf <http://www.on-waves.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later vers
+ */
+
+#include <netinet/ip.h>
+#include <netinet/udp.h>
+
+#include "proto.h"
+
+static int l4_udp_pkt_hdr_len(const uint8_t *pkt)
+{
+ const struct udphdr *udph = (const struct udphdr *)pkt;
+
+ return ntohs(udph->len);
+}
+
+static int l4_udp_pkt_no_data(const uint8_t *pkt)
+{
+ /* UDP has no control packets. */
+ return 0;
+}
+
+static struct osmo_pcap_proto_l4 udp = {
+ .l4protonum = IPPROTO_UDP,
+ .l4pkt_hdr_len = l4_udp_pkt_hdr_len,
+ .l4pkt_no_data = l4_udp_pkt_no_data,
+};
+
+void l4_udp_init(void)
+{
+ osmo_pcap_proto_l4_register(&udp);
+}