Hello,
The udhcp client currently does not follow RFC2131
(http://www.ietf.org/rfc/rfc2131.txt) when sending DHCPDECLINE and
DHCPRELEASE
messages.
The send_decline function in clientpacket.c includes the Parameter request
list in the packet, something the RFC tells us that we MUST NOT do.
Also send_decline neglects to include the Requested ip address and the
Server identifier.
The function init_packet, also in clientpacket.c, always includes the
Vendor class identifier even tho the RFC tells us that we MUST NOT include
it in DHCPDECLINE or DHCPRELEASE messages. And send_release currently
includes
the Requested IP address something we MUST NOT do.
The attached patch fixes this. It's against the daily snapshop of 20080118.
Regards
Jonas Danielsson
diff -ur bb-snapshot-20080118-new/networking/udhcp/clientpacket.c bb-snapshot-20080118/networking/udhcp/clientpacket.c
--- bb-snapshot-20080118-new/networking/udhcp/clientpacket.c 2008-01-18 09:20:03.000000000 +0100
+++ bb-snapshot-20080118/networking/udhcp/clientpacket.c 2008-01-18 14:39:26.000000000 +0100
@@ -48,7 +48,8 @@
add_option_string(packet->options, client_config.hostname);
if (client_config.fqdn)
add_option_string(packet->options, client_config.fqdn);
- add_option_string(packet->options, client_config.vendorclass);
+ if ((type != DHCPDECLINE) && (type != DHCPRELEASE))
+ add_option_string(packet->options, client_config.vendorclass);
}
@@ -76,13 +77,14 @@
#if ENABLE_FEATURE_UDHCPC_ARPING
/* Unicast a DHCP decline message */
-int send_decline(uint32_t xid, uint32_t server)
+int send_decline(uint32_t xid, uint32_t server, uint32_t requested)
{
struct dhcpMessage packet;
init_packet(&packet, DHCPDECLINE);
packet.xid = xid;
- add_requests(&packet);
+ add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
+ add_simple_option(packet.options, DHCP_SERVER_ID, server);
bb_info_msg("Sending decline...");
@@ -159,7 +161,6 @@
packet.xid = random_xid();
packet.ciaddr = ciaddr;
- add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr);
add_simple_option(packet.options, DHCP_SERVER_ID, server);
bb_info_msg("Sending release...");
diff -ur bb-snapshot-20080118-new/networking/udhcp/dhcpc.c bb-snapshot-20080118/networking/udhcp/dhcpc.c
--- bb-snapshot-20080118-new/networking/udhcp/dhcpc.c 2008-01-18 09:20:03.000000000 +0100
+++ bb-snapshot-20080118/networking/udhcp/dhcpc.c 2008-01-18 14:36:44.000000000 +0100
@@ -523,7 +523,7 @@
) {
bb_info_msg("offered address is in use "
"(got ARP reply), declining");
- send_decline(xid, server_addr);
+ send_decline(xid, server_addr, packet.yiaddr);
if (state != REQUESTING)
udhcp_run_script(NULL, "deconfig");
diff -ur bb-snapshot-20080118-new/networking/udhcp/dhcpc.h bb-snapshot-20080118/networking/udhcp/dhcpc.h
--- bb-snapshot-20080118-new/networking/udhcp/dhcpc.h 2008-01-18 09:20:03.000000000 +0100
+++ bb-snapshot-20080118/networking/udhcp/dhcpc.h 2008-01-18 14:37:27.000000000 +0100
@@ -42,7 +42,7 @@
int send_discover(uint32_t xid, uint32_t requested);
int send_selecting(uint32_t xid, uint32_t server, uint32_t requested);
#if ENABLE_FEATURE_UDHCPC_ARPING
-int send_decline(uint32_t xid, uint32_t server);
+int send_decline(uint32_t xid, uint32_t server, uint32_t requested);
#endif
int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox