summaryrefslogtreecommitdiff
path: root/trafgen_l2.c
AgeCommit message (Collapse)AuthorFilesLines
2016-04-22trafgen: proto: Replace panic() with bug() where applicableTobias Klauser1-1/+1
In some cases we use panic() in situations where the error could only happen due to an implementation error. Use bug() there as it is more applicable, as panic() is mainly used to report system call errors. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-02-23trafgen: l2: Add MPLS header generationVadim Kochan1-0/+32
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-02trafgen: l2: Add VLAN header generationVadim Kochan1-10/+53
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: eth: Add setting next protocol idVadim Kochan1-1/+23
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 Kochan1-1/+1
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 Kochan1-3/+1
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-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 Klauser1-2/+2
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-28trafgen: l2: Add ARP header generation logicVadim Kochan1-0/+50
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: l2: Add Ethernet protocol header generationVadim Kochan1-0/+32
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>