MoonGen
|
Internet protocol (v4) utility. More...
Go to the source code of this file.
Functions | |
function ip4Addr | get () |
Retrieve the IPv4 address. More... | |
function ip4Addr | set (ip) |
Set the IPv4 address. More... | |
function ip4Addr | setString (ip) |
Set the IPv4 address. More... | |
function ip4Addr | getString () |
Retrieve the string representation of the IPv4 address. More... | |
function ip4Addr | __eq (lhs, rhs) |
Test equality of two IPv4 addresses. More... | |
function ip4Addr | __add (lhs, rhs) |
Add a number to an IPv4 address. More... | |
function ip4Addr | add (val) |
Add a number to an IPv4 address in-place. More... | |
function ip4Addr | __sub (val) |
Subtract a number from an IPv4 address. More... | |
function ip4Header | setVersion (int) |
Set the version. More... | |
function ip4Header | getVersion () |
Retrieve the version. More... | |
function ip4Header | getVersionString () |
Retrieve the version. More... | |
function ip4Header | setHeaderLength (int) |
Set the header length. More... | |
function ip4Header | getHeaderLength () |
Retrieve the header length. More... | |
function ip4Header | getHeaderLengthString () |
Retrieve the header length. More... | |
function ip4Header | setTOS (int) |
Set the type of service (TOS). More... | |
function ip4Header | getTOS () |
Retrieve the type of service. More... | |
function ip4Header | getTOSString () |
Retrieve the type of service. More... | |
function ip4Header | setLength (int) |
Set the total length. More... | |
function ip4Header | getLength () |
Retrieve the length. More... | |
function ip4Header | getLengthString () |
Retrieve the length. More... | |
function ip4Header | setID (int) |
Set the identification. More... | |
function ip4Header | getID () |
Retrieve the identification. More... | |
function ip4Header | getIDString () |
Retrieve the identification. More... | |
function ip4Header | setFlags (int) |
Set the flags. More... | |
function ip4Header | getFlags () |
Retrieve the flags. More... | |
function ip4Header | getFlagsString () |
Retrieve the flags. More... | |
function ip4Header | setFragment (int) |
Set the fragment. More... | |
function ip4Header | getFragment () |
Retrieve the fragment. More... | |
function ip4Header | getFragmentString () |
Retrieve the fragemt. More... | |
function ip4Header | setTTL (int) |
Set the time-to-live (TTL). More... | |
function ip4Header | getTTL () |
Retrieve the time-to-live. More... | |
function ip4Header | getTTLString () |
Retrieve the time-to-live. More... | |
function ip4Header | setProtocol (int) |
Set the next layer protocol. More... | |
function ip4Header | getProtocol () |
Retrieve the next layer protocol. More... | |
function ip4Header | getProtocolString () |
Retrieve the next layer protocol. More... | |
function ip4Header | setChecksum (int) |
Set the checksum. More... | |
function ip4Header | getChecksum () |
Retrieve the checksum. More... | |
function ip4Header | getChecksumString () |
Retrieve the checksum. More... | |
function ip4Header | calculateChecksum () |
Calculate and set the checksum. More... | |
function ip4Header | setDst (int) |
Set the destination address. More... | |
function ip4Header | getDst () |
Retrieve the destination IP address. More... | |
function ip4Header | setSrc (int) |
Set the source address. More... | |
function ip4Header | getSrc () |
Retrieve the source IP address. More... | |
function ip4Header | setDstString (str) |
Set the destination address. More... | |
function ip4Header | getDstString () |
Retrieve the destination IP address. More... | |
function ip4Header | setSrcString (str) |
Set the source address. More... | |
function ip4Header | getSrcString () |
Retrieve the source IP address. More... | |
function ip4Header | fill (args, pre) |
Set all members of the ip header. More... | |
function ip4Header | get (pre) |
Retrieve the values of all members. More... | |
function ip4Header | resolveNextHeader () |
Resolve which header comes after this one (in a packet). More... | |
function ip4Header | setDefaultNamedArgs (pre, namedArgs, nextHeader, accumulatedLength) |
Change the default values for namedArguments (for fill/get). More... | |
Variables | |
local | ip = {} |
IP4 protocol constants. | |
ip | PROTO_ICMP = 0x01 |
Protocol field value for Icmp. | |
ip | PROTO_TCP = 0x06 |
Protocol field value for Tcp. | |
ip | PROTO_UDP = 0x11 |
Protocol field value for Udp. | |
local | ip4Addr = {} |
Module for ip4_address struct (see headers.lua). | |
local | ip4Header = {} |
Module for ip4_header struct (see headers.lua). | |
pkt | getIP4Packet = packetCreate("eth", "ip4") |
Cast the packet to an IP4 packet. | |
pkt | getIPPacket = function(self, ip4) |
Cast the packet to either an IP4 (nil/true) or IP6 (false) packet, depending on the passed boolean. | |
Internet protocol (v4) utility.
Utility functions for the ip4_address and ip4_header structs defined in headers.lua .
Includes:
Definition in file ip4.lua.
function ip4Addr __add | ( | lhs | , |
rhs | |||
) |
Add a number to an IPv4 address.
Max. 32 bit, commutative.
lhs | Address in 'union ip4_address' format. |
rhs | Number to add (32 bit integer). |
function ip4Addr __eq | ( | lhs | , |
rhs | |||
) |
Test equality of two IPv4 addresses.
lhs | Address in 'union ip4_address' format. |
rhs | Address in 'union ip4_address' format. |
function ip4Addr __sub | ( | val | ) |
Subtract a number from an IPv4 address.
Max. 32 bit.
val | Number to substract (32 bit integer) |
function ip4Addr add | ( | val | ) |
Add a number to an IPv4 address in-place.
Max. 32 bit.
val | Number to add (32 bit integer). |
function ip4Header calculateChecksum | ( | ) |
Calculate and set the checksum.
If possible use checksum offloading instead.
function ip4Header fill | ( | args | , |
pre | |||
) |
Set all members of the ip 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.
args | Table of named arguments. Available arguments: Version, HeaderLength, TOS, Length, ID, Flags, Fragment, TTL, Protocol, Checksum, Src, Dst |
pre | prefix for namedArgs. Default 'ip4'. |
function ip4Addr get | ( | ) |
Retrieve the IPv4 address.
function ip4Header get | ( | pre | ) |
function ip4Header getChecksum | ( | ) |
Retrieve the checksum.
function ip4Header getChecksumString | ( | ) |
Retrieve the checksum.
function ip4Header getDst | ( | ) |
Retrieve the destination IP address.
function ip4Header getDstString | ( | ) |
Retrieve the destination IP address.
function ip4Header getFlags | ( | ) |
Retrieve the flags.
function ip4Header getFlagsString | ( | ) |
Retrieve the flags.
function ip4Header getFragment | ( | ) |
Retrieve the fragment.
function ip4Header getFragmentString | ( | ) |
Retrieve the fragemt.
function ip4Header getHeaderLength | ( | ) |
Retrieve the header length.
function ip4Header getHeaderLengthString | ( | ) |
Retrieve the header length.
function ip4Header getID | ( | ) |
Retrieve the identification.
function ip4Header getIDString | ( | ) |
Retrieve the identification.
function ip4Header getLength | ( | ) |
Retrieve the length.
function ip4Header getLengthString | ( | ) |
Retrieve the length.
function ip4Header getProtocol | ( | ) |
Retrieve the next layer protocol.
function ip4Header getProtocolString | ( | ) |
Retrieve the next layer protocol.
function ip4Header getSrc | ( | ) |
Retrieve the source IP address.
function ip4Header getSrcString | ( | ) |
Retrieve the source IP address.
function ip4Addr getString | ( | ) |
Retrieve the string representation of the IPv4 address.
Retrieve the values of all members.
function ip4Header getTOS | ( | ) |
Retrieve the type of service.
function ip4Header getTOSString | ( | ) |
Retrieve the type of service.
function ip4Header getTTL | ( | ) |
Retrieve the time-to-live.
function ip4Header getTTLString | ( | ) |
Retrieve the time-to-live.
function ip4Header getVersion | ( | ) |
Retrieve the version.
function ip4Header getVersionString | ( | ) |
Retrieve the version.
function ip4Header 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 ip4Header setChecksum | ( | int | ) |
Set the checksum.
int | Checksum of the ip header as 16 bit integer. |
function ip4Header 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. 'ip4' |
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 ip4Header setDst | ( | int | ) |
Set the destination address.
int | Address in 'union ip4_address' format. |
function ip4Header setDstString | ( | str | ) |
Set the destination address.
str | Address in string format. |
function ip4Header setFlags | ( | int | ) |
Set the flags.
Bits: [ reserved (must be 0) | don't fragment | more fragments ]
int | Flags of the ip header as 3 bit integer |
function ip4Header setFragment | ( | int | ) |
Set the fragment.
int | Fragment of the ip header as 13 bit integer. |
function ip4Header setHeaderLength | ( | int | ) |
Set the header length.
int | Length of the ip header (in multiple of 32 bits) as 4 bit integer. Should always be '5'. |
function ip4Header setID | ( | int | ) |
Set the identification.
int | ID of the ip header as 16 bit integer. |
function ip4Header setLength | ( | int | ) |
Set the total length.
int | Length of the packet excluding layer 2. 16 bit integer. |
function ip4Header setProtocol | ( | int | ) |
Set the next layer protocol.
int | Next layer protocol of the ip header as 8 bit integer. |
function ip4Header setSrc | ( | int | ) |
Set the source address.
int | Address in 'union ip4_address' format. |
function ip4Header setSrcString | ( | str | ) |
Set the source address.
str | Address in string format. |
function ip4Header setTOS | ( | int | ) |
Set the type of service (TOS).
int | TOS of the ip header as 8 bit integer. |
function ip4Header setTTL | ( | int | ) |
Set the time-to-live (TTL).
int | TTL of the ip header as 8 bit integer. |
function ip4Header setVersion | ( | int | ) |
Set the version.
int | IP header version as 4 bit integer. Should always be '4'. |