dhcp client: validate DHCP options for class DHCPMessage
According to RFC2131, a DHCP Message must contains the option 53:
'DHCP Message Type'. In addition, there are also requirements for
a certain type of DHCP Messages.
This change allow class DHCPMessage to validate the DHCP options
right after parsing them.
This also add corresponding unittests for DHCPMessage.
Bug: 25642025
TEST=compile and unittests
Change-Id: I11cdd08d3425b437893952df3da9454cedfcef15
diff --git a/dhcp_message.h b/dhcp_message.h
index acd5db8..a839ee1 100644
--- a/dhcp_message.h
+++ b/dhcp_message.h
@@ -19,6 +19,7 @@
#include <map>
#include <memory>
+#include <set>
#include <string>
#include <vector>
@@ -69,7 +70,7 @@
uint32_t transaction_id() const {return transaction_id_;}
- uint32_t your_ip_Address() const {return your_ip_address_;}
+ uint32_t your_ip_address() const {return your_ip_address_;}
const std::vector<uint32_t>& dns_server() const {return dns_server_;}
@@ -80,6 +81,7 @@
private:
bool ParseDHCPOptions(const uint8_t* options, size_t options_length);
bool IsValid();
+ bool ContainsValidOptions(const std::set<uint8_t>& options_set);
// Message type: request or reply.
uint8_t opcode_;