MoonGen
|
Ethernet protocol utility. More...
Go to the source code of this file.
Functions | |
function macAddr | get () |
Retrieve the MAC address. More... | |
function macAddr | set (addr) |
Set the MAC address. More... | |
function macAddr | setString (mac) |
Set the MAC address. More... | |
function macAddr | __eq (lhs, rhs) |
Test equality of two MAC addresses. More... | |
function macAddr | getString () |
Retrieve the string representation of a MAC address. More... | |
function etherHeader | setDst (addr) |
Set the destination MAC address. More... | |
function etherHeader | getDst (addr) |
Retrieve the destination MAC address. More... | |
function etherHeader | setSrc (addr) |
Set the source MAC address. More... | |
function etherHeader | getSrc (addr) |
Retrieve the source MAC address. More... | |
function etherHeader | setDstString (str) |
Set the destination MAC address. More... | |
function etherHeader | getDstString () |
Retrieve the destination MAC address. More... | |
function etherHeader | setSrcString (str) |
Set the source MAC address. More... | |
function etherHeader | getSrcString () |
Retrieve the source MAC address. More... | |
function etherHeader | setType (int) |
Set the EtherType. More... | |
function etherHeader | getType () |
Retrieve the EtherType. More... | |
function etherHeader | getTypeString () |
Retrieve the ether type. More... | |
function etherHeader | fill (args, pre) |
Set all members of the ethernet header. More... | |
function etherHeader | get (pre) |
Retrieve the values of all members. More... | |
function etherHeader | resolveNextHeader () |
Resolve which header comes after this one (in a packet). More... | |
function etherHeader | setDefaultNamedArgs (pre, namedArgs, nextHeader, accumulatedLength) |
Change the default values for namedArguments (for fill/get). More... | |
Variables | |
local | eth = {} |
Ethernet protocol constants. | |
eth | TYPE_IP = 0x0800 |
EtherType for IP4. | |
eth | TYPE_ARP = 0x0806 |
EtherType for Arp. | |
eth | TYPE_IP6 = 0x86dd |
EtherType for IP6. | |
eth | TYPE_PTP = 0x88f7 |
EtherType for Ptp. | |
eth | BROADCAST = "ff:ff:ff:ff:ff:ff" |
Ethernet broadcast address. | |
local | macAddr = {} |
Module for mac_address struct (see headers.lua). | |
local | etherHeader = {} |
Module for ethernet_header struct (see headers.lua). | |
pkt | getEthernetPacket = packetCreate("eth") |
Cast the packet to an ethernet packet. | |
pkt | getEthPacket = pkt.getEthernetPacket |
Cast the packet to an ethernet packet (alias for pkt.getEthernetPacket) | |
Ethernet protocol utility.
Utility functions for the mac_address and ethernet_header structs defined in headers.lua .
Includes:
Definition in file ethernet.lua.
function macAddr __eq | ( | lhs | , |
rhs | |||
) |
Test equality of two MAC addresses.
lhs | Address in 'struct mac_address' format. |
rhs | Address in 'struct mac_address' format. |
function etherHeader fill | ( | args | , |
pre | |||
) |
Set all members of the ethernet header.
Per default, all members are set to default values specified in the respective set function. Optional named arguments can be used to set a member to a user-provided value.
Exemplary invocations:
args | Table of named arguments. Available arguments: Src, Dst, Type |
pre | Prefix for namedArgs. Default 'eth'. |
function macAddr get | ( | ) |
Retrieve the MAC address.
function etherHeader get | ( | pre | ) |
Retrieve the values of all members.
pre | Prefix for namedArgs. Default 'eth'. |
function etherHeader getDst | ( | addr | ) |
Retrieve the destination MAC address.
function etherHeader getDstString | ( | ) |
Retrieve the destination MAC address.
function etherHeader getSrc | ( | addr | ) |
Retrieve the source MAC address.
function etherHeader getSrcString | ( | ) |
Retrieve the source MAC address.
function macAddr getString | ( | ) |
Retrieve the string representation of a MAC address.
Retrieve the values of all members.
function etherHeader getType | ( | ) |
Retrieve the EtherType.
function etherHeader getTypeString | ( | ) |
Retrieve the ether type.
function etherHeader resolveNextHeader | ( | ) |
Resolve which header comes after this one (in a packet).
For instance: in tcp/udp based on the ports. This function must exist and is only used when get/dump is executed on an unknown (mbuf not yet casted to e.g. tcpv6 packet) packet (mbuf)
function macAddr set | ( | addr | ) |
Set the MAC address.
addr | Address in 'struct mac_address' format. |
function etherHeader setDefaultNamedArgs | ( | pre | , |
namedArgs | , | ||
nextHeader | , | ||
accumulatedLength | |||
) |
Change the default values for namedArguments (for fill/get).
This can be used to for instance calculate a length value based on the total packet length. See proto/ip4.setDefaultNamedArgs as an example. This function must exist and is only used by packet.fill.
pre | The prefix used for the namedArgs, e.g. 'eth' |
namedArgs | Table of named arguments (see See Also) |
nextHeader | The header following after this header in a packet |
accumulatedLength | The so far accumulated length for previous headers in a packet |
function etherHeader setDst | ( | addr | ) |
Set the destination MAC address.
addr | Address in 'struct mac_address' format. |
function etherHeader setDstString | ( | str | ) |
Set the destination MAC address.
str | Address in string format. |
function etherHeader setSrc | ( | addr | ) |
Set the source MAC address.
addr | Address in 'struct mac_address' format. |
function etherHeader setSrcString | ( | str | ) |
Set the source MAC address.
str | Address in string format. |
function macAddr setString | ( | mac | ) |
Set the MAC address.
mac | Address in string format. |
function etherHeader setType | ( | int | ) |
Set the EtherType.
int | EtherType as 16 bit integer. |