aboutsummaryrefslogtreecommitdiff
path: root/dhcp6c.c
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp6c.c')
-rw-r--r--dhcp6c.c246
1 files changed, 123 insertions, 123 deletions
diff --git a/dhcp6c.c b/dhcp6c.c
index b5f5ed7..c959b7c 100644
--- a/dhcp6c.c
+++ b/dhcp6c.c
@@ -218,7 +218,7 @@ main(argc, argv)
client6_init();
while (argc-- > 0) {
if ((ifp = ifinit(argv[0])) == NULL) {
- dprintf(LOG_ERR, FNAME, "failed to initialize %s",
+ debug_printf(LOG_ERR, FNAME, "failed to initialize %s",
argv[0]);
exit(1);
}
@@ -226,7 +226,7 @@ main(argc, argv)
}
if (infreq_mode == 0 && (cfparse(conffile)) != 0) {
- dprintf(LOG_ERR, FNAME, "failed to parse configuration file");
+ debug_printf(LOG_ERR, FNAME, "failed to parse configuration file");
exit(1);
}
@@ -266,12 +266,12 @@ client6_init()
/* get our DUID */
if (get_duid(DUID_FILE, &client_duid)) {
- dprintf(LOG_ERR, FNAME, "failed to get a DUID");
+ debug_printf(LOG_ERR, FNAME, "failed to get a DUID");
exit(1);
}
if (dhcp6_ctl_authinit(ctlkeyfile, &ctlkey, &ctldigestlen) != 0) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed initialize control message authentication");
/* run the server anyway */
}
@@ -283,25 +283,25 @@ client6_init()
hints.ai_flags = AI_PASSIVE;
error = getaddrinfo(NULL, DH6PORT_DOWNSTREAM, &hints, &res);
if (error) {
- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
gai_strerror(error));
exit(1);
}
sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (sock < 0) {
- dprintf(LOG_ERR, FNAME, "socket");
+ debug_printf(LOG_ERR, FNAME, "socket");
exit(1);
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
&on, sizeof(on)) < 0) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"setsockopt(SO_REUSEPORT): %s", strerror(errno));
exit(1);
}
#ifdef IPV6_RECVPKTINFO
if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
sizeof(on)) < 0) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"setsockopt(IPV6_RECVPKTINFO): %s",
strerror(errno));
exit(1);
@@ -309,7 +309,7 @@ client6_init()
#else
if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on)) < 0) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"setsockopt(IPV6_PKTINFO): %s",
strerror(errno));
exit(1);
@@ -317,7 +317,7 @@ client6_init()
#endif
if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &on,
sizeof(on)) < 0) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"setsockopt(sock, IPV6_MULTICAST_LOOP): %s",
strerror(errno));
exit(1);
@@ -325,7 +325,7 @@ client6_init()
#ifdef IPV6_V6ONLY
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
&on, sizeof(on)) < 0) {
- dprintf(LOG_ERR, FNAME, "setsockopt(IPV6_V6ONLY): %s",
+ debug_printf(LOG_ERR, FNAME, "setsockopt(IPV6_V6ONLY): %s",
strerror(errno));
exit(1);
}
@@ -337,14 +337,14 @@ client6_init()
* the outgoing port is also bound to the DH6PORT_DOWNSTREAM.
*/
if (bind(sock, res->ai_addr, res->ai_addrlen) < 0) {
- dprintf(LOG_ERR, FNAME, "bind: %s", strerror(errno));
+ debug_printf(LOG_ERR, FNAME, "bind: %s", strerror(errno));
exit(1);
}
freeaddrinfo(res);
/* open a routing socket to watch the routing table */
if ((rtsock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
- dprintf(LOG_ERR, FNAME, "open a routing socket: %s",
+ debug_printf(LOG_ERR, FNAME, "open a routing socket: %s",
strerror(errno));
exit(1);
}
@@ -355,7 +355,7 @@ client6_init()
hints.ai_protocol = IPPROTO_UDP;
error = getaddrinfo(DH6ADDR_ALLAGENT, DH6PORT_UPSTREAM, &hints, &res);
if (error) {
- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
gai_strerror(error));
exit(1);
}
@@ -365,21 +365,21 @@ client6_init()
/* set up control socket */
if (ctlkey == NULL)
- dprintf(LOG_NOTICE, FNAME, "skip opening control port");
+ debug_printf(LOG_NOTICE, FNAME, "skip opening control port");
else if (dhcp6_ctl_init(ctladdr, ctlport,
DHCP6CTL_DEF_COMMANDQUEUELEN, &ctlsock)) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"failed to initialize control channel");
exit(1);
}
if (signal(SIGHUP, client6_signal) == SIG_ERR) {
- dprintf(LOG_WARNING, FNAME, "failed to set signal: %s",
+ debug_printf(LOG_WARNING, FNAME, "failed to set signal: %s",
strerror(errno));
exit(1);
}
if (signal(SIGTERM, client6_signal) == SIG_ERR) {
- dprintf(LOG_WARNING, FNAME, "failed to set signal: %s",
+ debug_printf(LOG_WARNING, FNAME, "failed to set signal: %s",
strerror(errno));
exit(1);
}
@@ -393,28 +393,28 @@ client6_start(ifp)
/* make sure that the interface does not have a timer */
if (ifp->timer != NULL) {
- dprintf(LOG_DEBUG, FNAME,
+ debug_printf(LOG_DEBUG, FNAME,
"removed existing timer on %s", ifp->ifname);
dhcp6_remove_timer(&ifp->timer);
}
/* create an event for the initial delay */
if ((ev = dhcp6_create_event(ifp, DHCP6S_INIT)) == NULL) {
- dprintf(LOG_NOTICE, FNAME, "failed to create an event");
+ debug_printf(LOG_NOTICE, FNAME, "failed to create an event");
return (-1);
}
TAILQ_INSERT_TAIL(&ifp->event_list, ev, link);
if ((ev->authparam = new_authparam(ifp->authproto,
ifp->authalgorithm, ifp->authrdm)) == NULL) {
- dprintf(LOG_WARNING, FNAME, "failed to allocate "
+ debug_printf(LOG_WARNING, FNAME, "failed to allocate "
"authentication parameters");
dhcp6_remove_event(ev);
return (-1);
}
if ((ev->timer = dhcp6_add_timer(client6_timo, ev)) == NULL) {
- dprintf(LOG_NOTICE, FNAME, "failed to add a timer for %s",
+ debug_printf(LOG_NOTICE, FNAME, "failed to add a timer for %s",
ifp->ifname);
dhcp6_remove_event(ev);
return (-1);
@@ -432,7 +432,7 @@ client6_startall(isrestart)
for (ifp = dhcp6_if; ifp; ifp = ifp->next) {
if (isrestart &&ifreset(ifp)) {
- dprintf(LOG_NOTICE, FNAME, "failed to reset %s",
+ debug_printf(LOG_NOTICE, FNAME, "failed to reset %s",
ifp->ifname);
continue; /* XXX: try to recover? */
}
@@ -489,7 +489,7 @@ check_exit()
}
/* We have no existing event. Do exit. */
- dprintf(LOG_INFO, FNAME, "exiting");
+ debug_printf(LOG_INFO, FNAME, "exiting");
exit(0);
}
@@ -504,7 +504,7 @@ process_signals()
check_exit();
}
if ((sig_flags & SIGF_HUP)) {
- dprintf(LOG_INFO, FNAME, "restarting");
+ debug_printf(LOG_INFO, FNAME, "restarting");
free_resources(NULL);
client6_startall(1);
}
@@ -539,7 +539,7 @@ client6_mainloop()
switch (ret) {
case -1:
if (errno != EINTR) {
- dprintf(LOG_ERR, FNAME, "select: %s",
+ debug_printf(LOG_ERR, FNAME, "select: %s",
strerror(errno));
exit(1);
}
@@ -633,31 +633,31 @@ client6_do_ctlcommand(buf, len)
commandlen = (int)(ntohs(ctlhead->len));
version = ntohs(ctlhead->version);
if (len != sizeof(struct dhcp6ctl) + commandlen) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"assumption failure: command length mismatch");
return (DHCP6CTL_R_FAILURE);
}
/* replay protection and message authentication */
if ((now = time(NULL)) < 0) {
- dprintf(LOG_ERR, FNAME, "failed to get current time: %s",
+ debug_printf(LOG_ERR, FNAME, "failed to get current time: %s",
strerror(errno));
return (DHCP6CTL_R_FAILURE);
}
ts0 = (u_int32_t)now;
ts = ntohl(ctlhead->timestamp);
if (ts + CTLSKEW < ts0 || (ts - CTLSKEW) > ts0) {
- dprintf(LOG_INFO, FNAME, "timestamp is out of range");
+ debug_printf(LOG_INFO, FNAME, "timestamp is out of range");
return (DHCP6CTL_R_FAILURE);
}
if (ctlkey == NULL) { /* should not happen!! */
- dprintf(LOG_ERR, FNAME, "no secret key for control channel");
+ debug_printf(LOG_ERR, FNAME, "no secret key for control channel");
return (DHCP6CTL_R_FAILURE);
}
if (dhcp6_verify_mac(buf, len, DHCP6CTL_AUTHPROTO_UNDEF,
DHCP6CTL_AUTHALG_HMACMD5, sizeof(*ctlhead), ctlkey) != 0) {
- dprintf(LOG_INFO, FNAME, "authentication failure");
+ debug_printf(LOG_INFO, FNAME, "authentication failure");
return (DHCP6CTL_R_FAILURE);
}
@@ -665,14 +665,14 @@ client6_do_ctlcommand(buf, len)
commandlen -= ctldigestlen;
if (version > DHCP6CTL_VERSION) {
- dprintf(LOG_INFO, FNAME, "unsupported version: %d", version);
+ debug_printf(LOG_INFO, FNAME, "unsupported version: %d", version);
return (DHCP6CTL_R_FAILURE);
}
switch (command) {
case DHCP6CTL_COMMAND_RELOAD:
if (commandlen != 0) {
- dprintf(LOG_INFO, FNAME, "invalid command length "
+ debug_printf(LOG_INFO, FNAME, "invalid command length "
"for reload: %d", commandlen);
return (DHCP6CTL_R_DONE);
}
@@ -691,7 +691,7 @@ client6_do_ctlcommand(buf, len)
return (DHCP6CTL_R_FAILURE);
break;
default:
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"unknown start target: %ul", p32);
return (DHCP6CTL_R_FAILURE);
}
@@ -718,14 +718,14 @@ client6_do_ctlcommand(buf, len)
}
break;
default:
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"unknown start target: %ul", p32);
return (DHCP6CTL_R_FAILURE);
}
}
break;
default:
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"unknown control command: %d (len=%d)",
(int)command, commandlen);
return (DHCP6CTL_R_FAILURE);
@@ -739,12 +739,12 @@ client6_reload()
{
/* reload the configuration file */
if (cfparse(conffile) != 0) {
- dprintf(LOG_WARNING, FNAME,
+ debug_printf(LOG_WARNING, FNAME,
"failed to reload configuration file");
return;
}
- dprintf(LOG_NOTICE, FNAME, "client reloaded");
+ debug_printf(LOG_NOTICE, FNAME, "client reloaded");
return;
}
@@ -757,20 +757,20 @@ client6_ifctl(ifname, command)
struct dhcp6_if *ifp;
if ((ifp = find_ifconfbyname(ifname)) == NULL) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"failed to find interface configuration for %s",
ifname);
return (-1);
}
- dprintf(LOG_DEBUG, FNAME, "%s interface %s",
+ debug_printf(LOG_DEBUG, FNAME, "%s interface %s",
command == DHCP6CTL_COMMAND_START ? "start" : "stop", ifname);
switch(command) {
case DHCP6CTL_COMMAND_START:
free_resources(ifp);
if (client6_start(ifp)) {
- dprintf(LOG_NOTICE, FNAME, "failed to restart %s",
+ debug_printf(LOG_NOTICE, FNAME, "failed to restart %s",
ifname);
return (-1);
}
@@ -778,13 +778,13 @@ client6_ifctl(ifname, command)
case DHCP6CTL_COMMAND_STOP:
free_resources(ifp);
if (ifp->timer != NULL) {
- dprintf(LOG_DEBUG, FNAME,
+ debug_printf(LOG_DEBUG, FNAME,
"removed existing timer on %s", ifp->ifname);
dhcp6_remove_timer(&ifp->timer);
}
break;
default: /* impossible case, should be a bug */
- dprintf(LOG_ERR, FNAME, "unknown command: %d", (int)command);
+ debug_printf(LOG_ERR, FNAME, "unknown command: %d", (int)command);
break;
}
@@ -797,7 +797,7 @@ client6_expire_refreshtime(arg)
{
struct dhcp6_if *ifp = arg;
- dprintf(LOG_DEBUG, FNAME,
+ debug_printf(LOG_DEBUG, FNAME,
"information refresh time on %s expired", ifp->ifname);
dhcp6_remove_timer(&ifp->timer);
@@ -823,7 +823,7 @@ client6_timo(arg)
* [RFC3315 14.]
*/
if (ev->max_retrans_cnt && ev->timeouts >= ev->max_retrans_cnt) {
- dprintf(LOG_INFO, FNAME, "no responses were received");
+ debug_printf(LOG_INFO, FNAME, "no responses were received");
dhcp6_remove_event(ev);
if (state == DHCP6S_RELEASE)
@@ -840,7 +840,7 @@ client6_timo(arg)
else {
ev->state = DHCP6S_SOLICIT;
if (construct_confdata(ifp, ev)) {
- dprintf(LOG_ERR, FNAME, "can't send solicit");
+ debug_printf(LOG_ERR, FNAME, "can't send solicit");
exit(1); /* XXX */
}
}
@@ -856,7 +856,7 @@ client6_timo(arg)
if (!TAILQ_EMPTY(&ev->data_list))
client6_send(ev);
else {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"all information to be updated was canceled");
dhcp6_remove_event(ev);
return (NULL);
@@ -875,13 +875,13 @@ client6_timo(arg)
ev->current_server = select_server(ev);
if (ev->current_server == NULL) {
/* this should not happen! */
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"can't find a server");
exit(1); /* XXX */
}
if (duidcpy(&ev->serverid,
&ev->current_server->optinfo.serverID)) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"can't copy server ID");
return (NULL); /* XXX: better recovery? */
}
@@ -896,7 +896,7 @@ client6_timo(arg)
if (construct_reqdata(ifp,
&ev->current_server->optinfo, ev)) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed to construct request data");
break;
}
@@ -930,7 +930,7 @@ construct_confdata(ifp, ev)
evd = NULL;
if ((evd = malloc(sizeof(*evd))) == NULL) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed to create a new event data");
goto fail;
}
@@ -982,7 +982,7 @@ construct_confdata(ifp, ev)
TAILQ_INSERT_TAIL(&ev->data_list, evd, link);
break;
default:
- dprintf(LOG_ERR, FNAME, "internal error");
+ debug_printf(LOG_ERR, FNAME, "internal error");
exit(1);
}
}
@@ -1078,7 +1078,7 @@ construct_reqdata(ifp, optinfo, ev)
TAILQ_INSERT_TAIL(&ev->data_list, evd, link);
break;
default:
- dprintf(LOG_ERR, FNAME, "internal error");
+ debug_printf(LOG_ERR, FNAME, "internal error");
exit(1);
}
}
@@ -1102,7 +1102,7 @@ destruct_iadata(evd)
struct dhcp6_list *ial;
if (evd->type != DHCP6_EVDATA_IAPD && evd->type != DHCP6_EVDATA_IANA) {
- dprintf(LOG_ERR, FNAME, "assumption failure %d", evd->type);
+ debug_printf(LOG_ERR, FNAME, "assumption failure %d", evd->type);
exit(1);
}
@@ -1124,7 +1124,7 @@ select_server(ev)
*/
for (s = ev->servers; s; s = s->next) {
if (s->active) {
- dprintf(LOG_DEBUG, FNAME, "picked a server (ID: %s)",
+ debug_printf(LOG_DEBUG, FNAME, "picked a server (ID: %s)",
duidstr(&s->optinfo.serverID));
return (s);
}
@@ -1185,7 +1185,7 @@ client6_send(ev)
dh6->dh6_msgtype = DH6_INFORM_REQ;
break;
default:
- dprintf(LOG_ERR, FNAME, "unexpected state");
+ debug_printf(LOG_ERR, FNAME, "unexpected state");
exit(1); /* XXX */
}
@@ -1203,7 +1203,7 @@ client6_send(ev)
#else
ev->xid = random() & DH6_XIDMASK;
#endif
- dprintf(LOG_DEBUG, FNAME, "a new XID (%x) is generated",
+ debug_printf(LOG_DEBUG, FNAME, "a new XID (%x) is generated",
ev->xid);
}
dh6->dh6_xid &= ~ntohl(DH6_XIDMASK);
@@ -1221,7 +1221,7 @@ client6_send(ev)
case DHCP6S_RENEW:
case DHCP6S_RELEASE:
if (duidcpy(&optinfo.serverID, &ev->serverid)) {
- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
+ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
goto end;
}
break;
@@ -1229,7 +1229,7 @@ client6_send(ev)
/* client ID */
if (duidcpy(&optinfo.clientID, &client_duid)) {
- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
+ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
goto end;
}
@@ -1274,7 +1274,7 @@ client6_send(ev)
/* option request options */
if (ev->state != DHCP6S_RELEASE &&
dhcp6_copy_list(&optinfo.reqopt_list, &ifp->reqopt_list)) {
- dprintf(LOG_ERR, FNAME, "failed to copy requested options");
+ debug_printf(LOG_ERR, FNAME, "failed to copy requested options");
goto end;
}
@@ -1285,7 +1285,7 @@ client6_send(ev)
case DHCP6_EVDATA_IAPD:
if (dhcp6_copy_list(&optinfo.iapd_list,
(struct dhcp6_list *)evd->data)) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed to add an IAPD");
goto end;
}
@@ -1293,13 +1293,13 @@ client6_send(ev)
case DHCP6_EVDATA_IANA:
if (dhcp6_copy_list(&optinfo.iana_list,
(struct dhcp6_list *)evd->data)) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed to add an IAPD");
goto end;
}
break;
default:
- dprintf(LOG_ERR, FNAME, "unexpected event data (%d)",
+ debug_printf(LOG_ERR, FNAME, "unexpected event data (%d)",
evd->type);
exit(1);
}
@@ -1307,7 +1307,7 @@ client6_send(ev)
/* authentication information */
if (set_auth(ev, &optinfo)) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"failed to set authentication option");
goto end;
}
@@ -1316,7 +1316,7 @@ client6_send(ev)
if ((optlen = dhcp6_set_options(dh6->dh6_msgtype,
(struct dhcp6opt *)(dh6 + 1),
(struct dhcp6opt *)(buf + sizeof(buf)), &optinfo)) < 0) {
- dprintf(LOG_INFO, FNAME, "failed to construct options");
+ debug_printf(LOG_INFO, FNAME, "failed to construct options");
goto end;
}
len += optlen;
@@ -1332,7 +1332,7 @@ client6_send(ev)
optinfo.authproto, optinfo.authalgorithm,
optinfo.delayedauth_offset + sizeof(*dh6),
ev->authparam->key)) {
- dprintf(LOG_WARNING, FNAME,
+ debug_printf(LOG_WARNING, FNAME,
"failed to calculate MAC");
goto end;
}
@@ -1354,12 +1354,12 @@ client6_send(ev)
if (sendto(sock, buf, len, 0, (struct sockaddr *)&dst,
sysdep_sa_len((struct sockaddr *)&dst)) == -1) {
- dprintf(LOG_ERR, FNAME,
+ debug_printf(LOG_ERR, FNAME,
"transmit failed: %s", strerror(errno));
goto end;
}
- dprintf(LOG_DEBUG, FNAME, "send %s to %s",
+ debug_printf(LOG_DEBUG, FNAME, "send %s to %s",
dhcp6msgstr(dh6->dh6_msgtype), addr2str((struct sockaddr *)&dst));
end:
@@ -1417,7 +1417,7 @@ client6_recv()
mhdr.msg_control = (caddr_t)cmsgbuf;
mhdr.msg_controllen = sizeof(cmsgbuf);
if ((len = recvmsg(sock, &mhdr, 0)) < 0) {
- dprintf(LOG_ERR, FNAME, "recvmsg: %s", strerror(errno));
+ debug_printf(LOG_ERR, FNAME, "recvmsg: %s", strerror(errno));
return;
}
@@ -1431,24 +1431,24 @@ client6_recv()
}
}
if (pi == NULL) {
- dprintf(LOG_NOTICE, FNAME, "failed to get packet info");
+ debug_printf(LOG_NOTICE, FNAME, "failed to get packet info");
return;
}
if ((ifp = find_ifconfbyid((unsigned int)pi->ipi6_ifindex)) == NULL) {
- dprintf(LOG_INFO, FNAME, "unexpected interface (%d)",
+ debug_printf(LOG_INFO, FNAME, "unexpected interface (%d)",
(unsigned int)pi->ipi6_ifindex);
return;
}
if (len < sizeof(*dh6)) {
- dprintf(LOG_INFO, FNAME, "short packet (%d bytes)", len);
+ debug_printf(LOG_INFO, FNAME, "short packet (%d bytes)", len);
return;
}
dh6 = (struct dhcp6 *)rbuf;
- dprintf(LOG_DEBUG, FNAME, "receive %s from %s on %s",
+ debug_printf(LOG_DEBUG, FNAME, "receive %s from %s on %s",
dhcp6msgstr(dh6->dh6_msgtype),
addr2str((struct sockaddr *)&from), ifp->ifname);
@@ -1457,7 +1457,7 @@ client6_recv()
p = (struct dhcp6opt *)(dh6 + 1);
ep = (struct dhcp6opt *)((char *)dh6 + len);
if (dhcp6_get_options(p, ep, &optinfo) < 0) {
- dprintf(LOG_INFO, FNAME, "failed to parse options");
+ debug_printf(LOG_INFO, FNAME, "failed to parse options");
return;
}
@@ -1469,7 +1469,7 @@ client6_recv()
(void)client6_recvreply(ifp, dh6, len, &optinfo);
break;
default:
- dprintf(LOG_INFO, FNAME, "received an unexpected message (%s) "
+ debug_printf(LOG_INFO, FNAME, "received an unexpected message (%s) "
"from %s", dhcp6msgstr(dh6->dh6_msgtype),
addr2str((struct sockaddr *)&from));
break;
@@ -1494,32 +1494,32 @@ client6_recvadvert(ifp, dh6, len, optinfo)
/* find the corresponding event based on the received xid */
ev = find_event_withid(ifp, ntohl(dh6->dh6_xid) & DH6_XIDMASK);
if (ev == NULL) {
- dprintf(LOG_INFO, FNAME, "XID mismatch");
+ debug_printf(LOG_INFO, FNAME, "XID mismatch");
return (-1);
}
/* packet validation based on Section 15.3 of RFC3315. */
if (optinfo->serverID.duid_len == 0) {
- dprintf(LOG_INFO, FNAME, "no server ID option");
+ debug_printf(LOG_INFO, FNAME, "no server ID option");
return (-1);
} else {
- dprintf(LOG_DEBUG, FNAME, "server ID: %s, pref=%d",
+ debug_printf(LOG_DEBUG, FNAME, "server ID: %s, pref=%d",
duidstr(&optinfo->serverID),
optinfo->pref);
}
if (optinfo->clientID.duid_len == 0) {
- dprintf(LOG_INFO, FNAME, "no client ID option");
+ debug_printf(LOG_INFO, FNAME, "no client ID option");
return (-1);
}
if (duidcmp(&optinfo->clientID, &client_duid)) {
- dprintf(LOG_INFO, FNAME, "client DUID mismatch");
+ debug_printf(LOG_INFO, FNAME, "client DUID mismatch");
return (-1);
}
/* validate authentication */
authparam0 = *ev->authparam;
if (process_auth(&authparam0, dh6, len, optinfo)) {
- dprintf(LOG_INFO, FNAME, "failed to process authentication");
+ debug_printf(LOG_INFO, FNAME, "failed to process authentication");
return (-1);
}
@@ -1552,7 +1552,7 @@ client6_recvadvert(ifp, dh6, len, optinfo)
}
if (dhcp6_find_listval(&optinfo->stcode_list,
DHCP6_LISTVAL_STCODE, &stcode, 0)) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"advertise contains %s status", stcodestr);
return (-1);
}
@@ -1567,20 +1567,20 @@ client6_recvadvert(ifp, dh6, len, optinfo)
* We process the message as if we expected the Advertise.
* [RFC3315 Section 17.1.4]
*/
- dprintf(LOG_INFO, FNAME, "unexpected advertise");
+ debug_printf(LOG_INFO, FNAME, "unexpected advertise");
/* proceed anyway */
}
/* ignore the server if it is known */
if (find_server(ev, &optinfo->serverID)) {
- dprintf(LOG_INFO, FNAME, "duplicated server (ID: %s)",
+ debug_printf(LOG_INFO, FNAME, "duplicated server (ID: %s)",
duidstr(&optinfo->serverID));
return (-1);
}
/* keep the server */
if ((newserver = malloc(sizeof(*newserver))) == NULL) {
- dprintf(LOG_WARNING, FNAME,
+ debug_printf(LOG_WARNING, FNAME,
"memory allocation failed for server");
return (-1);
}
@@ -1595,7 +1595,7 @@ client6_recvadvert(ifp, dh6, len, optinfo)
/* allocate new authentication parameter for the soliciting event */
if ((authparam = new_authparam(ev->authparam->authproto,
ev->authparam->authalgorithm, ev->authparam->authrdm)) == NULL) {
- dprintf(LOG_WARNING, FNAME, "memory allocation failed "
+ debug_printf(LOG_WARNING, FNAME, "memory allocation failed "
"for authentication parameters");
free(newserver);
return (-1);
@@ -1605,7 +1605,7 @@ client6_recvadvert(ifp, dh6, len, optinfo)
/* copy options */
dhcp6_init_options(&newserver->optinfo);
if (dhcp6_copy_options(&newserver->optinfo, optinfo)) {
- dprintf(LOG_ERR, FNAME, "failed to copy options");
+ debug_printf(LOG_ERR, FNAME, "failed to copy options");
if (newserver->authparam != NULL)
free(newserver->authparam);
free(newserver);
@@ -1633,11 +1633,11 @@ client6_recvadvert(ifp, dh6, len, optinfo)
ev->current_server = newserver;
if (duidcpy(&ev->serverid,
&ev->current_server->optinfo.serverID)) {
- dprintf(LOG_NOTICE, FNAME, "can't copy server ID");
+ debug_printf(LOG_NOTICE, FNAME, "can't copy server ID");
return (-1); /* XXX: better recovery? */
}
if (construct_reqdata(ifp, &ev->current_server->optinfo, ev)) {
- dprintf(LOG_NOTICE, FNAME,
+ debug_printf(LOG_NOTICE, FNAME,
"failed to construct request data");
return (-1); /* XXX */
}
@@ -1673,7 +1673,7 @@ client6_recvadvert(ifp, dh6, len, optinfo)
else
timo.tv_sec = timo.tv_usec = 0;
- dprintf(LOG_DEBUG, FNAME, "reset timer for %s to %d.%06d",
+ debug_printf(LOG_DEBUG, FNAME, "reset timer for %s to %d.%06d",
ifp->ifname, (int)timo.tv_sec, (int)timo.tv_usec);
dhcp6_set_timer(&timo, ev->timer);
@@ -1711,7 +1711,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
/* find the corresponding event based on the received xid */
ev = find_event_withid(ifp, ntohl(dh6->dh6_xid) & DH6_XIDMASK);
if (ev == NULL) {
- dprintf(LOG_INFO, FNAME, "XID mismatch");
+ debug_printf(LOG_INFO, FNAME, "XID mismatch");
return (-1);
}
@@ -1723,13 +1723,13 @@ client6_recvreply(ifp, dh6, len, optinfo)
state != DHCP6S_RELEASE &&
(state != DHCP6S_SOLICIT ||
!(ifp->send_flags & DHCIFF_RAPID_COMMIT))) {
- dprintf(LOG_INFO, FNAME, "unexpected reply");
+ debug_printf(LOG_INFO, FNAME, "unexpected reply");
return (-1);
}
/* A Reply message must contain a Server ID option */
if (optinfo->serverID.duid_len == 0) {
- dprintf(LOG_INFO, FNAME, "no server ID option");
+ debug_printf(LOG_INFO, FNAME, "no server ID option");
return (-1);
}
@@ -1738,17 +1738,17 @@ client6_recvreply(ifp, dh6, len, optinfo)
* client implementation) must match ours.
*/
if (optinfo->clientID.duid_len == 0) {
- dprintf(LOG_INFO, FNAME, "no client ID option");
+ debug_printf(LOG_INFO, FNAME, "no client ID option");
return (-1);
}
if (duidcmp(&optinfo->clientID, &client_duid)) {
- dprintf(LOG_INFO, FNAME, "client DUID mismatch");
+ debug_printf(LOG_INFO, FNAME, "client DUID mismatch");
return (-1);
}
/* validate authentication */
if (process_auth(ev->authparam, dh6, len, optinfo)) {
- dprintf(LOG_INFO, FNAME, "failed to process authentication");
+ debug_printf(LOG_INFO, FNAME, "failed to process authentication");
return (-1);
}
@@ -1762,7 +1762,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
if (state == DHCP6S_SOLICIT &&
(ifp->send_flags & DHCIFF_RAPID_COMMIT) &&
!optinfo->rapidcommit) {
- dprintf(LOG_INFO, FNAME, "no rapid commit");
+ debug_printf(LOG_INFO, FNAME, "no rapid commit");
return (-1);
}
@@ -1773,7 +1773,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
*/
for (lv = TAILQ_FIRST(&optinfo->stcode_list); lv;
lv = TAILQ_NEXT(lv, link)) {
- dprintf(LOG_INFO, FNAME, "status code: %s",
+ debug_printf(LOG_INFO, FNAME, "status code: %s",
dhcp6_stcodestr(lv->val_num16));
}
@@ -1837,7 +1837,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
* configuration parameters.
*/
if (ifp->scriptpath != NULL && strlen(ifp->scriptpath) != 0) {
- dprintf(LOG_DEBUG, FNAME, "executes %s", ifp->scriptpath);
+ debug_printf(LOG_DEBUG, FNAME, "executes %s", ifp->scriptpath);
client6_script(ifp->scriptpath, state, optinfo);
}
@@ -1855,7 +1855,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
ifp->timer = dhcp6_add_timer(client6_expire_refreshtime, ifp);
if (ifp->timer == NULL) {
- dprintf(LOG_WARNING, FNAME,
+ debug_printf(LOG_WARNING, FNAME,
"failed to add timer for refresh time");
} else {
struct timeval tv;
@@ -1868,7 +1868,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
* XXX: tv_sec can overflow for an
* unsigned 32bit value.
*/
- dprintf(LOG_WARNING, FNAME,
+ debug_printf(LOG_WARNING, FNAME,
"refresh time is too large: %lu",
(u_int32_t)refreshtime);
tv.tv_sec = 0x7fffffff; /* XXX */
@@ -1881,7 +1881,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
* draft-ietf-dhc-lifetime-02 clarifies that refresh time
* is only used for information-request and reply exchanges.
*/
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"unexpected information refresh time option (ignored)");
}
@@ -1906,7 +1906,7 @@ client6_recvreply(ifp, dh6, len, optinfo)
check_exit();
}
- dprintf(LOG_DEBUG, FNAME, "got an expected reply, sleeping.");
+ debug_printf(LOG_DEBUG, FNAME, "got an expected reply, sleeping.");
if (infreq_mode) {
exit_ok = 1;
@@ -1949,19 +1949,19 @@ process_auth(authparam, dh6, len, optinfo)
break;
case DHCP6_AUTHPROTO_DELAYED:
if ((optinfo->authflags & DHCP6OPT_AUTHFLAG_NOINFO)) {
- dprintf(LOG_INFO, FNAME, "server did not include "
+ debug_printf(LOG_INFO, FNAME, "server did not include "
"authentication information");
break;
}
if (optinfo->authalgorithm != DHCP6_AUTHALG_HMACMD5) {
- dprintf(LOG_INFO, FNAME, "unknown authentication "
+ debug_printf(LOG_INFO, FNAME, "unknown authentication "
"algorithm (%d)", optinfo->authalgorithm);
break;
}
if (optinfo->authrdm != DHCP6_AUTHRDM_MONOCOUNTER) {
- dprintf(LOG_INFO, FNAME,"unknown RDM (%d)",
+ debug_printf(LOG_INFO, FNAME,"unknown RDM (%d)",
optinfo->authrdm);
break;
}
@@ -1971,12 +1971,12 @@ process_auth(authparam, dh6, len, optinfo)
* we accept the message anyway (XXX).
*/
if ((authparam->flags & AUTHPARAM_FLAGS_NOPREVRD)) {
- dprintf(LOG_WARNING, FNAME, "previous RD value is "
+ debug_printf(LOG_WARNING, FNAME, "previous RD value is "
"unknown (accept it)");
} else {
if (dhcp6_auth_replaycheck(optinfo->authrdm,
authparam->prevrd, optinfo->authrd)) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"possible replay attack detected");
break;
}
@@ -1993,7 +1993,7 @@ process_auth(authparam, dh6, len, optinfo)
optinfo->delayedauth_realmlen != key->realmlen ||
memcmp(optinfo->delayedauth_realmval, key->realm,
key->realmlen) != 0) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"authentication key mismatch");
break;
}
@@ -2002,12 +2002,12 @@ process_auth(authparam, dh6, len, optinfo)
optinfo->delayedauth_realmlen,
optinfo->delayedauth_keyid);
if (key == NULL) {
- dprintf(LOG_INFO, FNAME, "failed to find key "
+ debug_printf(LOG_INFO, FNAME, "failed to find key "
"provided by the server (ID: %x)",
optinfo->delayedauth_keyid);
break;
} else {
- dprintf(LOG_DEBUG, FNAME, "found key for "
+ debug_printf(LOG_DEBUG, FNAME, "found key for "
"authentication: %s", key->name);
}
authparam->key = key;
@@ -2015,7 +2015,7 @@ process_auth(authparam, dh6, len, optinfo)
/* check for the key lifetime */
if (dhcp6_validate_key(key)) {
- dprintf(LOG_INFO, FNAME, "key %s has expired",
+ debug_printf(LOG_INFO, FNAME, "key %s has expired",
key->name);
break;
}
@@ -2024,24 +2024,24 @@ process_auth(authparam, dh6, len, optinfo)
if (dhcp6_verify_mac((char *)dh6, len, optinfo->authproto,
optinfo->authalgorithm,
optinfo->delayedauth_offset + sizeof(*dh6), key) == 0) {
- dprintf(LOG_DEBUG, FNAME, "message authentication "
+ debug_printf(LOG_DEBUG, FNAME, "message authentication "
"validated");
authenticated = 1;
} else {
- dprintf(LOG_INFO, FNAME, "invalid message "
+ debug_printf(LOG_INFO, FNAME, "invalid message "
"authentication");
}
break;
default:
- dprintf(LOG_INFO, FNAME, "server sent unsupported "
+ debug_printf(LOG_INFO, FNAME, "server sent unsupported "
"authentication protocol (%d)", optinfo->authproto);
break;
}
if (authenticated == 0) {
if (authparam->authproto != DHCP6_AUTHPROTO_UNDEF) {
- dprintf(LOG_INFO, FNAME, "message not authenticated "
+ debug_printf(LOG_INFO, FNAME, "message not authenticated "
"while authentication required");
/*
@@ -2084,7 +2084,7 @@ set_auth(ev, optinfo)
* exchanges doesn't work. Specification is also
* unclear on this usage.
*/
- dprintf(LOG_WARNING, FNAME, "delayed authentication "
+ debug_printf(LOG_WARNING, FNAME, "delayed authentication "
"cannot be used for Information-request yet");
return (-1);
}
@@ -2095,21 +2095,21 @@ set_auth(ev, optinfo)
}
if (authparam->key == NULL) {
- dprintf(LOG_INFO, FNAME,
+ debug_printf(LOG_INFO, FNAME,
"no authentication key for %s",
dhcp6_event_statestr(ev));
return (-1);
}
if (dhcp6_validate_key(authparam->key)) {
- dprintf(LOG_INFO, FNAME, "key %s is invalid",
+ debug_printf(LOG_INFO, FNAME, "key %s is invalid",
authparam->key->name);
return (-1);
}
if (get_rdvalue(optinfo->authrdm, &optinfo->authrd,
sizeof(optinfo->authrd))) {
- dprintf(LOG_ERR, FNAME, "failed to get a replay "
+ debug_printf(LOG_ERR, FNAME, "failed to get a replay "
"detection value");
return (-1);
}
@@ -2119,7 +2119,7 @@ set_auth(ev, optinfo)
optinfo->delayedauth_realmval =
malloc(optinfo->delayedauth_realmlen);
if (optinfo->delayedauth_realmval == NULL) {
- dprintf(LOG_ERR, FNAME, "failed to allocate memory "
+ debug_printf(LOG_ERR, FNAME, "failed to allocate memory "
"for authentication realm");
return (-1);
}
@@ -2128,7 +2128,7 @@ set_auth(ev, optinfo)
break;
default:
- dprintf(LOG_ERR, FNAME, "unsupported authentication protocol "
+ debug_printf(LOG_ERR, FNAME, "unsupported authentication protocol "
"%d", authparam->authproto);
return (-1);
}
@@ -2145,7 +2145,7 @@ info_printf(const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(logbuf, sizeof(logbuf), fmt, ap);
- dprintf(LOG_DEBUG, FNAME, "%s", logbuf);
+ debug_printf(LOG_DEBUG, FNAME, "%s", logbuf);
if (infreq_mode)
printf("%s\n", logbuf);