libtins
4.0
|
Represents an ARP PDU. More...
#include <arp.h>
Public Types | |
enum | Flags { REQUEST = 0x0001, REPLY = 0x0002 } |
Enum which indicates the type of ARP packet. | |
enum | e { NETROM = 0, ETHER = 1, EETHER = 2, AX25 = 3, PRONET = 4, CHAOS = 5, IEEE802 = 6, ARCNET = 7, APPLETLK = 8, DLCI = 15, ATM = 19, METRICOM = 23, IEEE1394 = 24, EUI64 = 27, INFINIBAND = 32, SLIP = 256, CSLIP = 257, SLIP6 = 258, CSLIP6 = 259, RSRVD = 260, ADAPT = 264, ROSE = 270, X25 = 271, HWX25 = 272, PPP = 512, CISCO = 513, HDLC = CISCO, LAPB = 516, DDCMP = 517, RAWHDLC = 518, TUNNEL = 768, TUNNEL6 = 769, FRAD = 770, SKIP = 771, LOOPBACK = 772, LOCALTLK = 773, FDDI = 774, BIF = 775, SIT = 776, IPDDP = 777, IPGRE = 778, PIMREG = 779, HIPPI = 780, ASH = 781, ECONET = 782, IRDA = 783, FCPP = 784, FCAL = 785, FCPL = 786, FCFABRIC = 787, IEEE802_TR = 800, IEEE80211 = 801, IEEE80211_PRISM = 802, IEEE80211_RADIOTAP = 803, IEEE802154 = 804, IEEE802154_PHY = 805, VOID_TYPE = 0xFFFF, NONE = 0xFFFE } |
typedef HWAddress< 6 > | hwaddress_type |
typedef IPv4Address | ipaddress_type |
Public Types inherited from Tins::PDU | |
enum | endian_type { BE, LE } |
enum | PDUType { RAW, ETHERNET_II, IEEE802_3, DOT3 = IEEE802_3, RADIOTAP, DOT11, DOT11_ACK, DOT11_ASSOC_REQ, DOT11_ASSOC_RESP, DOT11_AUTH, DOT11_BEACON, DOT11_BLOCK_ACK, DOT11_BLOCK_ACK_REQ, DOT11_CF_END, DOT11_DATA, DOT11_CONTROL, DOT11_DEAUTH, DOT11_DIASSOC, DOT11_END_CF_ACK, DOT11_MANAGEMENT, DOT11_PROBE_REQ, DOT11_PROBE_RESP, DOT11_PS_POLL, DOT11_REASSOC_REQ, DOT11_REASSOC_RESP, DOT11_RTS, DOT11_QOS_DATA, LLC, SNAP, IP, ARP, TCP, UDP, ICMP, BOOTP, DHCP, EAPOL, RC4EAPOL, RSNEAPOL, DNS, LOOPBACK, IPv6, ICMPv6, SLL, DHCPv6, DOT1Q, PPPOE, STP, PPI, IPSEC_AH, IPSEC_ESP, PKTAP, MPLS, UNKNOWN = 999, USER_DEFINED_PDU = 1000 } |
Enum which identifies each type of PDU. More... | |
typedef byte_array | serialization_type |
Public Member Functions | |
ARP (ipaddress_type target_ip=ipaddress_type(), ipaddress_type sender_ip=ipaddress_type(), const hwaddress_type &target_hw=hwaddress_type(), const hwaddress_type &sender_hw=hwaddress_type()) | |
Constructs an ARP object using the provided addresses. More... | |
ARP (const uint8_t *buffer, uint32_t total_sz) | |
Constructs an ARP object from a buffer. More... | |
hwaddress_type | sender_hw_addr () const |
Getter for the sender's hardware address. More... | |
ipaddress_type | sender_ip_addr () const |
Getter for the sender's IP address. More... | |
hwaddress_type | target_hw_addr () const |
Getter for the target's hardware address. More... | |
ipaddress_type | target_ip_addr () const |
Getter for the target's IP address. More... | |
uint16_t | hw_addr_format () const |
Getter for the hardware address format field. More... | |
uint16_t | prot_addr_format () const |
Getter for the protocol address format field. More... | |
uint8_t | hw_addr_length () const |
Getter for the hardware address length field. More... | |
uint8_t | prot_addr_length () const |
Getter for the protocol address length field. More... | |
uint16_t | opcode () const |
Getter for the ARP opcode field. More... | |
uint32_t | header_size () const |
Getter for the header size. More... | |
void | sender_hw_addr (const hwaddress_type &address) |
Setter for the sender's hardware address. More... | |
void | sender_ip_addr (ipaddress_type address) |
Setter for the sender's IP address. More... | |
void | target_hw_addr (const hwaddress_type &address) |
Setter for the target's hardware address. More... | |
void | target_ip_addr (ipaddress_type address) |
Setter for the target's IP address. More... | |
void | hw_addr_format (uint16_t format) |
Setter for the hardware address format field. More... | |
void | prot_addr_format (uint16_t format) |
Setter for the protocol address format field. More... | |
void | hw_addr_length (uint8_t length) |
Setter for the hardware address length field. More... | |
void | prot_addr_length (uint8_t length) |
Setter for the protocol address length field. More... | |
void | opcode (Flags code) |
Setter for the ARP opcode field. More... | |
PDUType | pdu_type () const |
Getter for the PDU's type. More... | |
bool | matches_response (const uint8_t *ptr, uint32_t total_sz) const |
Check whether ptr points to a valid response for this PDU. More... | |
ARP * | clone () const |
Public Member Functions inherited from Tins::PDU | |
PDU () | |
Default constructor. | |
PDU (PDU &&rhs) TINS_NOEXCEPT | |
Move constructor. More... | |
PDU & | operator= (PDU &&rhs) TINS_NOEXCEPT |
Move assignment operator. More... | |
virtual | ~PDU () |
PDU destructor. More... | |
virtual uint32_t | trailer_size () const |
Trailer's size. More... | |
uint32_t | size () const |
The whole chain of PDU's size, including this one. More... | |
PDU * | inner_pdu () const |
Getter for the inner PDU. More... | |
PDU * | parent_pdu () const |
PDU * | release_inner_pdu () |
Releases the inner PDU. More... | |
void | inner_pdu (PDU *next_pdu) |
Sets the child PDU. More... | |
void | inner_pdu (const PDU &next_pdu) |
Sets the child PDU. More... | |
serialization_type | serialize () |
Serializes the whole chain of PDU's, including this one. More... | |
template<typename T > | |
T * | find_pdu (PDUType type=T::pdu_flag) |
Finds and returns the first PDU that matches the given flag. More... | |
template<typename T > | |
const T * | find_pdu (PDUType type=T::pdu_flag) const |
Finds and returns the first PDU that matches the given flag. More... | |
template<typename T > | |
T & | rfind_pdu (PDUType type=T::pdu_flag) |
Finds and returns the first PDU that matches the given flag. More... | |
template<typename T > | |
const T & | rfind_pdu (PDUType type=T::pdu_flag) const |
Finds and returns the first PDU that matches the given flag. More... | |
virtual void | send (PacketSender &sender, const NetworkInterface &iface) |
Send the stack of PDUs through a PacketSender. More... | |
virtual PDU * | recv_response (PacketSender &sender, const NetworkInterface &iface) |
Receives a matching response for this packet. More... | |
virtual bool | matches_flag (PDUType flag) const |
Check whether this PDU matches the specified flag. More... | |
Static Public Member Functions | |
static metadata | extract_metadata (const uint8_t *buffer, uint32_t total_sz) |
Extracts metadata for this protocol based on the buffer provided. More... | |
static EthernetII | make_arp_request (ipaddress_type target, ipaddress_type sender, const hwaddress_type &hw_snd=hwaddress_type()) |
Creates an ARP Request within an EthernetII PDU. More... | |
static EthernetII | make_arp_reply (ipaddress_type target, ipaddress_type sender, const hwaddress_type &hw_tgt=hwaddress_type(), const hwaddress_type &hw_snd=hwaddress_type()) |
Creates an ARP Reply within an EthernetII PDU. More... | |
Static Public Attributes | |
static const PDU::PDUType | pdu_flag = PDU::ARP |
This PDU's flag. | |
Static Public Attributes inherited from Tins::PDU | |
static const endian_type | endianness = BE |
Additional Inherited Members | |
Protected Member Functions inherited from Tins::PDU | |
PDU (const PDU &other) | |
Copy constructor. | |
PDU & | operator= (const PDU &other) |
Copy assignment operator. | |
void | copy_inner_pdu (const PDU &pdu) |
Copy other PDU's inner PDU(if any). More... | |
virtual void | prepare_for_serialize () |
Prepares this PDU for serialization. More... | |
void | serialize (uint8_t *buffer, uint32_t total_sz) |
Serializes this PDU and propagates this action to child PDUs. More... | |
Represents an ARP PDU.
typedef HWAddress<6> Tins::ARP::hwaddress_type |
The type of the hardware address.
typedef IPv4Address Tins::ARP::ipaddress_type |
The type of the IP address.
Tins::ARP::ARP | ( | ipaddress_type | target_ip = ipaddress_type() , |
ipaddress_type | sender_ip = ipaddress_type() , |
||
const hwaddress_type & | target_hw = hwaddress_type() , |
||
const hwaddress_type & | sender_hw = hwaddress_type() |
||
) |
Constructs an ARP object using the provided addresses.
ARP requests and replies can be constructed easily using ARP::make_arp_request/reply static member functions.
Tins::ARP::ARP | ( | const uint8_t * | buffer, |
uint32_t | total_sz | ||
) |
Constructs an ARP object from a buffer.
If there is not enough size for an ARP header in the buffer, a malformed_packet exception is thrown.
If the buffer is bigger than the size of the ARP header, then the extra data is stored in a RawPDU.
buffer | The buffer from which this PDU will be constructed. |
total_sz | The total size of the buffer. |
|
inlinevirtual |
Implements Tins::PDU.
|
static |
Extracts metadata for this protocol based on the buffer provided.
buffer | Pointer to a buffer |
total_sz | Size of the buffer pointed by buffer |
|
virtual |
Getter for the header size.
Implements Tins::PDU.
|
inline |
Getter for the hardware address format field.
void Tins::ARP::hw_addr_format | ( | uint16_t | format | ) |
Setter for the hardware address format field.
format | The new hardware address format. |
|
inline |
Getter for the hardware address length field.
void Tins::ARP::hw_addr_length | ( | uint8_t | length | ) |
Setter for the hardware address length field.
length | The new hardware address length. |
|
static |
Creates an ARP Reply within an EthernetII PDU.
Creates an ARP Reply PDU and embeds it inside an EthernetII PDU.
target | The target's IP address. |
sender | The sender's IP address. |
hw_tgt | The target's hardware address. |
hw_snd | The sender's hardware address. |
|
static |
Creates an ARP Request within an EthernetII PDU.
Creates an ARP Request PDU and embeds it inside an EthernetII PDU.
target | The target's IP address. |
sender | The sender's IP address. |
hw_snd | The sender's hardware address. |
|
virtual |
Check whether ptr points to a valid response for this PDU.
ptr | The pointer to the buffer. |
total_sz | The size of the buffer. |
Reimplemented from Tins::PDU.
void Tins::ARP::opcode | ( | Flags | code | ) |
|
inlinevirtual |
|
inline |
Getter for the protocol address format field.
void Tins::ARP::prot_addr_format | ( | uint16_t | format | ) |
Setter for the protocol address format field.
format | The new protocol address format. |
|
inline |
Getter for the protocol address length field.
void Tins::ARP::prot_addr_length | ( | uint8_t | length | ) |
Setter for the protocol address length field.
length | The new protocol address length. |
|
inline |
Getter for the sender's hardware address.
void Tins::ARP::sender_hw_addr | ( | const hwaddress_type & | address | ) |
Setter for the sender's hardware address.
address | The new sender hardware address. |
|
inline |
void Tins::ARP::sender_ip_addr | ( | ipaddress_type | address | ) |
|
inline |
Getter for the target's hardware address.
void Tins::ARP::target_hw_addr | ( | const hwaddress_type & | address | ) |
Setter for the target's hardware address.
address | The new target hardware address. |
|
inline |
void Tins::ARP::target_ip_addr | ( | ipaddress_type | address | ) |