libtins
4.0
|
Represents a BootP PDU. More...
#include <bootp.h>
Classes | |
struct | bootp_header |
Public Types | |
enum | OpCodes { BOOTREQUEST = 1, BOOTREPLY = 2 } |
Enum which contains the different opcodes BootP messages. | |
typedef IPv4Address | ipaddress_type |
typedef HWAddress< 16 > | chaddr_type |
typedef std::vector< uint8_t > | vend_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 | |
BootP () | |
Creates an instance of BootP. More... | |
BootP (const uint8_t *buffer, uint32_t total_sz, uint32_t vend_field_size=64) | |
Constructs a BootP object from a buffer . More... | |
uint8_t | opcode () const |
Getter for the opcode field. More... | |
uint8_t | htype () const |
Getter for the htype field. More... | |
uint8_t | hlen () const |
Getter for the hlen field. More... | |
uint8_t | hops () const |
Getter for the hops field. More... | |
uint32_t | xid () const |
Getter for the xid field. More... | |
uint16_t | secs () const |
Getter for the secs field. More... | |
uint16_t | padding () const |
Getter for the padding field. More... | |
ipaddress_type | ciaddr () const |
Getter for the ciaddr field. More... | |
ipaddress_type | yiaddr () const |
Getter for the yiaddr field. More... | |
ipaddress_type | siaddr () const |
Getter for the siaddr field. More... | |
ipaddress_type | giaddr () const |
Getter for the giaddr field. More... | |
chaddr_type | chaddr () const |
Getter for the chaddr field. More... | |
const uint8_t * | sname () const |
Getter for the sname field. More... | |
const uint8_t * | file () const |
Getter for the file field. More... | |
const vend_type & | vend () const |
Getter for the vend field. More... | |
uint32_t | header_size () const |
Getter for the header size. More... | |
void | opcode (uint8_t code) |
Setter for the opcode field. More... | |
void | htype (uint8_t type) |
Setter for the hardware type field. More... | |
void | hlen (uint8_t length) |
Setter for the hlen field. More... | |
void | hops (uint8_t count) |
Setter for the hops field. More... | |
void | xid (uint32_t identifier) |
Setter for the xid field. More... | |
void | secs (uint16_t value) |
Setter for the secs field. More... | |
void | padding (uint16_t value) |
Setter for the padding field. More... | |
void | ciaddr (ipaddress_type address) |
Setter for the ciaddr field. More... | |
void | yiaddr (ipaddress_type address) |
Setter for the yiaddr field. More... | |
void | siaddr (ipaddress_type address) |
Setter for the siaddr field. More... | |
void | giaddr (ipaddress_type address) |
Setter for the giaddr field. More... | |
template<size_t n> | |
void | chaddr (const HWAddress< n > &new_chaddr) |
Setter for the chaddr field. The new_chaddr pointer must be at least BOOTP::hlen() bytes long. More... | |
void | sname (const uint8_t *new_sname) |
Setter for the sname field. More... | |
void | file (const uint8_t *new_file) |
Setter for the file field. More... | |
void | vend (const vend_type &newvend_) |
Setter for the vend field. 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... | |
PDUType | pdu_type () const |
Getter for the PDU's type. More... | |
BootP * | 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 Attributes | |
static const PDU::PDUType | pdu_flag = PDU::BOOTP |
This PDU's flag. | |
Static Public Attributes inherited from Tins::PDU | |
static const endian_type | endianness = BE |
Protected Member Functions | |
vend_type & | vend () |
Getter for the vend field. More... | |
void | write_serialization (uint8_t *buffer, uint32_t total_sz) |
Serializes this TCP PDU. More... | |
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... | |
Protected Attributes | |
TINS_BEGIN_PACK struct Tins::BootP::bootp_header | TINS_END_PACK |
Represents a BootP PDU.
typedef HWAddress<16> Tins::BootP::chaddr_type |
The type of the chaddr field.
The type of the IP addresses.
typedef std::vector<uint8_t> Tins::BootP::vend_type |
The type of the vend field.
Tins::BootP::BootP | ( | ) |
Tins::BootP::BootP | ( | const uint8_t * | buffer, |
uint32_t | total_sz, | ||
uint32_t | vend_field_size = 64 |
||
) |
Constructs a BootP object from a buffer .
If there's not enough size for a BootP header, then a malformed_packet exception is thrown.
buffer | The buffer from which this PDU will be constructed. |
total_sz | The total size of the buffer. |
vend_field_size | The vend field size to allocate. Subclasses might use 0 to provide their own interpretation of this field. |
|
inline |
|
inline |
Setter for the chaddr field. The new_chaddr pointer must be at least BOOTP::hlen() bytes long.
new_chaddr | The chaddr to be set. |
|
inline |
void Tins::BootP::ciaddr | ( | ipaddress_type | address | ) |
Setter for the ciaddr field.
address | The ciaddr to be set. |
|
inlinevirtual |
|
inline |
void Tins::BootP::file | ( | const uint8_t * | new_file | ) |
Setter for the file field.
new_file | The file to be set. |
|
inline |
void Tins::BootP::giaddr | ( | ipaddress_type | address | ) |
Setter for the giaddr field.
address | The giaddr to be set. |
|
virtual |
Getter for the header size.
Implements Tins::PDU.
Reimplemented in Tins::DHCP.
|
inline |
void Tins::BootP::hlen | ( | uint8_t | length | ) |
Setter for the hlen field.
length | The hlen field value to be set. |
|
inline |
void Tins::BootP::hops | ( | uint8_t | count | ) |
Setter for the hops field.
count | The hops field value to be set. |
|
inline |
void Tins::BootP::htype | ( | uint8_t | type | ) |
Setter for the hardware type field.
type | The hardware type field value to be set. |
|
virtual |
Check whether ptr points to a valid response for this PDU.
This returns true if the xid field is equal.
ptr | The pointer to the buffer. |
total_sz | The size of the buffer. |
Reimplemented from Tins::PDU.
|
inline |
void Tins::BootP::opcode | ( | uint8_t | code | ) |
Setter for the opcode field.
code | The opcode to be set. |
|
inline |
void Tins::BootP::padding | ( | uint16_t | value | ) |
Setter for the padding field.
value | The padding to be set. |
|
inlinevirtual |
|
inline |
void Tins::BootP::secs | ( | uint16_t | value | ) |
Setter for the secs field.
value | The secs to be set. |
|
inline |
void Tins::BootP::siaddr | ( | ipaddress_type | address | ) |
Setter for the siaddr field.
address | The siaddr to be set. |
|
inline |
void Tins::BootP::sname | ( | const uint8_t * | new_sname | ) |
Setter for the sname field.
new_sname | The sname to be set. |
|
inline |
void Tins::BootP::vend | ( | const vend_type & | newvend_ | ) |
Setter for the vend field.
newvend_ | The vend to be set. |
|
inlineprotected |
|
protectedvirtual |
|
inline |
void Tins::BootP::xid | ( | uint32_t | identifier | ) |
Setter for the xid field.
identifier | The xid to be set. |
|
inline |
void Tins::BootP::yiaddr | ( | ipaddress_type | address | ) |
Setter for the yiaddr field.
address | The yiaddr to be set. |