diff --git a/include/tins/dhcp.h b/include/tins/dhcp.h index 41aedd9..6fb7b50 100644 --- a/include/tins/dhcp.h +++ b/include/tins/dhcp.h @@ -210,6 +210,17 @@ namespace Tins { _options.push_back(std::move(opt)); } #endif + + /** + * \brief Removes a DHCP option. + * + * If there are multiple options of the given type, only the first one + * will be removed. + * + * \param type The type of the option to be removed. + * \return true if the option was removed, false otherwise. + */ + bool remove_option(OptionTypes type); /** * \brief Searchs for an option that matchs the given flag. @@ -501,6 +512,8 @@ namespace Tins { void internal_add_option(const option &opt); serialization_type serialize_list(const std::vector &ip_list); + options_type::const_iterator search_option_iterator(OptionTypes opt) const; + options_type::iterator search_option_iterator(OptionTypes opt); options_type _options; uint32_t _size; diff --git a/include/tins/dhcpv6.h b/include/tins/dhcpv6.h index 027b9b6..0226ace 100644 --- a/include/tins/dhcpv6.h +++ b/include/tins/dhcpv6.h @@ -816,15 +816,26 @@ public: void add_option(const option &opt); /** - * \brief Searchs for an option that matchs the given flag. + * \brief Removes a DHCPv6 option. + * + * If there are multiple options of the given type, only the first one + * will be removed. + * + * \param type The type of the option to be removed. + * \return true if the option was removed, false otherwise. + */ + bool remove_option(OptionTypes type); + + /** + * \brief Searchs for an option that matchs the given type. * * If the option is not found, a null pointer is returned. * Deleting the returned pointer will result in undefined * behaviour. * - * \param id The option identifier to be searched. + * \param type The option identifier to be searched. */ - const option *search_option(OptionTypes id) const; + const option *search_option(OptionTypes type) const; // PDU stuff @@ -859,6 +870,8 @@ public: private: void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *); uint8_t* write_option(const option &option, uint8_t* buffer) const; + options_type::const_iterator search_option_iterator(OptionTypes type) const; + options_type::iterator search_option_iterator(OptionTypes type); template