1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 21:14:28 +01:00

Added some serialization tests to every PDU.

This commit is contained in:
Matias Fontanini
2012-08-26 12:50:30 -03:00
parent ba17ca3045
commit 1b08d1af71
19 changed files with 331 additions and 166 deletions

View File

@@ -205,6 +205,17 @@ namespace Tins {
*/
bool add_type_option(Flags type);
/**
* \brief Adds an end option the the option list.
*
* The END option is not added automatically. You should explicitly
* add it at the end of the DHCP options for the PDU to be
* standard-compliant.
*
* \return True if the option was added successfully. \sa DHCP::add_option
*/
bool add_end_option();
/**
* \brief Searchs for a type option.
* \param value A pointer in which the option's value will be stored.

View File

@@ -42,7 +42,6 @@ namespace Tins {
IPv4Address &operator=(const std::string &ip);
operator uint32_t() const;
operator std::string() const;
std::string to_string() const;
@@ -55,7 +54,7 @@ namespace Tins {
}
friend std::ostream &operator<<(std::ostream &output, const IPv4Address &addr) {
return output << (std::string)addr;
return output << addr.to_string();
}
private:
uint32_t ip_to_int(const std::string &ip);

View File

@@ -24,6 +24,7 @@
#include <stdint.h>
#include <vector>
#include "packetsender.h"
/** \brief The Tins namespace.
@@ -43,6 +44,10 @@ namespace Tins {
*/
class PDU {
public:
/**
* The type that will be returned when serializing PDUs.
*/
typedef std::vector<uint8_t> serialization_type;
/**
* \brief Enum which identifies each type of PDU.
@@ -148,13 +153,16 @@ namespace Tins {
void inner_pdu(PDU *next_pdu);
/** \brief Serializes the whole chain of PDU's, including this one.
/**
* \brief Serializes the whole chain of PDU's, including this one.
*
* \param sz The size of the buffer must be returned through this parameter.
* The buffer returned must be deleted by the user using
* operator delete[].
* This allocates a std::vector of size size(), and fills it
* with the serialization this PDU, and all of the inner ones'.
*
* \return serialization_type containing the serialization
* of the whole stack of PDUs.
*/
uint8_t *serialize(uint32_t &sz);
serialization_type serialize();
/**
* \brief Find and returns the first PDU that matches the given flag.