diff --git a/include/tins/ip.h b/include/tins/ip.h index c2c06826..420f974c 100644 --- a/include/tins/ip.h +++ b/include/tins/ip.h @@ -410,7 +410,7 @@ class TINS_API IP : public PDU { * \return The stored options. */ const options_type& options() const { - return ip_options_; + return options_; } /* Setters */ @@ -525,7 +525,7 @@ class TINS_API IP : public PDU { */ void add_option(option &&opt) { internal_add_option(opt); - ip_options_.push_back(std::move(opt)); + options_.push_back(std::move(opt)); } /** @@ -538,8 +538,8 @@ class TINS_API IP : public PDU { */ template void add_option(Args&&... args) { - ip_options_.emplace_back(std::forward(args)...); - internal_add_option(ip_options_.back()); + options_.emplace_back(std::forward(args)...); + internal_add_option(options_.back()); } #endif @@ -770,7 +770,7 @@ class TINS_API IP : public PDU { ip_header header_; uint16_t options_size_, padded_options_size_; - options_type ip_options_; + options_type options_; }; } // Tins diff --git a/include/tins/pdu_option.h b/include/tins/pdu_option.h index efb45a68..6e950c9d 100644 --- a/include/tins/pdu_option.h +++ b/include/tins/pdu_option.h @@ -537,22 +537,36 @@ class PDUOption { }; namespace Internals { - /* - * \cond - */ - template - struct option_type_equality_comparator { - option_type_equality_comparator(typename Option::option_type type) : type(type) { } +/* + * \cond + */ - bool operator()(const Option& opt) const { - return opt.option() == type; +template +typename Container::iterator find_option(Container& cont, typename Option::option_type type) { + typename Container::iterator iter; + for (iter = cont.begin(); iter != cont.end(); ++iter) { + if (iter->option() == type) { + break; } + } + return iter; +} - typename Option::option_type type; - }; - /* - * \endcond - */ +template +typename Container::const_iterator find_option_const(const Container& cont, + typename Option::option_type type) { + typename Container::const_iterator iter; + for (iter = cont.begin(); iter != cont.end(); ++iter) { + if (iter->option() == type) { + break; + } + } + return iter; +} + +/* + * \endcond + */ } // Internals } // namespace Tins diff --git a/src/arp.cpp b/src/arp.cpp index f415d47c..06eb32d7 100644 --- a/src/arp.cpp +++ b/src/arp.cpp @@ -28,7 +28,6 @@ */ #include -#include #include "arp.h" #include "ethernetII.h" #include "rawpdu.h" diff --git a/src/dhcp.cpp b/src/dhcp.cpp index 0ab03ef4..2a862890 100644 --- a/src/dhcp.cpp +++ b/src/dhcp.cpp @@ -29,7 +29,6 @@ #include #include -#include #include "endianness.h" #include "dhcp.h" #include "exceptions.h" @@ -39,7 +38,6 @@ using std::string; using std::vector; using std::list; using std::runtime_error; -using std::find_if; using Tins::Memory::InputMemoryStream; using Tins::Memory::OutputMemoryStream; @@ -113,13 +111,11 @@ const DHCP::option* DHCP::search_option(OptionTypes opt) const { } DHCP::options_type::const_iterator DHCP::search_option_iterator(OptionTypes opt) const { - Internals::option_type_equality_comparator