35 #include <tins/bootp.h>
36 #include <tins/macros.h>
37 #include <tins/pdu_option.h>
38 #include <tins/cxxstd.h>
103 RESOURCE_LOCATION_SERVERS,
112 NON_LOCAL_SOURCE_ROUTING,
114 MAX_DGRAM_REASSEMBLY,
116 PATH_MTU_AGING_TIMEOUT,
117 PATH_MTU_PLATEAU_TABLE,
121 PERFORM_MASK_DISCOVERY,
124 ROUTER_SOLICITATION_ADDRESS,
126 TRAILER_ENCAPSULATION,
128 IEEE802_3_ENCAPSULATION,
130 TCP_KEEPALIVE_INTERVAL,
131 TCP_KEEPALIVE_GARBAGE,
135 VENDOR_ENCAPSULATED_OPTIONS,
136 NETBIOS_NAME_SERVERS,
142 DHCP_REQUESTED_ADDRESS,
144 DHCP_OPTION_OVERLOAD,
146 DHCP_SERVER_IDENTIFIER,
147 DHCP_PARAMETER_REQUEST_LIST,
149 DHCP_MAX_MESSAGE_SIZE,
152 VENDOR_CLASS_IDENTIFIER,
153 DHCP_CLIENT_IDENTIFIER,
158 DHCP_AGENT_OPTIONS = 82,
159 SUBNET_SELECTION = 118,
180 static metadata extract_metadata(
const uint8_t *buffer, uint32_t total_sz);
200 DHCP(
const uint8_t* buffer, uint32_t total_sz);
206 void add_option(
const option& opt);
217 internal_add_option(opt);
218 options_.push_back(std::move(opt));
231 bool remove_option(OptionTypes type);
238 const option* search_option(OptionTypes opt)
const;
247 void type(Flags type);
267 void server_identifier(ipaddress_type ip);
276 void lease_time(uint32_t time);
285 void renewal_time(uint32_t time);
294 void rebind_time(uint32_t time);
303 void subnet_mask(ipaddress_type mask);
312 void routers(
const std::vector<ipaddress_type>& routers);
369 uint8_t type()
const;
389 uint32_t lease_time()
const;
399 uint32_t renewal_time()
const;
409 uint32_t rebind_time()
const;
430 std::vector<ipaddress_type> routers()
const;
440 std::vector<ipaddress_type> domain_name_servers()
const;
470 std::string domain_name()
const;
480 std::string hostname()
const;
499 uint32_t header_size()
const;
505 return new DHCP(*
this);
508 static const uint32_t MAX_DHCP_SIZE;
510 void write_serialization(uint8_t* buffer, uint32_t total_sz);
512 template <
typename T>
513 T search_and_convert(OptionTypes opt)
const {
514 const option* option = search_option(opt);
518 return option->to<T>();
521 void internal_add_option(
const option& opt);
522 serialization_type serialize_list(
const std::vector<ipaddress_type>& ip_list);
523 options_type::const_iterator search_option_iterator(OptionTypes opt)
const;
524 options_type::iterator search_option_iterator(OptionTypes opt);
526 options_type options_;
Represents a BootP PDU.
Definition: bootp.h:47
Represents the DHCP PDU.
Definition: dhcp.h:67
DHCP * clone() const
Definition: dhcp.h:504
const options_type options() const
Getter for the options list.
Definition: dhcp.h:486
Flags
Definition: dhcp.h:77
void add_option(option &&opt)
Adds a new option to this DHCP PDU.
Definition: dhcp.h:216
void hostname(const std::string &name)
Adds a hostname option.
void routers(const std::vector< ipaddress_type > &routers)
Adds a routers option.
OptionTypes
DHCP options enum.
Definition: dhcp.h:91
PDUOption< uint8_t, DHCP > option
Definition: dhcp.h:167
void domain_name_servers(const std::vector< ipaddress_type > &dns)
Adds a domain name servers option.
PDUType pdu_type() const
Getter for the PDU's type.
Definition: dhcp.h:492
void domain_name(const std::string &name)
Adds a domain name option.
std::vector< option > options_type
Definition: dhcp.h:172
Abstraction of an IPv4 address.
Definition: ip_address.h:45
Represents a PDU option field.
Definition: pdu_option.h:201
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
Exception thrown when an option is not found.
Definition: exceptions.h:56
The Tins namespace.
Definition: address_range.h:38