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.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index d1a0eaf02..656295ff7 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -906,7 +906,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
906 if (bytes < 0) { 906 if (bytes < 0) {
907 if (errno == EINTR) 907 if (errno == EINTR)
908 continue; 908 continue;
909 log1("packet read error, ignoring"); 909 log1s("packet read error, ignoring");
910 /* NB: possible down interface, etc. Caller should pause. */ 910 /* NB: possible down interface, etc. Caller should pause. */
911 return bytes; /* returns -1 */ 911 return bytes; /* returns -1 */
912 } 912 }
@@ -914,13 +914,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
914 } 914 }
915 915
916 if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) { 916 if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
917 log1("packet is too short, ignoring"); 917 log1s("packet is too short, ignoring");
918 return -2; 918 return -2;
919 } 919 }
920 920
921 if (bytes < ntohs(packet.ip.tot_len)) { 921 if (bytes < ntohs(packet.ip.tot_len)) {
922 /* packet is bigger than sizeof(packet), we did partial read */ 922 /* packet is bigger than sizeof(packet), we did partial read */
923 log1("oversized packet, ignoring"); 923 log1s("oversized packet, ignoring");
924 return -2; 924 return -2;
925 } 925 }
926 926
@@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
935 /* || bytes > (int) sizeof(packet) - can't happen */ 935 /* || bytes > (int) sizeof(packet) - can't happen */
936 || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip)) 936 || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
937 ) { 937 ) {
938 log1("unrelated/bogus packet, ignoring"); 938 log1s("unrelated/bogus packet, ignoring");
939 return -2; 939 return -2;
940 } 940 }
941 941
@@ -943,7 +943,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
943 check = packet.ip.check; 943 check = packet.ip.check;
944 packet.ip.check = 0; 944 packet.ip.check = 0;
945 if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) { 945 if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) {
946 log1("bad IP header checksum, ignoring"); 946 log1s("bad IP header checksum, ignoring");
947 return -2; 947 return -2;
948 } 948 }
949 949
@@ -968,13 +968,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
968 check = packet.udp.check; 968 check = packet.udp.check;
969 packet.udp.check = 0; 969 packet.udp.check = 0;
970 if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { 970 if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
971 log1("packet with bad UDP checksum received, ignoring"); 971 log1s("packet with bad UDP checksum received, ignoring");
972 return -2; 972 return -2;
973 } 973 }
974 skip_udp_sum_check: 974 skip_udp_sum_check:
975 975
976 if (packet.data.cookie != htonl(DHCP_MAGIC)) { 976 if (packet.data.cookie != htonl(DHCP_MAGIC)) {
977 bb_info_msg("packet with bad magic, ignoring"); 977 bb_simple_info_msg("packet with bad magic, ignoring");
978 return -2; 978 return -2;
979 } 979 }
980 980
@@ -1089,10 +1089,10 @@ static int udhcp_raw_socket(int ifindex)
1089 1089
1090 if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { 1090 if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) {
1091 if (errno != ENOPROTOOPT) 1091 if (errno != ENOPROTOOPT)
1092 log1("can't set PACKET_AUXDATA on raw socket"); 1092 log1s("can't set PACKET_AUXDATA on raw socket");
1093 } 1093 }
1094 1094
1095 log1("created raw socket"); 1095 log1s("created raw socket");
1096 1096
1097 return fd; 1097 return fd;
1098} 1098}
@@ -1120,7 +1120,7 @@ static void change_listen_mode(int new_mode)
1120/* Called only on SIGUSR1 */ 1120/* Called only on SIGUSR1 */
1121static void perform_renew(void) 1121static void perform_renew(void)
1122{ 1122{
1123 bb_info_msg("performing DHCP renew"); 1123 bb_simple_info_msg("performing DHCP renew");
1124 switch (client_data.state) { 1124 switch (client_data.state) {
1125 case BOUND: 1125 case BOUND:
1126 change_listen_mode(LISTEN_KERNEL); 1126 change_listen_mode(LISTEN_KERNEL);
@@ -1158,7 +1158,7 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
1158 inet_ntoa(temp_addr), buffer); 1158 inet_ntoa(temp_addr), buffer);
1159 send_release(server_addr, requested_ip); /* unicast */ 1159 send_release(server_addr, requested_ip); /* unicast */
1160 } 1160 }
1161 bb_info_msg("entering released state"); 1161 bb_simple_info_msg("entering released state");
1162/* 1162/*
1163 * We can be here on: SIGUSR2, 1163 * We can be here on: SIGUSR2,
1164 * or on exit (SIGTERM) and -R "release on quit" is specified. 1164 * or on exit (SIGTERM) and -R "release on quit" is specified.
@@ -1303,7 +1303,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1303 ); 1303 );
1304 if (opt & (OPT_h|OPT_H)) { 1304 if (opt & (OPT_h|OPT_H)) {
1305 //msg added 2011-11 1305 //msg added 2011-11
1306 bb_error_msg("option -h NAME is deprecated, use -x hostname:NAME"); 1306 bb_simple_error_msg("option -h NAME is deprecated, use -x hostname:NAME");
1307 client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0); 1307 client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0);
1308 } 1308 }
1309 if (opt & OPT_F) { 1309 if (opt & OPT_F) {
@@ -1397,7 +1397,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1397 /* Create pidfile */ 1397 /* Create pidfile */
1398 write_pidfile(client_data.pidfile); 1398 write_pidfile(client_data.pidfile);
1399 /* Goes to stdout (unless NOMMU) and possibly syslog */ 1399 /* Goes to stdout (unless NOMMU) and possibly syslog */
1400 bb_info_msg("started, v"BB_VER); 1400 bb_simple_info_msg("started, v"BB_VER);
1401 /* We want random_xid to be random... */ 1401 /* We want random_xid to be random... */
1402 srand(monotonic_us()); 1402 srand(monotonic_us());
1403 1403
@@ -1444,7 +1444,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1444 continue; 1444 continue;
1445 } 1445 }
1446 /* Else: an error occurred, panic! */ 1446 /* Else: an error occurred, panic! */
1447 bb_perror_msg_and_die("poll"); 1447 bb_simple_perror_msg_and_die("poll");
1448 } 1448 }
1449 } 1449 }
1450 1450
@@ -1485,7 +1485,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1485 udhcp_run_script(NULL, "leasefail"); 1485 udhcp_run_script(NULL, "leasefail");
1486#if BB_MMU /* -b is not supported on NOMMU */ 1486#if BB_MMU /* -b is not supported on NOMMU */
1487 if (opt & OPT_b) { /* background if no lease */ 1487 if (opt & OPT_b) { /* background if no lease */
1488 bb_info_msg("no lease, forking to background"); 1488 bb_simple_info_msg("no lease, forking to background");
1489 client_background(); 1489 client_background();
1490 /* do not background again! */ 1490 /* do not background again! */
1491 opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); 1491 opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
@@ -1498,7 +1498,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1498 } else 1498 } else
1499#endif 1499#endif
1500 if (opt & OPT_n) { /* abort if no lease */ 1500 if (opt & OPT_n) { /* abort if no lease */
1501 bb_info_msg("no lease, failing"); 1501 bb_simple_info_msg("no lease, failing");
1502 retval = 1; 1502 retval = 1;
1503 goto ret; 1503 goto ret;
1504 } 1504 }
@@ -1526,7 +1526,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1526 client_data.state = RENEWING; 1526 client_data.state = RENEWING;
1527 client_data.first_secs = 0; /* make secs field count from 0 */ 1527 client_data.first_secs = 0; /* make secs field count from 0 */
1528 change_listen_mode(LISTEN_KERNEL); 1528 change_listen_mode(LISTEN_KERNEL);
1529 log1("entering renew state"); 1529 log1s("entering renew state");
1530 /* fall right through */ 1530 /* fall right through */
1531 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ 1531 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
1532 case_RENEW_REQUESTED: 1532 case_RENEW_REQUESTED:
@@ -1559,7 +1559,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1559 */ 1559 */
1560 } 1560 }
1561 /* Timed out or error, enter rebinding state */ 1561 /* Timed out or error, enter rebinding state */
1562 log1("entering rebinding state"); 1562 log1s("entering rebinding state");
1563 client_data.state = REBINDING; 1563 client_data.state = REBINDING;
1564 /* fall right through */ 1564 /* fall right through */
1565 case REBINDING: 1565 case REBINDING:
@@ -1574,7 +1574,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1574 continue; 1574 continue;
1575 } 1575 }
1576 /* Timed out, enter init state */ 1576 /* Timed out, enter init state */
1577 bb_info_msg("lease lost, entering init state"); 1577 bb_simple_info_msg("lease lost, entering init state");
1578 udhcp_run_script(NULL, "deconfig"); 1578 udhcp_run_script(NULL, "deconfig");
1579 client_data.state = INIT_SELECTING; 1579 client_data.state = INIT_SELECTING;
1580 client_data.first_secs = 0; /* make secs field count from 0 */ 1580 client_data.first_secs = 0; /* make secs field count from 0 */
@@ -1660,13 +1660,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1660 || memcmp(packet.chaddr, client_data.client_mac, 6) != 0 1660 || memcmp(packet.chaddr, client_data.client_mac, 6) != 0
1661 ) { 1661 ) {
1662//FIXME: need to also check that last 10 bytes are zero 1662//FIXME: need to also check that last 10 bytes are zero
1663 log1("chaddr does not match, ignoring packet"); // log2? 1663 log1("chaddr does not match%s", ", ignoring packet"); // log2?
1664 continue; 1664 continue;
1665 } 1665 }
1666 1666
1667 message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); 1667 message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
1668 if (message == NULL) { 1668 if (message == NULL) {
1669 bb_info_msg("no message type option, ignoring packet"); 1669 bb_info_msg("no message type option%s", ", ignoring packet");
1670 continue; 1670 continue;
1671 } 1671 }
1672 1672
@@ -1703,7 +1703,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1703 server_addr = 0; 1703 server_addr = 0;
1704 temp = udhcp_get_option32(&packet, DHCP_SERVER_ID); 1704 temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
1705 if (!temp) { 1705 if (!temp) {
1706 bb_info_msg("no server ID, using 0.0.0.0"); 1706 bb_simple_info_msg("no server ID, using 0.0.0.0");
1707 } else { 1707 } else {
1708 /* it IS unaligned sometimes, don't "optimize" */ 1708 /* it IS unaligned sometimes, don't "optimize" */
1709 move_from_unaligned32(server_addr, temp); 1709 move_from_unaligned32(server_addr, temp);
@@ -1730,7 +1730,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1730 1730
1731 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME); 1731 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
1732 if (!temp) { 1732 if (!temp) {
1733 bb_info_msg("no lease time with ACK, using 1 hour lease"); 1733 bb_simple_info_msg("no lease time with ACK, using 1 hour lease");
1734 lease_seconds = 60 * 60; 1734 lease_seconds = 60 * 60;
1735 } else { 1735 } else {
1736 /* it IS unaligned sometimes, don't "optimize" */ 1736 /* it IS unaligned sometimes, don't "optimize" */
@@ -1763,7 +1763,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1763 client_data.interface, 1763 client_data.interface,
1764 arpping_ms) 1764 arpping_ms)
1765 ) { 1765 ) {
1766 bb_info_msg("offered address is in use " 1766 bb_simple_info_msg("offered address is in use "
1767 "(got ARP reply), declining"); 1767 "(got ARP reply), declining");
1768 send_decline(/*xid,*/ server_addr, packet.yiaddr); 1768 send_decline(/*xid,*/ server_addr, packet.yiaddr);
1769 1769
@@ -1827,7 +1827,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1827 if (!temp) { 1827 if (!temp) {
1828 non_matching_svid: 1828 non_matching_svid:
1829 log1("received DHCP NAK with wrong" 1829 log1("received DHCP NAK with wrong"
1830 " server ID, ignoring packet"); 1830 " server ID%s", ", ignoring packet");
1831 continue; 1831 continue;
1832 } 1832 }
1833 move_from_unaligned32(svid, temp); 1833 move_from_unaligned32(svid, temp);