aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-11-18 02:09:13 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-11-18 02:09:13 +0100
commit860491c5251886c40d6dfb89723f392db3a397a9 (patch)
treea675dd7a0713ad113eb016ca78b2273400dba3d9 /networking/udhcp/dhcpc.c
parent1dc80bae0b4c339553b8ee9fd8309c13f8c1f1d8 (diff)
downloadbusybox-w32-860491c5251886c40d6dfb89723f392db3a397a9.tar.gz
busybox-w32-860491c5251886c40d6dfb89723f392db3a397a9.tar.bz2
busybox-w32-860491c5251886c40d6dfb89723f392db3a397a9.zip
udhcpc: shrink code by setting xid more economically
function old new delta send_decline 90 82 -8 udhcpc_main 2649 2640 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 43d682341..945600c6b 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -726,7 +726,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
726#if ENABLE_FEATURE_UDHCPC_ARPING 726#if ENABLE_FEATURE_UDHCPC_ARPING
727/* Broadcast a DHCP decline message */ 727/* Broadcast a DHCP decline message */
728/* NOINLINE: limit stack usage in caller */ 728/* NOINLINE: limit stack usage in caller */
729static NOINLINE int send_decline(uint32_t xid, uint32_t server, uint32_t requested) 729static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t requested)
730{ 730{
731 struct dhcp_packet packet; 731 struct dhcp_packet packet;
732 732
@@ -735,12 +735,14 @@ static NOINLINE int send_decline(uint32_t xid, uint32_t server, uint32_t request
735 */ 735 */
736 init_packet(&packet, DHCPDECLINE); 736 init_packet(&packet, DHCPDECLINE);
737 737
738#if 0
738 /* RFC 2131 says DHCPDECLINE's xid is randomly selected by client, 739 /* RFC 2131 says DHCPDECLINE's xid is randomly selected by client,
739 * but in case the server is buggy and wants DHCPDECLINE's xid 740 * but in case the server is buggy and wants DHCPDECLINE's xid
740 * to match the xid which started entire handshake, 741 * to match the xid which started entire handshake,
741 * we use the same xid we used in initial DHCPDISCOVER: 742 * we use the same xid we used in initial DHCPDISCOVER:
742 */ 743 */
743 packet.xid = xid; 744 packet.xid = xid;
745#endif
744 /* DHCPDECLINE uses "requested ip", not ciaddr, to store offered IP */ 746 /* DHCPDECLINE uses "requested ip", not ciaddr, to store offered IP */
745 udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); 747 udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested);
746 748
@@ -1131,7 +1133,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1131 int discover_retries = 3; 1133 int discover_retries = 3;
1132 uint32_t server_addr = server_addr; /* for compiler */ 1134 uint32_t server_addr = server_addr; /* for compiler */
1133 uint32_t requested_ip = 0; 1135 uint32_t requested_ip = 0;
1134 uint32_t xid = 0; 1136 uint32_t xid = xid; /* for compiler */
1135 int packet_num; 1137 int packet_num;
1136 int timeout; /* must be signed */ 1138 int timeout; /* must be signed */
1137 unsigned already_waited_sec; 1139 unsigned already_waited_sec;
@@ -1520,7 +1522,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1520 1522
1521 switch (state) { 1523 switch (state) {
1522 case INIT_SELECTING: 1524 case INIT_SELECTING:
1523 /* Must be a DHCPOFFER to one of our xid's */ 1525 /* Must be a DHCPOFFER */
1524 if (*message == DHCPOFFER) { 1526 if (*message == DHCPOFFER) {
1525/* What exactly is server's IP? There are several values. 1527/* What exactly is server's IP? There are several values.
1526 * Example DHCP offer captured with tchdump: 1528 * Example DHCP offer captured with tchdump:
@@ -1600,7 +1602,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1600 ) { 1602 ) {
1601 bb_info_msg("Offered address is in use " 1603 bb_info_msg("Offered address is in use "
1602 "(got ARP reply), declining"); 1604 "(got ARP reply), declining");
1603 send_decline(xid, server_addr, packet.yiaddr); 1605 send_decline(/*xid,*/ server_addr, packet.yiaddr);
1604 1606
1605 if (state != REQUESTING) 1607 if (state != REQUESTING)
1606 udhcp_run_script(NULL, "deconfig"); 1608 udhcp_run_script(NULL, "deconfig");
@@ -1637,6 +1639,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1637 opt = ((opt & ~OPT_b) | OPT_f); 1639 opt = ((opt & ~OPT_b) | OPT_f);
1638 } 1640 }
1639#endif 1641#endif
1642 /* make future renew packets use different xid */
1643 /* xid = random_xid(); ...but why bother? */
1640 already_waited_sec = 0; 1644 already_waited_sec = 0;
1641 continue; /* back to main loop */ 1645 continue; /* back to main loop */
1642 } 1646 }