trafgen: fix packet socket initialization with multiple CPUs
[netsniff-ng.git] / trafgen.zsh
blob5ab99fdefc5371dc2fc39428834bfb9aafa918e4
1 #compdef trafgen
3 # trafgen.zsh -- zsh completion function for trafgen
5 # Copyright (C) 2013 Hideo Hattori <hhatto.jp@gmail.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 as
9 # published by the Free Software Foundation.
11 typeset -A opt_args
12 local context state line
14 _cpu () {
15 _cpus=(${${(f)"$(grep processor /proc/cpuinfo | awk '{print $3}')"}})
16 compadd -a _cpus
19 _user_info () {
20 user_info=(${${(f)"$(awk -F':' '{print $3":"$1}' /etc/passwd)"}})
21 _describe -t usr "user info" user_info && ret=0
24 _group_info () {
25 group_info=(${${(f)"$(awk -F':' '{print $4":"$1}' /etc/passwd)"}})
26 _describe -t usr "group info" group_info && ret=0
29 _interfaces () {
30 _wanted interfaces expl 'network interface' \
31 _net_interfaces
32 _values "Pseudo-device that captures on all interfaces" "any"
35 _arguments -s -S \
36 "(-i -c --in --conf)"{-i,-c,--in,--conf}"[Packet configuration file/stdin]:input:_files" \
37 "(-o -d --out --dev)"{-o,-d,--out,--dev}"[Networking device i.e., eth0]:device:_interfaces" \
38 "(-p --cpp)"{-p,--cpp}"[Run packet config through C preprocessor]" \
39 "(-D --define)"{-D,--define}"[Add macro definition for the C preprocessor]::" \
40 "(-J --jumbo-support)"{-J,--jumbo-support}"[Support 64KB super jumbo frames (def: 2048B)]" \
41 "(-R --rfraw)"{-R,--rfraw}"[Inject raw 802.11 frames]" \
42 "(-s --smoke-test)"{-s,--smoke-test}"[Probe if machine survived fuzz-tested packet]" \
43 "(-n --num)"{-n,--num}"[Number of packets until exit (def: 0)]" \
44 "(-r --rand)"{-r,--rand}"[Randomize packet selection (def: round robin)]" \
45 "(-P --cpus)"{-P,--cpus}"[Specify number of forks(<= CPUs) (def: #CPUs)]:cpunum:_cpu" \
46 "(-t --gap)"{-t,--gap}"[Set approx. interpacket gap (s/ms/us/ns, def: us)]:gap:" \
47 "(-b --rate)"(-b,--rate)"[Send traffic at specified rate (pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB):rate:" \
48 "(-S --ring-size)"{-S,--ring-size}"[Manually set mmap size (KiB/MiB/GiB)]:ringsize:" \
49 "(-E --seed)"{-E,--seed}"[Manually set srand(3) seed]" \
50 "(-u --user)"{-u,--user}"[Drop privileges and change to userid]:user:_user_info" \
51 "(-g --group)"{-g,--group}"[Drop privileges and change to groupid]:group:_group_info" \
52 "(-H --prio-high)"{-H,--prio-high}"[Make this high priority process]" \
53 "(-A --no-sock-mem)"{-A,--no-sock-mem}"[Do not change default socket memory setting]" \
54 "(-Q --notouch-irq)"{-Q,--notouch-irq}"[Do not touch IRQ CPU affinity of NIC]" \
55 "(-q --qdisc-path)"{-q,--qdisc-path}"[Enable qdisc kernel path (default off since 3.14)]" \
56 "(-e --example)"{-e,--example}"[Show built-in packet config example]:" \
57 "(-V --verbose)"{-V,--verbose}"[Be more verbose]" \
58 "(-C --no-cpu-stats)"{-C,--no-cpu-stats}"[Do not print CPU time statistics on exit]" \
59 {-v,--version}"[Show version and exit]:" \
60 {-h,--help}"[Guess what?!]:" \
61 "*::args:_gnu_generic"