specifies the hostname carried in the Hostname option sent by the
client.
+% DHCP4_CLIENT_HOSTNAME_EMPTY %1: client sent bogus empty Hostname option
+This informational message is issued when the server receives an
+empty Hostname option. Such option is bogus (size is required to be
+at least one) and is ignored.
+
% DHCP4_CLIENT_HOSTNAME_PROCESS %1: processing client's Hostname option
This debug message is issued when the server starts processing the Hostname
option sent in the client's query. The argument includes the client and
OptionStringPtr opt_hostname = boost::dynamic_pointer_cast<OptionString>
(ex.getQuery()->getOption(DHO_HOST_NAME));
+ // Ignore empty/bogus Hostname option.
+ if (opt_hostname && opt_hostname->getValue().empty()) {
+ opt_hostname.reset();
+ LOG_INFO(ddns4_logger, DHCP4_CLIENT_HOSTNAME_EMPTY)
+ .arg(ex.getQuery()->getLabel());
+ }
+
if (opt_hostname) {
LOG_DEBUG(ddns4_logger, DBG_DHCP4_DETAIL_DATA, DHCP4_CLIENT_HOSTNAME_DATA)
.arg(ex.getQuery()->getLabel())
}
+ // Create a message holding an empty Hostname option.
+ Pkt4Ptr generatePktWithEmptyHostname(const uint8_t msg_type) {
+
+ Pkt4Ptr pkt = Pkt4Ptr(new Pkt4(msg_type, 1234));
+ pkt->setRemoteAddr(IOAddress("192.0.2.3"));
+ // For DISCOVER we don't include server id, because client broadcasts
+ // the message to all servers.
+ if (msg_type != DHCPDISCOVER) {
+ pkt->addOption(srv_->getServerID());
+ }
+
+ pkt->addOption(generateClientId());
+
+ // Create Hostname option.
+ std::string hostname(" ");
+ OptionPtr opt = createHostname(hostname);
+ opt->setData(hostname.begin(), hostname.begin());
+ pkt->addOption(opt);
+
+ return (pkt);
+
+ }
+
// Create a message holding of a given type
Pkt4Ptr generatePkt(const uint8_t msg_type) {
Pkt4Ptr pkt = Pkt4Ptr(new Pkt4(msg_type, 1234));
EXPECT_FALSE(hostname);
}
+// Test that the server skips processing of an empty Hostname option.
+TEST_F(NameDhcpv4SrvTest, serverUpdateEmptyHostname) {
+ Pkt4Ptr query;
+ ASSERT_NO_THROW(query = generatePktWithEmptyHostname(DHCPREQUEST));
+ OptionStringPtr hostname;
+ ASSERT_NO_THROW(hostname = processHostname(query));
+ EXPECT_FALSE(hostname);
+}
+
// Test that server generates the fully qualified domain name for the client
// if client supplies the partial name.