#ifdef DEBUG/#endif blocks.
Suggestions on correct idiom (C99 vs gcc) from millert@
ok tom@
-/* $OpenBSD: dhclient.c,v 1.544 2018/01/24 19:12:49 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.545 2018/01/25 15:43:51 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
linkstat = interface_status(ifi->name);
if (linkstat != ifi->linkstat) {
-#ifdef DEBUG
- log_debug("%s: link %s -> %s", log_procname,
+ DPRINTF("%s: link %s -> %s", log_procname,
(ifi->linkstat != 0) ? "up" : "down",
(linkstat != 0) ? "up" : "down");
-#endif /* DEBUG */
ifi->linkstat = linkstat;
if (ifi->linkstat != 0) {
if (ifi->state == S_PREBOOT) {
time_t cur_time, stop_selecting;
if (ifi->state != S_SELECTING) {
-#ifdef DEBUG
- log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
ifi->state);
-#endif /* DEBUG */
return;
}
ifi->state != S_REQUESTING &&
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
-#ifdef DEBUG
- log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
ifi->state);
-#endif /* DEBUG */
return;
}
ifi->state != S_REQUESTING &&
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
-#ifdef DEBUG
- log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
ifi->state);
-#endif /* DEBUG */
return;
}
if (ifi->active == NULL) {
-#ifdef DEBUG
- log_debug("%s: unexpected %s - no active lease", log_procname,
+ DPRINTF("%s: unexpected %s - no active lease", log_procname,
info);
-#endif /* DEBUG */
return;
}
-/* $OpenBSD: dhcpd.h,v 1.245 2018/01/04 03:02:05 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.246 2018/01/25 15:43:51 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
struct client_lease_tq lease_db;
};
+#if DEBUG
+#define DPRINTF(...) log_debug(__VA_ARGS__)
+#else
+#define DPRINTF(...) do {} while(0)
+#endif
+
#define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
#define _PATH_LEASE_DB "/var/db/dhclient.leases"
-/* $OpenBSD: dispatch.c,v 1.147 2018/01/24 19:12:49 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.148 2018/01/25 15:43:51 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
ifrom.s_addr = from.sin_addr.s_addr;
if (packet->hlen != ETHER_ADDR_LEN) {
-#ifdef DEBUG
- log_debug("%s: discarding packet with hlen == %u", log_procname,
+ DPRINTF("%s: discarding packet with hlen == %u", log_procname,
packet->hlen);
-#endif /* DEBUG */
return;
} else if (memcmp(&ifi->hw_address, packet->chaddr,
sizeof(ifi->hw_address))) {
-#ifdef DEBUG
- log_debug("%s: discarding packet with chaddr == %s",
+ DPRINTF("%s: discarding packet with chaddr == %s",
log_procname,
ether_ntoa((struct ether_addr *)packet->chaddr));
-#endif /* DEBUG */
return;
}
if (ifi->xid != packet->xid) {
-#ifdef DEBUG
- log_debug("%s: discarding packet with XID != %u (%u)",
+ DPRINTF("%s: discarding packet with XID != %u (%u)",
log_procname, ifi->xid, packet->xid);
-#endif /* DEBUG */
return;
}
TAILQ_FOREACH(ap, &config->reject_list, next)
if (ifrom.s_addr == ap->addr.s_addr) {
-#ifdef DEBUG
- log_debug("%s: discarding packet from address on reject "
+ DPRINTF("%s: discarding packet from address on reject "
"list (%s)", log_procname, inet_ntoa(ifrom));
-#endif /* DEBUG */
return;
}
((options[i].len != config->send_options[i].len) ||
memcmp(options[i].data, config->send_options[i].data,
options[i].len) != 0)) {
-#ifdef DEBUG
- log_debug("%s: discarding packet with client-identifier %s'",
+ DPRINTF("%s: discarding packet with client-identifier %s'",
log_procname, pretty_print_option(i, &options[i], 0));
-#endif /* DEBUG */
return;
}
type = "DHCPACK";
break;
default:
-#ifdef DEBUG
- log_debug("%s: discarding DHCP packet of unknown type "
+ DPRINTF("%s: discarding DHCP packet of unknown type "
"(%d)", log_procname, options[i].data[0]);
-#endif /* DEBUG */
return;
}
} else if (packet->op == BOOTREPLY) {
handler = dhcpoffer;
type = "BOOTREPLY";
} else {
-#ifdef DEBUG
- log_debug("%s: discarding packet which is neither DHCP nor "
+ DPRINTF("%s: discarding packet which is neither DHCP nor "
"BOOTP", log_procname);
-#endif /* DEBUG */
return;
}
-/* $OpenBSD: packet.c,v 1.41 2017/09/17 21:20:23 krw Exp $ */
+/* $OpenBSD: packet.c,v 1.42 2018/01/25 15:43:51 krw Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
memcpy(&from->sin_addr, &ip->ip_src, sizeof(from->sin_addr));
-#ifdef DEBUG
if (ntohs(ip->ip_len) != buflen)
- log_debug("%s: ip length %hu disagrees with bytes received %d",
+ DPRINTF("%s: ip length %hu disagrees with bytes received %d",
log_procname, ntohs(ip->ip_len), buflen);
-#endif /* DEBUG */
/* Assure that the entire IP packet is within the buffer. */
if (ntohs(ip->ip_len) > buflen)
}
return -1;
}
-#ifdef DEBUG
if (len + data != buf + buflen)
- log_debug("%s: accepting packet with data after udp payload",
+ DPRINTF("%s: accepting packet with data after udp payload",
log_procname);
-#endif /* DEBUG */
usum = udp->uh_sum;
udp->uh_sum = 0;