summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-01-28trafgen: Add basic protocol generation logicVadim Kochan4-0/+427
Add new trafgen_proto.c module with basic protocol header fields generation logic. This will allow to support protocol specific keywords in the trafgen configuration language. Each protocol must implement struct proto_hdr and register it to the global proto list. Protocol headers consist of a set of fields, and each field must be described via struct proto_field by specifying unique id, length and offset (relative to the header start). Fields smaller than 8 bits can be described via left shift & mask. The following callbacks are invoked to perform special actions to build the header during parsing: 1) header_init - required fields must be added to the packet and initialized with default values. 2) header_finish - it is invoked when header is specified, all user specified fields are set. 3) packet_finish - callback is invoked from upper to lower header to calculate fields depending on upper layers such as total length or checksum. The protocol generation API provides convenience protocol field setters/getters to to be used in the parser while crafting the packet. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tk: wordsmithing on commit message, minor variable type changes] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-28trafgen: Add helper to get current packetVadim Kochan2-0/+7
Add current_packet() helper for getting current used packet and make it public to other modules. It will be used by proto generation logic. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-28trafgen: Export set_fill funcVadim Kochan2-1/+3
Make public set_fill func to be used by proto generation code. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-27netsniff-ng: Rename proto_vlan.h to vlan.hTobias Klauser3-9/+4
The proto_ prefix is reserved for dissectors and the header contains helper functions not exclusive to the proto_vlan dissector, so give it a more generic name. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-27ring: Make needlessly global function join_fanout_group() staticTobias Klauser1-1/+1
This fixes the following sparse warning: ring_rx.c:197:6: warning: symbol 'join_fanout_group' was not declared. Should it be static? Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-26dissectors: arp: Simplify arp_print_addrs()Tobias Klauser1-8/+3
Simplify the code in arp_print_addrs() a bit. This was actually intended as an amend to commit f6371fb6df91 ("dissectors: arp: Print hardware & protocol addresses"). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-26dissectors: arp: Print hardware & protocol addressesVadim Kochan1-0/+44
Print sender/target MAC and/or IPv4 address if htype is Ethernet and/or ptype is IPv4, respectively. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tk: minor simplifications of the code] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-21mausezahn: Fix reading of hex payload fileThomas Fleischmann1-2/+6
Using the option -F with mausezahn, to read input out of a hexfile, results in corrupt data transmitted (first byte will always be 0). Properly parse "payload="/p=" at the start of the file by the same method as used in layer3.c and layer4.c Closes #153 Reference: http://permalink.gmane.org/gmane.linux.network.netsniff-ng/600 Signed-off-by: Thomas Fleischmann <thomas.fleischmann.08@googlemail.com> Reported-by: Thomas De Schampheleire Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-14trafgen: Simplify ring size unit parsingVadim Kochan1-12/+7
Lets strtoul(...) func set pointer of unit name for ring size option, instead of check each character by isdigit(...). Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-14trafgen: Simplify 'gap' option unit parsingVadim Kochan1-8/+3
It is not needed to parse each character to find unit name in the option string but just let to do it via strtoul providing the pointer which will keep non numeric value. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-12trafgen: Move gap feature into shaper logicVadim Kochan1-28/+40
Move gap feature into rate shaper, as these features means the same - delay the packet sending. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-12flowtop: Use one nfct handle for dump & refresh flowsVadim Kochan1-13/+1
Simplify dump & flows refreshing via one nfct handle, which is enough. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-12flowtop: Use single function to update flow entryVadim Kochan1-51/+33
There is no need to have 2 separate handlers for the flow updating, so use the one which was used for flow refreshing. Significant change is that a new flow entry will be not added during update (i.e. on NFCT_T_UPDATE events) if it was not found in the list. But this case shoud never happen as there will always be an NFCT_T_NEW event before an NFCT_T_UPDATE event. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-05zsh: trafgen: Add completion for -b/--rateTobias Klauser1-0/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-05trafgen: Fix typo of kbit in usage and manpageTobias Klauser2-2/+2
Use 'kbit' instead of kBit in usage and manpage to actually reflect what trafgen expects. Fixes: 9ece0fe02096 ("trafgen: Add option to specify packets sending rate") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-05trafgen: Add option to specify packets sending rateVadim Kochan2-9/+135
Added -b,--rate option in units of: pps/B/kB/MB/kBit/Mbit/Gbit/KiB/MiB/GiB to specify rate at which packets will be sent. Similarly to -t,--gap option the packets will be sent in slow mode with 1 CPU. Tested with ifpps. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-27build: Use busybox compatible gzip command line optionTobias Klauser1-1/+1
gzip from busybox does not understand the '--best' command line option. Use '-9' instead which is understood by all gzip flavours (checked with GNU, BSD and busybox). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-21flowtop: Refresh flows if filter was changed while flows loadingVadim Kochan1-2/+2
Reset do_reload_flows flag before dump flows. It allows to change filter state more dynamically Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-21flowtop: Indicate if 'active' flows mode is selectedVadim Kochan1-0/+4
Show 'Active' filter status if 'a' was pressed. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-21flowtop: Show selected proto familyVadim Kochan1-9/+18
Show family name in the filter status line. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17zsh: trafgen: Add completion for -D/--defineTobias Klauser1-0/+1
Add zsh completion for -D/--define command line option added in commit 126e0038a73b ("trafgen: Added option to pass macro/define for C preprocessor") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17zsh: bpfc: Add completion for -D/--defineTobias Klauser1-0/+1
Add zsh completion for -D/--define command line option added in commit 121119215276 ("bpfc: Add option to pass macro/define for C preprocessor") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17cpp: Constify cpp argv passed to cpp_execTobias Klauser5-8/+8
Pass argv as char *const argv[] as execvp expects it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17trafgen: Added option to pass macro/define for C preprocessorVadim Kochan4-7/+24
Add -D,--define option which allows to pass multiple macro/defines which can be used in trafgen script (e.g. by #ifdef ). Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17bpfc: Add option to pass macro/define for C preprocessorVadim Kochan3-6/+20
Add -D,--define option to pass macro/define for C preprocessor (e.g. to use #ifdef's within bpf file). Option allows to pass multiple -D,--define options. Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-12-17str: Add helper to extend dynamically argv listVadim Kochan2-0/+22
Add argv_insert function to dynamically insert string into argv list. Also added argv_free func to easy free dynamically allocated argv list. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17cpp: Allow to pass additional cpp optionsVadim Kochan4-12/+33
Extend cpp_exec function with args parameter to specify additional cpp options (like -D). Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17cpp: Use new proc_exec function to invoke cppVadim Kochan2-5/+11
Replace 'system' call by proc_exec function from proc.c module. It allows to easy extend cpp invoking with additional options (like -D) in more secure way. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-17proc: Add function to execute process with argv listVadim Kochan2-0/+28
Add proc_exec function which executes given process with argv list via fork + execvp. It allows to replace 'system' call approach which is used for invoking cpp and securely extend it with additional options like -D. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-14astraceroute: Use proper type for ctx.sd_lenTobias Klauser1-1/+2
The sd_len member of struct ctx stores a copy of struct addrinfo member ai_addrlen which is of type socklen_t. Also it is used in a sendto() call which also expects a socklen_t. Adjust sd_len to be socklen_t too. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-12-14zsh: trafgen: Add missing backspaceTobias Klauser1-1/+1
The zsh completion of trafgen is missing a backspace after the -t/--gap option which leads to the completion not working correctly. Fix it. Signed-off-by: Tobias Klauser <tobias.klauser@zhinst.com>
2015-12-10build: misc: Adjust coverity scanner URLTobias Klauser1-4/+8
The URL and one form name for the coverity scanner changed, adjust our coverity target accordingly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-29AUTHORS: Add Reiner for his contributionTobias Klauser1-0/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-29build: Make the build reproducibleReiner Herrmann1-1/+1
Ensure a stable link order independent of the configured locale in order to make the build reproducible. Patch from Reiner Herrmann, submitted via the Debian Bug Tracker (#806547). Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806547 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-27netsniff-ng: nlmsg: Remove unnecessary empty linesTobias Klauser1-7/+0
Remove empty lines in switch/case after break in genl_print_ctrl_attrs to be consistent with coding style in the rest of the file. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-27netsniff-ng: nlmsg: Print genl ops & mcast groups attributesVadim Kochan1-14/+92
Dump Generic netlink ops & mcast groups nested attributes. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-25bpfc: Check yyin against NULL before calling fclose() on itTobias Klauser1-1/+1
Follow 3f2f363485d3 ("trafgen: Make sure yyin is set before close it") and check the yyin pointer against NULL before attempting to call fclose() with it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-25trafgen: Make sure yyin is set before close itVadim Kochan1-1/+1
In case if cpp failed then it is possible that trafgen may hang on closing uninitialized yyin. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24trafgen: Preprocess packets directly after compilingTobias Klauser1-4/+2
No need to duplicate the call to preprocess_packets(), just call it directly after compile_packets()/compile_packets_str(). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24trafgen: Fix error message if no packet configuration is givenTobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24cpp: Use /tmp folder for output filesVadim Kochan1-8/+5
There might be a case when input file is located in read-only directory and cpp fails when it tries to create output file there, so use /tmp folder for that as usually it should be writeable for any user. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24trafgen: Invoke C preprocessor from cpp.c moduleVadim Kochan2-12/+3
Use cpp_exec func to invoke C preprocesor. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24bpfc: Invoke C preprocessor from cpp.c moduleVadim Kochan2-12/+7
Use cpp_exec func from cpp.c module to invoke C preprocessor. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24cpp: Add cpp.c module to invoke C preprocessorVadim Kochan2-0/+33
Add cpp_exec func to invoke C preprocessor which allow to change the logic in one place only. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24flowtop: Add runtime commands to filter flows by protoVadim Kochan1-6/+65
Add U/T/I/D/S runtime commands (same like for command line) to filter flows by UDP/TCP/ICMP/DCCP/SCTP proto. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16AUTHORS: Add two new contributorsTobias Klauser1-0/+2
Add Ken-ichirou MATSUZAWA and Martin Hauke to the list of contributors. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16bpfc: Do not panic if bpf file is not validVadim Kochan1-4/+9
If bpf file is not valid then cpp generated file is not deleted because panic() func is invoked. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tk: Move exit label to the correct place] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16netsniff-ng: nlmsg: Check message length before dissect rtnlVadim Kochan1-0/+12
Do not print rtnl message if there is only nlmsg header, which is happen when dump all rtnl table. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16netsniff-ng: nlmsg: Rename attr_fmt to rta_fmtTobias Klauser1-38/+37
Rename attr_fmt to rta_fmt as it uses rtattr struct. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16netsniff-ng: nlmsg: Print generic netlink ctrl family infoVadim Kochan1-13/+158
Add dissection of basic Netlink Generic Controller family info. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>