Class Arp

Class Documentation

class Arp

This class is repsonsible for managing ARP requests.

Generates an ARP response based on a request.

Public Types

enum class Error

Values:

enumerator ARP_OK
enumerator INVALID_MESSAGE
enumerator UNKNOWN_PROTOCOL
enumerator UNKNOWN_OP
enumerator PACKET_CONSTRUCTION
enumerator IO_ERROR
enumerator NO_RESPONSE

Public Functions

inline Arp(const in_addr_t own_ip, const rte_ether_addr own_mac)
template<typename Send>
inline Error ReceivePacket(RTEMbuf<DefaultPacket> &pkt, RTEMempool<DefaultPacket, MbufType::Pkt> &mpool, Send send)

Receive an ARP packet and generate an optional response.

Parameters:
  • arp_pkt – The received ARP packet.

  • resp – mbuf for the response.

  • send – Function with signature [] (rte_mbuf*) -> bool that sends a single packet over the active network interface.

Returns:

An error code.

template<typename Send, typename Recv>
inline Error RequestAddr(const in_addr_t addr, RTEMempool<DefaultPacket, MbufType::Pkt> &mpool, Send &send, Recv &recv)

Perform entire request sequence for an IPv4 address.

If a the requested (ip, mac) pair already exists it is deleted and retrieved again.

Parameters:
  • addr – The IPv4 address.

  • mmpool – An rte_mempool used to allocate packets.

  • send – Function with signature [] (rte_mbuf*) -> bool that sends a single packet over the active network interface.

  • recv – Function with signature [] (rte_mbuf**, uint16_t) -> uint16_t that receives a single packet on the active network interface.

Returns:

An error code.

std::optional<rte_ether_addr> GetEtherAddr(const in_addr_t addr)

Get the Ethernet address for a particular address.

Parameters:

addr – The address needed to be resolved.

Returns:

optional Ethernet address for the Ipv4 address. If std::nullopt is returned, address should be looked up explictely.

void InsertAddr(const in_addr_t ip, const rte_ether_addr mac)

Manually insert an (ip, mac) pair.

Parameters:
  • ip – The Ipv4 address.

  • mac – The MAC address.

size_t EraseAddr(const in_addr_t ip)

Erases the (ip, mac) pair identified by ip, if it exists.

Parameters:

ip – The Ipv4 address.

Returns:

Number of elements removed from map (0 or 1)

Public Static Functions

static inline constexpr const char *ErrorToString(Error e)