36 #include <tins/macros.h> 37 #include <tins/endianness.h> 38 #include <tins/small_uint.h> 39 #include <tins/pdu_option.h> 40 #include <tins/cxxstd.h> 55 #if TINS_IS_LITTLE_ENDIAN 59 VENDOR_SPECIFIC = 0x501,
60 RELAY_SESSION_ID = 0x101,
61 SERVICE_NAME_ERROR = 0x102,
62 AC_SYSTEM_ERROR = 0x202,
68 VENDOR_SPECIFIC = 0x105,
69 RELAY_SESSION_ID = 0x110,
70 SERVICE_NAME_ERROR = 0x201,
71 AC_SYSTEM_ERROR = 0x202,
90 typedef std::vector<uint8_t> data_type;
95 vendor_spec_type(uint32_t vendor_id = 0,
const data_type& data = data_type())
96 : vendor_id(vendor_id), data(data) { }
122 PPPoE(
const uint8_t* buffer, uint32_t total_sz);
131 return header_.version;
155 return Endian::be_to_host(header_.session_id);
163 return Endian::be_to_host(header_.payload_length);
171 uint32_t header_size()
const;
176 const tags_type&
tags()
const {
184 return new PPPoE(*
this);
187 const tag* search_tag(
TagTypes identifier)
const;
213 void code(uint8_t new_code);
219 void session_id(uint16_t new_session_id);
225 void payload_length(uint16_t new_payload_length);
232 void add_tag(
const tag& option);
243 tags_size_ +=
static_cast<uint16_t
>(option.
data_size() +
sizeof(uint16_t) * 2);
244 tags_.push_back(std::move(option));
260 void service_name(
const std::string& value);
267 void ac_name(
const std::string& value);
295 void relay_session_id(
const byte_array& value);
302 void service_name_error(
const std::string& value);
309 void ac_system_error(
const std::string& value);
316 void generic_error(
const std::string& value);
326 std::string service_name()
const;
334 std::string ac_name()
const;
374 std::string service_name_error()
const;
382 std::string ac_system_error()
const;
390 std::string generic_error()
const;
392 void write_serialization(uint8_t* buffer, uint32_t total_sz);
395 void add_tag_iterable(
TagTypes id,
const T& data) {
406 T search_and_convert(
TagTypes id)
const {
407 const tag* t = search_tag(
id);
415 struct pppoe_header {
416 #if TINS_IS_LITTLE_ENDIAN 426 uint16_t payload_length;
429 pppoe_header header_;
435 #endif // TINS_PPPoE_H TagTypes
Definition: pppoe.h:52
std::vector< uint8_t > byte_array
Definition: pdu.h:45
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
small_uint< 4 > type() const
Getter for the type field.
Definition: pppoe.h:138
small_uint< 4 > version() const
Getter for the version field.
Definition: pppoe.h:130
Represents a PDU option field.
Definition: pdu_option.h:201
PPPoE * clone() const
Definition: pppoe.h:183
void add_tag(tag &&option)
Adds a PPPoE tag.
Definition: pppoe.h:242
PDUOption< TagTypes, PPPoE > tag
Definition: pppoe.h:79
uint16_t session_id() const
Getter for the session_id field.
Definition: pppoe.h:154
The Tins namespace.
Definition: address_range.h:38
const tags_type & tags() const
Returns the list of tags.
Definition: pppoe.h:176
T to() const
Constructs a T from this PDUOption.
Definition: pdu_option.h:389
uint16_t payload_length() const
Getter for the payload_length field.
Definition: pppoe.h:162
uint8_t code() const
Getter for the code field.
Definition: pppoe.h:146
std::vector< tag > tags_type
Definition: pppoe.h:84
PDUType pdu_type() const
Getter for the PDU's type.
Definition: pppoe.h:193
size_t data_size() const
Retrieves the length of this option's data.
Definition: pdu_option.h:361
Base class for protocol data units.
Definition: pdu.h:107
Exception thrown when an option is not found.
Definition: exceptions.h:56
Represents a Point-to-point protocol over Ethernet PDU.
Definition: pppoe.h:47