1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 04:34:27 +01:00

Modified some protocols' internal type names.

This commit is contained in:
Matias Fontanini
2013-04-09 15:40:58 -03:00
parent 20054e6c73
commit ae1e1c2ce2
22 changed files with 356 additions and 319 deletions

View File

@@ -67,7 +67,7 @@ namespace Tins {
/**
* \brief DHCP options enum.
*/
enum Options {
enum OptionTypes {
PAD,
SUBNET_MASK,
TIME_OFFSET,
@@ -140,15 +140,19 @@ namespace Tins {
END = 255
};
TINS_DEPRECATED(typedef OptionTypes Options);
/**
* The DHCP option type.
*/
typedef PDUOption<uint8_t> dhcp_option;
typedef PDUOption<uint8_t> option;
TINS_DEPRECATED(typedef option dhcp_option);
/**
* The type used to store the DHCP options.
*/
typedef std::list<dhcp_option> options_type;
typedef std::list<option> options_type;
/**
* \brief Creates an instance of DHCP.
@@ -169,9 +173,9 @@ namespace Tins {
/**
* \brief Adds a new option to this DHCP PDU.
* \param option The option to be added.
* \param opt The option to be added.
*/
void add_option(const dhcp_option &option);
void add_option(const option &opt);
#if TINS_IS_CXX11
/**
@@ -179,9 +183,9 @@ namespace Tins {
*
* The option is move-constructed.
*
* \param option The option to be added.
* \param opt The option to be added.
*/
void add_option(dhcp_option &&option);
void add_option(option &&opt);
#endif
/**
@@ -189,7 +193,7 @@ namespace Tins {
* \param opt_flag The flag to be searched.
* \return A pointer to the option, or 0 if it was not found.
*/
const dhcp_option *search_option(Options opt) const;
const option *search_option(OptionTypes opt) const;
/**
* \brief Adds a type option the the option list.
@@ -413,18 +417,18 @@ namespace Tins {
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
template<class T>
T generic_search(Options opt, type2type<T>) const {
const dhcp_option *option = search_option(opt);
T generic_search(OptionTypes opt, type2type<T>) const {
const option *option = search_option(opt);
if(option && option->data_size() == sizeof(T))
return *(const T*)option->data_ptr();
else
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;
void internal_add_option(const option &opt);
std::list<ipaddress_type> generic_search(OptionTypes opt, type2type<std::list<ipaddress_type> >) const;
std::string generic_search(OptionTypes opt, type2type<std::string>) const;
ipaddress_type generic_search(OptionTypes opt, type2type<ipaddress_type>) const;
serialization_type serialize_list(const std::list<ipaddress_type> &ip_list);

View File

@@ -46,7 +46,9 @@ public:
/**
* Represents a DHCPv6 option.
*/
typedef PDUOption<uint16_t> dhcpv6_option;
typedef PDUOption<uint16_t> option;
TINS_DEPRECATED(typedef option dhcpv6_option);
/**
* The message types.
@@ -74,7 +76,7 @@ public:
/**
* The DHCPv6 options.
*/
enum Option {
enum OptionTypes {
CLIENTID = 1,
SERVERID,
IA_NA,
@@ -150,11 +152,13 @@ public:
KRB_DEFAULT_REALM_NAME,
KRB_KDC
};
TINS_DEPRECATED(typedef OptionTypes Option);
/**
* The type used to store the DHCPv6 options.
*/
typedef std::list<dhcpv6_option> options_type;
typedef std::list<option> options_type;
/**
* The type used to store IP addresses.
@@ -366,7 +370,7 @@ public:
/**
* The type used to store the Option Request option.
*/
typedef std::vector<Option> option_request_type;
typedef std::vector<OptionTypes> option_request_type;
/**
* The type used to store the Relay Message option.
@@ -779,9 +783,9 @@ public:
* The option is added after the last option in the option
* fields.
*
* \param option The option to be added
* \param opt The option to be added
*/
void add_option(const dhcpv6_option &option);
void add_option(const option &opt);
/**
* \brief Searchs for an option that matchs the given flag.
@@ -792,7 +796,7 @@ public:
*
* \param id The option identifier to be searched.
*/
const dhcpv6_option *search_option(Option id) const;
const option *search_option(OptionTypes id) const;
// PDU stuff
@@ -826,11 +830,11 @@ public:
}
private:
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *);
uint8_t* write_option(const dhcpv6_option &option, uint8_t* buffer) const;
uint8_t* write_option(const option &option, uint8_t* buffer) const;
template<template <typename> class Functor>
const dhcpv6_option *safe_search_option(Option opt, uint32_t size) const {
const dhcpv6_option *option = search_option(opt);
const option *safe_search_option(OptionTypes opt, uint32_t size) const {
const option *option = search_option(opt);
if(!option || Functor<uint32_t>()(option->data_size(), size))
throw option_not_found();
return option;

View File

@@ -77,7 +77,7 @@ namespace Tins {
/**
* \brief Enum for the different types of tagged options.
*/
enum TaggedOption {
enum OptionTypes {
SSID,
SUPPORTED_RATES,
FH_SET,
@@ -112,6 +112,8 @@ namespace Tins {
RSN = 48,
EXT_SUPPORTED_RATES = 50
};
TINS_DEPRECATED(typedef OptionTypes TaggedOption);
/**
* \brief Enum for the different subtypes of 802.11 management frames.
@@ -169,7 +171,9 @@ namespace Tins {
/**
* \brief IEEE 802.11 options struct.
*/
typedef PDUOption<uint8_t> dot11_option;
typedef PDUOption<uint8_t> option;
TINS_DEPRECATED(typedef option dot11_option);
/**
* \brief Constructor for creating an 802.11 PDU
@@ -395,7 +399,13 @@ namespace Tins {
* \brief Adds a new option to this Dot11 PDU.
* \param opt The option to be added.
*/
void add_tagged_option(const dot11_option &opt);
TINS_DEPRECATED(void add_tagged_option(const option &opt));
/**
* \brief Adds a new option to this Dot11 PDU.
* \param opt The option to be added.
*/
void add_option(const option &opt);
#if TINS_IS_CXX11
/**
@@ -405,7 +415,7 @@ namespace Tins {
*
* \param opt The option to be added.
*/
void add_tagged_option(dot11_option &&opt);
void add_option(option &&opt);
#endif
/**
@@ -416,7 +426,7 @@ namespace Tins {
* \param opt The option identifier.
* \return The option found, or 0 if no such option has been set.
*/
const dot11_option *search_option(TaggedOption opt) const;
const option *search_option(OptionTypes opt) const;
/**
* \brief Getter for the PDU's type.
@@ -457,7 +467,7 @@ namespace Tins {
virtual uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz) { return 0; }
virtual uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { return 0; }
void parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz);
void add_tagged_option(TaggedOption opt, uint8_t len, const uint8_t *val);
void add_tagged_option(OptionTypes opt, uint8_t len, const uint8_t *val);
protected:
/**
* Struct that represents the 802.11 header
@@ -499,14 +509,14 @@ namespace Tins {
private:
Dot11(const ieee80211_header *header_ptr);
void internal_add_option(const dot11_option &opt);
void internal_add_option(const option &opt);
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
ieee80211_header _header;
NetworkInterface _iface;
uint32_t _options_size;
std::list<dot11_option> _options;
std::list<option> _options;
};
/**
@@ -1487,7 +1497,7 @@ namespace Tins {
}
private:
static uint8_t *serialize_rates(const rates_type &rates);
static rates_type deserialize_rates(const dot11_option *option);
static rates_type deserialize_rates(const option *option);
ExtendedHeader _ext_header;
address_type _addr4;

View File

@@ -84,7 +84,7 @@ public:
/**
* The types of ICMPv6 options.
*/
enum Options {
enum OptionTypes {
SOURCE_ADDRESS = 1,
TARGET_ADDRESS,
PREFIX_INFO,
@@ -122,6 +122,8 @@ public:
CARD_REPLY
};
TINS_DEPRECATED(typedef OptionTypes Options);
/**
* The type used to store addresses.
*/
@@ -135,12 +137,14 @@ public:
/**
* The type used to represent ICMPv6 options.
*/
typedef PDUOption<uint8_t> icmpv6_option;
typedef PDUOption<uint8_t> option;
TINS_DEPRECATED(typedef option icmpv6_option);
/**
* The type used to store options.
*/
typedef std::list<icmpv6_option> options_type;
typedef std::list<option> options_type;
/**
* \brief The type used to store the new home agent information
@@ -737,7 +741,7 @@ public:
*
* \param option The option to be added
*/
void add_option(const icmpv6_option &option);
void add_option(const option &option);
#if TINS_IS_CXX11
/**
@@ -747,7 +751,7 @@ public:
*
* \param option The option to be added.
*/
void add_option(icmpv6_option &&option);
void add_option(option &&option);
#endif
/**
@@ -776,7 +780,7 @@ public:
*
* \param id The option identifier to be searched.
*/
const icmpv6_option *search_option(Options id) const;
const option *search_option(OptionTypes id) const;
/**
* \sa PDU::clone
@@ -1202,17 +1206,17 @@ private:
};
} TINS_END_PACK;
void internal_add_option(const icmpv6_option &option);
void internal_add_option(const 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);
uint8_t *write_option(const option &opt, uint8_t *buffer);
void parse_options(const uint8_t *&buffer, uint32_t &total_sz);
void add_addr_list(uint8_t type, const addr_list_type &value);
addr_list_type search_addr_list(Options type) const;
addr_list_type search_addr_list(OptionTypes type) const;
template<template <typename> class Functor>
const icmpv6_option *safe_search_option(Options opt, uint32_t size) const {
const icmpv6_option *option = search_option(opt);
const option *safe_search_option(OptionTypes opt, uint32_t size) const {
const option *option = search_option(opt);
if(!option || Functor<uint32_t>()(option->data_size(), size))
throw option_not_found();
return option;

View File

@@ -169,7 +169,9 @@ namespace Tins {
/**
* The IP options type.
*/
typedef PDUOption<option_identifier> ip_option;
typedef PDUOption<option_identifier> option;
TINS_DEPRECATED(typedef option ip_option);
/**
* The type of the security option.
@@ -218,7 +220,7 @@ namespace Tins {
/**
* The type used to store IP options.
*/
typedef std::list<ip_option> options_type;
typedef std::list<option> options_type;
/**
* \brief Constructor for building the IP PDU.
@@ -415,9 +417,9 @@ namespace Tins {
* The option is added after the last option in the option
* fields.
*
* \param option The option to be added
* \param opt The option to be added
*/
void add_option(const ip_option &option);
void add_option(const option &opt);
#if TINS_IS_CXX11
/**
@@ -425,9 +427,9 @@ namespace Tins {
*
* The option is move-constructed.
*
* \param option The option to be added.
* \param opt The option to be added.
*/
void add_option(ip_option &&option);
void add_option(option &&opt);
#endif
/**
@@ -439,7 +441,7 @@ namespace Tins {
*
* \param id The option identifier to be searched.
*/
const ip_option *search_option(option_identifier id) const;
const option *search_option(option_identifier id) const;
// Option setters
@@ -635,10 +637,10 @@ namespace Tins {
} TINS_END_PACK;
void prepare_for_serialize(const PDU *parent);
void internal_add_option(const ip_option &option);
void internal_add_option(const 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);
uint8_t* write_option(const option &opt, uint8_t* buffer);
void add_route_option(option_identifier id, const generic_route_option_type &data);
generic_route_option_type search_route_option(option_identifier id) const;

View File

@@ -60,12 +60,14 @@ public:
/**
* The type used to represent IPv6 extension headers.
*/
typedef PDUOption<uint8_t> ipv6_ext_header;
typedef PDUOption<uint8_t> ext_header;
TINS_DEPRECATED(typedef ext_header ipv6_ext_header);
/**
* The type used to store the extension headers.
*/
typedef std::list<ipv6_ext_header> headers_type;
typedef std::list<ext_header> headers_type;
/**
* The values used to identify extension headers.
@@ -291,7 +293,7 @@ public:
*
* \param header The extension header to be added.
*/
void add_ext_header(const ipv6_ext_header &header);
void add_ext_header(const ext_header &header);
/**
* \brief Searchs for an extension header that matchs the given
@@ -303,11 +305,11 @@ public:
*
* \param id The header identifier to be searched.
*/
const ipv6_ext_header *search_header(ExtensionHeader id) const;
const ext_header *search_header(ExtensionHeader id) const;
private:
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
void set_last_next_header(uint8_t value);
static uint8_t *write_header(const ipv6_ext_header &header, uint8_t *buffer);
static uint8_t *write_header(const ext_header &header, uint8_t *buffer);
static bool is_extension_header(uint8_t header_id);
TINS_BEGIN_PACK

View File

@@ -45,7 +45,7 @@ public:
/**
* The tag types enum.
*/
enum tag_identifiers {
enum TagTypes {
END_OF_LIST = 0,
SERVICE_NAME = 0x101,
#if TINS_IS_LITTLE_ENDIAN
@@ -72,12 +72,12 @@ public:
/**
* The type used to store a TLV option.
*/
typedef PDUOption<tag_identifiers> pppoe_tag;
typedef PDUOption<TagTypes> tag;
/**
* The type used to store the options.
*/
typedef std::list<pppoe_tag> tags_type;
typedef std::list<tag> tags_type;
/**
* The type used to store the Vendor-Specific tag's value.
@@ -175,7 +175,7 @@ public:
return new PPPoE(*this);
}
const pppoe_tag *search_tag(tag_identifiers identifier) const;
const tag *search_tag(TagTypes identifier) const;
/**
* \brief Getter for the PDU's type.
@@ -220,7 +220,7 @@ public:
*
* \param option The option to be added.
*/
void add_tag(const pppoe_tag &option);
void add_tag(const tag &option);
#if TINS_IS_CXX11
/**
@@ -230,7 +230,7 @@ public:
*
* \param option The option to be added.
*/
void add_tag(pppoe_tag &&option);
void add_tag(tag &&option);
#endif
// Option setters
@@ -380,9 +380,9 @@ private:
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *);
template<typename T>
void add_tag_iterable(tag_identifiers id, const T &data) {
void add_tag_iterable(TagTypes id, const T &data) {
add_tag(
pppoe_tag(
tag(
id,
data.begin(),
data.end()
@@ -391,16 +391,16 @@ private:
}
template<typename T>
T retrieve_tag_iterable(tag_identifiers id) const {
const pppoe_tag *tag = search_tag(id);
T retrieve_tag_iterable(TagTypes id) const {
const tag *tag = search_tag(id);
if(!tag)
throw option_not_found();
return T(tag->data_ptr(), tag->data_ptr() + tag->data_size());
}
template<template <typename> class Functor>
const pppoe_tag *safe_search_tag(tag_identifiers opt, uint32_t size) const {
const pppoe_tag *option = search_tag(opt);
const tag *safe_search_tag(TagTypes opt, uint32_t size) const {
const tag *option = search_tag(opt);
if(!option || Functor<uint32_t>()(option->data_size(), size))
throw option_not_found();
return option;

View File

@@ -79,8 +79,7 @@ namespace Tins {
*
* This enum identifies valid options supported by TCP PDU.
*/
enum Option {
enum OptionTypes {
EOL = 0,
NOP = 1,
MSS = 2,
@@ -91,6 +90,8 @@ namespace Tins {
ALTCHK = 14
};
TINS_DEPRECATED(typedef OptionTypes Option);
/**
* \brief Alternate checksum enum.
*/
@@ -100,12 +101,17 @@ namespace Tins {
CHK_16FLETCHER
};
typedef PDUOption<uint8_t> tcp_option;
/**
* The type used to store TCP options.
*/
typedef PDUOption<uint8_t> option;
TINS_DEPRECATED(typedef option tcp_option);
/**
* The type used to store the options.
*/
typedef std::list<tcp_option> options_type;
typedef std::list<option> options_type;
/**
* The type used to store the sack option.
@@ -357,20 +363,20 @@ namespace Tins {
* \brief Adds a TCP option.
*
* \deprecated This function is deprecated. The overloads taking
* tcp_option should be used.
* a 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).
*/
TINS_DEPRECATED(void add_option(Option option, uint8_t length = 0, const uint8_t *data = 0));
TINS_DEPRECATED(void add_option(OptionTypes opt, 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);
void add_option(const option &opt);
#if TINS_IS_CXX11
/**
@@ -380,7 +386,7 @@ namespace Tins {
*
* \param option The option to be added.
*/
void add_option(tcp_option &&option);
void add_option(option &&opt);
#endif
/**
@@ -414,7 +420,7 @@ namespace Tins {
* \param opt_flag The flag to be searched.
* \return A pointer to the option, or 0 if it was not found.
*/
const tcp_option *search_option(Option opt) const;
const option *search_option(OptionTypes opt) const;
/**
* \sa PDU::clone
@@ -462,17 +468,17 @@ namespace Tins {
static const uint16_t DEFAULT_WINDOW;
template<class T>
T generic_search(Option opt) const {
const tcp_option *option = search_option(opt);
T generic_search(OptionTypes opt) const {
const option *option = search_option(opt);
if(option && option->data_size() == sizeof(T))
return *(const T*)(&option->data_ptr()[0]);
throw option_not_found();
}
void internal_add_option(const tcp_option &option);
void internal_add_option(const 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);
uint8_t *write_option(const option &opt, uint8_t *buffer);
tcphdr _tcp;
uint16_t _options_size, _total_options_size;