| typedef vector<uint8_t> PAYLOAD | PAYLOAD |
| enum Op { ARP_REQUEST = 1, ARP_REPLY } | Op |
| enum HwFmt { HW_ETHER = 1 } | HwFmt |
| ArpHeader& assign (uint8_t* data)
| assign |
[static]
Create an ARP packet. The caller must allocate memory and ensure enough space (sizeof(ArpHeader) + (2 hw addresses) + (2 network addresses)).
Parameters:
| data | pointer where data should be stored. |
Returns: the ARP header.
| const ArpHeader& assign (const PAYLOAD& payload)
| assign |
[static]
Parse an ARP packet.
Parameters:
| payload | the ARP header and data. |
Returns: the ARP header.
| void make_gratuitous (PAYLOAD& payload, const Mac& mac,
const IPv4& ip)
| make_gratuitous |
[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:
| output | data (output argument). |
| MAC | address of IP. |
| ip | IP address to create request for. |
| void set_sender (const Mac& mac, const IPv4& ip)
| set_sender |
Set the sender information in the ARP packet.
Parameters:
| mac | source MAC address. |
| ip | source IP address. |
| void set_request (const IPv4& ip)
| set_request |
Create an ARP request for an IP address.
Parameters:
| ip | IP address to ask request for. |
| void set_reply (const Mac& mac, const IPv4& ip)
| set_reply |
Create an ARP reply.
Parameters:
| mac | MAC address of requested IP address. |
| ip | IP address requested in the ARP request. |
| uint32_t size ()
| size |
[const]
The size of the ARP packet (ARP header + data).
Returns: the size of the ARP packet.
| bool is_request ()
| 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.
| IPv4 get_request ()
| get_request |
[const]
If an ARP request, return the IP address that is being asked for.
Returns: the IP address being asked for.
| void make_reply (PAYLOAD& out, const Mac& mac)
| make_reply |
[const]
If this is an ARP request, create an ARP reply with the give MAC address.
Parameters:
| out | the ARP reply data (output parameter). |
| mac | the MAC address of the requested IP address. |
| uint16_t ah_hw_fmt | ah_hw_fmt |
| uint16_t ah_proto_fmt | ah_proto_fmt |
| uint8_t ah_hw_len | ah_hw_len |
| uint8_t ah_proto_len | ah_proto_len |
| uint16_t ah_op | ah_op |
| uint8_t ah_data[0] | ah_data[0] |