dlclose(h);
return -1;
}
- loginfo("dev: loaded %s", ctx->dev->name);
+ loginfox("dev: loaded %s", ctx->dev->name);
ctx->dev_handle = h;
return r;
}
ifo->reboot, ipv4ll_start, ifp);
#endif
if (ifo->options & DHCPCD_REQUEST)
- loginfo("%s: soliciting a DHCP lease (requesting %s)",
+ loginfox("%s: soliciting a DHCP lease (requesting %s)",
ifp->name, inet_ntoa(ifo->req_addr));
else
- loginfo("%s: soliciting a %s lease",
+ loginfox("%s: soliciting a %s lease",
ifp->name, ifo->options & DHCPCD_BOOTP ? "BOOTP" : "DHCP");
send_discover(ifp);
}
}
get_lease(ifp, lease, state->new, state->new_len);
if (ifo->options & DHCPCD_STATIC) {
- loginfo("%s: using static address %s/%d",
+ loginfox("%s: using static address %s/%d",
ifp->name, inet_ntoa(lease->addr),
inet_ntocidr(lease->mask));
lease->leasetime = ~0U;
state->reason = "STATIC";
} else if (ifo->options & DHCPCD_INFORM) {
- loginfo("%s: received approval for %s",
+ loginfox("%s: received approval for %s",
ifp->name, inet_ntoa(lease->addr));
lease->leasetime = ~0U;
state->reason = "INFORM";
lease->renewaltime =
lease->rebindtime =
lease->leasetime;
- loginfo("%s: leased %s for infinity",
+ loginfox("%s: leased %s for infinity",
ifp->name, inet_ntoa(lease->addr));
} else {
if (lease->leasetime < DHCP_MIN_LEASE) {
ifp->name, inet_ntoa(lease->addr),
lease->leasetime);
else
- loginfo("%s: leased %s for %"PRIu32" seconds",
+ loginfox("%s: leased %s for %"PRIu32" seconds",
ifp->name, inet_ntoa(lease->addr),
lease->leasetime);
}
struct interface *ifp = arg;
struct dhcp_state *state = D_STATE(ifp);
- loginfo("%s: timed out contacting a DHCP server, using last lease",
+ loginfox("%s: timed out contacting a DHCP server, using last lease",
ifp->name);
dhcp_bind(ifp);
/* If we forked, stop here. */
/* Add the address now, let the kernel handle DAD. */
ipv4_addaddr(ifp, &l.addr, &l.mask, &l.brd);
} else
- loginfo("%s: waiting for DAD on %s",
+ loginfox("%s: waiting for DAD on %s",
ifp->name, inet_ntoa(addr));
return 0;
}
struct dhcp_lease l;
get_lease(ifp, &l, state->offer, state->offer_len);
- loginfo("%s: probing address %s/%d",
+ loginfox("%s: probing address %s/%d",
ifp->name, inet_ntoa(l.addr), inet_ntocidr(l.mask));
/* We need to handle DAD. */
arp_probe(astate);
if (ifo->req_addr.s_addr == INADDR_ANY &&
(ia = ipv4_iffindaddr(ifp, NULL, NULL)) == NULL)
{
- loginfo("%s: waiting for 3rd party to "
+ loginfox("%s: waiting for 3rd party to "
"configure IP address", ifp->name);
state->reason = "3RDPARTY";
script_runreason(ifp, state->reason);
if (ifo->req_addr.s_addr == INADDR_ANY) {
ia = ipv4_iffindaddr(ifp, NULL, NULL);
if (ia == NULL) {
- loginfo("%s: waiting for 3rd party to "
+ loginfox("%s: waiting for 3rd party to "
"configure IP address",
ifp->name);
if (!(ifp->ctx->options & DHCPCD_TEST)) {
state->interval = 0;
if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
- loginfo("%s: waiting for carrier", ifp->name);
+ loginfox("%s: waiting for carrier", ifp->name);
return;
}
if (ifo->options & DHCPCD_STATIC) {
return;
}
if (ifo->options & DHCPCD_INFORM) {
- loginfo("%s: informing address of %s",
+ loginfox("%s: informing address of %s",
ifp->name, inet_ntoa(state->lease.addr));
dhcp_inform(ifp);
return;
if (!IS_DHCP(state->offer))
return;
- loginfo("%s: rebinding lease of %s",
+ loginfox("%s: rebinding lease of %s",
ifp->name, inet_ntoa(state->lease.addr));
dhcp_new_xid(ifp);
state->lease.server.s_addr = 0;
state->new != NULL &&
state->lease.server.s_addr != INADDR_ANY)
{
- loginfo("%s: releasing lease of %s",
+ loginfox("%s: releasing lease of %s",
ifp->name, inet_ntoa(state->lease.addr));
dhcp_new_xid(ifp);
send_message(ifp, DHCP_RELEASE, NULL);
logdebugx("%s: validated using 0x%08" PRIu32,
ifp->name, state->auth.token->secretid);
else
- loginfo("%s: accepted reconfigure key", ifp->name);
+ loginfox("%s: accepted reconfigure key", ifp->name);
} else if (ifo->auth.options & DHCPCD_AUTH_SEND) {
if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
LOGDHCP0(logerrx, "no authentication");
LOGDHCP(logdebugx, "not bound, ignoring Force Renew");
return;
}
- LOGDHCP(loginfo, "Force Renew from");
+ LOGDHCP(loginfox, "Force Renew from");
/* The rebind and expire timings are still the same, we just
* enter the renew state early */
if (state->state == DHS_BOUND)
goto rapidcommit;
}
- LOGDHCP(loginfo, "offered");
+ LOGDHCP(loginfox, "offered");
if (state->offer_len < bootp_len) {
free(state->offer);
if ((state->offer = malloc(bootp_len)) == NULL) {
if (cmd == RTM_DELADDR) {
if (state->addr == ia) {
- loginfo("%s: deleted IP address %s",
+ loginfox("%s: deleted IP address %s",
ifp->name, ia->saddr);
state->addr = NULL;
/* Don't clear the added state as we need
#ifndef SMALL
dhcp6_delete_delegates(ifp);
#endif
- loginfo("%s: soliciting a DHCPv6 lease", ifp->name);
+ loginfox("%s: soliciting a DHCPv6 lease", ifp->name);
state = D6_STATE(ifp);
state->state = DH6S_DISCOVER;
state->RTC = 0;
if (state->state == DH6S_RENEW)
logwarnx("%s: failed to renew DHCPv6, rebinding", ifp->name);
else
- loginfo("%s: rebinding prior DHCPv6 lease", ifp->name);
+ loginfox("%s: rebinding prior DHCPv6 lease", ifp->name);
state->state = DH6S_REBIND;
state->RTC = 0;
state->MRC = 0;
state->MRT = CNF_MAX_RT;
state->MRC = 0;
- loginfo("%s: confirming prior DHCPv6 lease", ifp->name);
+ loginfox("%s: confirming prior DHCPv6 lease", ifp->name);
if (dhcp6_makemessage(ifp) == -1) {
logerr("%s: %s", __func__, ifp->name);
return;
ifp = arg;
state = D6_STATE(ifp);
if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG)
- loginfo("%s: requesting DHCPv6 information", ifp->name);
+ loginfox("%s: requesting DHCPv6 information", ifp->name);
state->state = DH6S_INFORM;
state->RTC = 0;
state->IMD = INF_MAX_DELAY;
logdebugx("%s: validated using 0x%08" PRIu32,
ifp->name, state->auth.token->secretid);
else
- loginfo("%s: accepted reconfigure key", ifp->name);
+ loginfox("%s: accepted reconfigure key", ifp->name);
} else if ((ifp->options->auth.options & DHCPCD_AUTH_SENDREQUIRE) ==
DHCPCD_AUTH_SENDREQUIRE)
{
logfunc_t *logfunc;
if (ap->flags & IPV6_AF_NEW)
- logfunc = loginfo;
+ logfunc = loginfox;
else
logfunc = logdebugx;
/* We only want to log this the once as we loop
}
if (k) {
- loginfo("%s: adding delegated prefixes", ifp->name);
+ loginfox("%s: adding delegated prefixes", ifp->name);
state = D6_STATE(ifp);
state->state = DH6S_DELEGATED;
ipv6_addaddrs(&state->addrs);
logdebugx("%s: validated using 0x%08" PRIu32,
ifp->name, state->auth.token->secretid);
else
- loginfo("%s: accepted reconfigure key", ifp->name);
+ loginfox("%s: accepted reconfigure key", ifp->name);
} else if (ifo->auth.options & DHCPCD_AUTH_SEND) {
if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
logerr("%s: no authentication from %s",
return;
#ifdef AUTH
}
- loginfo("%s: %s from %s", ifp->name, op, ctx->sfrom);
+ loginfox("%s: %s from %s", ifp->name, op, ctx->sfrom);
o = dhcp6_findmoption(r, len, D6_OPTION_RECONF_MSG, &ol);
if (o == NULL) {
logerrx("%s: missing Reconfigure Message option",
}
if (ap == NULL)
ap = TAILQ_FIRST(&state->addrs);
- loginfo("%s: ADV %s from %s", ifp->name, ap->saddr, ctx->sfrom);
+ loginfox("%s: ADV %s from %s", ifp->name, ap->saddr, ctx->sfrom);
if (ifp->ctx->options & DHCPCD_TEST)
break;
dhcp6_startrequest(ifp);
break;
}
}
- lognewinfo = has_new ? loginfo : logdebugx;
+ lognewinfo = has_new ? loginfox : logdebugx;
lognewinfo("%s: %s received from %s", ifp->name, op, ctx->sfrom);
state->reason = NULL;
continue;
}
if (!ifd->active) {
- loginfo("%s: activating for delegation",
+ loginfox("%s: activating for delegation",
sla->ifname);
dhcpcd_activateinterface(ifd,
DHCPCD_IPV6 | DHCPCD_DHCP6);
}
if (ctx->options & DHCPCD_ONESHOT) {
- loginfo("exiting due to oneshot");
+ loginfox("exiting due to oneshot");
eloop_exit(ctx->eloop, EXIT_SUCCESS);
return 0;
}
if (read(sidpipe[0], &buf, 1) == -1)
logerr("%s: read", __func__);
close(sidpipe[0]);
- loginfo("forked to background, child pid %d", pid);
+ loginfox("forked to background, child pid %d", pid);
ctx->options |= DHCPCD_FORKED;
eloop_exit(ctx->eloop, EXIT_SUCCESS);
return pid;
struct dhcpcd_ctx *ctx;
ctx = ifp->ctx;
- loginfo("%s: removing interface", ifp->name);
+ loginfox("%s: removing interface", ifp->name);
ifp->options->options |= DHCPCD_STOPPING;
dhcpcd_drop(ifp, 1);
}
if (profile != NULL) {
strlcpy(ifp->profile, profile, sizeof(ifp->profile));
- loginfo("%s: selected profile %s", ifp->name, profile);
+ loginfox("%s: selected profile %s", ifp->name, profile);
} else
*ifp->profile = '\0';
} else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
if (ifp->carrier != LINK_DOWN) {
if (ifp->carrier == LINK_UP)
- loginfo("%s: carrier lost", ifp->name);
+ loginfox("%s: carrier lost", ifp->name);
ifp->carrier = LINK_DOWN;
script_runreason(ifp, "NOCARRIER");
#ifdef NOCARRIER_PRESERVE_IP
}
} else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
if (ifp->carrier != LINK_UP) {
- loginfo("%s: carrier acquired", ifp->name);
+ loginfox("%s: carrier acquired", ifp->name);
ifp->carrier = LINK_UP;
#if !defined(__linux__) && !defined(__NetBSD__)
/* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
case LINK_UP:
break;
case LINK_DOWN:
- loginfo("%s: waiting for carrier", ifp->name);
+ loginfox("%s: waiting for carrier", ifp->name);
return;
case LINK_UNKNOWN:
/* No media state available.
if (ifp->ctx->duid == NULL) {
if (duid_init(ifp) == 0)
return;
- loginfo("DUID %s",
+ loginfox("DUID %s",
hwaddr_ntoa(ifp->ctx->duid,
ifp->ctx->duid_len,
buf, sizeof(buf)));
if (ifo->options & (DHCPCD_DUID | DHCPCD_IPV6)) {
/* Report IAIDs */
- loginfo("%s: IAID %s", ifp->name,
+ loginfox("%s: IAID %s", ifp->name,
hwaddr_ntoa(ifo->iaid, sizeof(ifo->iaid),
buf, sizeof(buf)));
warn_iaid_conflict(ifp, ifo->iaid);
if (memcmp(ifo->iaid, ifo->ia[i].iaid,
sizeof(ifo->iaid)))
{
- loginfo("%s: IAID %s",
+ loginfox("%s: IAID %s",
ifp->name, hwaddr_ntoa(ifo->ia[i].iaid,
sizeof(ifo->ia[i].iaid),
buf, sizeof(buf)));
ifp->flags, ifp->name);
return;
}
- loginfo("%s: unknown carrier, waiting for interface flags",
+ loginfox("%s: unknown carrier, waiting for interface flags",
ifp->name);
}
if (ifp->hwlen == hwlen && memcmp(ifp->hwaddr, hwaddr, hwlen) == 0)
return;
- loginfo("%s: new hardware address: %s", ifp->name,
+ loginfox("%s: new hardware address: %s", ifp->name,
hwaddr_ntoa(hwaddr, hwlen, buf, sizeof(buf)));
ifp->hwlen = hwlen;
memcpy(ifp->hwaddr, hwaddr, hwlen);
exit_code = EXIT_FAILURE;
switch (sig) {
case SIGINT:
- loginfo(sigmsg, "SIGINT", "stopping");
+ loginfox(sigmsg, "SIGINT", "stopping");
break;
case SIGTERM:
- loginfo(sigmsg, "SIGTERM", "stopping");
+ loginfox(sigmsg, "SIGTERM", "stopping");
exit_code = EXIT_SUCCESS;
break;
case SIGALRM:
- loginfo(sigmsg, "SIGALRM", "releasing");
+ loginfox(sigmsg, "SIGALRM", "releasing");
opts |= DHCPCD_RELEASE;
exit_code = EXIT_SUCCESS;
break;
case SIGHUP:
- loginfo(sigmsg, "SIGHUP", "rebinding");
+ loginfox(sigmsg, "SIGHUP", "rebinding");
reload_config(ctx);
/* Preserve any options passed on the commandline
* when we were started. */
ctx->argc - ctx->ifc);
return;
case SIGUSR1:
- loginfo(sigmsg, "SIGUSR1", "renewing");
+ loginfox(sigmsg, "SIGUSR1", "renewing");
dhcpcd_renew(ctx);
return;
case SIGUSR2:
- loginfo(sigmsg, "SIGUSR2", "reopening log");
+ loginfox(sigmsg, "SIGUSR2", "reopening log");
logclose();
if (logopen(ctx->logfile) == -1)
logerr(__func__);
*p++ = ' ';
}
*--p = '\0';
- loginfo("control command: %s", tmp);
+ loginfox("control command: %s", tmp);
free(tmp);
optind = 0;
if (ctx.control_fd == -1)
ctx.control_fd = control_open(NULL);
if (ctx.control_fd != -1) {
- loginfo("sending commands to master dhcpcd process");
+ loginfox("sending commands to master dhcpcd process");
len = control_send(&ctx, argc, argv);
control_close(&ctx);
if (len > 0) {
if (sig != 0) {
pid = pidfile_read(ctx.pidfile);
if (pid != 0 && pid != -1)
- loginfo("sending signal %s to pid %d", siga, pid);
+ loginfox("sending signal %s to pid %d", siga, pid);
if (pid == 0 || pid == -1 || kill(pid, sig) != 0) {
if (sig != SIGHUP && sig != SIGUSR1 && errno != EPERM)
logerrx(PACKAGE" not running");
if (sig == SIGHUP || sig == SIGUSR1)
goto exit_success;
/* Spin until it exits */
- loginfo("waiting for pid %d to exit", pid);
+ loginfox("waiting for pid %d to exit", pid);
ts.tv_sec = 0;
ts.tv_nsec = 100000000; /* 10th of a second */
for(i = 0; i < 100; i++) {
free(ctx.iov[0].iov_base);
if (ctx.options & DHCPCD_STARTED && !(ctx.options & DHCPCD_FORKED))
- loginfo(PACKAGE " exited");
+ loginfox(PACKAGE " exited");
logclose();
#ifdef USE_SIGNALS
if (ctx.options & DHCPCD_FORKED)
nstate->addr->addr.s_addr == lease->addr.s_addr)
{
if (r == 0) {
- loginfo("%s: preferring %s on %s",
+ loginfox("%s: preferring %s on %s",
ifp->name,
inet_ntoa(lease->addr),
ifn->name);
return;
}
- loginfo("%s: preferring %s on %s",
+ loginfox("%s: preferring %s on %s",
ifn->name,
inet_ntoa(lease->addr),
ifp->name);
#ifdef IN_IFF_NOTREADY
if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY)
#endif
- loginfo("%s: using IPv4LL address %s",
+ loginfox("%s: using IPv4LL address %s",
ifp->name, inet_ntoa(astate->addr));
if (ia == NULL) {
if (ifp->ctx->options & DHCPCD_TEST)
astate->addr = ia->addr;
#ifdef IN_IFF_TENTATIVE
if (ia->addr_flags & (IN_IFF_TENTATIVE | IN_IFF_DETACHED)) {
- loginfo("%s: waiting for DAD to complete on %s",
+ loginfox("%s: waiting for DAD to complete on %s",
ifp->name, inet_ntoa(ia->addr));
return;
}
- loginfo("%s: using IPv4LL address %s", ifp->name, ia->saddr);
+ loginfox("%s: using IPv4LL address %s", ifp->name, ia->saddr);
#endif
ipv4ll_probed(astate);
return;
}
- loginfo("%s: probing for an IPv4LL address", ifp->name);
+ loginfox("%s: probing for an IPv4LL address", ifp->name);
astate->addr.s_addr = ipv4ll_pickaddr(astate);
#ifdef IN_IFF_TENTATIVE
ipv4ll_probed(astate);
struct ipv6_state *state;
struct ipv6_addr *ap;
- loginfo("%s: deleting address %s", ia->iface->name, ia->saddr);
+ loginfox("%s: deleting address %s", ia->iface->name, ia->saddr);
if (if_address6(RTM_DELADDR, ia) == -1 &&
errno != EADDRNOTAVAIL && errno != ESRCH &&
errno != ENXIO && errno != ENODEV)
ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_NOTUSEABLE))
ap->flags |= IPV6_AF_DADCOMPLETED;
- logfunc = ap->flags & IPV6_AF_NEW ? loginfo : logdebugx;
+ logfunc = ap->flags & IPV6_AF_NEW ? loginfox : logdebugx;
logfunc("%s: adding %saddress %s", ap->iface->name,
#ifdef IPV6_AF_TEMPORARY
ap->flags & IPV6_AF_TEMPORARY ? "temporary " : "",
&ap->addr, IPV6_AF_ADDED);
if (apf && apf->iface != ap->iface) {
if (apf->iface->metric <= ap->iface->metric) {
- loginfo("%s: preferring %s on %s",
+ loginfox("%s: preferring %s on %s",
ap->iface->name,
ap->saddr,
apf->iface->name);
continue;
}
- loginfo("%s: preferring %s on %s",
+ loginfox("%s: preferring %s on %s",
apf->iface->name,
ap->saddr,
ap->iface->name);
dbp = inet_ntop(AF_INET6, &addr->s6_addr,
dbuf, INET6_ADDRSTRLEN);
- loginfo("%s: cmd %d addr %s",
+ loginfox("%s: cmd %d addr %s",
ifname, cmd, dbp);
#endif
switch (cmd) {
case RTM_DELADDR:
if (ia->flags & IPV6_AF_ADDED) {
- loginfo("%s: deleted address %s",
+ logwarnx("%s: deleted address %s",
ia->iface->name, ia->saddr);
ia->flags &= ~IPV6_AF_ADDED;
}
if (flags & IPV6ND_REACHABLE) {
if (rap->lifetime && rap->expired) {
- loginfo("%s: %s is reachable again",
+ loginfox("%s: %s is reachable again",
rap->iface->name, rap->sfrom);
rap->expired = 0;
rt_build(rap->iface->ctx, AF_INET6);
ifp->name);
goto try_script;
}
- loginfo("%s: deleting address %s",
+ loginfox("%s: deleting address %s",
ifp->name, ap->saddr);
if (if_address6(RTM_DELADDR, ap) == -1 &&
errno != EADDRNOTAVAIL && errno != ENXIO)
* routers like to decrease the advertised valid and preferred times
* in accordance with the own prefix times which would result in too
* much needless log spam. */
- logfunc = new_rap ? loginfo : logdebugx,
+ logfunc = new_rap ? loginfox : logdebugx,
logfunc("%s: Router Advertisement from %s",
ifp->name, ctx->sfrom);
/* Node is no longer a router, so remove it from consideration */
if (!is_router && !rap->expired) {
- loginfo("%s: %s not a router (%s)",
+ loginfox("%s: %s not a router (%s)",
ifp->name, taddr, ctx->sfrom);
rap->expired = 1;
rt_build(ifp->ctx, AF_INET6);
if (is_solicited && is_router && rap->lifetime) {
if (rap->expired) {
rap->expired = 0;
- loginfo("%s: %s reachable (%s)",
+ loginfox("%s: %s reachable (%s)",
ifp->name, taddr, ctx->sfrom);
rt_build(ifp->ctx, AF_INET6);
script_runreason(rap->iface, "ROUTERADVERT"); /* XXX */
struct interface *ifp = arg;
struct rs_state *state;
- loginfo("%s: soliciting an IPv6 router", ifp->name);
+ loginfox("%s: soliciting an IPv6 router", ifp->name);
if (ipv6nd_open(ifp->ctx) == -1) {
logerr(__func__);
return;
{
va_list args;
+ va_start(args, fmt);
+ vlogerrmessage(LOG_INFO, fmt, args);
+ va_end(args);
+}
+
+void
+loginfox(const char *fmt, ...)
+{
+ va_list args;
+
va_start(args, fmt);
vlogmessage(LOG_INFO, fmt, args);
va_end(args);
__printflike(1, 2) void logdebug(const char *, ...);
__printflike(1, 2) void logdebugx(const char *, ...);
__printflike(1, 2) void loginfo(const char *, ...);
+__printflike(1, 2) void loginfox(const char *, ...);
__printflike(1, 2) void logwarn(const char *, ...);
__printflike(1, 2) void logwarnx(const char *, ...);
__printflike(1, 2) void logerr(const char *, ...);
if (rt->rt_flags & RTF_HOST) {
if (gateway_unspec)
- loginfo("%s: %s host route to %s",
+ loginfox("%s: %s host route to %s",
ifname, cmd, dest);
else
- loginfo("%s: %s host route to %s via %s",
+ loginfox("%s: %s host route to %s via %s",
ifname, cmd, dest, gateway);
} else if (sa_is_unspecified(&rt->rt_dest) &&
sa_is_unspecified(&rt->rt_netmask))
{
if (gateway_unspec)
- loginfo("%s: %s default route",
+ loginfox("%s: %s default route",
ifname, cmd);
else
- loginfo("%s: %s default route via %s",
+ loginfox("%s: %s default route via %s",
ifname, cmd, gateway);
} else if (gateway_unspec)
- loginfo("%s: %s%s route to %s/%d",
+ loginfox("%s: %s%s route to %s/%d",
ifname, cmd,
rt->rt_flags & RTF_REJECT ? " reject" : "",
dest, prefix);
else
- loginfo("%s: %s%s route to %s/%d via %s",
+ loginfox("%s: %s%s route to %s/%d via %s",
ifname, cmd,
rt->rt_flags & RTF_REJECT ? " reject" : "",
dest, prefix, gateway);