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

ARP message More...

#include <arp_message.hh>

Public Member Functions

ParseResult parse (const Buffer buffer)
 Parse the ARP message from a string. More...
 
std::string serialize () const
 Serialize the ARP message to a string. More...
 
bool supported () const
 Is this type of ARP message supported by the parser? More...
 
std::string to_string () const
 Return a string containing the ARP message in human-readable format. More...
 

Public Attributes

ARPheader fields
uint16_t hardware_type = TYPE_ETHERNET
 Type of the link-layer protocol (generally Ethernet/Wi-Fi) More...
 
uint16_t protocol_type = EthernetHeader::TYPE_IPv4
 Type of the Internet-layer protocol (generally IPv4) More...
 
uint8_t hardware_address_size = sizeof(EthernetHeader::src)
 
uint8_t protocol_address_size = sizeof(IPv4Header::src)
 
uint16_t opcode {}
 Request or reply. More...
 
EthernetAddress sender_ethernet_address {}
 
uint32_t sender_ip_address {}
 
EthernetAddress target_ethernet_address {}
 
uint32_t target_ip_address {}
 

Static Public Attributes

static constexpr size_t LENGTH = 28
 ARP message length in bytes. More...
 
static constexpr uint16_t OPCODE_REPLY = 2
 
static constexpr uint16_t OPCODE_REQUEST = 1
 
static constexpr uint16_t TYPE_ETHERNET = 1
 ARP type for Ethernet/Wi-Fi as link-layer protocol. More...
 

Detailed Description

ARP message

This struct can be used to parse an existing ARP message or to create a new one.

Definition at line 10 of file arp_message.hh.

Member Function Documentation

◆ parse()

ParseResult ARPMessage::parse ( const Buffer  buffer)

Parse the ARP message from a string.

Definition at line 9 of file arp_message.cc.

◆ serialize()

string ARPMessage::serialize ( ) const

Serialize the ARP message to a string.

Definition at line 47 of file arp_message.cc.

◆ supported()

bool ARPMessage::supported ( ) const

Is this type of ARP message supported by the parser?

Definition at line 41 of file arp_message.cc.

◆ to_string()

string ARPMessage::to_string ( ) const

Return a string containing the ARP message in human-readable format.

Definition at line 75 of file arp_message.cc.

Member Data Documentation

◆ hardware_address_size

uint8_t ARPMessage::hardware_address_size = sizeof(EthernetHeader::src)

Definition at line 20 of file arp_message.hh.

◆ hardware_type

uint16_t ARPMessage::hardware_type = TYPE_ETHERNET

Type of the link-layer protocol (generally Ethernet/Wi-Fi)

Definition at line 18 of file arp_message.hh.

◆ LENGTH

constexpr size_t ARPMessage::LENGTH = 28
staticconstexpr

ARP message length in bytes.

Definition at line 11 of file arp_message.hh.

◆ opcode

uint16_t ARPMessage::opcode {}

Request or reply.

Definition at line 22 of file arp_message.hh.

◆ OPCODE_REPLY

constexpr uint16_t ARPMessage::OPCODE_REPLY = 2
staticconstexpr

Definition at line 14 of file arp_message.hh.

◆ OPCODE_REQUEST

constexpr uint16_t ARPMessage::OPCODE_REQUEST = 1
staticconstexpr

Definition at line 13 of file arp_message.hh.

◆ protocol_address_size

uint8_t ARPMessage::protocol_address_size = sizeof(IPv4Header::src)

Definition at line 21 of file arp_message.hh.

◆ protocol_type

uint16_t ARPMessage::protocol_type = EthernetHeader::TYPE_IPv4

Type of the Internet-layer protocol (generally IPv4)

Definition at line 19 of file arp_message.hh.

◆ sender_ethernet_address

EthernetAddress ARPMessage::sender_ethernet_address {}

Definition at line 24 of file arp_message.hh.

◆ sender_ip_address

uint32_t ARPMessage::sender_ip_address {}

Definition at line 25 of file arp_message.hh.

◆ target_ethernet_address

EthernetAddress ARPMessage::target_ethernet_address {}

Definition at line 27 of file arp_message.hh.

◆ target_ip_address

uint32_t ARPMessage::target_ip_address {}

Definition at line 28 of file arp_message.hh.

◆ TYPE_ETHERNET

constexpr uint16_t ARPMessage::TYPE_ETHERNET = 1
staticconstexpr

ARP type for Ethernet/Wi-Fi as link-layer protocol.

Definition at line 12 of file arp_message.hh.


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