udhcp: get rid of bb_info_msg()
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 30 Mar 2016 16:41:23 +0000 (18:41 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 30 Mar 2016 16:41:23 +0000 (18:41 +0200)
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>
16 files changed:
include/libbb.h
libbb/Kbuild.src
libbb/info_msg.c [deleted file]
networking/udhcp/arpping.c
networking/udhcp/common.c
networking/udhcp/common.h
networking/udhcp/d6_dhcpc.c
networking/udhcp/d6_packet.c
networking/udhcp/d6_socket.c
networking/udhcp/dhcpc.c
networking/udhcp/dhcpd.c
networking/udhcp/files.c
networking/udhcp/leases.c
networking/udhcp/packet.c
networking/udhcp/socket.c
networking/udhcp/static_leases.c

index 8b226c00c5147791b32fdec8716bfc4d5437a76f..98d788402d25db9fb9205e8081bde729fd46a03b 100644 (file)
@@ -1150,7 +1150,6 @@ extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1,
 extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
 extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
 extern void bb_perror_nomsg(void) FAST_FUNC;
-extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
 extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
 extern void bb_logenv_override(void) FAST_FUNC;
 
index 7fb6872275af42fcee41d177c3422127e391861e..b08ce11582c40995f190b2d77b8f80a55d47a1d1 100644 (file)
@@ -46,7 +46,6 @@ lib-y += get_volsize.o
 lib-y += herror_msg.o
 lib-y += human_readable.o
 lib-y += inet_common.o
-lib-y += info_msg.o
 lib-y += inode_hash.o
 lib-y += isdirectory.o
 lib-y += kernel_version.o
diff --git a/libbb/info_msg.c b/libbb/info_msg.c
deleted file mode 100644 (file)
index 56ca2ef..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * Licensed under GPLv2 or later, see file LICENSE in this source tree.
- */
-
-#include "libbb.h"
-#if ENABLE_FEATURE_SYSLOG
-# include <syslog.h>
-#endif
-
-void FAST_FUNC bb_info_msg(const char *s, ...)
-{
-#ifdef THIS_ONE_DOESNT_DO_SINGLE_WRITE
-       va_list p;
-       /* va_copy is used because it is not portable
-        * to use va_list p twice */
-       va_list p2;
-
-       va_start(p, s);
-       va_copy(p2, p);
-       if (logmode & LOGMODE_STDIO) {
-               vprintf(s, p);
-               fputs(msg_eol, stdout);
-       }
-# if ENABLE_FEATURE_SYSLOG
-       if (logmode & LOGMODE_SYSLOG)
-               vsyslog(LOG_INFO, s, p2);
-# endif
-       va_end(p2);
-       va_end(p);
-#else
-       int used;
-       char *msg;
-       va_list p;
-
-       if (logmode == 0)
-               return;
-
-       va_start(p, s);
-       used = vasprintf(&msg, s, p);
-       va_end(p);
-       if (used < 0)
-               return;
-
-# if ENABLE_FEATURE_SYSLOG
-       if (logmode & LOGMODE_SYSLOG)
-               syslog(LOG_INFO, "%s", msg);
-# endif
-       if (logmode & LOGMODE_STDIO) {
-               fflush_all();
-               /* used = strlen(msg); - must be true already */
-               msg[used++] = '\n';
-               full_write(STDOUT_FILENO, msg, used);
-       }
-
-       free(msg);
-#endif
-}
index fad2283c3e3f86a54add518d9595dcf3b357bd3f..c9802731619cee362a55293034f0b18f943f0a78 100644 (file)
@@ -132,6 +132,6 @@ int FAST_FUNC arpping(uint32_t test_nip,
 
  ret:
        close(s);
-       log1("%srp reply received for this address", rv ? "No a" : "A");
+       log1("%srp reply received for this address", rv ? "no a" : "A");
        return rv;
 }
index 680852ce4d7cbc0a69104e86574a0e0b3580221b..1c186345156f7a0578d2d5ecad314bb456d2db45 100644 (file)
@@ -183,7 +183,7 @@ static void log_option(const char *pfx, const uint8_t *opt)
        if (dhcp_verbose >= 2) {
                char buf[256 * 2 + 2];
                *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
-               bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
+               bb_error_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
        }
 }
 #else
@@ -269,7 +269,7 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code)
        }
 
        /* log3 because udhcpc uses it a lot - very noisy */
-       log3("Option 0x%02x not found", code);
+       log3("option 0x%02x not found", code);
        return NULL;
 }
 
@@ -402,7 +402,7 @@ static NOINLINE void attach_option(
                struct option_set *new, **curr;
 
                /* make a new option */
-               log2("Attaching option %02x to list", optflag->code);
+               log2("attaching option %02x to list", optflag->code);
                new = xmalloc(sizeof(*new));
                new->data = xmalloc(length + OPT_DATA);
                new->data[OPT_CODE] = optflag->code;
@@ -422,7 +422,7 @@ static NOINLINE void attach_option(
                unsigned old_len;
 
                /* add it to an existing option */
-               log2("Attaching option %02x to existing member of list", optflag->code);
+               log2("attaching option %02x to existing member of list", optflag->code);
                old_len = existing->data[OPT_LEN];
                if (old_len + length < 255) {
                        /* actually 255 is ok too, but adding a space can overlow it */
index d20659e2f9b2a2fc09d0a854f0f43ee1e2396f80..496ab11a1aef73f97fc6fc68b02544b024045dfe 100644 (file)
@@ -256,16 +256,16 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code)
 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
 # define IF_UDHCP_VERBOSE(...) __VA_ARGS__
 extern unsigned dhcp_verbose;
-# define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0)
+# define log1(...) do { if (dhcp_verbose >= 1) bb_error_msg(__VA_ARGS__); } while (0)
 # if CONFIG_UDHCP_DEBUG >= 2
 void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
-#  define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0)
+#  define log2(...) do { if (dhcp_verbose >= 2) bb_error_msg(__VA_ARGS__); } while (0)
 # else
 #  define udhcp_dump_packet(...) ((void)0)
 #  define log2(...) ((void)0)
 # endif
 # if CONFIG_UDHCP_DEBUG >= 3
-#  define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0)
+#  define log3(...) do { if (dhcp_verbose >= 3) bb_error_msg(__VA_ARGS__); } while (0)
 # else
 #  define log3(...) ((void)0)
 # endif
index 4e9b705b9ebf3617db4975ab9f999345580f5da0..422254d62ebc17f0351413280b688a9a3a68dcb8 100644 (file)
@@ -251,7 +251,7 @@ static void d6_run_script(struct d6_packet *packet, const char *name)
        envp = fill_envp(packet);
 
        /* call script */
-       log1("Executing %s %s", client_config.script, name);
+       log1("executing %s %s", client_config.script, name);
        argv[0] = (char*) client_config.script;
        argv[1] = (char*) name;
        argv[2] = NULL;
@@ -428,7 +428,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip
         */
        opt_ptr = add_d6_client_options(opt_ptr);
 
-       bb_info_msg("Sending discover...");
+       bb_error_msg("sending %s", "discover");
        return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
 }
 
@@ -481,7 +481,7 @@ static NOINLINE int send_d6_select(uint32_t xid)
         */
        opt_ptr = add_d6_client_options(opt_ptr);
 
-       bb_info_msg("Sending select...");
+       bb_error_msg("sending %s", "select");
        return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
 }
 
@@ -550,7 +550,7 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
         */
        opt_ptr = add_d6_client_options(opt_ptr);
 
-       bb_info_msg("Sending renew...");
+       bb_error_msg("sending %s", "renew");
        if (server_ipv6)
                return d6_send_kernel_packet(
                        &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
        /* IA NA (contains our current IP) */
        opt_ptr = d6_store_blob(opt_ptr, client6_data.ia_na, client6_data.ia_na->len + 2+2);
 
-       bb_info_msg("Sending release...");
+       bb_error_msg("sending %s", "release");
        return d6_send_kernel_packet(
                &packet, (opt_ptr - (uint8_t*) &packet),
                our_cur_ipv6, CLIENT_PORT6,
@@ -592,19 +592,19 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
 
        bytes = safe_read(fd, &packet, sizeof(packet));
        if (bytes < 0) {
-               log1("Packet read error, ignoring");
+               log1("packet read error, ignoring");
                /* NB: possible down interface, etc. Caller should pause. */
                return bytes; /* returns -1 */
        }
 
        if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) {
-               log1("Packet is too short, ignoring");
+               log1("packet is too short, ignoring");
                return -2;
        }
 
        if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) {
                /* packet is bigger than sizeof(packet), we did partial read */
-               log1("Oversized packet, ignoring");
+               log1("oversized packet, ignoring");
                return -2;
        }
 
@@ -618,7 +618,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
        /* || bytes > (int) sizeof(packet) - can't happen */
         || packet.udp.len != packet.ip6.ip6_plen
        ) {
-               log1("Unrelated/bogus packet, ignoring");
+               log1("unrelated/bogus packet, ignoring");
                return -2;
        }
 
@@ -630,11 +630,11 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
 //     check = packet.udp.check;
 //     packet.udp.check = 0;
 //     if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
-//             log1("Packet with bad UDP checksum received, ignoring");
+//             log1("packet with bad UDP checksum received, ignoring");
 //             return -2;
 //     }
 
-       log1("Received a packet");
+       log1("received %s", "a packet");
        d6_dump_packet(&packet.data);
 
        bytes -= sizeof(packet.ip6) + sizeof(packet.udp);
@@ -722,10 +722,10 @@ static int d6_raw_socket(int ifindex)
        };
 #endif
 
-       log1("Opening raw socket on ifindex %d", ifindex); //log2?
+       log1("opening raw socket on ifindex %d", ifindex); //log2?
 
        fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
-       log1("Got raw socket fd %d", fd); //log2?
+       log1("got raw socket fd %d", fd); //log2?
 
        sock.sll_family = AF_PACKET;
        sock.sll_protocol = htons(ETH_P_IPV6);
@@ -738,18 +738,18 @@ static int d6_raw_socket(int ifindex)
                /* Ignoring error (kernel may lack support for this) */
                if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
                                sizeof(filter_prog)) >= 0)
-                       log1("Attached filter to raw socket fd %d", fd); // log?
+                       log1("attached filter to raw socket fd %d", fd); // log?
        }
 #endif
 
-       log1("Created raw socket");
+       log1("created raw socket");
 
        return fd;
 }
 
 static void change_listen_mode(int new_mode)
 {
-       log1("Entering listen mode: %s",
+       log1("entering listen mode: %s",
                new_mode != LISTEN_NONE
                        ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw")
                        : "none"
@@ -770,7 +770,7 @@ static void change_listen_mode(int new_mode)
 /* Called only on SIGUSR1 */
 static void perform_renew(void)
 {
-       bb_info_msg("Performing a DHCP renew");
+       bb_error_msg("performing DHCP renew");
        switch (state) {
        case BOUND:
                change_listen_mode(LISTEN_KERNEL);
@@ -794,11 +794,11 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
 {
        /* send release packet */
        if (state == BOUND || state == RENEWING || state == REBINDING) {
-               bb_info_msg("Unicasting a release");
+               bb_error_msg("unicasting a release");
                send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
                d6_run_script(NULL, "deconfig");
        }
-       bb_info_msg("Entering released state");
+       bb_error_msg("entering released state");
 
        change_listen_mode(LISTEN_NONE);
        state = RELEASED;
@@ -1034,7 +1034,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
        /* Create pidfile */
        write_pidfile(client_config.pidfile);
        /* Goes to stdout (unless NOMMU) and possibly syslog */
-       bb_info_msg("%s (v"BB_VER") started", applet_name);
+       bb_error_msg("started, v"BB_VER);
        /* Set up the signal pipe */
        udhcp_sp_setup();
        /* We want random_xid to be random... */
@@ -1074,7 +1074,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                retval = 0;
                /* If we already timed out, fall through with retval = 0, else... */
                if ((int)tv.tv_sec > 0) {
-                       log1("Waiting on select %u seconds", (int)tv.tv_sec);
+                       log1("waiting on select %u seconds", (int)tv.tv_sec);
                        timestamp_before_wait = (unsigned)monotonic_sec();
                        retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
                        if (retval < 0) {
@@ -1124,14 +1124,14 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                d6_run_script(NULL, "leasefail");
 #if BB_MMU /* -b is not supported on NOMMU */
                                if (opt & OPT_b) { /* background if no lease */
-                                       bb_info_msg("No lease, forking to background");
+                                       bb_error_msg("no lease, forking to background");
                                        client_background();
                                        /* do not background again! */
                                        opt = ((opt & ~OPT_b) | OPT_f);
                                } else
 #endif
                                if (opt & OPT_n) { /* abort if no lease */
-                                       bb_info_msg("No lease, failing");
+                                       bb_error_msg("no lease, failing");
                                        retval = 1;
                                        goto ret;
                                }
@@ -1159,7 +1159,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                state = RENEWING;
                                client_config.first_secs = 0; /* make secs field count from 0 */
                                change_listen_mode(LISTEN_KERNEL);
-                               log1("Entering renew state");
+                               log1("entering renew state");
                                /* fall right through */
                        case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
                        case_RENEW_REQUESTED:
@@ -1179,7 +1179,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                        continue;
                                }
                                /* Timed out, enter rebinding state */
-                               log1("Entering rebinding state");
+                               log1("entering rebinding state");
                                state = REBINDING;
                                /* fall right through */
                        case REBINDING:
@@ -1194,7 +1194,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                        continue;
                                }
                                /* Timed out, enter init state */
-                               bb_info_msg("Lease lost, entering init state");
+                               bb_error_msg("lease lost, entering init state");
                                d6_run_script(NULL, "deconfig");
                                state = INIT_SELECTING;
                                client_config.first_secs = 0; /* make secs field count from 0 */
@@ -1242,7 +1242,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                        timeout = INT_MAX;
                        continue;
                case SIGTERM:
-                       bb_info_msg("Received SIGTERM");
+                       bb_error_msg("received %s", "SIGTERM");
                        goto ret0;
                }
 
@@ -1260,7 +1260,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd);
                        if (len == -1) {
                                /* Error is severe, reopen socket */
-                               bb_info_msg("Read error: %s, reopening socket", strerror(errno));
+                               bb_error_msg("read error: %s, reopening socket", strerror(errno));
                                sleep(discover_timeout); /* 3 seconds by default */
                                change_listen_mode(listen_mode); /* just close and reopen */
                        }
@@ -1298,7 +1298,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE);
                                if (option && option->data[4] != 0) {
                                        /* return to init state */
-                                       bb_info_msg("Received DHCP NAK (%u)", option->data[4]);
+                                       bb_error_msg("received DHCP NAK (%u)", option->data[4]);
                                        d6_run_script(&packet, "nak");
                                        if (state != REQUESTING)
                                                d6_run_script(NULL, "deconfig");
@@ -1453,7 +1453,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
                                        lease_seconds = 0x0fffffff;
                                /* enter bound state */
                                timeout = lease_seconds / 2;
-                               bb_info_msg("Lease obtained, lease time %u",
+                               bb_error_msg("lease obtained, lease time %u",
                                        /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
                                d6_run_script(&packet, state == REQUESTING ? "bound" : "renew");
 
index b340b5db6d6447fc9d0d3bed9cf368bd5f4b996f..e166f520de994b50c2c9f77094297ee4dc4e103e 100644 (file)
@@ -17,8 +17,8 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet)
        if (dhcp_verbose < 2)
                return;
 
-       bb_info_msg(
-               " xid %x"
+       bb_error_msg(
+               "xid %x"
                , packet->d6_xid32
        );
        //*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
        memset(packet, 0, sizeof(*packet));
        bytes = safe_read(fd, packet, sizeof(*packet));
        if (bytes < 0) {
-               log1("Packet read error, ignoring");
+               log1("packet read error, ignoring");
                return bytes; /* returns -1 */
        }
 
        if (bytes < offsetof(struct d6_packet, d6_options)) {
-               bb_info_msg("Packet with bad magic, ignoring");
+               bb_error_msg("packet with bad magic, ignoring");
                return -2;
        }
-       log1("Received a packet");
+       log1("received %s", "a packet");
        d6_dump_packet(packet);
 
        return bytes;
index 56f69f6a1b9fb4ffbe573b27015af8aa23d41070..910f296a31707fbafdc628eaaf1726813f4ae050 100644 (file)
@@ -13,7 +13,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf)
        int fd;
        struct sockaddr_in6 addr;
 
-       log1("Opening listen socket on *:%d %s", port, inf);
+       log1("opening listen socket on *:%d %s", port, inf);
        fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
 
        setsockopt_reuseaddr(fd);
index dfd5ca6061aa8519748667ce9e6848e58f415d88..660b943ce734a39cf92685f15e7a885e3138a83d 100644 (file)
@@ -561,7 +561,7 @@ static void udhcp_run_script(struct dhcp_packet *packet, const char *name)
        envp = fill_envp(packet);
 
        /* call script */
-       log1("Executing %s %s", client_config.script, name);
+       log1("executing %s %s", client_config.script, name);
        argv[0] = (char*) client_config.script;
        argv[1] = (char*) name;
        argv[2] = NULL;
@@ -714,7 +714,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
         */
        add_client_options(&packet);
 
-       bb_info_msg("Sending discover...");
+       bb_error_msg("sending %s", "discover");
        return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
 }
 
@@ -758,7 +758,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
        add_client_options(&packet);
 
        addr.s_addr = requested;
-       bb_info_msg("Sending select for %s...", inet_ntoa(addr));
+       bb_error_msg("sending select for %s", inet_ntoa(addr));
        return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
 }
 
@@ -797,7 +797,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
         */
        add_client_options(&packet);
 
-       bb_info_msg("Sending renew...");
+       bb_error_msg("sending %s", "renew");
        return bcast_or_ucast(&packet, ciaddr, server);
 }
 
@@ -826,7 +826,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
 
        udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
 
-       bb_info_msg("Sending decline...");
+       bb_error_msg("sending %s", "decline");
        return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
 }
 #endif
@@ -846,7 +846,7 @@ static int send_release(uint32_t server, uint32_t ciaddr)
 
        udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
 
-       bb_info_msg("Sending release...");
+       bb_error_msg("sending %s", "release");
        /* Note: normally we unicast here since "server" is not zero.
         * However, there _are_ people who run "address-less" DHCP servers,
         * 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)
                if (bytes < 0) {
                        if (errno == EINTR)
                                continue;
-                       log1("Packet read error, ignoring");
+                       log1("packet read error, ignoring");
                        /* NB: possible down interface, etc. Caller should pause. */
                        return bytes; /* returns -1 */
                }
@@ -889,13 +889,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
        }
 
        if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
-               log1("Packet is too short, ignoring");
+               log1("packet is too short, ignoring");
                return -2;
        }
 
        if (bytes < ntohs(packet.ip.tot_len)) {
                /* packet is bigger than sizeof(packet), we did partial read */
-               log1("Oversized packet, ignoring");
+               log1("oversized packet, ignoring");
                return -2;
        }
 
@@ -910,7 +910,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
        /* || bytes > (int) sizeof(packet) - can't happen */
         || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
        ) {
-               log1("Unrelated/bogus packet, ignoring");
+               log1("unrelated/bogus packet, ignoring");
                return -2;
        }
 
@@ -918,7 +918,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
        check = packet.ip.check;
        packet.ip.check = 0;
        if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) {
-               log1("Bad IP header checksum, ignoring");
+               log1("bad IP header checksum, ignoring");
                return -2;
        }
 
@@ -943,17 +943,17 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
        check = packet.udp.check;
        packet.udp.check = 0;
        if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
-               log1("Packet with bad UDP checksum received, ignoring");
+               log1("packet with bad UDP checksum received, ignoring");
                return -2;
        }
  skip_udp_sum_check:
 
        if (packet.data.cookie != htonl(DHCP_MAGIC)) {
-               bb_info_msg("Packet with bad magic, ignoring");
+               bb_error_msg("packet with bad magic, ignoring");
                return -2;
        }
 
-       log1("Received a packet");
+       log1("received %s", "a packet");
        udhcp_dump_packet(&packet.data);
 
        bytes -= sizeof(packet.ip) + sizeof(packet.udp);
@@ -992,14 +992,14 @@ static int udhcp_raw_socket(int ifindex)
        int fd;
        struct sockaddr_ll sock;
 
-       log1("Opening raw socket on ifindex %d", ifindex); //log2?
+       log1("opening raw socket on ifindex %d", ifindex); //log2?
 
        fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
        /* ^^^^^
         * SOCK_DGRAM: remove link-layer headers on input (SOCK_RAW keeps them)
         * ETH_P_IP: want to receive only packets with IPv4 eth type
         */
-       log1("Got raw socket fd"); //log2?
+       log1("got raw socket fd"); //log2?
 
        sock.sll_family = AF_PACKET;
        sock.sll_protocol = htons(ETH_P_IP);
@@ -1055,23 +1055,23 @@ static int udhcp_raw_socket(int ifindex)
                /* Ignoring error (kernel may lack support for this) */
                if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
                                sizeof(filter_prog)) >= 0)
-                       log1("Attached filter to raw socket fd"); // log?
+                       log1("attached filter to raw socket fd"); // log?
        }
 #endif
 
        if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) {
                if (errno != ENOPROTOOPT)
-                       log1("Can't set PACKET_AUXDATA on raw socket");
+                       log1("can't set PACKET_AUXDATA on raw socket");
        }
 
-       log1("Created raw socket");
+       log1("created raw socket");
 
        return fd;
 }
 
 static void change_listen_mode(int new_mode)
 {
-       log1("Entering listen mode: %s",
+       log1("entering listen mode: %s",
                new_mode != LISTEN_NONE
                        ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw")
                        : "none"
@@ -1092,7 +1092,7 @@ static void change_listen_mode(int new_mode)
 /* Called only on SIGUSR1 */
 static void perform_renew(void)
 {
-       bb_info_msg("Performing a DHCP renew");
+       bb_error_msg("performing DHCP renew");
        switch (state) {
        case BOUND:
                change_listen_mode(LISTEN_KERNEL);
@@ -1122,12 +1122,12 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
                temp_addr.s_addr = server_addr;
                strcpy(buffer, inet_ntoa(temp_addr));
                temp_addr.s_addr = requested_ip;
-               bb_info_msg("Unicasting a release of %s to %s",
+               bb_error_msg("unicasting a release of %s to %s",
                                inet_ntoa(temp_addr), buffer);
                send_release(server_addr, requested_ip); /* unicast */
                udhcp_run_script(NULL, "deconfig");
        }
-       bb_info_msg("Entering released state");
+       bb_error_msg("entering released state");
 
        change_listen_mode(LISTEN_NONE);
        state = RELEASED;
@@ -1395,7 +1395,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
        /* Create pidfile */
        write_pidfile(client_config.pidfile);
        /* Goes to stdout (unless NOMMU) and possibly syslog */
-       bb_info_msg("%s (v"BB_VER") started", applet_name);
+       bb_error_msg("started, v"BB_VER);
        /* Set up the signal pipe */
        udhcp_sp_setup();
        /* We want random_xid to be random... */
@@ -1434,7 +1434,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                retval = 0;
                /* If we already timed out, fall through with retval = 0, else... */
                if ((int)tv.tv_sec > 0) {
-                       log1("Waiting on select %u seconds", (int)tv.tv_sec);
+                       log1("waiting on select %u seconds", (int)tv.tv_sec);
                        timestamp_before_wait = (unsigned)monotonic_sec();
                        retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
                        if (retval < 0) {
@@ -1485,14 +1485,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                udhcp_run_script(NULL, "leasefail");
 #if BB_MMU /* -b is not supported on NOMMU */
                                if (opt & OPT_b) { /* background if no lease */
-                                       bb_info_msg("No lease, forking to background");
+                                       bb_error_msg("no lease, forking to background");
                                        client_background();
                                        /* do not background again! */
                                        opt = ((opt & ~OPT_b) | OPT_f);
                                } else
 #endif
                                if (opt & OPT_n) { /* abort if no lease */
-                                       bb_info_msg("No lease, failing");
+                                       bb_error_msg("no lease, failing");
                                        retval = 1;
                                        goto ret;
                                }
@@ -1520,7 +1520,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                state = RENEWING;
                                client_config.first_secs = 0; /* make secs field count from 0 */
                                change_listen_mode(LISTEN_KERNEL);
-                               log1("Entering renew state");
+                               log1("entering renew state");
                                /* fall right through */
                        case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
                        case_RENEW_REQUESTED:
@@ -1540,7 +1540,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                        continue;
                                }
                                /* Timed out, enter rebinding state */
-                               log1("Entering rebinding state");
+                               log1("entering rebinding state");
                                state = REBINDING;
                                /* fall right through */
                        case REBINDING:
@@ -1555,7 +1555,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                        continue;
                                }
                                /* Timed out, enter init state */
-                               bb_info_msg("Lease lost, entering init state");
+                               bb_error_msg("lease lost, entering init state");
                                udhcp_run_script(NULL, "deconfig");
                                state = INIT_SELECTING;
                                client_config.first_secs = 0; /* make secs field count from 0 */
@@ -1603,7 +1603,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                        timeout = INT_MAX;
                        continue;
                case SIGTERM:
-                       bb_info_msg("Received SIGTERM");
+                       bb_error_msg("received %s", "SIGTERM");
                        goto ret0;
                }
 
@@ -1621,7 +1621,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                len = udhcp_recv_raw_packet(&packet, sockfd);
                        if (len == -1) {
                                /* Error is severe, reopen socket */
-                               bb_info_msg("Read error: %s, reopening socket", strerror(errno));
+                               bb_error_msg("read error: %s, reopening socket", strerror(errno));
                                sleep(discover_timeout); /* 3 seconds by default */
                                change_listen_mode(listen_mode); /* just close and reopen */
                        }
@@ -1744,7 +1744,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                                        client_config.interface,
                                                        arpping_ms)
                                        ) {
-                                               bb_info_msg("Offered address is in use "
+                                               bb_error_msg("offered address is in use "
                                                        "(got ARP reply), declining");
                                                send_decline(/*xid,*/ server_addr, packet.yiaddr);
 
@@ -1763,7 +1763,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 #endif
                                /* enter bound state */
                                temp_addr.s_addr = packet.yiaddr;
-                               bb_info_msg("Lease of %s obtained, lease time %u",
+                               bb_error_msg("lease of %s obtained, lease time %u",
                                        inet_ntoa(temp_addr), (unsigned)lease_seconds);
                                requested_ip = packet.yiaddr;
 
@@ -1817,7 +1817,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                                goto non_matching_svid;
                                }
                                /* return to init state */
-                               bb_info_msg("Received DHCP NAK");
+                               bb_error_msg("received %s", "DHCP NAK");
                                udhcp_run_script(&packet, "nak");
                                if (state != REQUESTING)
                                        udhcp_run_script(NULL, "deconfig");
index 2de074f9bc61f689659f21cbd22bb06a2cc2703d..79677ee9379a29e0bc8c7eedde01833cf0eb934c 100644 (file)
@@ -61,11 +61,11 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
         || (dhcp_pkt->flags & htons(BROADCAST_FLAG))
         || dhcp_pkt->ciaddr == 0
        ) {
-               log1("Broadcasting packet to client");
+               log1("broadcasting packet to client");
                ciaddr = INADDR_BROADCAST;
                chaddr = MAC_BCAST_ADDR;
        } else {
-               log1("Unicasting packet to client ciaddr");
+               log1("unicasting packet to client ciaddr");
                ciaddr = dhcp_pkt->ciaddr;
                chaddr = dhcp_pkt->chaddr;
        }
@@ -79,7 +79,7 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
 /* Send a packet to gateway_nip using the kernel ip stack */
 static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
 {
-       log1("Forwarding packet to relay");
+       log1("forwarding packet to relay");
 
        udhcp_send_kernel_packet(dhcp_pkt,
                        server_config.server_nip, SERVER_PORT,
@@ -214,7 +214,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
        add_server_options(&packet);
 
        addr.s_addr = packet.yiaddr;
-       bb_info_msg("Sending OFFER of %s", inet_ntoa(addr));
+       bb_error_msg("sending OFFER of %s", inet_ntoa(addr));
        /* send_packet emits error message itself if it detects failure */
        send_packet(&packet, /*force_bcast:*/ 0);
 }
@@ -226,7 +226,7 @@ static NOINLINE void send_NAK(struct dhcp_packet *oldpacket)
 
        init_packet(&packet, oldpacket, DHCPNAK);
 
-       log1("Sending NAK");
+       log1("sending NAK");
        send_packet(&packet, /*force_bcast:*/ 1);
 }
 
@@ -247,7 +247,7 @@ static NOINLINE void send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr)
        add_server_options(&packet);
 
        addr.s_addr = yiaddr;
-       bb_info_msg("Sending ACK to %s", inet_ntoa(addr));
+       bb_error_msg("sending ACK to %s", inet_ntoa(addr));
        send_packet(&packet, /*force_bcast:*/ 0);
 
        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)
        write_pidfile(server_config.pidfile);
        /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
 
-       bb_info_msg("%s (v"BB_VER") started", applet_name);
+       bb_error_msg("started, v"BB_VER);
 
        option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
        server_config.max_lease_sec = DEFAULT_LEASE_TIME;
@@ -427,18 +427,18 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
                        goto continue_with_autotime;
                }
                if (retval < 0 && errno != EINTR) {
-                       log1("Error on select");
+                       log1("error on select");
                        continue;
                }
 
                switch (udhcp_sp_read(&rfds)) {
                case SIGUSR1:
-                       bb_info_msg("Received SIGUSR1");
+                       bb_error_msg("received %s", "SIGUSR1");
                        write_leases();
                        /* why not just reset the timeout, eh */
                        goto continue_with_autotime;
                case SIGTERM:
-                       bb_info_msg("Received SIGTERM");
+                       bb_error_msg("received %s", "SIGTERM");
                        write_leases();
                        goto ret0;
                case 0: /* no signal: read a packet */
@@ -451,7 +451,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
                if (bytes < 0) {
                        /* bytes can also be -2 ("bad packet data") */
                        if (bytes == -1 && errno != EINTR) {
-                               log1("Read error: %s, reopening socket", strerror(errno));
+                               log1("read error: %s, reopening socket", strerror(errno));
                                close(server_socket);
                                server_socket = -1;
                        }
@@ -486,7 +486,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
                /* Look for a static/dynamic lease */
                static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
                if (static_lease_nip) {
-                       bb_info_msg("Found static lease: %x", static_lease_nip);
+                       bb_error_msg("found static lease: %x", static_lease_nip);
                        memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
                        fake_lease.lease_nip = static_lease_nip;
                        fake_lease.expires = 0;
@@ -504,13 +504,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
                switch (state[0]) {
 
                case DHCPDISCOVER:
-                       log1("Received DISCOVER");
+                       log1("received %s", "DISCOVER");
 
                        send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
                        break;
 
                case DHCPREQUEST:
-                       log1("Received REQUEST");
+                       log1("received %s", "REQUEST");
 /* RFC 2131:
 
 o DHCPREQUEST generated during SELECTING state:
@@ -635,7 +635,7 @@ o DHCPREQUEST generated during REBINDING state:
                         * chaddr must be filled in,
                         * ciaddr must be 0 (we do not check this)
                         */
-                       log1("Received DECLINE");
+                       log1("received %s", "DECLINE");
                        if (server_id_opt
                         && requested_ip_opt
                         && lease  /* chaddr matches this lease */
@@ -655,7 +655,7 @@ o DHCPREQUEST generated during REBINDING state:
                         * chaddr must be filled in,
                         * ciaddr must be filled in
                         */
-                       log1("Received RELEASE");
+                       log1("received %s", "RELEASE");
                        if (server_id_opt
                         && lease  /* chaddr matches this lease */
                         && packet.ciaddr == lease->lease_nip
@@ -665,7 +665,7 @@ o DHCPREQUEST generated during REBINDING state:
                        break;
 
                case DHCPINFORM:
-                       log1("Received INFORM");
+                       log1("received %s", "INFORM");
                        send_inform(&packet);
                        break;
                }
index 5b90e26d28fd113dac2c165edccdece93010dd93..7b57c62584b0acd442dc6a11d8f26aea93dbf4ff 100644 (file)
@@ -226,7 +226,7 @@ void FAST_FUNC read_leases(const char *file)
 #endif
                }
        }
-       log1("Read %d leases", i);
+       log1("read %d leases", i);
  ret:
        close(fd);
 }
index 411b74962fb8186967ba2cded5eb07aedfaea521..6642e396d61d8b7d19a996cecbf45ab5e80585bc 100644 (file)
@@ -133,7 +133,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigne
                return r;
 
        temp.s_addr = nip;
-       bb_info_msg("%s belongs to someone, reserving it for %u seconds",
+       bb_error_msg("%s belongs to someone, reserving it for %u seconds",
                inet_ntoa(temp), (unsigned)server_config.conflict_time);
        add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
        return 0;
index 148f52551a129e179ea8fe031ddb36a81eaa09a2..0a31f2643410a04144f684bfe9cd71a48257aa5e 100644 (file)
@@ -38,8 +38,8 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
        if (dhcp_verbose < 2)
                return;
 
-       bb_info_msg(
-               //" op %x"
+       bb_error_msg(
+               //"op %x"
                //" htype %x"
                " hlen %x"
                //" hops %x"
@@ -73,7 +73,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet)
                //, packet->options[]
        );
        *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
-       bb_info_msg(" chaddr %s", buf);
+       bb_error_msg("chaddr %s", buf);
 }
 #endif
 
@@ -85,17 +85,17 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
        memset(packet, 0, sizeof(*packet));
        bytes = safe_read(fd, packet, sizeof(*packet));
        if (bytes < 0) {
-               log1("Packet read error, ignoring");
+               log1("packet read error, ignoring");
                return bytes; /* returns -1 */
        }
 
        if (bytes < offsetof(struct dhcp_packet, options)
         || packet->cookie != htonl(DHCP_MAGIC)
        ) {
-               bb_info_msg("Packet with bad magic, ignoring");
+               bb_error_msg("packet with bad magic, ignoring");
                return -2;
        }
-       log1("Received a packet");
+       log1("received %s", "a packet");
        udhcp_dump_packet(packet);
 
        return bytes;
index a42106960801d160a2f25b88976a368ba66dcebd..4fd79f4238440a67e80c2fabe512d7514daffabb 100644 (file)
@@ -56,7 +56,7 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t
                        close(fd);
                        return -1;
                }
-               log1("Adapter index %d", ifr->ifr_ifindex);
+               log1("adapter index %d", ifr->ifr_ifindex);
                *ifindex = ifr->ifr_ifindex;
        }
 
@@ -82,7 +82,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
        struct sockaddr_in addr;
        char *colon;
 
-       log1("Opening listen socket on *:%d %s", port, inf);
+       log1("opening listen socket on *:%d %s", port, inf);
        fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
        setsockopt_reuseaddr(fd);
index f4a24ab627a955180f6d385dedb58b424fc42de5..b7f9e5c594d85188d81d0caa61c40c781b795ad5 100644 (file)
@@ -66,7 +66,7 @@ void FAST_FUNC log_static_leases(struct static_lease **st_lease_pp)
 
        cur = *st_lease_pp;
        while (cur) {
-               bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
+               bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
                        cur->mac[0], cur->mac[1], cur->mac[2],
                        cur->mac[3], cur->mac[4], cur->mac[5],
                        cur->nip