don't warn for DHCP release commands
This commit is contained in:
+10
-2
@@ -401,6 +401,9 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
if (dhcp.magic != 0x63825363) {
|
||||
throw runtime_error("incorrect DHCP magic cookie");
|
||||
}
|
||||
if (dhcp.opcode != 1) { // Request
|
||||
throw runtime_error("DHCP packet is not a request");
|
||||
}
|
||||
|
||||
unordered_map<uint8_t, string> option_data;
|
||||
for (;;) {
|
||||
@@ -412,7 +415,6 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
option_data.emplace(option, r.read(size));
|
||||
}
|
||||
|
||||
if (dhcp.opcode == 1) { // Request
|
||||
uint8_t command = 0;
|
||||
try {
|
||||
command = option_data.at(53).at(0);
|
||||
@@ -420,6 +422,10 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
throw runtime_error("client did not send a DHCP command option");
|
||||
}
|
||||
|
||||
if (command == 7) {
|
||||
// Release IP address (we just ignore these)
|
||||
|
||||
} else if ((command == 1) || (command == 3)) {
|
||||
// Populate the client's addresses
|
||||
c->mac_addr = dhcp.client_hardware_address.data();
|
||||
c->ipv4_addr = 0x0A000105; // 10.0.1.5
|
||||
@@ -495,7 +501,7 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
r_data = std::move(w.str());
|
||||
|
||||
} else {
|
||||
throw runtime_error("unknown DHCP command");
|
||||
throw runtime_error("client sent unknown DHCP command");
|
||||
}
|
||||
|
||||
} else if (fi.udp->dest_port == 53) { // DNS
|
||||
@@ -510,6 +516,7 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
throw runtime_error("UDP packet is not DHCP or DNS");
|
||||
}
|
||||
|
||||
if (!r_data.empty()) {
|
||||
r_ipv4.size = sizeof(IPv4Header) + sizeof(UDPHeader) + r_data.size();
|
||||
r_udp.size = sizeof(UDPHeader) + r_data.size();
|
||||
r_ipv4.checksum = FrameInfo::computed_ipv4_header_checksum(r_ipv4);
|
||||
@@ -539,6 +546,7 @@ void IPStackSimulator::on_client_udp_frame(
|
||||
w.write(r_data.data(), r_data.size());
|
||||
this->log_frame(w.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t IPStackSimulator::tcp_conn_key_for_connection(
|
||||
|
||||
Reference in New Issue
Block a user