From 439af62bca4794d78d53fb4634f560d6a75f0adb Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sat, 29 Jul 2017 12:46:09 +0300 Subject: trafgen: Dump proto headers in *.cfg format Added trafgen_dump.c module which dumps headers from packet in .cfg format. Packet is dumped if -o .cfg was specified, it might be useful to specify *.pcap file as input and convert it into .cfg file to edit proto fields in human readable format. To make it possible several main changes were added: 1) packet id is embedded into struct packet.id, and it is updated on each realloc_packet() 2) Added new struct proto_hdr.get_next_proto callback to make possible apply fields of next header. 3) Added new dev_io ops for writting packets into .cfg file, to re-use common dev_io mechsnism for packets dumping. Before dump the default ETH_PROTO fields are applied as first header and then next proto_hdr is identified via .get_next_proto(...) callback. Meanwhile only eth, arp, vlan, ip4, udp, & tcp protos can be dissected into *.cfg format. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- trafgen_parser.y | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'trafgen_parser.y') diff --git a/trafgen_parser.y b/trafgen_parser.y index 74015b5..38f170a 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -169,6 +169,8 @@ static inline void __setup_new_csum16(struct csum16 *s, off_t from, off_t to, struct packet *realloc_packet(void) { + uint32_t i; + if (test_ignore()) return NULL; @@ -185,6 +187,9 @@ struct packet *realloc_packet(void) __init_new_csum_slot(&packet_dyn[packetd_last]); __init_new_fields_slot(&packet_dyn[packetd_last]); + for (i = 0; i < plen; i++) + packets[i].id = i; + return &packets[packet_last]; } -- cgit v1.2.3-54-g00ecf