summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-07-29 12:46:09 +0300
committerTobias Klauser <tklauser@distanz.ch>2017-08-10 09:03:46 +0200
commit439af62bca4794d78d53fb4634f560d6a75f0adb (patch)
tree346cc168c42bbe1d7f0eb6bd493d244016172a01 /trafgen.c
parent19348cec323373d84674c1d2cf34315cbf47c80d (diff)
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 <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>
Diffstat (limited to 'trafgen.c')
-rw-r--r--trafgen.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/trafgen.c b/trafgen.c
index 97ac046..9b54399 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -185,31 +185,31 @@ static void __noreturn help(void)
puts("http://www.netsniff-ng.org\n\n"
"Usage: trafgen [options] [packet]\n"
"Options:\n"
- " -i|-c|--in|--conf <cfg/-> Packet configuration file/stdin\n"
- " -o|-d|--out|--dev <netdev> Networking device i.e., eth0\n"
- " -p|--cpp Run packet config through C preprocessor\n"
- " -D|--define Add macro/define for C preprocessor\n"
- " -J|--jumbo-support Support 64KB super jumbo frames (def: 2048B)\n"
- " -R|--rfraw Inject raw 802.11 frames\n"
- " -s|--smoke-test <ipv4> Probe if machine survived fuzz-tested packet\n"
- " -n|--num <uint> Number of packets until exit (def: 0)\n"
- " -r|--rand Randomize packet selection (def: round robin)\n"
- " -P|--cpus <uint> Specify number of forks(<= CPUs) (def: #CPUs)\n"
- " -t|--gap <time> Set approx. interpacket gap (s/ms/us/ns, def: us)\n"
- " -b|--rate <rate> Send traffic at specified rate (pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n"
- " -S|--ring-size <size> Manually set mmap size (KiB/MiB/GiB)\n"
- " -E|--seed <uint> Manually set srand(3) seed\n"
- " -u|--user <userid> Drop privileges and change to userid\n"
- " -g|--group <groupid> Drop privileges and change to groupid\n"
- " -H|--prio-high Make this high priority process\n"
- " -A|--no-sock-mem Don't tune core socket memory\n"
- " -Q|--notouch-irq Do not touch IRQ CPU affinity of NIC\n"
- " -q|--qdisc-path Enable qdisc kernel path (default off since 3.14)\n"
- " -V|--verbose Be more verbose\n"
- " -C|--no-cpu-stats Do not print CPU time statistics on exit\n"
- " -v|--version Show version and exit\n"
- " -e|--example Show built-in packet config example\n"
- " -h|--help Guess what?!\n\n"
+ " -i|-c|--in|--conf <cfg/-> Packet configuration file/stdin\n"
+ " -o|-d|--out|--dev <netdev|.cfg|.pcap> Networking device or configuration file i.e., eth0\n"
+ " -p|--cpp Run packet config through C preprocessor\n"
+ " -D|--define Add macro/define for C preprocessor\n"
+ " -J|--jumbo-support Support 64KB super jumbo frames (def: 2048B)\n"
+ " -R|--rfraw Inject raw 802.11 frames\n"
+ " -s|--smoke-test <ipv4> Probe if machine survived fuzz-tested packet\n"
+ " -n|--num <uint> Number of packets until exit (def: 0)\n"
+ " -r|--rand Randomize packet selection (def: round robin)\n"
+ " -P|--cpus <uint> Specify number of forks(<= CPUs) (def: #CPUs)\n"
+ " -t|--gap <time> Set approx. interpacket gap (s/ms/us/ns, def: us)\n"
+ " -b|--rate <rate> Send traffic at specified rate (pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n"
+ " -S|--ring-size <size> Manually set mmap size (KiB/MiB/GiB)\n"
+ " -E|--seed <uint> Manually set srand(3) seed\n"
+ " -u|--user <userid> Drop privileges and change to userid\n"
+ " -g|--group <groupid> Drop privileges and change to groupid\n"
+ " -H|--prio-high Make this high priority process\n"
+ " -A|--no-sock-mem Don't tune core socket memory\n"
+ " -Q|--notouch-irq Do not touch IRQ CPU affinity of NIC\n"
+ " -q|--qdisc-path Enable qdisc kernel path (default off since 3.14)\n"
+ " -V|--verbose Be more verbose\n"
+ " -C|--no-cpu-stats Do not print CPU time statistics on exit\n"
+ " -v|--version Show version and exit\n"
+ " -e|--example Show built-in packet config example\n"
+ " -h|--help Guess what?!\n\n"
"Examples:\n"
" trafgen --dev eth0 --conf trafgen.cfg\n"
" trafgen -e | trafgen -i - -o eth0 --cpp -n 1\n"
@@ -1284,8 +1284,8 @@ int main(int argc, char **argv)
protos_init(ctx.dev_out);
- if (shaper_is_set(&ctx.sh) || (ctx.dev_in && dev_io_is_pcap(ctx.dev_in))
- || dev_io_is_pcap(ctx.dev_out)) {
+ if (shaper_is_set(&ctx.sh) || (ctx.dev_in && !dev_io_is_netdev(ctx.dev_in))
+ || !dev_io_is_netdev(ctx.dev_out)) {
prctl(PR_SET_TIMERSLACK, 1UL);
/* Fall back to single core to not mess up correct timing.