-/* $OpenBSD: dhclient.c,v 1.547 2018/01/28 23:12:36 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.548 2018/01/29 13:41:30 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
char path_option_db[PATH_MAX];
-int log_perror = 1;
int nullfd = -1;
int cmd_opts;
saved_argv = argv;
if (isatty(STDERR_FILENO) != 0)
- log_perror = 1; /* log to stderr until daemonized */
+ log_init(1, LOG_DEBUG); /* log to stderr until daemonized */
else
- log_perror = 0; /* can't log to stderr */
+ log_init(0, LOG_DEBUG); /* can't log to stderr */
- log_init(log_perror, LOG_DAEMON);
- log_setverbose(1);
+ log_setverbose(1); /* Show log_debug() messages. */
while ((ch = getopt(argc, argv, "c:di:l:L:nq")) != -1)
switch (ch) {
cmd_opts &= ~OPT_QUIET;
if ((cmd_opts & OPT_QUIET) != 0)
- log_perror = 0;
-
- log_init(log_perror, LOG_DAEMON);
+ log_setverbose(0); /* Don't show log_debug() */
ifi = calloc(1, sizeof(*ifi));
if (ifi == NULL)
ifi->linkstat = interface_status(ifi->name);
- if (log_perror != 0 && interval > 3) {
+ if (isatty(STDERR_FILENO) != 0 && interval > 3) {
if (preamble == 0 && ifi->linkstat == 0) {
fprintf(stderr, "%s: no link ....", ifi->name);
preamble = 1;
void
dhcpoffer(struct interface_info *ifi, struct option_data *options,
- const char *src)
+ const char *src)
{
if (ifi->state != S_SELECTING) {
DPRINTF("%s: unexpected DHCPOFFER from %s - state #%d",
return;
}
- log_info("%s: DHCPACK from %s", log_procname, src);
+ log_debug("%s: DHCPACK from %s", log_procname, src);
lease = packet_to_lease(ifi, options);
if (lease == NULL) {
rslt = send_packet(ifi, inaddr_any, inaddr_broadcast, "DHCPDISCOVER");
if (rslt != -1)
- log_info("%s: DHCPDISCOVER - interval %lld", log_procname,
+ log_debug("%s: DHCPDISCOVER - interval %lld", log_procname,
(long long)ifi->interval);
set_timeout(ifi, ifi->interval, send_discover);
void
state_panic(struct interface_info *ifi)
{
- log_info("%s: no acceptable DHCPOFFERS received", log_procname);
+ log_debug("%s: no acceptable DHCPOFFERS received", log_procname);
ifi->offer = get_recorded_lease(ifi);
if (ifi->offer != NULL) {
/*
* No leases were available, or what was available didn't work
*/
- log_info("%s: no working leases in persistent database - sleeping",
+ log_debug("%s: no working leases in persistent database - sleeping",
log_procname);
ifi->state = S_INIT;
set_timeout(ifi, config->retry_interval, state_init);
rslt = send_packet(ifi, from, destination.sin_addr, "DHCPREQUEST");
if (rslt != -1)
- log_info("%s: DHCPREQUEST to %s", log_procname,
+ log_debug("%s: DHCPREQUEST to %s", log_procname,
inet_ntoa(destination.sin_addr));
set_timeout(ifi, ifi->interval, send_request);
rslt = send_packet(ifi, inaddr_any, inaddr_broadcast, "DHCPDECLINE");
if (rslt != -1)
- log_info("%s: DHCPDECLINE", log_procname);
+ log_debug("%s: DHCPDECLINE", log_procname);
}
void
fatal("daemonize");
/* Stop logging to stderr. */
- log_perror = 0;
log_init(0, LOG_DAEMON);
+ if ((cmd_opts & OPT_QUIET) == 0)
+ log_setverbose(1); /* show log_debug() messages. */
log_procinit(log_procname);
-#ifdef DEBUG
- log_setverbose(1);
-#else
- log_setverbose(0);
-#endif /* DEBUG */
setproctitle("%s", log_procname);
signal(SIGHUP, sighdlr);
i = name_to_code(p);
if (i == DHO_END) {
- log_info("%s: invalid option name: '%s'", log_procname,
+ log_debug("%s: invalid option name: '%s'", log_procname,
p);
return;
}
-/* $OpenBSD: packet.c,v 1.42 2018/01/25 15:43:51 krw Exp $ */
+/* $OpenBSD: packet.c,v 1.43 2018/01/29 13:41:30 krw Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
ip_packets_bad_checksum++;
if (ip_packets_seen > 4 && ip_packets_bad_checksum != 0 &&
(ip_packets_seen / ip_packets_bad_checksum) < 2) {
- log_info("%s: %d bad IP checksums seen in %d packets",
+ log_debug("%s: %d bad IP checksums seen in %d packets",
log_procname, ip_packets_bad_checksum,
ip_packets_seen);
ip_packets_seen = ip_packets_bad_checksum = 0;
udp_packets_length_overflow != 0 &&
(udp_packets_length_checked /
udp_packets_length_overflow) < 2) {
- log_info("%s: %d udp packets in %d too long - dropped",
+ log_debug("%s: %d udp packets in %d too long - dropped",
log_procname, udp_packets_length_overflow,
udp_packets_length_checked);
udp_packets_length_overflow =
udp_packets_bad_checksum++;
if (udp_packets_seen > 4 && udp_packets_bad_checksum != 0 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
- log_info("%s: %d bad udp checksums in %d packets",
+ log_debug("%s: %d bad udp checksums in %d packets",
log_procname, udp_packets_bad_checksum,
udp_packets_seen);
udp_packets_seen = udp_packets_bad_checksum = 0;