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.
12 local context state line
15 _cpus
=(${${(f)"$(grep processor /proc/cpuinfo | awk '{print $3}')"}})
20 user_info=(${${(f)"$(awk -F':' '{print $3":"$1}' /etc
/passwd
)"}})
21 _describe -t usr "user info
" user_info && ret=0
25 group_info=(${${(f)"$(awk -F':' '{print $4":"$1}' /etc/passwd)"}})
26 _describe
-t usr
"group info" group_info
&& ret
=0
30 _wanted interfaces expl
'network interface' \
32 _values
"Pseudo-device that captures on all interfaces" "any"
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 "(-J --jumbo-support)"{-J,--jumbo-support}"[Support 64KB super jumbo frames (def: 2048B)]" \
40 "(-R --rfraw)"{-R,--rfraw}"[Inject raw 802.11 frames]" \
41 "(-s --smoke-test)"{-s,--smoke-test}"[Probe if machine survived fuzz-tested packet]" \
42 "(-n --num)"{-n,--num}"[Number of packets until exit (def: 0)]" \
43 "(-r --rand)"{-r,--rand}"[Randomize packet selection (def: round robin)]" \
44 "(-P --cpus)"{-P,--cpus}"[Specify number of forks(<= CPUs) (def: #CPUs)]:cpunum:_cpu" \
45 "(-t --gap)"{-t,--gap}"[Set approx. interpacket gap (s/ms/us/ns, def: us)]:gap:"
46 "(-S --ring-size)"{-S,--ring-size}"[Manually set mmap size (KiB/MiB/GiB)]:ringsize:" \
47 "(-E --seed)"{-E,--seed}"[Manually set srand(3) seed]" \
48 "(-u --user)"{-u,--user}"[Drop privileges and change to userid]:user:_user_info" \
49 "(-g --group)"{-g,--group}"[Drop privileges and change to groupid]:group:_group_info" \
50 "(-H --prio-high)"{-H,--prio-high}"[Make this high priority process]" \
51 "(-A --no-sock-mem)"{-A,--no-sock-mem}"[Do not change default socket memory setting]" \
52 "(-Q --notouch-irq)"{-Q,--notouch-irq}"[Do not touch IRQ CPU affinity of NIC]" \
53 "(-e --example)"{-e,--example}"[Show built-in packet config example]:" \
54 "(-V --verbose)"{-V,--verbose}"[Be more verbose]" \
55 "(-C --no-cpu-stats)"{-C,--no-cpu-stats}"[Do not print CPU time statistics on exit]" \
56 {-v,--version}"[Show version and exit]:" \
57 {-h,--help}"[Guess what?!]:" \
58 "*::args:_gnu_generic"