Age | Commit message (Collapse) | Author | Files | Lines |
|
Get rid of some unnecessary double spaces to make parsers rules look
consistent.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Commit 2ba202b introduced the [e]type field for specifiying the
Ethertype, but at the same time made the existing "prot[o]" field name
not work anymore. Fix it by providing a specific parser rule as it
cannot be solved in the lexer grammar alone (which will always use the
first matching token).
Fixes: 2ba202b ("trafgen: parser: Support "etype"/"type" keywords for Ethertype")
Reported-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
It's not changed inside the function, so mark it as const. Also adjust
the header guards.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add a function 'tcp()' to generate TCP headers from the trafgen
configuration language.
Fields supported:
sp|sport TCP source port (default 0)
dp|dport TCP destination port (default 0)
seq Sequence number (default: 0)
aseq|ackseq Acknowledgement number (default 0)
doff|hlen Header length/data offset (default: 5)
cwr Congestion Window Reduced flag (default: 0)
ece|ecn ECN-Echo flag (default: 0)
urg Urgent flag (default: 0)
ack Acknowledgement flag (default: 0)
psh Push flag (default: 0)
rst Reset flag (default: 0)
syn Synchronize flag (default: 0)
fin Finish flag (default: 0)
win|window Receive window size (default: 0)
csum Checksum field (calculated automatically)
urgptr Urgent pointer (default: 0)
Example (SYN on port 80/http):
{ tcp(dport=80, syn, window=5840) }
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Rename lexer/parser type and union member ip_addr to ip4_addr. This
will make it easier to distinguish from IPv6 addresses, to be added an a
follow-up patch.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
This fixes the following sparse warning:
trafgen_l2.c:13:20: warning: symbol 'eth_fields' was not declared. Should it be static?
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
The IEEE 802.3 standard commonly refers to the field specifying the
upper layer protocol as Ethertype, not protocol. Thus, also support the
keywords "etype" and "type" for this field.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Remove a duplicate '=' introduced by me when amending commit 0ae726d
("netsniff-ng: Use time of SIGHUP time when rotating files
prematurely").
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Use the timestamp of the SIGHUP in the file name when rotating file
prematurely instead of the file creation date, which might be delayed
depending on when the next packet arrives.
This should make it a bit easier to synchronize pcap files captures by
multiple instances of netsniff-ng on multiple interfaces.
Signed-off-by: Erik Bengtsson <e.bengtsson@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Include cpp.h for the prototype of cpp_exec() in order to fix the
following sparse warning:
cpp.c:18:5: warning: symbol 'cpp_exec' was not declared. Should it be static?
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
s/packet packet/packet/
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add description (basic syntax, proto header fields) for newer added
proto headers:
Ethernet, ARP, IPv4, UDP.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: reworded and reformatted a few parts]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add function 'udp()' to generate UDP header.
Fields supported:
sp|sport UDP source port (default 0)
dp|dport UDP destination port (default 0)
len|length Length of UDP header + payload (calculated automatically)
csum Checksum field (calculated automatically)
Example (Echo request):
{ udp(dport=7) }
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add trafgen_l4.c module with generation UDP header fields.
UDP protocol generation logic automaticaly sets the protocol field of
the lower level protocol to IPPROTO_UDP by default (if it is IPv4).
Also checksum & length are calculated and set if it is not given by the
user.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add 'ip4(), ipv4()' function to build IPv4 header.
Fields supported:
ihl IPv4 header length (default 5 )
ver|version IPv4 version (default 4)
ttl Time To Live (TTL) field (default 0)
dscp DiffServ field (default 0)
ecn ECN bits (default 0)
tos TOS (DSCP + ECN) field (default 0)
len|length IPv4 header + payload length (calculated by default)
id Identifier (default 0)
flags Flags field (default 0)
frag Fragment offset (default 0)
csum IPv4 header checksum (calculated by default)
df Set DF (Dont Fragment) bit to 1 (default is 0)
mf Set MF (More Fragments) bit to 1 (default is 0)
sa|saddr IPv4 source address (default used from output device)
da|daddr IPv4 destination address (default 0.0.0.0)
proto IPv4 protocol id (default 0)
Example:
{ ip4(df, mf, frag=100, prot=0x1, ecn=2, dscp=20) }
{ ip4(da=1.1.1.1), ip4(sa=3.3.3.3, da=3.3.3.4) }
Last example generates IP-in-IP packet.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add L3 module for implement L3 layer protocols generation.
Implemented setting of IPv4 header with all fields except options.
By default IPv4 address of output device is used as src ip address.
On finish (after packet is specified) - total len & checksum are calculated.
Meanwhile Ethernet protocol is initialized as default lower header.
If the lower protocol is IPv4 then IPv4 protocol id is set
to IP-in-IP in lower protocol header.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add function 'arp()' to support generating ARP header fields from
the trafgen configuration language.
Supported fields:
htype hardware type, default: 1 (Ethernet)
ptype protocol type, default: 0x0800 (IP)
op|oper operation (req|request, reply, <num>), default: 1 (request)
sha|smac sender MAC address, default: device MAC
spa|sip sender IP address, default: device IP
tha|tmac target MAC address, default: 00:00:00:00:00:00
tpa|tip target IP address, default: 0.0.0.0
Note: setting hlen and tlen is not supported, these will by set to
hlen=6 and plen=4 in any case.
Example usage:
{ arp(op=request, sip=1.1.1.1, smac=11:22:33:44:55:66, tip=42.42.42.42) }
{ arp() }
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: document keywords in commit message]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add ARP protocol header fields generation. By default htype ethernet (1)
and ptype IPv4 (0x0800) and the corresponding hlen/plen values will be
initialized and the opcode is set to ARP Request (1).
Source MAC and IP address are set to the device's addresses if not
specified.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: rephrase and extend commit message]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add helper which fills a device's ipv4 addr to the specified protocol field.
It will be used by protocols like ARP, IPv4, etc.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add function 'eth()' to support generating Ethernet header fields from the
trafgen configuration language.
Supported fields:
da|daddr destination address, default: 00:00:00:00:00:00
sa|saddr source address, default: device MAC
prot|proto protocol number, default: 0x0000
Example usage:
{ eth(prot=0x0800, da=11:22:33:44:55:66), fill(0xff, 60) }
{ eth(prot=0x0800) }
{ eth() }
It is important that proto_init is called before fields will be filled
to initialize the specified proto with header fields.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: document supported keywords in commit message]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add function to convert a string in the format xx:xx:xx:xx:xx:xx to a
MAC address byte array.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: Add len parameter and error out on too short buffers]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add trafgen_l2.c module for generating L2 related headers.
Add Ethernet header generating. By default source MAC address
is used from the specified output device.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add helper function to set device's MAC address to protocol field which may
be used by Ethernet & ARP protocol header generation functions.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Add device_hw_address() function to get device MAC address.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: Add len parameter and error out on too short buffers]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Show 'Active' filter status if 'a' was pressed.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
Show family name in the filter status line.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|
|
Pass argv as char *const argv[] as execvp expects it.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
|
|
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>
|
|
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>
|