From 75755dd7d948992d6c5d05f298559f01b511607d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 28 Jun 2012 12:53:45 +0200 Subject: 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 --- tests/osmo-pcap-test/proto.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/osmo-pcap-test/proto.h (limited to 'tests/osmo-pcap-test/proto.h') 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 + +#include + +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 -- cgit v1.2.3