summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-03-22netsniff-ng v0.6.1v0.6.1Tobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-23trafgen: man: Add description for 'mpls()' functionVadim Kochan1-2/+27
Add syntax & fields description for 'mpls()' function, also: 1) add line break for VLAN header notes 2) fix ip -> ipv4 in UDP echo example 3) consistent spelling of EtherType Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-23trafgen: parser: Add syntax for MPLS header creatingVadim Kochan2-1/+40
Add 'mpls()' function for creating MPLS header with parameters: lbl|label MPLS label last Indicates the last label on MPLS stack tc|tclass|exp Traffic Class (TC) ttl TTL (Time To Live) Currently only unicast MPLS is supported, but multicast might be set via 'eth()' function. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-23trafgen: l2: Add MPLS header generationVadim Kochan3-0/+40
Add support for MPLS header creating with fields: Label, TClass, Bottom-Stack, TTL By default S-field is set to 1 (last label), but resets to 0 if lower MPLS header is added. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-23trafgen: proto: Fix bad field maskingVadim Kochan1-4/+20
Current logic does OR of existing field value & shift-masked specified value, which is not enough as 0s bits from the specified value will be not set (be cause of OR), so fixed it by reseting original field value by AND with reverted field mask, in otherwords - bits part of original field value is reset to 0s and only after OR-ed with specified shift-masked value. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-03built_in: Include stddef.h to avoid redefinition of offsetof() macroTobias Klauser1-1/+2
The stddef.h header might define the offsetof() macro unconditionally, leading to the macro being redefined if built_in.h is included _before_ stddef.h. This will lead sparse to complain as follows: /usr/lib/gcc/x86_64-linux-gnu/4.8//include/stddef.h:413:9: warning: preprocessor token offsetof redefined ./built_in.h:151:10: this was the original definition Fix this by explicitly including stddef.h in built_in.h Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-03trafgen: proto: Make proto_current_header() staticTobias Klauser2-2/+1
After commit 88b359d2aa7e ("trafgen: proto: Simplify getting lower protocol after init") proto_current_header() is no longer used outside trafgen_proto.c, so make it static. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: man: Add help for VLAN header functionVadim Kochan1-0/+29
Add usage, syntax & parameters description for 'vlan()' function. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: parser: Add syntax for VLAN header creatingVadim Kochan2-0/+49
Add 'vlan()' function to generate VLAN header. Fields supported: tpid|proto Set TPID (Tag Protocol Identifier) (default 0x8100) 1ad Set TPID field as 0x88a8 1q Set TPID field as 0x8100 tci Set TCI (Tag Control Information) (default 0) pcp Set PCP (Priority Code Point) (PCP) (default 0) dei|cfi Set DEI (Drop Eligible Indicator) (default 0) id Set VID (VLAN Identifier) (default 0) Examples: { eth(), vlan(id=1), ipv4() } { vlan(id=1, 1ad), vlan(id=100, pcp=3), ipv4() } Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: l2: Add VLAN header generationVadim Kochan3-11/+65
Add generation of VLAN header with supported fields: TPID, DEI/CFI, PCP, VID Changed struct proto_field.offset uint16_t -> int16_t to make TPID offset -2 to point to ether type. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: ipv4: Add setting next protocol idVadim Kochan2-20/+26
Move setting lower protocol id field value from UDP & TCP protocols to IPv4 only, so lower layer will know exactly value to set in protocol id field. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: eth: Add setting next protocol idVadim Kochan2-4/+24
Move setting next protocol id field from higher protocols (ARP, IPv4) to Ethernet. It makes code little more generic w/o checking each lower protocol and setting specific field id. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: proto: Add set_next_proto callback to struct proto_hdrVadim Kochan5-9/+20
Add set_next_proto callback to proto_hdr struct to allow lower protocol set next protocol id by enum proto_id. Extended proto_lower_default_add(...) function to take upper protocol to delegate it's id to lower protocol to set next protocol field. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trafgen: proto: Simplify getting lower protocol after initVadim Kochan6-19/+16
Change proto_header_init(...) and proto_lower_default_add(...) functions to return struct proto_hdr * to do not call proto_current_header(...) after, so it makes more sense to get struct proto_hdr * right after initializing protocol by id. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-02trivial: trafgen: parser: Fix spacingTobias Klauser1-11/+11
Get rid of some unnecessary double spaces to make parsers rules look consistent. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-01trafgen: parser: Fix parsing of "prot[o]" field in eth()Tobias Klauser2-3/+7
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>
2016-02-01trafgen: proto: Mark fields parameter to proto_header_fields_add as constTobias Klauser2-6/+7
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>
2016-02-01trafgen: parser: Add TCP header generation functionTobias Klauser5-1/+202
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>
2016-01-29trafgen: parser: Rename IPv4 specific types and union membersTobias Klauser2-10/+10
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>
2016-01-29trafgen: l2: Make needlessly global symbol eth_fields staticTobias Klauser1-1/+1
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>
2016-01-29trafgen: parser: Support "etype"/"type" keywords for EthertypeTobias Klauser6-12/+18
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>
2016-01-29AUTHORS: Add Erik for his contributionTobias Klauser1-0/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-29netsniff-ng: Remove duplicate '=' in assignmentTobias Klauser1-1/+1
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>
2016-01-29netsniff-ng: Use time of SIGHUP time when rotating files prematurelyErik Bengtsson1-2/+13
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>
2016-01-29cpp: Fix sparse warningTobias Klauser1-0/+1
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>
2016-01-29man: trafgen: Remove double wordTobias Klauser1-2/+2
s/packet packet/packet/ Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-01-29trafgen: man: Add help for Ethernet, ARP, IPv4, UDP headersVadim Kochan1-0/+168
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>
2016-01-29trafgen: parser: Add syntax to build UDP headerVadim Kochan2-0/+33
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>
2016-01-29trafgen: l4: Add UDP header generation logicVadim Kochan4-0/+87
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>
2016-01-29trafgen: parser: Add syntax for IPv4 protocol generationVadim Kochan2-0/+66
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>
2016-01-29trafgen: l3: Add IPv4 header generation backendVadim Kochan4-0/+110
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>
2016-01-28trafgen: parser: Add syntax to generate ARP header fieldsVadim Kochan2-1/+64
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>
2016-01-28trafgen: l2: Add ARP header generation logicVadim Kochan2-0/+62
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>
2016-01-28trafgen: proto: Add functon to fill field with device ipv4 addressVadim Kochan2-0/+35
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>
2016-01-28trafgen: parser: Add syntax to generate Ethernet header fieldsVadim Kochan2-1/+71
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>
2016-01-28str: Add str2mac helper functionVadim Kochan2-0/+32
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>
2016-01-28trafgen: l2: Add Ethernet protocol header generationVadim Kochan4-1/+49
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>
2016-01-28trafgen: proto: Add function to set field from device MACVadim Kochan2-0/+34
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>
2016-01-28dev: Add function to get device hardware addressVadim Kochan2-0/+26
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>
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>