aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-03-30 18:41:23 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-30 18:41:23 +0200
commit8f2e99c813dcac25faf58162ed18848a02888ff6 (patch)
treeb8e0371701511e7600aad1874c0871148331a36f
parent80f0f1d712fb3ab236e1fc8b37dfa7a9224d7849 (diff)
downloadbusybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.tar.gz
busybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.tar.bz2
busybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.zip
udhcp: get rid of bb_info_msg()
function old new delta udhcpd_main 1501 1531 +30 d6_recv_raw_packet 251 264 +13 perform_d6_release 188 198 +10 udhcpc6_main 2443 2449 +6 udhcp_recv_raw_packet 582 588 +6 udhcp_recv_kernel_packet 132 138 +6 send_d6_renew 140 146 +6 d6_recv_kernel_packet 118 124 +6 send_renew 77 82 +5 send_discover 85 90 +5 send_decline 84 89 +5 send_d6_select 97 102 +5 send_d6_discover 174 179 +5 perform_release 167 172 +5 count_lines 72 74 +2 udhcpc_main 2836 2837 +1 bb_info_msg 125 - -125 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180) Total: -63 bytes text data bss dec hex filename 924935 906 17160 943001 e6399 busybox_old 924736 906 17160 942802 e62d2 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/Kbuild.src1
-rw-r--r--libbb/info_msg.c62
-rw-r--r--networking/udhcp/arpping.c2
-rw-r--r--networking/udhcp/common.c8
-rw-r--r--networking/udhcp/common.h6
-rw-r--r--networking/udhcp/d6_dhcpc.c60
-rw-r--r--networking/udhcp/d6_packet.c10
-rw-r--r--networking/udhcp/d6_socket.c2
-rw-r--r--networking/udhcp/dhcpc.c70
-rw-r--r--networking/udhcp/dhcpd.c34
-rw-r--r--networking/udhcp/files.c2
-rw-r--r--networking/udhcp/leases.c2
-rw-r--r--networking/udhcp/packet.c12
-rw-r--r--networking/udhcp/socket.c4
-rw-r--r--networking/udhcp/static_leases.c2
16 files changed, 107 insertions, 171 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 8b226c00c..98d788402 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1150,7 +1150,6 @@ extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1,
1150extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC; 1150extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
1151extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC; 1151extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
1152extern void bb_perror_nomsg(void) FAST_FUNC; 1152extern void bb_perror_nomsg(void) FAST_FUNC;
1153extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
1154extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC; 1153extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
1155extern void bb_logenv_override(void) FAST_FUNC; 1154extern void bb_logenv_override(void) FAST_FUNC;
1156 1155
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 7fb687227..b08ce1158 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -46,7 +46,6 @@ lib-y += get_volsize.o
46lib-y += herror_msg.o 46lib-y += herror_msg.o
47lib-y += human_readable.o 47lib-y += human_readable.o
48lib-y += inet_common.o 48lib-y += inet_common.o
49lib-y += info_msg.o
50lib-y += inode_hash.o 49lib-y += inode_hash.o
51lib-y += isdirectory.o 50lib-y += isdirectory.o
52lib-y += kernel_version.o 51lib-y += kernel_version.o
diff --git a/libbb/info_msg.c b/libbb/info_msg.c
deleted file mode 100644
index 56ca2efd4..000000000
--- a/libbb/info_msg.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */
9
10#include "libbb.h"
11#if ENABLE_FEATURE_SYSLOG
12# include <syslog.h>
13#endif
14
15void FAST_FUNC bb_info_msg(const char *s, ...)
16{
17#ifdef THIS_ONE_DOESNT_DO_SINGLE_WRITE
18 va_list p;
19 /* va_copy is used because it is not portable
20 * to use va_list p twice */
21 va_list p2;
22
23 va_start(p, s);
24 va_copy(p2, p);
25 if (logmode & LOGMODE_STDIO) {
26 vprintf(s, p);
27 fputs(msg_eol, stdout);
28 }
29# if ENABLE_FEATURE_SYSLOG
30 if (logmode & LOGMODE_SYSLOG)
31 vsyslog(LOG_INFO, s, p2);
32# endif
33 va_end(p2);
34 va_end(p);
35#else
36 int used;
37 char *msg;
38 va_list p;
39
40 if (logmode == 0)
41 return;
42
43 va_start(p, s);
44 used = vasprintf(&msg, s, p);
45 va_end(p);
46 if (used < 0)
47 return;
48
49# if ENABLE_FEATURE_SYSLOG
50 if (logmode & LOGMODE_SYSLOG)
51 syslog(LOG_INFO, "%s", msg);
52# endif
53 if (logmode & LOGMODE_STDIO) {
54 fflush_all();
55 /* used = strlen(msg); - must be true already */
56 msg[used++] = '\n';
57 full_write(STDOUT_FILENO, msg, used);
58 }
59
60 free(msg);
61#endif
62}
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index fad2283c3..c98027316 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -132,6 +132,6 @@ int FAST_FUNC arpping(uint32_t test_nip,
132 132
133 ret: 133 ret:
134 close(s); 134 close(s);
135 log1("%srp reply received for this address", rv ? "No a" : "A"); 135 log1("%srp reply received for this address", rv ? "no a" : "A");
136 return rv; 136 return rv;
137} 137}
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 680852ce4..1c1863451 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -183,7 +183,7 @@ static void log_option(const char *pfx, const uint8_t *opt)
183 if (dhcp_verbose >= 2) { 183 if (dhcp_verbose >= 2) {
184 char buf[256 * 2 + 2]; 184 char buf[256 * 2 + 2];
185 *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0'; 185 *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
186 bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf); 186 bb_error_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
187 } 187 }
188} 188}
189#else 189#else
@@ -269,7 +269,7 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code)
269 } 269 }
270 270
271 /* log3 because udhcpc uses it a lot - very noisy */ 271 /* log3 because udhcpc uses it a lot - very noisy */
272 log3("Option 0x%02x not found", code); 272 log3("option 0x%02x not found", code);
273 return NULL; 273 return NULL;
274} 274}
275 275
@@ -402,7 +402,7 @@ static NOINLINE void attach_option(
402 struct option_set *new, **curr; 402 struct option_set *new, **curr;
403 403
404 /* make a new option */ 404 /* make a new option */
405 log2("Attaching option %02x to list", optflag->code); 405 log2("attaching option %02x to list", optflag->code);
406 new = xmalloc(sizeof(*new)); 406 new = xmalloc(sizeof(*new));
407 new->data = xmalloc(length + OPT_DATA); 407 new->data = xmalloc(length + OPT_DATA);
408 new->data[OPT_CODE] = optflag->code; 408 new->data[OPT_CODE] = optflag->code;
@@ -422,7 +422,7 @@ static NOINLINE void attach_option(
422 unsigned old_len; 422 unsigned old_len;
423 423
424 /* add it to an existing option */ 424 /* add it to an existing option */
425 log2("Attaching option %02x to existing member of list", optflag->code); 425 log2("attaching option %02x to existing member of list", optflag->code);
426 old_len = existing->data[OPT_LEN]; 426 old_len = existing->data[OPT_LEN];
427 if (old_len + length < 255) { 427 if (old_len + length < 255) {
428 /* actually 255 is ok too, but adding a space can overlow it */ 428 /* actually 255 is ok too, but adding a space can overlow it */
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index d20659e2f..496ab11a1 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -256,16 +256,16 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code)
256#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 256#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
257# define IF_UDHCP_VERBOSE(...) __VA_ARGS__ 257# define IF_UDHCP_VERBOSE(...) __VA_ARGS__
258extern unsigned dhcp_verbose; 258extern unsigned dhcp_verbose;
259# define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0) 259# define log1(...) do { if (dhcp_verbose >= 1) bb_error_msg(__VA_ARGS__); } while (0)
260# if CONFIG_UDHCP_DEBUG >= 2 260# if CONFIG_UDHCP_DEBUG >= 2
261void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC; 261void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
262# define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0) 262# define log2(...) do { if (dhcp_verbose >= 2) bb_error_msg(__VA_ARGS__); } while (0)
263# else 263# else
264# define udhcp_dump_packet(...) ((void)0) 264# define udhcp_dump_packet(...) ((void)0)
265# define log2(...) ((void)0) 265# define log2(...) ((void)0)
266# endif 266# endif
267# if CONFIG_UDHCP_DEBUG >= 3 267# if CONFIG_UDHCP_DEBUG >= 3
268# define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0) 268# define log3(...) do { if (dhcp_verbose >= 3) bb_error_msg(__VA_ARGS__); } while (0)
269# else 269# else
270# define log3(...) ((void)0) 270# define log3(...) ((void)0)
271# endif 271# endif
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 4e9b705b9..422254d62 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -251,7 +251,7 @@ static void d6_run_script(struct d6_packet *packet, const char *name)
251 envp = fill_envp(packet); 251 envp = fill_envp(packet);
252 252
253 /* call script */ 253 /* call script */
254 log1("Executing %s %s", client_config.script, name); 254 log1("executing %s %s", client_config.script, name);
255 argv[0] = (char*) client_config.script; 255 argv[0] = (char*) client_config.script;
256 argv[1] = (char*) name; 256 argv[1] = (char*) name;
257 argv[2] = NULL; 257 argv[2] = NULL;
@@ -428,7 +428,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip
428 */ 428 */
429 opt_ptr = add_d6_client_options(opt_ptr); 429 opt_ptr = add_d6_client_options(opt_ptr);
430 430
431 bb_info_msg("Sending discover..."); 431 bb_error_msg("sending %s", "discover");
432 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 432 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
433} 433}
434 434
@@ -481,7 +481,7 @@ static NOINLINE int send_d6_select(uint32_t xid)
481 */ 481 */
482 opt_ptr = add_d6_client_options(opt_ptr); 482 opt_ptr = add_d6_client_options(opt_ptr);
483 483
484 bb_info_msg("Sending select..."); 484 bb_error_msg("sending %s", "select");
485 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 485 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
486} 486}
487 487
@@ -550,7 +550,7 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
550 */ 550 */
551 opt_ptr = add_d6_client_options(opt_ptr); 551 opt_ptr = add_d6_client_options(opt_ptr);
552 552
553 bb_info_msg("Sending renew..."); 553 bb_error_msg("sending %s", "renew");
554 if (server_ipv6) 554 if (server_ipv6)
555 return d6_send_kernel_packet( 555 return d6_send_kernel_packet(
556 &packet, (opt_ptr - (uint8_t*) &packet), 556 &packet, (opt_ptr - (uint8_t*) &packet),
@@ -573,7 +573,7 @@ static int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cu
573 /* IA NA (contains our current IP) */ 573 /* IA NA (contains our current IP) */
574 opt_ptr = d6_store_blob(opt_ptr, client6_data.ia_na, client6_data.ia_na->len + 2+2); 574 opt_ptr = d6_store_blob(opt_ptr, client6_data.ia_na, client6_data.ia_na->len + 2+2);
575 575
576 bb_info_msg("Sending release..."); 576 bb_error_msg("sending %s", "release");
577 return d6_send_kernel_packet( 577 return d6_send_kernel_packet(
578 &packet, (opt_ptr - (uint8_t*) &packet), 578 &packet, (opt_ptr - (uint8_t*) &packet),
579 our_cur_ipv6, CLIENT_PORT6, 579 our_cur_ipv6, CLIENT_PORT6,
@@ -592,19 +592,19 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
592 592
593 bytes = safe_read(fd, &packet, sizeof(packet)); 593 bytes = safe_read(fd, &packet, sizeof(packet));
594 if (bytes < 0) { 594 if (bytes < 0) {
595 log1("Packet read error, ignoring"); 595 log1("packet read error, ignoring");
596 /* NB: possible down interface, etc. Caller should pause. */ 596 /* NB: possible down interface, etc. Caller should pause. */
597 return bytes; /* returns -1 */ 597 return bytes; /* returns -1 */
598 } 598 }
599 599
600 if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) { 600 if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) {
601 log1("Packet is too short, ignoring"); 601 log1("packet is too short, ignoring");
602 return -2; 602 return -2;
603 } 603 }
604 604
605 if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) { 605 if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) {
606 /* packet is bigger than sizeof(packet), we did partial read */ 606 /* packet is bigger than sizeof(packet), we did partial read */
607 log1("Oversized packet, ignoring"); 607 log1("oversized packet, ignoring");
608 return -2; 608 return -2;
609 } 609 }
610 610
@@ -618,7 +618,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
618 /* || bytes > (int) sizeof(packet) - can't happen */ 618 /* || bytes > (int) sizeof(packet) - can't happen */
619 || packet.udp.len != packet.ip6.ip6_plen 619 || packet.udp.len != packet.ip6.ip6_plen
620 ) { 620 ) {
621 log1("Unrelated/bogus packet, ignoring"); 621 log1("unrelated/bogus packet, ignoring");
622 return -2; 622 return -2;
623 } 623 }
624 624
@@ -630,11 +630,11 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
630// check = packet.udp.check; 630// check = packet.udp.check;
631// packet.udp.check = 0; 631// packet.udp.check = 0;
632// if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { 632// if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
633// log1("Packet with bad UDP checksum received, ignoring"); 633// log1("packet with bad UDP checksum received, ignoring");
634// return -2; 634// return -2;
635// } 635// }
636 636
637 log1("Received a packet"); 637 log1("received %s", "a packet");
638 d6_dump_packet(&packet.data); 638 d6_dump_packet(&packet.data);
639 639
640 bytes -= sizeof(packet.ip6) + sizeof(packet.udp); 640 bytes -= sizeof(packet.ip6) + sizeof(packet.udp);
@@ -722,10 +722,10 @@ static int d6_raw_socket(int ifindex)
722 }; 722 };
723#endif 723#endif
724 724
725 log1("Opening raw socket on ifindex %d", ifindex); //log2? 725 log1("opening raw socket on ifindex %d", ifindex); //log2?
726 726
727 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); 727 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
728 log1("Got raw socket fd %d", fd); //log2? 728 log1("got raw socket fd %d", fd); //log2?
729 729
730 sock.sll_family = AF_PACKET; 730 sock.sll_family = AF_PACKET;
731 sock.sll_protocol = htons(ETH_P_IPV6); 731 sock.sll_protocol = htons(ETH_P_IPV6);
@@ -738,18 +738,18 @@ static int d6_raw_socket(int ifindex)
738 /* Ignoring error (kernel may lack support for this) */ 738 /* Ignoring error (kernel may lack support for this) */
739 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, 739 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
740 sizeof(filter_prog)) >= 0) 740 sizeof(filter_prog)) >= 0)
741 log1("Attached filter to raw socket fd %d", fd); // log? 741 log1("attached filter to raw socket fd %d", fd); // log?
742 } 742 }
743#endif 743#endif
744 744
745 log1("Created raw socket"); 745 log1("created raw socket");
746 746
747 return fd; 747 return fd;
748} 748}
749 749
750static void change_listen_mode(int new_mode) 750static void change_listen_mode(int new_mode)
751{ 751{
752 log1("Entering listen mode: %s", 752 log1("entering listen mode: %s",
753 new_mode != LISTEN_NONE 753 new_mode != LISTEN_NONE
754 ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw") 754 ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw")
755 : "none" 755 : "none"
@@ -770,7 +770,7 @@ static void change_listen_mode(int new_mode)
770/* Called only on SIGUSR1 */ 770/* Called only on SIGUSR1 */
771static void perform_renew(void) 771static void perform_renew(void)
772{ 772{
773 bb_info_msg("Performing a DHCP renew"); 773 bb_error_msg("performing DHCP renew");
774 switch (state) { 774 switch (state) {
775 case BOUND: 775 case BOUND:
776 change_listen_mode(LISTEN_KERNEL); 776 change_listen_mode(LISTEN_KERNEL);
@@ -794,11 +794,11 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
794{ 794{
795 /* send release packet */ 795 /* send release packet */
796 if (state == BOUND || state == RENEWING || state == REBINDING) { 796 if (state == BOUND || state == RENEWING || state == REBINDING) {
797 bb_info_msg("Unicasting a release"); 797 bb_error_msg("unicasting a release");
798 send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ 798 send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
799 d6_run_script(NULL, "deconfig"); 799 d6_run_script(NULL, "deconfig");
800 } 800 }
801 bb_info_msg("Entering released state"); 801 bb_error_msg("entering released state");
802 802
803 change_listen_mode(LISTEN_NONE); 803 change_listen_mode(LISTEN_NONE);
804 state = RELEASED; 804 state = RELEASED;
@@ -1034,7 +1034,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1034 /* Create pidfile */ 1034 /* Create pidfile */
1035 write_pidfile(client_config.pidfile); 1035 write_pidfile(client_config.pidfile);
1036 /* Goes to stdout (unless NOMMU) and possibly syslog */ 1036 /* Goes to stdout (unless NOMMU) and possibly syslog */
1037 bb_info_msg("%s (v"BB_VER") started", applet_name); 1037 bb_error_msg("started, v"BB_VER);
1038 /* Set up the signal pipe */ 1038 /* Set up the signal pipe */
1039 udhcp_sp_setup(); 1039 udhcp_sp_setup();
1040 /* We want random_xid to be random... */ 1040 /* We want random_xid to be random... */
@@ -1074,7 +1074,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1074 retval = 0; 1074 retval = 0;
1075 /* If we already timed out, fall through with retval = 0, else... */ 1075 /* If we already timed out, fall through with retval = 0, else... */
1076 if ((int)tv.tv_sec > 0) { 1076 if ((int)tv.tv_sec > 0) {
1077 log1("Waiting on select %u seconds", (int)tv.tv_sec); 1077 log1("waiting on select %u seconds", (int)tv.tv_sec);
1078 timestamp_before_wait = (unsigned)monotonic_sec(); 1078 timestamp_before_wait = (unsigned)monotonic_sec();
1079 retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); 1079 retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
1080 if (retval < 0) { 1080 if (retval < 0) {
@@ -1124,14 +1124,14 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1124 d6_run_script(NULL, "leasefail"); 1124 d6_run_script(NULL, "leasefail");
1125#if BB_MMU /* -b is not supported on NOMMU */ 1125#if BB_MMU /* -b is not supported on NOMMU */
1126 if (opt & OPT_b) { /* background if no lease */ 1126 if (opt & OPT_b) { /* background if no lease */
1127 bb_info_msg("No lease, forking to background"); 1127 bb_error_msg("no lease, forking to background");
1128 client_background(); 1128 client_background();
1129 /* do not background again! */ 1129 /* do not background again! */
1130 opt = ((opt & ~OPT_b) | OPT_f); 1130 opt = ((opt & ~OPT_b) | OPT_f);
1131 } else 1131 } else
1132#endif 1132#endif
1133 if (opt & OPT_n) { /* abort if no lease */ 1133 if (opt & OPT_n) { /* abort if no lease */
1134 bb_info_msg("No lease, failing"); 1134 bb_error_msg("no lease, failing");
1135 retval = 1; 1135 retval = 1;
1136 goto ret; 1136 goto ret;
1137 } 1137 }
@@ -1159,7 +1159,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1159 state = RENEWING; 1159 state = RENEWING;
1160 client_config.first_secs = 0; /* make secs field count from 0 */ 1160 client_config.first_secs = 0; /* make secs field count from 0 */
1161 change_listen_mode(LISTEN_KERNEL); 1161 change_listen_mode(LISTEN_KERNEL);
1162 log1("Entering renew state"); 1162 log1("entering renew state");
1163 /* fall right through */ 1163 /* fall right through */
1164 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ 1164 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
1165 case_RENEW_REQUESTED: 1165 case_RENEW_REQUESTED:
@@ -1179,7 +1179,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1179 continue; 1179 continue;
1180 } 1180 }
1181 /* Timed out, enter rebinding state */ 1181 /* Timed out, enter rebinding state */
1182 log1("Entering rebinding state"); 1182 log1("entering rebinding state");
1183 state = REBINDING; 1183 state = REBINDING;
1184 /* fall right through */ 1184 /* fall right through */
1185 case REBINDING: 1185 case REBINDING:
@@ -1194,7 +1194,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1194 continue; 1194 continue;
1195 } 1195 }
1196 /* Timed out, enter init state */ 1196 /* Timed out, enter init state */
1197 bb_info_msg("Lease lost, entering init state"); 1197 bb_error_msg("lease lost, entering init state");
1198 d6_run_script(NULL, "deconfig"); 1198 d6_run_script(NULL, "deconfig");
1199 state = INIT_SELECTING; 1199 state = INIT_SELECTING;
1200 client_config.first_secs = 0; /* make secs field count from 0 */ 1200 client_config.first_secs = 0; /* make secs field count from 0 */
@@ -1242,7 +1242,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1242 timeout = INT_MAX; 1242 timeout = INT_MAX;
1243 continue; 1243 continue;
1244 case SIGTERM: 1244 case SIGTERM:
1245 bb_info_msg("Received SIGTERM"); 1245 bb_error_msg("received %s", "SIGTERM");
1246 goto ret0; 1246 goto ret0;
1247 } 1247 }
1248 1248
@@ -1260,7 +1260,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1260 len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); 1260 len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd);
1261 if (len == -1) { 1261 if (len == -1) {
1262 /* Error is severe, reopen socket */ 1262 /* Error is severe, reopen socket */
1263 bb_info_msg("Read error: %s, reopening socket", strerror(errno)); 1263 bb_error_msg("read error: %s, reopening socket", strerror(errno));
1264 sleep(discover_timeout); /* 3 seconds by default */ 1264 sleep(discover_timeout); /* 3 seconds by default */
1265 change_listen_mode(listen_mode); /* just close and reopen */ 1265 change_listen_mode(listen_mode); /* just close and reopen */
1266 } 1266 }
@@ -1298,7 +1298,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1298 option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); 1298 option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE);
1299 if (option && option->data[4] != 0) { 1299 if (option && option->data[4] != 0) {
1300 /* return to init state */ 1300 /* return to init state */
1301 bb_info_msg("Received DHCP NAK (%u)", option->data[4]); 1301 bb_error_msg("received DHCP NAK (%u)", option->data[4]);
1302 d6_run_script(&packet, "nak"); 1302 d6_run_script(&packet, "nak");
1303 if (state != REQUESTING) 1303 if (state != REQUESTING)
1304 d6_run_script(NULL, "deconfig"); 1304 d6_run_script(NULL, "deconfig");
@@ -1453,7 +1453,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1453 lease_seconds = 0x0fffffff; 1453 lease_seconds = 0x0fffffff;
1454 /* enter bound state */ 1454 /* enter bound state */
1455 timeout = lease_seconds / 2; 1455 timeout = lease_seconds / 2;
1456 bb_info_msg("Lease obtained, lease time %u", 1456 bb_error_msg("lease obtained, lease time %u",
1457 /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); 1457 /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
1458 d6_run_script(&packet, state == REQUESTING ? "bound" : "renew"); 1458 d6_run_script(&packet, state == REQUESTING ? "bound" : "renew");
1459 1459
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c
index b340b5db6..e166f520d 100644
--- a/networking/udhcp/d6_packet.c
+++ b/networking/udhcp/d6_packet.c
@@ -17,8 +17,8 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet)
17 if (dhcp_verbose < 2) 17 if (dhcp_verbose < 2)
18 return; 18 return;
19 19
20 bb_info_msg( 20 bb_error_msg(
21 " xid %x" 21 "xid %x"
22 , packet->d6_xid32 22 , packet->d6_xid32
23 ); 23 );
24 //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; 24 //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
@@ -35,15 +35,15 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6
35 memset(packet, 0, sizeof(*packet)); 35 memset(packet, 0, sizeof(*packet));
36 bytes = safe_read(fd, packet, sizeof(*packet)); 36 bytes = safe_read(fd, packet, sizeof(*packet));
37 if (bytes < 0) { 37 if (bytes < 0) {
38 log1("Packet read error, ignoring"); 38 log1("packet read error, ignoring");
39 return bytes; /* returns -1 */ 39 return bytes; /* returns -1 */
40 } 40 }
41 41
42 if (bytes < offsetof(struct d6_packet, d6_options)) { 42 if (bytes < offsetof(struct d6_packet, d6_options)) {
43 bb_info_msg("Packet with bad magic, ignoring"); 43 bb_error_msg("packet with bad magic, ignoring");
44 return -2; 44 return -2;
45 } 45 }
46 log1("Received a packet"); 46 log1("received %s", "a packet");
47 d6_dump_packet(packet); 47 d6_dump_packet(packet);
48 48
49 return bytes; 49 return bytes;
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c
index 56f69f6a1..910f296a3 100644
--- a/networking/udhcp/d6_socket.c
+++ b/networking/udhcp/d6_socket.c
@@ -13,7 +13,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf)
13 int fd; 13 int fd;
14 struct sockaddr_in6 addr; 14 struct sockaddr_in6 addr;
15 15
16 log1("Opening listen socket on *:%d %s", port, inf); 16 log1("opening listen socket on *:%d %s", port, inf);
17 fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); 17 fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
18 18
19 setsockopt_reuseaddr(fd); 19 setsockopt_reuseaddr(fd);
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index dfd5ca606..660b943ce 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -561,7 +561,7 @@ static void udhcp_run_script(struct dhcp_packet *packet, const char *name)
561 envp = fill_envp(packet); 561 envp = fill_envp(packet);
562 562
563 /* call script */ 563 /* call script */
564 log1("Executing %s %s", client_config.script, name); 564 log1("executing %s %s", client_config.script, name);
565 argv[0] = (char*) client_config.script; 565 argv[0] = (char*) client_config.script;
566 argv[1] = (char*) name; 566 argv[1] = (char*) name;
567 argv[2] = NULL; 567 argv[2] = NULL;
@@ -714,7 +714,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
714 */ 714 */
715 add_client_options(&packet); 715 add_client_options(&packet);
716 716
717 bb_info_msg("Sending discover..."); 717 bb_error_msg("sending %s", "discover");
718 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); 718 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
719} 719}
720 720
@@ -758,7 +758,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
758 add_client_options(&packet); 758 add_client_options(&packet);
759 759
760 addr.s_addr = requested; 760 addr.s_addr = requested;
761 bb_info_msg("Sending select for %s...", inet_ntoa(addr)); 761 bb_error_msg("sending select for %s", inet_ntoa(addr));
762 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); 762 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
763} 763}
764 764
@@ -797,7 +797,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
797 */ 797 */
798 add_client_options(&packet); 798 add_client_options(&packet);
799 799
800 bb_info_msg("Sending renew..."); 800 bb_error_msg("sending %s", "renew");
801 return bcast_or_ucast(&packet, ciaddr, server); 801 return bcast_or_ucast(&packet, ciaddr, server);
802} 802}
803 803
@@ -826,7 +826,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
826 826
827 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); 827 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
828 828
829 bb_info_msg("Sending decline..."); 829 bb_error_msg("sending %s", "decline");
830 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); 830 return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
831} 831}
832#endif 832#endif
@@ -846,7 +846,7 @@ static int send_release(uint32_t server, uint32_t ciaddr)
846 846
847 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); 847 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
848 848
849 bb_info_msg("Sending release..."); 849 bb_error_msg("sending %s", "release");
850 /* Note: normally we unicast here since "server" is not zero. 850 /* Note: normally we unicast here since "server" is not zero.
851 * However, there _are_ people who run "address-less" DHCP servers, 851 * However, there _are_ people who run "address-less" DHCP servers,
852 * and reportedly ISC dhcp client and Windows allow that. 852 * and reportedly ISC dhcp client and Windows allow that.
@@ -881,7 +881,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
881 if (bytes < 0) { 881 if (bytes < 0) {
882 if (errno == EINTR) 882 if (errno == EINTR)
883 continue; 883 continue;
884 log1("Packet read error, ignoring"); 884 log1("packet read error, ignoring");
885 /* NB: possible down interface, etc. Caller should pause. */ 885 /* NB: possible down interface, etc. Caller should pause. */
886 return bytes; /* returns -1 */ 886 return bytes; /* returns -1 */
887 } 887 }
@@ -889,13 +889,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
889 } 889 }
890 890
891 if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) { 891 if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
892 log1("Packet is too short, ignoring"); 892 log1("packet is too short, ignoring");
893 return -2; 893 return -2;
894 } 894 }
895 895
896 if (bytes < ntohs(packet.ip.tot_len)) { 896 if (bytes < ntohs(packet.ip.tot_len)) {
897 /* packet is bigger than sizeof(packet), we did partial read */ 897 /* packet is bigger than sizeof(packet), we did partial read */
898 log1("Oversized packet, ignoring"); 898 log1("oversized packet, ignoring");
899 return -2; 899 return -2;
900 } 900 }
901 901
@@ -910,7 +910,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
910 /* || bytes > (int) sizeof(packet) - can't happen */ 910 /* || bytes > (int) sizeof(packet) - can't happen */
911 || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip)) 911 || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
912 ) { 912 ) {
913 log1("Unrelated/bogus packet, ignoring"); 913 log1("unrelated/bogus packet, ignoring");
914 return -2; 914 return -2;
915 } 915 }
916 916
@@ -918,7 +918,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
918 check = packet.ip.check; 918 check = packet.ip.check;
919 packet.ip.check = 0; 919 packet.ip.check = 0;
920 if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) { 920 if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) {
921 log1("Bad IP header checksum, ignoring"); 921 log1("bad IP header checksum, ignoring");
922 return -2; 922 return -2;
923 } 923 }
924 924
@@ -943,17 +943,17 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
943 check = packet.udp.check; 943 check = packet.udp.check;
944 packet.udp.check = 0; 944 packet.udp.check = 0;
945 if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { 945 if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
946 log1("Packet with bad UDP checksum received, ignoring"); 946 log1("packet with bad UDP checksum received, ignoring");
947 return -2; 947 return -2;
948 } 948 }
949 skip_udp_sum_check: 949 skip_udp_sum_check:
950 950
951 if (packet.data.cookie != htonl(DHCP_MAGIC)) { 951 if (packet.data.cookie != htonl(DHCP_MAGIC)) {
952 bb_info_msg("Packet with bad magic, ignoring"); 952 bb_error_msg("packet with bad magic, ignoring");
953 return -2; 953 return -2;
954 } 954 }
955 955
956 log1("Received a packet"); 956 log1("received %s", "a packet");
957 udhcp_dump_packet(&packet.data); 957 udhcp_dump_packet(&packet.data);
958 958
959 bytes -= sizeof(packet.ip) + sizeof(packet.udp); 959 bytes -= sizeof(packet.ip) + sizeof(packet.udp);
@@ -992,14 +992,14 @@ static int udhcp_raw_socket(int ifindex)
992 int fd; 992 int fd;
993 struct sockaddr_ll sock; 993 struct sockaddr_ll sock;
994 994
995 log1("Opening raw socket on ifindex %d", ifindex); //log2? 995 log1("opening raw socket on ifindex %d", ifindex); //log2?
996 996
997 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); 997 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
998 /* ^^^^^ 998 /* ^^^^^
999 * SOCK_DGRAM: remove link-layer headers on input (SOCK_RAW keeps them) 999 * SOCK_DGRAM: remove link-layer headers on input (SOCK_RAW keeps them)
1000 * ETH_P_IP: want to receive only packets with IPv4 eth type 1000 * ETH_P_IP: want to receive only packets with IPv4 eth type
1001 */ 1001 */
1002 log1("Got raw socket fd"); //log2? 1002 log1("got raw socket fd"); //log2?
1003 1003
1004 sock.sll_family = AF_PACKET; 1004 sock.sll_family = AF_PACKET;
1005 sock.sll_protocol = htons(ETH_P_IP); 1005 sock.sll_protocol = htons(ETH_P_IP);
@@ -1055,23 +1055,23 @@ static int udhcp_raw_socket(int ifindex)
1055 /* Ignoring error (kernel may lack support for this) */ 1055 /* Ignoring error (kernel may lack support for this) */
1056 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, 1056 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
1057 sizeof(filter_prog)) >= 0) 1057 sizeof(filter_prog)) >= 0)
1058 log1("Attached filter to raw socket fd"); // log? 1058 log1("attached filter to raw socket fd"); // log?
1059 } 1059 }
1060#endif 1060#endif
1061 1061
1062 if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { 1062 if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) {
1063 if (errno != ENOPROTOOPT) 1063 if (errno != ENOPROTOOPT)
1064 log1("Can't set PACKET_AUXDATA on raw socket"); 1064 log1("can't set PACKET_AUXDATA on raw socket");
1065 } 1065 }
1066 1066
1067 log1("Created raw socket"); 1067 log1("created raw socket");
1068 1068
1069 return fd; 1069 return fd;
1070} 1070}
1071 1071
1072static void change_listen_mode(int new_mode) 1072static void change_listen_mode(int new_mode)
1073{ 1073{
1074 log1("Entering listen mode: %s", 1074 log1("entering listen mode: %s",
1075 new_mode != LISTEN_NONE 1075 new_mode != LISTEN_NONE
1076 ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw") 1076 ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw")
1077 : "none" 1077 : "none"
@@ -1092,7 +1092,7 @@ static void change_listen_mode(int new_mode)
1092/* Called only on SIGUSR1 */ 1092/* Called only on SIGUSR1 */
1093static void perform_renew(void) 1093static void perform_renew(void)
1094{ 1094{
1095 bb_info_msg("Performing a DHCP renew"); 1095 bb_error_msg("performing DHCP renew");
1096 switch (state) { 1096 switch (state) {
1097 case BOUND: 1097 case BOUND:
1098 change_listen_mode(LISTEN_KERNEL); 1098 change_listen_mode(LISTEN_KERNEL);
@@ -1122,12 +1122,12 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
1122 temp_addr.s_addr = server_addr; 1122 temp_addr.s_addr = server_addr;
1123 strcpy(buffer, inet_ntoa(temp_addr)); 1123 strcpy(buffer, inet_ntoa(temp_addr));
1124 temp_addr.s_addr = requested_ip; 1124 temp_addr.s_addr = requested_ip;
1125 bb_info_msg("Unicasting a release of %s to %s", 1125 bb_error_msg("unicasting a release of %s to %s",
1126 inet_ntoa(temp_addr), buffer); 1126 inet_ntoa(temp_addr), buffer);
1127 send_release(server_addr, requested_ip); /* unicast */ 1127 send_release(server_addr, requested_ip); /* unicast */
1128 udhcp_run_script(NULL, "deconfig"); 1128 udhcp_run_script(NULL, "deconfig");
1129 } 1129 }
1130 bb_info_msg("Entering released state"); 1130 bb_error_msg("entering released state");
1131 1131
1132 change_listen_mode(LISTEN_NONE); 1132 change_listen_mode(LISTEN_NONE);
1133 state = RELEASED; 1133 state = RELEASED;
@@ -1395,7 +1395,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1395 /* Create pidfile */ 1395 /* Create pidfile */
1396 write_pidfile(client_config.pidfile); 1396 write_pidfile(client_config.pidfile);
1397 /* Goes to stdout (unless NOMMU) and possibly syslog */ 1397 /* Goes to stdout (unless NOMMU) and possibly syslog */
1398 bb_info_msg("%s (v"BB_VER") started", applet_name); 1398 bb_error_msg("started, v"BB_VER);
1399 /* Set up the signal pipe */ 1399 /* Set up the signal pipe */
1400 udhcp_sp_setup(); 1400 udhcp_sp_setup();
1401 /* We want random_xid to be random... */ 1401 /* We want random_xid to be random... */
@@ -1434,7 +1434,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1434 retval = 0; 1434 retval = 0;
1435 /* If we already timed out, fall through with retval = 0, else... */ 1435 /* If we already timed out, fall through with retval = 0, else... */
1436 if ((int)tv.tv_sec > 0) { 1436 if ((int)tv.tv_sec > 0) {
1437 log1("Waiting on select %u seconds", (int)tv.tv_sec); 1437 log1("waiting on select %u seconds", (int)tv.tv_sec);
1438 timestamp_before_wait = (unsigned)monotonic_sec(); 1438 timestamp_before_wait = (unsigned)monotonic_sec();
1439 retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); 1439 retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
1440 if (retval < 0) { 1440 if (retval < 0) {
@@ -1485,14 +1485,14 @@ 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_error_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_f); 1491 opt = ((opt & ~OPT_b) | OPT_f);
1492 } else 1492 } else
1493#endif 1493#endif
1494 if (opt & OPT_n) { /* abort if no lease */ 1494 if (opt & OPT_n) { /* abort if no lease */
1495 bb_info_msg("No lease, failing"); 1495 bb_error_msg("no lease, failing");
1496 retval = 1; 1496 retval = 1;
1497 goto ret; 1497 goto ret;
1498 } 1498 }
@@ -1520,7 +1520,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1520 state = RENEWING; 1520 state = RENEWING;
1521 client_config.first_secs = 0; /* make secs field count from 0 */ 1521 client_config.first_secs = 0; /* make secs field count from 0 */
1522 change_listen_mode(LISTEN_KERNEL); 1522 change_listen_mode(LISTEN_KERNEL);
1523 log1("Entering renew state"); 1523 log1("entering renew state");
1524 /* fall right through */ 1524 /* fall right through */
1525 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ 1525 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
1526 case_RENEW_REQUESTED: 1526 case_RENEW_REQUESTED:
@@ -1540,7 +1540,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1540 continue; 1540 continue;
1541 } 1541 }
1542 /* Timed out, enter rebinding state */ 1542 /* Timed out, enter rebinding state */
1543 log1("Entering rebinding state"); 1543 log1("entering rebinding state");
1544 state = REBINDING; 1544 state = REBINDING;
1545 /* fall right through */ 1545 /* fall right through */
1546 case REBINDING: 1546 case REBINDING:
@@ -1555,7 +1555,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1555 continue; 1555 continue;
1556 } 1556 }
1557 /* Timed out, enter init state */ 1557 /* Timed out, enter init state */
1558 bb_info_msg("Lease lost, entering init state"); 1558 bb_error_msg("lease lost, entering init state");
1559 udhcp_run_script(NULL, "deconfig"); 1559 udhcp_run_script(NULL, "deconfig");
1560 state = INIT_SELECTING; 1560 state = INIT_SELECTING;
1561 client_config.first_secs = 0; /* make secs field count from 0 */ 1561 client_config.first_secs = 0; /* make secs field count from 0 */
@@ -1603,7 +1603,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1603 timeout = INT_MAX; 1603 timeout = INT_MAX;
1604 continue; 1604 continue;
1605 case SIGTERM: 1605 case SIGTERM:
1606 bb_info_msg("Received SIGTERM"); 1606 bb_error_msg("received %s", "SIGTERM");
1607 goto ret0; 1607 goto ret0;
1608 } 1608 }
1609 1609
@@ -1621,7 +1621,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1621 len = udhcp_recv_raw_packet(&packet, sockfd); 1621 len = udhcp_recv_raw_packet(&packet, sockfd);
1622 if (len == -1) { 1622 if (len == -1) {
1623 /* Error is severe, reopen socket */ 1623 /* Error is severe, reopen socket */
1624 bb_info_msg("Read error: %s, reopening socket", strerror(errno)); 1624 bb_error_msg("read error: %s, reopening socket", strerror(errno));
1625 sleep(discover_timeout); /* 3 seconds by default */ 1625 sleep(discover_timeout); /* 3 seconds by default */
1626 change_listen_mode(listen_mode); /* just close and reopen */ 1626 change_listen_mode(listen_mode); /* just close and reopen */
1627 } 1627 }
@@ -1744,7 +1744,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1744 client_config.interface, 1744 client_config.interface,
1745 arpping_ms) 1745 arpping_ms)
1746 ) { 1746 ) {
1747 bb_info_msg("Offered address is in use " 1747 bb_error_msg("offered address is in use "
1748 "(got ARP reply), declining"); 1748 "(got ARP reply), declining");
1749 send_decline(/*xid,*/ server_addr, packet.yiaddr); 1749 send_decline(/*xid,*/ server_addr, packet.yiaddr);
1750 1750
@@ -1763,7 +1763,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1763#endif 1763#endif
1764 /* enter bound state */ 1764 /* enter bound state */
1765 temp_addr.s_addr = packet.yiaddr; 1765 temp_addr.s_addr = packet.yiaddr;
1766 bb_info_msg("Lease of %s obtained, lease time %u", 1766 bb_error_msg("lease of %s obtained, lease time %u",
1767 inet_ntoa(temp_addr), (unsigned)lease_seconds); 1767 inet_ntoa(temp_addr), (unsigned)lease_seconds);
1768 requested_ip = packet.yiaddr; 1768 requested_ip = packet.yiaddr;
1769 1769
@@ -1817,7 +1817,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1817 goto non_matching_svid; 1817 goto non_matching_svid;
1818 } 1818 }
1819 /* return to init state */ 1819 /* return to init state */
1820 bb_info_msg("Received DHCP NAK"); 1820 bb_error_msg("received %s", "DHCP NAK");
1821 udhcp_run_script(&packet, "nak"); 1821 udhcp_run_script(&packet, "nak");
1822 if (state != REQUESTING) 1822 if (state != REQUESTING)
1823 udhcp_run_script(NULL, "deconfig"); 1823 udhcp_run_script(NULL, "deconfig");
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 2de074f9b..79677ee93 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -61,11 +61,11 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
61 || (dhcp_pkt->flags & htons(BROADCAST_FLAG)) 61 || (dhcp_pkt->flags & htons(BROADCAST_FLAG))
62 || dhcp_pkt->ciaddr == 0 62 || dhcp_pkt->ciaddr == 0
63 ) { 63 ) {
64 log1("Broadcasting packet to client"); 64 log1("broadcasting packet to client");
65 ciaddr = INADDR_BROADCAST; 65 ciaddr = INADDR_BROADCAST;
66 chaddr = MAC_BCAST_ADDR; 66 chaddr = MAC_BCAST_ADDR;
67 } else { 67 } else {
68 log1("Unicasting packet to client ciaddr"); 68 log1("unicasting packet to client ciaddr");
69 ciaddr = dhcp_pkt->ciaddr; 69 ciaddr = dhcp_pkt->ciaddr;
70 chaddr = dhcp_pkt->chaddr; 70 chaddr = dhcp_pkt->chaddr;
71 } 71 }
@@ -79,7 +79,7 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
79/* Send a packet to gateway_nip using the kernel ip stack */ 79/* Send a packet to gateway_nip using the kernel ip stack */
80static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt) 80static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
81{ 81{
82 log1("Forwarding packet to relay"); 82 log1("forwarding packet to relay");
83 83
84 udhcp_send_kernel_packet(dhcp_pkt, 84 udhcp_send_kernel_packet(dhcp_pkt,
85 server_config.server_nip, SERVER_PORT, 85 server_config.server_nip, SERVER_PORT,
@@ -214,7 +214,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
214 add_server_options(&packet); 214 add_server_options(&packet);
215 215
216 addr.s_addr = packet.yiaddr; 216 addr.s_addr = packet.yiaddr;
217 bb_info_msg("Sending OFFER of %s", inet_ntoa(addr)); 217 bb_error_msg("sending OFFER of %s", inet_ntoa(addr));
218 /* send_packet emits error message itself if it detects failure */ 218 /* send_packet emits error message itself if it detects failure */
219 send_packet(&packet, /*force_bcast:*/ 0); 219 send_packet(&packet, /*force_bcast:*/ 0);
220} 220}
@@ -226,7 +226,7 @@ static NOINLINE void send_NAK(struct dhcp_packet *oldpacket)
226 226
227 init_packet(&packet, oldpacket, DHCPNAK); 227 init_packet(&packet, oldpacket, DHCPNAK);
228 228
229 log1("Sending NAK"); 229 log1("sending NAK");
230 send_packet(&packet, /*force_bcast:*/ 1); 230 send_packet(&packet, /*force_bcast:*/ 1);
231} 231}
232 232
@@ -247,7 +247,7 @@ static NOINLINE void send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr)
247 add_server_options(&packet); 247 add_server_options(&packet);
248 248
249 addr.s_addr = yiaddr; 249 addr.s_addr = yiaddr;
250 bb_info_msg("Sending ACK to %s", inet_ntoa(addr)); 250 bb_error_msg("sending ACK to %s", inet_ntoa(addr));
251 send_packet(&packet, /*force_bcast:*/ 0); 251 send_packet(&packet, /*force_bcast:*/ 0);
252 252
253 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME); 253 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME);
@@ -361,7 +361,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
361 write_pidfile(server_config.pidfile); 361 write_pidfile(server_config.pidfile);
362 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */ 362 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
363 363
364 bb_info_msg("%s (v"BB_VER") started", applet_name); 364 bb_error_msg("started, v"BB_VER);
365 365
366 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME); 366 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
367 server_config.max_lease_sec = DEFAULT_LEASE_TIME; 367 server_config.max_lease_sec = DEFAULT_LEASE_TIME;
@@ -427,18 +427,18 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
427 goto continue_with_autotime; 427 goto continue_with_autotime;
428 } 428 }
429 if (retval < 0 && errno != EINTR) { 429 if (retval < 0 && errno != EINTR) {
430 log1("Error on select"); 430 log1("error on select");
431 continue; 431 continue;
432 } 432 }
433 433
434 switch (udhcp_sp_read(&rfds)) { 434 switch (udhcp_sp_read(&rfds)) {
435 case SIGUSR1: 435 case SIGUSR1:
436 bb_info_msg("Received SIGUSR1"); 436 bb_error_msg("received %s", "SIGUSR1");
437 write_leases(); 437 write_leases();
438 /* why not just reset the timeout, eh */ 438 /* why not just reset the timeout, eh */
439 goto continue_with_autotime; 439 goto continue_with_autotime;
440 case SIGTERM: 440 case SIGTERM:
441 bb_info_msg("Received SIGTERM"); 441 bb_error_msg("received %s", "SIGTERM");
442 write_leases(); 442 write_leases();
443 goto ret0; 443 goto ret0;
444 case 0: /* no signal: read a packet */ 444 case 0: /* no signal: read a packet */
@@ -451,7 +451,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
451 if (bytes < 0) { 451 if (bytes < 0) {
452 /* bytes can also be -2 ("bad packet data") */ 452 /* bytes can also be -2 ("bad packet data") */
453 if (bytes == -1 && errno != EINTR) { 453 if (bytes == -1 && errno != EINTR) {
454 log1("Read error: %s, reopening socket", strerror(errno)); 454 log1("read error: %s, reopening socket", strerror(errno));
455 close(server_socket); 455 close(server_socket);
456 server_socket = -1; 456 server_socket = -1;
457 } 457 }
@@ -486,7 +486,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
486 /* Look for a static/dynamic lease */ 486 /* Look for a static/dynamic lease */
487 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr); 487 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
488 if (static_lease_nip) { 488 if (static_lease_nip) {
489 bb_info_msg("Found static lease: %x", static_lease_nip); 489 bb_error_msg("found static lease: %x", static_lease_nip);
490 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6); 490 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
491 fake_lease.lease_nip = static_lease_nip; 491 fake_lease.lease_nip = static_lease_nip;
492 fake_lease.expires = 0; 492 fake_lease.expires = 0;
@@ -504,13 +504,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
504 switch (state[0]) { 504 switch (state[0]) {
505 505
506 case DHCPDISCOVER: 506 case DHCPDISCOVER:
507 log1("Received DISCOVER"); 507 log1("received %s", "DISCOVER");
508 508
509 send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms); 509 send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
510 break; 510 break;
511 511
512 case DHCPREQUEST: 512 case DHCPREQUEST:
513 log1("Received REQUEST"); 513 log1("received %s", "REQUEST");
514/* RFC 2131: 514/* RFC 2131:
515 515
516o DHCPREQUEST generated during SELECTING state: 516o DHCPREQUEST generated during SELECTING state:
@@ -635,7 +635,7 @@ o DHCPREQUEST generated during REBINDING state:
635 * chaddr must be filled in, 635 * chaddr must be filled in,
636 * ciaddr must be 0 (we do not check this) 636 * ciaddr must be 0 (we do not check this)
637 */ 637 */
638 log1("Received DECLINE"); 638 log1("received %s", "DECLINE");
639 if (server_id_opt 639 if (server_id_opt
640 && requested_ip_opt 640 && requested_ip_opt
641 && lease /* chaddr matches this lease */ 641 && lease /* chaddr matches this lease */
@@ -655,7 +655,7 @@ o DHCPREQUEST generated during REBINDING state:
655 * chaddr must be filled in, 655 * chaddr must be filled in,
656 * ciaddr must be filled in 656 * ciaddr must be filled in
657 */ 657 */
658 log1("Received RELEASE"); 658 log1("received %s", "RELEASE");
659 if (server_id_opt 659 if (server_id_opt
660 && lease /* chaddr matches this lease */ 660 && lease /* chaddr matches this lease */
661 && packet.ciaddr == lease->lease_nip 661 && packet.ciaddr == lease->lease_nip
@@ -665,7 +665,7 @@ o DHCPREQUEST generated during REBINDING state:
665 break; 665 break;
666 666
667 case DHCPINFORM: 667 case DHCPINFORM:
668 log1("Received INFORM"); 668 log1("received %s", "INFORM");
669 send_inform(&packet); 669 send_inform(&packet);
670 break; 670 break;
671 } 671 }
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 5b90e26d2..7b57c6258 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -226,7 +226,7 @@ void FAST_FUNC read_leases(const char *file)
226#endif 226#endif
227 } 227 }
228 } 228 }
229 log1("Read %d leases", i); 229 log1("read %d leases", i);
230 ret: 230 ret:
231 close(fd); 231 close(fd);
232} 232}
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index 411b74962..6642e396d 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -133,7 +133,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigne
133 return r; 133 return r;
134 134
135 temp.s_addr = nip; 135 temp.s_addr = nip;
136 bb_info_msg("%s belongs to someone, reserving it for %u seconds", 136 bb_error_msg("%s belongs to someone, reserving it for %u seconds",
137 inet_ntoa(temp), (unsigned)server_config.conflict_time); 137 inet_ntoa(temp), (unsigned)server_config.conflict_time);
138 add_lease(NULL, nip, server_config.conflict_time, NULL, 0); 138 add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
139 return 0; 139 return 0;
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 148f52551..0a31f2643 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -38,8 +38,8 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
38 if (dhcp_verbose < 2) 38 if (dhcp_verbose < 2)
39 return; 39 return;
40 40
41 bb_info_msg( 41 bb_error_msg(
42 //" op %x" 42 //"op %x"
43 //" htype %x" 43 //" htype %x"
44 " hlen %x" 44 " hlen %x"
45 //" hops %x" 45 //" hops %x"
@@ -73,7 +73,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
73 //, packet->options[] 73 //, packet->options[]
74 ); 74 );
75 *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; 75 *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
76 bb_info_msg(" chaddr %s", buf); 76 bb_error_msg("chaddr %s", buf);
77} 77}
78#endif 78#endif
79 79
@@ -85,17 +85,17 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
85 memset(packet, 0, sizeof(*packet)); 85 memset(packet, 0, sizeof(*packet));
86 bytes = safe_read(fd, packet, sizeof(*packet)); 86 bytes = safe_read(fd, packet, sizeof(*packet));
87 if (bytes < 0) { 87 if (bytes < 0) {
88 log1("Packet read error, ignoring"); 88 log1("packet read error, ignoring");
89 return bytes; /* returns -1 */ 89 return bytes; /* returns -1 */
90 } 90 }
91 91
92 if (bytes < offsetof(struct dhcp_packet, options) 92 if (bytes < offsetof(struct dhcp_packet, options)
93 || packet->cookie != htonl(DHCP_MAGIC) 93 || packet->cookie != htonl(DHCP_MAGIC)
94 ) { 94 ) {
95 bb_info_msg("Packet with bad magic, ignoring"); 95 bb_error_msg("packet with bad magic, ignoring");
96 return -2; 96 return -2;
97 } 97 }
98 log1("Received a packet"); 98 log1("received %s", "a packet");
99 udhcp_dump_packet(packet); 99 udhcp_dump_packet(packet);
100 100
101 return bytes; 101 return bytes;
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index a42106960..4fd79f423 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -56,7 +56,7 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t
56 close(fd); 56 close(fd);
57 return -1; 57 return -1;
58 } 58 }
59 log1("Adapter index %d", ifr->ifr_ifindex); 59 log1("adapter index %d", ifr->ifr_ifindex);
60 *ifindex = ifr->ifr_ifindex; 60 *ifindex = ifr->ifr_ifindex;
61 } 61 }
62 62
@@ -82,7 +82,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
82 struct sockaddr_in addr; 82 struct sockaddr_in addr;
83 char *colon; 83 char *colon;
84 84
85 log1("Opening listen socket on *:%d %s", port, inf); 85 log1("opening listen socket on *:%d %s", port, inf);
86 fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); 86 fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
87 87
88 setsockopt_reuseaddr(fd); 88 setsockopt_reuseaddr(fd);
diff --git a/networking/udhcp/static_leases.c b/networking/udhcp/static_leases.c
index f4a24ab62..b7f9e5c59 100644
--- a/networking/udhcp/static_leases.c
+++ b/networking/udhcp/static_leases.c
@@ -66,7 +66,7 @@ void FAST_FUNC log_static_leases(struct static_lease **st_lease_pp)
66 66
67 cur = *st_lease_pp; 67 cur = *st_lease_pp;
68 while (cur) { 68 while (cur) {
69 bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x", 69 bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
70 cur->mac[0], cur->mac[1], cur->mac[2], 70 cur->mac[0], cur->mac[1], cur->mac[2],
71 cur->mac[3], cur->mac[4], cur->mac[5], 71 cur->mac[3], cur->mac[4], cur->mac[5],
72 cur->nip 72 cur->nip