aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 922c71ebd..bbcbd1fca 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -729,7 +729,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
729 */ 729 */
730 add_client_options(&packet); 730 add_client_options(&packet);
731 731
732 bb_info_msg("sending %s", "discover"); 732 bb_simple_info_msg("broadcasting discover");
733 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 733 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
734} 734}
735 735
@@ -742,6 +742,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
742{ 742{
743 struct dhcp_packet packet; 743 struct dhcp_packet packet;
744 struct in_addr temp_addr; 744 struct in_addr temp_addr;
745 char server_str[sizeof("255.255.255.255")];
745 746
746/* 747/*
747 * RFC 2131 4.3.2 DHCPREQUEST message 748 * RFC 2131 4.3.2 DHCPREQUEST message
@@ -772,8 +773,13 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
772 */ 773 */
773 add_client_options(&packet); 774 add_client_options(&packet);
774 775
776 temp_addr.s_addr = server;
777 strcpy(server_str, inet_ntoa(temp_addr));
775 temp_addr.s_addr = requested; 778 temp_addr.s_addr = requested;
776 bb_info_msg("sending select for %s", inet_ntoa(temp_addr)); 779 bb_info_msg("broadcasting select for %s, server %s",
780 inet_ntoa(temp_addr),
781 server_str
782 );
777 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 783 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
778} 784}
779 785
@@ -782,7 +788,6 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
782static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) 788static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
783{ 789{
784 struct dhcp_packet packet; 790 struct dhcp_packet packet;
785 struct in_addr temp_addr;
786 791
787/* 792/*
788 * RFC 2131 4.3.2 DHCPREQUEST message 793 * RFC 2131 4.3.2 DHCPREQUEST message
@@ -813,8 +818,14 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
813 */ 818 */
814 add_client_options(&packet); 819 add_client_options(&packet);
815 820
816 temp_addr.s_addr = server; 821 if (server) {
817 bb_info_msg("sending renew to %s", inet_ntoa(temp_addr)); 822 struct in_addr temp_addr;
823 temp_addr.s_addr = server;
824 bb_info_msg("sending renew to server %s", inet_ntoa(temp_addr));
825 } else {
826 bb_simple_info_msg("broadcasting renew");
827 }
828
818 return bcast_or_ucast(&packet, ciaddr, server); 829 return bcast_or_ucast(&packet, ciaddr, server);
819} 830}
820 831
@@ -843,7 +854,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
843 854
844 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); 855 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
845 856
846 bb_info_msg("sending %s", "decline"); 857 bb_simple_info_msg("broadcasting decline");
847 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 858 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
848} 859}
849#endif 860#endif
@@ -1644,8 +1655,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1644 } 1655 }
1645 1656
1646 if (packet.xid != xid) { 1657 if (packet.xid != xid) {
1647 log1("xid %x (our is %x), ignoring packet", 1658 log1("xid %x (our is %x)%s",
1648 (unsigned)packet.xid, (unsigned)xid); 1659 (unsigned)packet.xid, (unsigned)xid,
1660 ", ignoring packet"
1661 );
1649 continue; 1662 continue;
1650 } 1663 }
1651 1664
@@ -1720,6 +1733,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1720 unsigned start; 1733 unsigned start;
1721 uint32_t lease_seconds; 1734 uint32_t lease_seconds;
1722 struct in_addr temp_addr; 1735 struct in_addr temp_addr;
1736 char server_str[sizeof("255.255.255.255")];
1723 uint8_t *temp; 1737 uint8_t *temp;
1724 1738
1725 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME); 1739 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
@@ -1775,9 +1789,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1775 } 1789 }
1776#endif 1790#endif
1777 /* enter bound state */ 1791 /* enter bound state */
1792 temp_addr.s_addr = server_addr;
1793 strcpy(server_str, inet_ntoa(temp_addr));
1778 temp_addr.s_addr = packet.yiaddr; 1794 temp_addr.s_addr = packet.yiaddr;
1779 bb_info_msg("lease of %s obtained, lease time %u", 1795 bb_info_msg("lease of %s obtained from %s, lease time %u",
1780 inet_ntoa(temp_addr), (unsigned)lease_seconds); 1796 inet_ntoa(temp_addr), server_str, (unsigned)lease_seconds);
1781 requested_ip = packet.yiaddr; 1797 requested_ip = packet.yiaddr;
1782 1798
1783 start = monotonic_sec(); 1799 start = monotonic_sec();