1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 12:01:34 +01:00

Added an overload of add_option that takes an rvalue-ref in IP, TCP, DHCP, ICMPv6 and Dot11.

This commit is contained in:
Matias Fontanini
2013-03-24 00:08:53 -03:00
parent 584fe81f04
commit d7dd1e131f
12 changed files with 386 additions and 113 deletions

View File

@@ -35,6 +35,7 @@
#include <string>
#include "bootp.h"
#include "pdu_option.h"
#include "cxxstd.h"
namespace Tins {
/**
@@ -171,6 +172,17 @@ namespace Tins {
* \param option The option to be added.
*/
void add_option(const dhcp_option &option);
#if TINS_IS_CXX11
/**
* \brief Adds a new option to this DHCP PDU.
*
* The option is move-constructed.
*
* \param option The option to be added.
*/
void add_option(dhcp_option &&option);
#endif
/**
* \brief Searchs for an option that matchs the given flag.
@@ -409,6 +421,7 @@ namespace Tins {
throw option_not_found();
}
void internal_add_option(const dhcp_option &option);
std::list<ipaddress_type> generic_search(Options opt, type2type<std::list<ipaddress_type> >) const;
std::string generic_search(Options opt, type2type<std::string>) const;
ipaddress_type generic_search(Options opt, type2type<ipaddress_type>) const;

View File

@@ -42,6 +42,7 @@
#include "small_uint.h"
#include "pdu_option.h"
#include "network_interface.h"
#include "cxxstd.h"
namespace Tins {
class RSNInformation;
@@ -395,6 +396,17 @@ namespace Tins {
* \param opt The option to be added.
*/
void add_tagged_option(const dot11_option &opt);
#if TINS_IS_CXX11
/**
* \brief Adds a new option to this Dot11 PDU.
*
* The option is move-constructed
*
* \param opt The option to be added.
*/
void add_tagged_option(dot11_option &&opt);
#endif
/**
* \brief Looks up a tagged option in the option list.
@@ -484,10 +496,10 @@ namespace Tins {
uint8_t addr1[address_type::address_size];
} TINS_END_PACK;
private:
private:
Dot11(const ieee80211_header *header_ptr);
void internal_add_option(const dot11_option &opt);
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);

View File

@@ -40,6 +40,7 @@
#include "small_uint.h"
#include "hw_address.h"
#include "small_uint.h"
#include "cxxstd.h"
namespace Tins {
/**
@@ -737,6 +738,17 @@ public:
* \param option The option to be added
*/
void add_option(const icmpv6_option &option);
#if TINS_IS_CXX11
/**
* \brief Adds an ICMPv6 option.
*
* The option is move-constructed.
*
* \param option The option to be added.
*/
void add_option(icmpv6_option &&option);
#endif
/**
* \brief Returns the header size.
@@ -1181,6 +1193,7 @@ private:
};
} TINS_END_PACK;
void internal_add_option(const icmpv6_option &option);
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
bool has_options() const;
uint8_t *write_option(const icmpv6_option &opt, uint8_t *buffer);

View File

@@ -37,6 +37,7 @@
#include "ip_address.h"
#include "pdu_option.h"
#include "macros.h"
#include "cxxstd.h"
namespace Tins {
@@ -417,6 +418,17 @@ namespace Tins {
* \param option The option to be added
*/
void add_option(const ip_option &option);
#if TINS_IS_CXX11
/**
* \brief Adds an IP option.
*
* The option is move-constructed.
*
* \param option The option to be added.
*/
void add_option(ip_option &&option);
#endif
/**
* \brief Searchs for an option that matchs the given flag.
@@ -620,6 +632,7 @@ namespace Tins {
/*The options start here. */
} TINS_END_PACK;
void internal_add_option(const ip_option &option);
void init_ip_fields();
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
uint8_t* write_option(const ip_option &opt, uint8_t* buffer);

View File

@@ -39,10 +39,12 @@
#define TINS_BEGIN_PACK __pragma( pack(push, 1) )
#define TINS_END_PACK __pragma( pack(pop) )
#define TINS_PACKED(DECLARATION) __pragma( pack(push, 1) ) DECLARATION __pragma( pack(pop) )
#define TINS_DEPRECATED(func) __declspec(deprecated) func
#else
#define TINS_BEGIN_PACK
#define TINS_END_PACK __attribute__((packed))
#define TINS_PACKED(DECLARATION) DECLARATION __attribute__((packed))
#define TINS_DEPRECATED(func) func __attribute__ ((deprecated))
#endif
#endif

View File

@@ -41,6 +41,7 @@
#include "endianness.h"
#include "small_uint.h"
#include "pdu_option.h"
#include "cxxstd.h"
namespace Tins {
/**
@@ -355,11 +356,32 @@ namespace Tins {
/**
* \brief Adds a TCP option.
*
* \deprecated This function is deprecated. The overloads taking
* tcp_option should be used.
*
* \param option The option type flag to be set.
* \param length The length of this option(optional).
* \param data Pointer to this option's data(optional).
*/
void add_option(Option option, uint8_t length = 0, const uint8_t *data = 0);
TINS_DEPRECATED(void add_option(Option option, uint8_t length = 0, const uint8_t *data = 0));
/**
* \brief Adds a TCP option.
*
* \param option The option to be added.
*/
void add_option(const tcp_option &option);
#if TINS_IS_CXX11
/**
* \brief Adds a TCP option.
*
* This move-constructs the option.
*
* \param option The option to be added.
*/
void add_option(tcp_option &&option);
#endif
/**
* \brief Returns the header size.
@@ -437,7 +459,8 @@ namespace Tins {
return *(const T*)(&option->data_ptr()[0]);
throw option_not_found();
}
void internal_add_option(const tcp_option &option);
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
uint8_t *write_option(const tcp_option &opt, uint8_t *buffer);