libtins
4.0
|
Represents a Point-to-point protocol over Ethernet PDU. More...
#include <pppoe.h>
Classes | |
struct | vendor_spec_type |
Public Types | |
enum | TagTypes { END_OF_LIST = 0, SERVICE_NAME = 0x101, AC_NAME = 0x102, HOST_UNIQ = 0x103, AC_COOKIE = 0x104, VENDOR_SPECIFIC = 0x105, RELAY_SESSION_ID = 0x110, SERVICE_NAME_ERROR = 0x201, AC_SYSTEM_ERROR = 0x202, GENERIC_ERROR = 0x203 } |
typedef PDUOption< TagTypes, PPPoE > | tag |
typedef std::vector< tag > | tags_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 | |
PPPoE () | |
Default constructor. More... | |
PPPoE (const uint8_t *buffer, uint32_t total_sz) | |
Constructor which creates an PPPoE object from a buffer. More... | |
small_uint< 4 > | version () const |
Getter for the version field. More... | |
small_uint< 4 > | type () const |
Getter for the type field. More... | |
uint8_t | code () const |
Getter for the code field. More... | |
uint16_t | session_id () const |
Getter for the session_id field. More... | |
uint16_t | payload_length () const |
Getter for the payload_length field. More... | |
uint32_t | header_size () const |
Returns the header size. More... | |
const tags_type & | tags () const |
Returns the list of tags. | |
PPPoE * | clone () const |
const tag * | search_tag (TagTypes identifier) const |
PDUType | pdu_type () const |
Getter for the PDU's type. More... | |
void | version (small_uint< 4 > new_version) |
Setter for the version field. More... | |
void | type (small_uint< 4 > new_type) |
Setter for the type field. More... | |
void | code (uint8_t new_code) |
Setter for the code field. More... | |
void | session_id (uint16_t new_session_id) |
Setter for the session_id field. More... | |
void | payload_length (uint16_t new_payload_length) |
Setter for the payload_length field. More... | |
void | add_tag (const tag &option) |
Adds a PPPoE tag. More... | |
void | add_tag (tag &&option) |
Adds a PPPoE tag. More... | |
void | end_of_list () |
Adds an end-of-list tag. | |
void | service_name (const std::string &value) |
Adds a service-name tag. More... | |
void | ac_name (const std::string &value) |
Adds a AC-name tag. More... | |
void | host_uniq (const byte_array &value) |
Adds a host-uniq tag. More... | |
void | ac_cookie (const byte_array &value) |
Adds a AC-Cookie tag. More... | |
void | vendor_specific (const vendor_spec_type &value) |
Adds a Vendor-Specific tag. More... | |
void | relay_session_id (const byte_array &value) |
Adds a Relay-Session-Id tag. More... | |
void | service_name_error (const std::string &value) |
Adds a Service-Name-Error tag. More... | |
void | ac_system_error (const std::string &value) |
Adds a AC-System-Error tag. More... | |
void | generic_error (const std::string &value) |
Adds a Generic-Error tag. More... | |
std::string | service_name () const |
Getter for the service-name tag. More... | |
std::string | ac_name () const |
Getter for the AC-name tag. More... | |
byte_array | host_uniq () const |
Getter for the host-uniq tag. More... | |
byte_array | ac_cookie () const |
Getter for the AC-Cookie tag. More... | |
vendor_spec_type | vendor_specific () const |
Getter for the Vendor-Specific tag. More... | |
byte_array | relay_session_id () const |
Getter for the Vendor-Specific tag. More... | |
std::string | service_name_error () const |
Getter for the Service-Name-Error tag. More... | |
std::string | ac_system_error () const |
Getter for the AC-System-Error tag. More... | |
std::string | generic_error () const |
Getter for the Generic-Error tag. More... | |
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_response (const uint8_t *ptr, uint32_t total_sz) const |
Check whether ptr points to a valid response for this PDU. 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::PPPOE |
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 a Point-to-point protocol over Ethernet PDU.
typedef PDUOption<TagTypes, PPPoE> Tins::PPPoE::tag |
The type used to store a TLV option.
typedef std::vector<tag> Tins::PPPoE::tags_type |
The type used to store the options.
The tag types enum.
Tins::PPPoE::PPPoE | ( | ) |
Default constructor.
This sets the version and type fields to 0x1.
Tins::PPPoE::PPPoE | ( | const uint8_t * | buffer, |
uint32_t | total_sz | ||
) |
Constructor which creates an PPPoE object from a buffer.
If there is not enough size for a PPPoE header, a malformed_packet exception is thrown.
buffer | The buffer from which this PDU will be constructed. |
total_sz | The total size of the buffer. |
void Tins::PPPoE::ac_cookie | ( | const byte_array & | value | ) |
Adds a AC-Cookie tag.
value | The tag's value. |
byte_array Tins::PPPoE::ac_cookie | ( | ) | const |
Getter for the AC-Cookie tag.
This method will throw an option_not_found exception if the option is not found.
void Tins::PPPoE::ac_name | ( | const std::string & | value | ) |
Adds a AC-name tag.
value | The AC name. |
string Tins::PPPoE::ac_name | ( | ) | const |
Getter for the AC-name tag.
This method will throw an option_not_found exception if the option is not found.
void Tins::PPPoE::ac_system_error | ( | const std::string & | value | ) |
Adds a AC-System-Error tag.
value | The tag's value. |
string Tins::PPPoE::ac_system_error | ( | ) | const |
Getter for the AC-System-Error tag.
This method will throw an option_not_found exception if the option is not found.
void Tins::PPPoE::add_tag | ( | const tag & | option | ) |
Adds a PPPoE tag.
option | The option to be added. |
|
inline |
|
inlinevirtual |
Implements Tins::PDU.
|
inline |
Getter for the code field.
void Tins::PPPoE::code | ( | uint8_t | new_code | ) |
Setter for the code field.
new_code | The new code field value. |
void Tins::PPPoE::generic_error | ( | const std::string & | value | ) |
Adds a Generic-Error tag.
value | The tag's value. |
string Tins::PPPoE::generic_error | ( | ) | const |
Getter for the Generic-Error tag.
This method will throw an option_not_found exception if the option is not found.
|
virtual |
Returns the header size.
This method overrides PDU::header_size.
Implements Tins::PDU.
void Tins::PPPoE::host_uniq | ( | const byte_array & | value | ) |
Adds a host-uniq tag.
value | The tag's value. |
byte_array Tins::PPPoE::host_uniq | ( | ) | const |
Getter for the host-uniq tag.
This method will throw an option_not_found exception if the option is not found.
|
inline |
Getter for the payload_length field.
void Tins::PPPoE::payload_length | ( | uint16_t | new_payload_length | ) |
Setter for the payload_length field.
new_payload_length | The new payload_length field value. |
|
inlinevirtual |
void Tins::PPPoE::relay_session_id | ( | const byte_array & | value | ) |
Adds a Relay-Session-Id tag.
value | The tag's value. |
byte_array Tins::PPPoE::relay_session_id | ( | ) | const |
Getter for the Vendor-Specific tag.
This method will throw an option_not_found exception if the option is not found.
void Tins::PPPoE::service_name | ( | const std::string & | value | ) |
Adds a service-name tag.
value | The service name. |
string Tins::PPPoE::service_name | ( | ) | const |
Getter for the service-name tag.
This method will throw an option_not_found exception if the option is not found.
void Tins::PPPoE::service_name_error | ( | const std::string & | value | ) |
Adds a Service-Name-Error tag.
value | The tag's value. |
string Tins::PPPoE::service_name_error | ( | ) | const |
Getter for the Service-Name-Error tag.
This method will throw an option_not_found exception if the option is not found.
|
inline |
Getter for the session_id field.
void Tins::PPPoE::session_id | ( | uint16_t | new_session_id | ) |
Setter for the session_id field.
new_session_id | The new session_id field value. |
|
inline |
Getter for the type field.
void Tins::PPPoE::type | ( | small_uint< 4 > | new_type | ) |
Setter for the type field.
new_type | The new type field value. |
void Tins::PPPoE::vendor_specific | ( | const vendor_spec_type & | value | ) |
Adds a Vendor-Specific tag.
value | The tag's value. |
PPPoE::vendor_spec_type Tins::PPPoE::vendor_specific | ( | ) | const |
Getter for the Vendor-Specific tag.
This method will throw an option_not_found exception if the option is not found.
|
inline |
Getter for the version field.
void Tins::PPPoE::version | ( | small_uint< 4 > | new_version | ) |
Setter for the version field.
new_version | The new version field value. |
|
static |
This PDU's flag.