+static void dhcpv6_log(uint8_t msgtype, struct interface *iface, time_t now,
+ const char *duidbuf, bool is_pd, struct dhcpv6_assignment *a, int code)
+{
+ const char *type = "UNKNOWN";
+ const char *status = "UNKNOWN";
+
+ if (msgtype == DHCPV6_MSG_RENEW)
+ return;
+
+ switch (msgtype) {
+ case DHCPV6_MSG_SOLICIT:
+ type = "SOLICIT";
+ break;
+ case DHCPV6_MSG_REQUEST:
+ type = "REQUEST";
+ break;
+ case DHCPV6_MSG_CONFIRM:
+ type = "CONFIRM";
+ break;
+ case DHCPV6_MSG_RENEW:
+ type = "RENEW";
+ break;
+ case DHCPV6_MSG_REBIND:
+ type = "REBIND";
+ break;
+ case DHCPV6_MSG_RELEASE:
+ type = "RELEASE";
+ break;
+ case DHCPV6_MSG_DECLINE:
+ type = "DECLINE";
+ break;
+ }
+
+ switch (code) {
+ case DHCPV6_STATUS_OK:
+ status = "ok";
+ break;
+ case DHCPV6_STATUS_NOADDRSAVAIL:
+ status = "no addresses available";
+ break;
+ case DHCPV6_STATUS_NOBINDING:
+ status = "no binding";
+ break;
+ case DHCPV6_STATUS_NOTONLINK:
+ status = "not on-link";
+ break;
+ case DHCPV6_STATUS_NOPREFIXAVAIL:
+ status = "no prefix available";
+ break;
+ }
+
+ char leasebuf[256] = "";
+
+ if (a) {
+ struct odhcpd_ipaddr *addrs = (a->managed) ? a->managed : iface->ia_addr;
+ size_t addrlen = (a->managed) ? (size_t)a->managed_size : iface->ia_addr_len;
+ size_t lbsize = 0;
+ char addrbuf[INET6_ADDRSTRLEN];
+
+ for (size_t i = 0; i < addrlen; ++i) {
+ if (addrs[i].prefix > 96 || addrs[i].preferred <= (uint32_t)now)
+ continue;
+
+ struct in6_addr addr = addrs[i].addr;
+ int prefix = a->managed ? addrs[i].prefix : a->length;
+ if (prefix == 128)
+ addr.s6_addr32[3] = htonl(a->assigned);
+ else
+ addr.s6_addr32[1] |= htonl(a->assigned);
+
+ inet_ntop(AF_INET6, &addr, addrbuf, sizeof(addrbuf));
+ lbsize += snprintf(leasebuf + lbsize, sizeof(leasebuf) - lbsize, "%s/%d ", addrbuf, prefix);
+ }
+ }
+
+ syslog(LOG_WARNING, "DHCPV6 %s %s from %s on %s: %s %s", type, (is_pd) ? "IA_PD" : "IA_NA",
+ duidbuf, iface->ifname, status, leasebuf);
+}
+
+
+