diff --git a/include/dhcp.h b/include/dhcp.h index 28bbfc2..a82679e 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -251,6 +251,20 @@ namespace Tins { */ bool search_lease_time(uint32_t *value); + /** + * \brief Adds a lease renewal time option. + * \param time The lease renew time. + * \return True if the option was added successfully. \sa DHCP::add_option + */ + bool add_renewal_time(uint32_t time); + + /** + * \brief Searchs for a lease renewal time option. + * \param value A pointer in which the option's value will be stored. + * \return True if the option was found, false otherwise. + */ + bool search_renewal_time(uint32_t *value); + /** * \brief Adds a subnet mask option. * \param mask The subnet mask. diff --git a/src/dhcp.cpp b/src/dhcp.cpp index 092d00d..a6895f1 100644 --- a/src/dhcp.cpp +++ b/src/dhcp.cpp @@ -142,6 +142,19 @@ bool Tins::DHCP::search_lease_time(uint32_t *value) { return false; } +bool Tins::DHCP::add_renewal_time(uint32_t time) { + time = Utils::net_to_host_l(time); + return add_option(DHCP_RENEWAL_TIME, sizeof(uint32_t), (const uint8_t*)&time); +} + +bool Tins::DHCP::search_renewal_time(uint32_t *value) { + if(generic_search(DHCP_RENEWAL_TIME, value)) { + *value = Utils::net_to_host_l(*value); + return true; + } + return false; +} + bool Tins::DHCP::add_subnet_mask(uint32_t mask) { return add_option(SUBNET_MASK, sizeof(uint32_t), (const uint8_t*)&mask); }