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;
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
+++ /dev/null
-/* 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
-}
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;
}
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
}
/* 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;
}
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;
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 */
#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
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;
*/
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);
}
*/
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);
}
*/
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),
/* 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,
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;
}
/* || 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;
}
// 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);
};
#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);
/* 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"
/* 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);
{
/* 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;
/* 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... */
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) {
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;
}
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:
continue;
}
/* Timed out, enter rebinding state */
- log1("Entering rebinding state");
+ log1("entering rebinding state");
state = REBINDING;
/* fall right through */
case REBINDING:
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 */
timeout = INT_MAX;
continue;
case SIGTERM:
- bb_info_msg("Received SIGTERM");
+ bb_error_msg("received %s", "SIGTERM");
goto ret0;
}
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 */
}
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");
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");
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';
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;
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);
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;
*/
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);
}
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);
}
*/
add_client_options(&packet);
- bb_info_msg("Sending renew...");
+ bb_error_msg("sending %s", "renew");
return bcast_or_ucast(&packet, ciaddr, server);
}
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
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.
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 */
}
}
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;
}
/* || 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;
}
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;
}
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);
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);
/* 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"
/* 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);
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;
/* 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... */
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) {
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;
}
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:
continue;
}
/* Timed out, enter rebinding state */
- log1("Entering rebinding state");
+ log1("entering rebinding state");
state = REBINDING;
/* fall right through */
case REBINDING:
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 */
timeout = INT_MAX;
continue;
case SIGTERM:
- bb_info_msg("Received SIGTERM");
+ bb_error_msg("received %s", "SIGTERM");
goto ret0;
}
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 */
}
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);
#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;
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");
|| (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;
}
/* 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,
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);
}
init_packet(&packet, oldpacket, DHCPNAK);
- log1("Sending NAK");
+ log1("sending NAK");
send_packet(&packet, /*force_bcast:*/ 1);
}
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);
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;
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 */
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;
}
/* 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;
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:
* 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 */
* 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
break;
case DHCPINFORM:
- log1("Received INFORM");
+ log1("received %s", "INFORM");
send_inform(&packet);
break;
}
#endif
}
}
- log1("Read %d leases", i);
+ log1("read %d leases", i);
ret:
close(fd);
}
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;
if (dhcp_verbose < 2)
return;
- bb_info_msg(
- //" op %x"
+ bb_error_msg(
+ //"op %x"
//" htype %x"
" hlen %x"
//" hops %x"
//, packet->options[]
);
*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
- bb_info_msg(" chaddr %s", buf);
+ bb_error_msg("chaddr %s", buf);
}
#endif
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;
close(fd);
return -1;
}
- log1("Adapter index %d", ifr->ifr_ifindex);
+ log1("adapter index %d", ifr->ifr_ifindex);
*ifindex = ifr->ifr_ifindex;
}
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);
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