libtins  4.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Tins::BootP Class Reference

Represents a BootP PDU. More...

#include <bootp.h>

Inheritance diagram for Tins::BootP:
Tins::PDU Tins::DHCP

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_typevend () 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...
 
BootPclone () const
 
- Public Member Functions inherited from Tins::PDU
 PDU ()
 Default constructor.
 
 PDU (PDU &&rhs) TINS_NOEXCEPT
 Move constructor. More...
 
PDUoperator= (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...
 
PDUinner_pdu () const
 Getter for the inner PDU. More...
 
PDUparent_pdu () const
 
PDUrelease_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 PDUrecv_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_typevend ()
 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.
 
PDUoperator= (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
 

Detailed Description

Represents a BootP PDU.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

Tins::BootP::BootP ( )

Creates an instance of BootP.

This sets the size of the vend field to 64, as the BootP RFC states.

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.

Parameters
bufferThe buffer from which this PDU will be constructed.
total_szThe total size of the buffer.
vend_field_sizeThe vend field size to allocate. Subclasses might use 0 to provide their own interpretation of this field.

Member Function Documentation

chaddr_type Tins::BootP::chaddr ( ) const
inline

Getter for the chaddr field.

Returns
The chddr field for this BootP PDU.
template<size_t n>
void Tins::BootP::chaddr ( const HWAddress< n > &  new_chaddr)
inline

Setter for the chaddr field. The new_chaddr pointer must be at least BOOTP::hlen() bytes long.

Parameters
new_chaddrThe chaddr to be set.
ipaddress_type Tins::BootP::ciaddr ( ) const
inline

Getter for the ciaddr field.

Returns
The ciaddr field for this BootP PDU.
void Tins::BootP::ciaddr ( ipaddress_type  address)

Setter for the ciaddr field.

Parameters
addressThe ciaddr to be set.
BootP* Tins::BootP::clone ( ) const
inlinevirtual
See also
PDU::clone

Implements Tins::PDU.

Reimplemented in Tins::DHCP.

const uint8_t* Tins::BootP::file ( ) const
inline

Getter for the file field.

Returns
The file field for this BootP PDU.
void Tins::BootP::file ( const uint8_t *  new_file)

Setter for the file field.

Parameters
new_fileThe file to be set.
ipaddress_type Tins::BootP::giaddr ( ) const
inline

Getter for the giaddr field.

Returns
The giaddr field for this BootP PDU.
void Tins::BootP::giaddr ( ipaddress_type  address)

Setter for the giaddr field.

Parameters
addressThe giaddr to be set.
uint32_t Tins::BootP::header_size ( ) const
virtual

Getter for the header size.

Returns
Returns the BOOTP header size.
See also
PDU::header_size

Implements Tins::PDU.

Reimplemented in Tins::DHCP.

uint8_t Tins::BootP::hlen ( ) const
inline

Getter for the hlen field.

Returns
The hlen field for this BootP PDU.
void Tins::BootP::hlen ( uint8_t  length)

Setter for the hlen field.

Parameters
lengthThe hlen field value to be set.
uint8_t Tins::BootP::hops ( ) const
inline

Getter for the hops field.

Returns
The hops field for this BootP PDU.
void Tins::BootP::hops ( uint8_t  count)

Setter for the hops field.

Parameters
countThe hops field value to be set.
uint8_t Tins::BootP::htype ( ) const
inline

Getter for the htype field.

Returns
The htype field for this BootP PDU.
void Tins::BootP::htype ( uint8_t  type)

Setter for the hardware type field.

Parameters
typeThe hardware type field value to be set.
bool Tins::BootP::matches_response ( const uint8_t *  ptr,
uint32_t  total_sz 
) const
virtual

Check whether ptr points to a valid response for this PDU.

This returns true if the xid field is equal.

See also
PDU::matches_response
Parameters
ptrThe pointer to the buffer.
total_szThe size of the buffer.

Reimplemented from Tins::PDU.

uint8_t Tins::BootP::opcode ( ) const
inline

Getter for the opcode field.

Returns
The opcode field for this BootP PDU.
void Tins::BootP::opcode ( uint8_t  code)

Setter for the opcode field.

Parameters
codeThe opcode to be set.
uint16_t Tins::BootP::padding ( ) const
inline

Getter for the padding field.

Returns
The padding field for this BootP PDU.
void Tins::BootP::padding ( uint16_t  value)

Setter for the padding field.

Parameters
valueThe padding to be set.
PDUType Tins::BootP::pdu_type ( ) const
inlinevirtual

Getter for the PDU's type.

See also
PDU::pdu_type

Implements Tins::PDU.

Reimplemented in Tins::DHCP.

uint16_t Tins::BootP::secs ( ) const
inline

Getter for the secs field.

Returns
The secs field for this BootP PDU.
void Tins::BootP::secs ( uint16_t  value)

Setter for the secs field.

Parameters
valueThe secs to be set.
ipaddress_type Tins::BootP::siaddr ( ) const
inline

Getter for the siaddr field.

Returns
The siaddr field for this BootP PDU.
void Tins::BootP::siaddr ( ipaddress_type  address)

Setter for the siaddr field.

Parameters
addressThe siaddr to be set.
const uint8_t* Tins::BootP::sname ( ) const
inline

Getter for the sname field.

Returns
The sname field for this BootP PDU.
void Tins::BootP::sname ( const uint8_t *  new_sname)

Setter for the sname field.

Parameters
new_snameThe sname to be set.
const vend_type& Tins::BootP::vend ( ) const
inline

Getter for the vend field.

Returns
The vend field for this BootP PDU.
void Tins::BootP::vend ( const vend_type newvend_)

Setter for the vend field.

Parameters
newvend_The vend to be set.
vend_type& Tins::BootP::vend ( )
inlineprotected

Getter for the vend field.

This getter can be used by subclasses to avoid copying the vend field around.

Returns
The vend field for this BootP PDU.
void Tins::BootP::write_serialization ( uint8_t *  buffer,
uint32_t  total_sz 
)
protectedvirtual

Serializes this TCP PDU.

Each PDU must override this method and implement it's own serialization.

Parameters
bufferThe buffer in which the PDU will be serialized.
total_szThe size available in the buffer.

Implements Tins::PDU.

uint32_t Tins::BootP::xid ( ) const
inline

Getter for the xid field.

Returns
The xid field for this BootP PDU.
void Tins::BootP::xid ( uint32_t  identifier)

Setter for the xid field.

Parameters
identifierThe xid to be set.
ipaddress_type Tins::BootP::yiaddr ( ) const
inline

Getter for the yiaddr field.

Returns
The yiaddr field for this BootP PDU.
void Tins::BootP::yiaddr ( ipaddress_type  address)

Setter for the yiaddr field.

Parameters
addressThe yiaddr to be set.

The documentation for this class was generated from the following files: