xorp

ArpHeader Class Reference

an ARP packet. More...

#include <packet.hh>

List of all members.

Public Types

enum  Op { ARP_REQUEST = 1, ARP_REPLY }
enum  HwFmt { HW_ETHER = 1 }

Public Member Functions

 ArpHeader (const vector< uint8_t > &pkt)
void set_sender (const Mac &mac, const IPv4 &ip)
 Set the sender information in the ARP packet.
void set_request (const IPv4 &ip)
 Create an ARP request for an IP address.
void set_reply (const Mac &mac, const IPv4 &ip)
 Create an ARP reply.
uint32_t size () const
 The size of the ARP packet (ARP header + data).
bool is_request () const
 Determine whether it is an ARP request.
IPv4 get_request () const
 If an ARP request, return the IP address that is being asked for.
void make_reply (vector< uint8_t > &out, const Mac &mac) const
 If this is an ARP request, create an ARP reply with the give MAC address.

Static Public Member Functions

static void make_gratuitous (vector< uint8_t > &payload, const Mac &mac, const IPv4 &ip)
 Create a gratuitous ARP.

Public Attributes

enum ArpHeader::Op __attribute__

Private Attributes

uint16_t ah_hw_fmt
uint16_t ah_proto_fmt
uint8_t ah_hw_len
uint8_t ah_proto_len
uint16_t ah_op
uint8_t ah_data_store [6 *2+4 *2]

Detailed Description

an ARP packet.


Member Function Documentation

IPv4 ArpHeader::get_request ( ) const

If an ARP request, return the IP address that is being asked for.

Returns:
the IP address being asked for.
bool ArpHeader::is_request ( ) const

Determine whether it is an ARP request.

This (usually) implies whether or not it is an ARP reply.

Returns:
true if it is an ARP request.
void ArpHeader::make_gratuitous ( vector< uint8_t > &  payload,
const Mac mac,
const IPv4 ip 
) [static]

Create a gratuitous ARP.

I.e., an ARP request for my own IP address - the one used in the source section of the ARP packet.

Parameters:
outputdata (output argument).
MACaddress of IP.
ipIP address to create request for.
void ArpHeader::make_reply ( vector< uint8_t > &  out,
const Mac mac 
) const

If this is an ARP request, create an ARP reply with the give MAC address.

Parameters:
outthe ARP reply data (output parameter).
macthe MAC address of the requested IP address.
void ArpHeader::set_reply ( const Mac mac,
const IPv4 ip 
)

Create an ARP reply.

Parameters:
macMAC address of requested IP address.
ipIP address requested in the ARP request.
void ArpHeader::set_request ( const IPv4 ip)

Create an ARP request for an IP address.

Parameters:
ipIP address to ask request for.
void ArpHeader::set_sender ( const Mac mac,
const IPv4 ip 
)

Set the sender information in the ARP packet.

Parameters:
macsource MAC address.
ipsource IP address.
uint32_t ArpHeader::size ( ) const

The size of the ARP packet (ARP header + data).

Returns:
the size of the ARP packet.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations