Sponge
CS144's user-space TCP library
Public Member Functions | Static Public Attributes | List of all members
EthernetHeader Struct Reference

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...
 

Detailed Description

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.

Member Function Documentation

◆ parse()

ParseResult EthernetHeader::parse ( NetParser p)

Parse the Ethernet fields from the provided NetParser.

Definition at line 10 of file ethernet_header.cc.

◆ serialize()

string EthernetHeader::serialize ( ) const

Serialize the Ethernet fields to a string.

Definition at line 31 of file ethernet_header.cc.

◆ to_string()

string EthernetHeader::to_string ( ) const

Return a string containing a header in human-readable format.

Returns
A string with the header's contents

Definition at line 65 of file ethernet_header.cc.

Member Data Documentation

◆ dst

EthernetAddress EthernetHeader::dst

Definition at line 25 of file ethernet_header.hh.

◆ LENGTH

constexpr size_t EthernetHeader::LENGTH = 14
staticconstexpr

Ethernet header length in bytes.

Definition at line 19 of file ethernet_header.hh.

◆ src

EthernetAddress EthernetHeader::src

Definition at line 26 of file ethernet_header.hh.

◆ type

uint16_t EthernetHeader::type

Definition at line 27 of file ethernet_header.hh.

◆ TYPE_ARP

constexpr uint16_t EthernetHeader::TYPE_ARP = 0x806
staticconstexpr

Type number for ARP.

Definition at line 21 of file ethernet_header.hh.

◆ TYPE_IPv4

constexpr uint16_t EthernetHeader::TYPE_IPv4 = 0x800
staticconstexpr

Type number for IPv4.

Definition at line 20 of file ethernet_header.hh.


The documentation for this struct was generated from the following files: