aboutsummaryrefslogtreecommitdiffstats
path: root/tests/osmo-pcap-test/proto.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2012-06-28 12:53:45 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-06-28 16:42:22 +0200
commit75755dd7d948992d6c5d05f298559f01b511607d (patch)
treefa6276508c9ef6f1c8e5a16238b6d2149b3e9a52 /tests/osmo-pcap-test/proto.h
parent729a0917ac17e2c5a70ab24cc884ff68a7df52af (diff)
test: add osmo-pcap-test infrastructure
This patch adds the osmo-pcap-test infrastructure that allows you to take packets stored in one pcap file, convert them to msgb and pass it to some function. The infrastructure also provides timing reconstruction based on the pcap file information. This is useful for easy protocol development, automated testing and fuzzying of the existing code to validate the code. Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
Diffstat (limited to 'tests/osmo-pcap-test/proto.h')
-rw-r--r--tests/osmo-pcap-test/proto.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/osmo-pcap-test/proto.h b/tests/osmo-pcap-test/proto.h
new file mode 100644
index 0000000..8cb41ed
--- /dev/null
+++ b/tests/osmo-pcap-test/proto.h
@@ -0,0 +1,40 @@
+#ifndef _OSMO_PCAP_PROTO_H_
+#define _OSMO_PCAP_PROTO_H_
+
+#include <stdint.h>
+
+#include <osmocom/core/linuxlist.h>
+
+struct osmo_pcap_proto_l4 {
+ struct llist_head head;
+
+ unsigned int l4protonum;
+
+ int (*l4pkt_hdr_len)(const uint8_t *pkt);
+ int (*l4pkt_no_data)(const uint8_t *pkt);
+};
+
+struct osmo_pcap_proto_l2l3 {
+ struct llist_head head;
+
+ unsigned int l2protonum;
+ unsigned int l2hdr_len;
+
+ unsigned int l3protonum;
+
+ int (*l3pkt_hdr_len)(const uint8_t *pkt);
+ int (*l4pkt_proto)(const uint8_t *pkt);
+};
+
+struct osmo_pcap_proto_l2l3 *osmo_pcap_proto_l2l3_find(const uint8_t *pkt);
+void osmo_pcap_proto_l2l3_register(struct osmo_pcap_proto_l2l3 *h);
+
+struct osmo_pcap_proto_l4 *osmo_pcap_proto_l4_find(const uint8_t *pkt, unsigned int l4protonum);
+void osmo_pcap_proto_l4_register(struct osmo_pcap_proto_l4 *h);
+
+/* Initialization of supported protocols here. */
+void l2l3_ipv4_init(void);
+void l4_tcp_init(void);
+void l4_udp_init(void);
+
+#endif