Sponge
CS144's user-space TCP library
|
Ethernet frame header. More...
#include <ethernet_header.hh>
Public Member Functions | |
ParseResult | parse (NetParser &p) |
Parse the Ethernet fields from the provided NetParser. More... | |
std::string | serialize () const |
Serialize the Ethernet fields to a string. More... | |
std::string | to_string () const |
Return a string containing a header in human-readable format. More... | |
Public Attributes | |
Ethernet header fields | |
EthernetAddress | dst |
EthernetAddress | src |
uint16_t | type |
Static Public Attributes | |
static constexpr size_t | LENGTH = 14 |
Ethernet header length in bytes. More... | |
static constexpr uint16_t | TYPE_ARP = 0x806 |
Type number for ARP. More... | |
static constexpr uint16_t | TYPE_IPv4 = 0x800 |
Type number for IPv4. More... | |
Ethernet frame header.
This struct can be used to parse an existing Ethernet header or to create a new one.
Definition at line 18 of file ethernet_header.hh.
ParseResult EthernetHeader::parse | ( | NetParser & | p | ) |
Parse the Ethernet fields from the provided NetParser.
Definition at line 10 of file ethernet_header.cc.
string EthernetHeader::serialize | ( | ) | const |
Serialize the Ethernet fields to a string.
Definition at line 31 of file ethernet_header.cc.
string EthernetHeader::to_string | ( | ) | const |
Return a string containing a header in human-readable format.
Definition at line 65 of file ethernet_header.cc.
EthernetAddress EthernetHeader::dst |
Definition at line 25 of file ethernet_header.hh.
|
staticconstexpr |
Ethernet header length in bytes.
Definition at line 19 of file ethernet_header.hh.
EthernetAddress EthernetHeader::src |
Definition at line 26 of file ethernet_header.hh.
uint16_t EthernetHeader::type |
Definition at line 27 of file ethernet_header.hh.
|
staticconstexpr |
Type number for ARP.
Definition at line 21 of file ethernet_header.hh.
|
staticconstexpr |
Type number for IPv4.
Definition at line 20 of file ethernet_header.hh.