libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
Tins::PPPoE Class Reference

Represents a Point-to-point protocol over Ethernet PDU. More...

#include <pppoe.h>

Inheritance diagram for Tins::PPPoE:
Tins::PDU

Classes

struct  vendor_spec_type
 

Public Types

enum  TagTypes {
  END_OF_LIST = 0, SERVICE_NAME = 0x101, AC_NAME = 0x201, HOST_UNIQ = 0x301,
  AC_COOKIE = 0x401, VENDOR_SPECIFIC = 0x501, RELAY_SESSION_ID = 0x101, SERVICE_NAME_ERROR = 0x102,
  AC_SYSTEM_ERROR = 0x202, GENERIC_ERROR = 0x302
}
 
typedef PDUOption< TagTypes,
PPPoE
tag
 
typedef std::list< tagtags_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_typetags () const
 Returns the list of tags.
 
PPPoEclone () const
 
const tagsearch_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...
 
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...
 
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_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.
 
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 (const PDU *parent)
 Prepares this PDU for serialization. More...
 
void serialize (uint8_t *buffer, uint32_t total_sz, const PDU *parent)
 Serializes this PDU and propagates this action to child PDUs. More...
 

Detailed Description

Represents a Point-to-point protocol over Ethernet PDU.

Member Typedef Documentation

The type used to store a TLV option.

typedef std::list<tag> Tins::PPPoE::tags_type

The type used to store the options.

Member Enumeration Documentation

The tag types enum.

Constructor & Destructor Documentation

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.

Parameters
bufferThe buffer from which this PDU will be constructed.
total_szThe total size of the buffer.

Member Function Documentation

void Tins::PPPoE::ac_cookie ( const byte_array value)

Adds a AC-Cookie tag.

Parameters
valueThe 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.

Parameters
valueThe 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.

Parameters
valueThe 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.

Parameters
optionThe option to be added.
void Tins::PPPoE::add_tag ( tag &&  option)
inline

Adds a PPPoE tag.

This move-constructs the option.

Parameters
optionThe option to be added.
PPPoE* Tins::PPPoE::clone ( ) const
inlinevirtual
See Also
PDU::clone

Implements Tins::PDU.

uint8_t Tins::PPPoE::code ( ) const
inline

Getter for the code field.

Returns
The stored code field value.
void Tins::PPPoE::code ( uint8_t  new_code)

Setter for the code field.

Parameters
new_codeThe new code field value.
void Tins::PPPoE::generic_error ( const std::string &  value)

Adds a Generic-Error tag.

Parameters
valueThe 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.

uint32_t Tins::PPPoE::header_size ( ) const
virtual

Returns the header size.

This method overrides PDU::header_size.

See Also
PDU::header_size

Implements Tins::PDU.

void Tins::PPPoE::host_uniq ( const byte_array value)

Adds a host-uniq tag.

Parameters
valueThe 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.

uint16_t Tins::PPPoE::payload_length ( ) const
inline

Getter for the payload_length field.

Returns
The stored payload_length field value.
void Tins::PPPoE::payload_length ( uint16_t  new_payload_length)

Setter for the payload_length field.

Parameters
new_payload_lengthThe new payload_length field value.
PDUType Tins::PPPoE::pdu_type ( ) const
inlinevirtual

Getter for the PDU's type.

See Also
PDU::pdu_type

Implements Tins::PDU.

void Tins::PPPoE::relay_session_id ( const byte_array value)

Adds a Relay-Session-Id tag.

Parameters
valueThe 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.

Parameters
valueThe 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.

Parameters
valueThe 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.

uint16_t Tins::PPPoE::session_id ( ) const
inline

Getter for the session_id field.

Returns
The stored session_id field value.
void Tins::PPPoE::session_id ( uint16_t  new_session_id)

Setter for the session_id field.

Parameters
new_session_idThe new session_id field value.
small_uint<4> Tins::PPPoE::type ( ) const
inline

Getter for the type field.

Returns
The stored type field value.
void Tins::PPPoE::type ( small_uint< 4 >  new_type)

Setter for the type field.

Parameters
new_typeThe new type field value.
void Tins::PPPoE::vendor_specific ( const vendor_spec_type value)

Adds a Vendor-Specific tag.

Parameters
valueThe 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.

small_uint<4> Tins::PPPoE::version ( ) const
inline

Getter for the version field.

Returns
The stored version field value.
void Tins::PPPoE::version ( small_uint< 4 >  new_version)

Setter for the version field.

Parameters
new_versionThe new version field value.

Member Data Documentation

const PDU::PDUType Tins::PPPoE::pdu_flag = PDU::PPPOE
static

This PDU's flag.


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