summaryrefslogtreecommitdiff
path: root/trafgen_dev.h
AgeCommit message (Collapse)AuthorFilesLines
2017-09-15trafgen: fix packet socket initialization with multiple CPUsPaolo Abeni1-1/+3
The commit 78c13b71e196 ("trafgen: Allow to generate packets to output pcap file") introduced a regression when output is a network device and multiple CPU are in use: the packet socket is created before fork() and thus the socket is shared among all the processes: all of them except the first will fail while setting the tx_ring. Fix it splitting the io open() helper in a create() op, called before forking, and the open() op called by each process. Fixes: 78c13b71e196 ("trafgen: Allow to generate packets to output pcap file") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-08-10trafgen: Dump proto headers in *.cfg formatVadim Kochan1-2/+2
Added trafgen_dump.c module which dumps headers from packet in .cfg format. Packet is dumped if -o <file>.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 <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-08-10trafgen: dev_io: Change read/write to specify struct packet *Vadim Kochan1-5/+7
Refactor dev_io_ops read & write to specify struct packet *, it may simplify a bit a caller logic. And it allow to keep required members within one struct packet object. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-17trafgen: Delegate creation of rfraw to dev_io APIVadim Kochan1-1/+3
Simplify a bit of creation rfraw device by delegating it to the dev_io API, also in case the output device is pcap file the --rfraw option sets the link type to ieee80211 radio tap. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-06-09trafgen: Allow to generate packets to output pcap fileVadim Kochan1-0/+49
Add trafgen_dev.c module which provides generic way of reading and writing packets to/from networking device or a pcap file. Also allow to handle output pcap file via '-o, --out, --dev' option. It might be useful in future for testing some link protocols which is not easy to capture (e.g. wlan packets) w/o having some special setup. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tklauser: fix whitespace issues] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>