summaryrefslogtreecommitdiffstats
path: root/debian/patches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:43:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:43:03 +0000
commitf504d0d8a469f3f913a853e97020112fcf262c1b (patch)
tree25a4b573f8fc510c99d931a382598bee699a215c /debian/patches
parentAdding upstream version 20080615. (diff)
downloadwide-dhcpv6-f504d0d8a469f3f913a853e97020112fcf262c1b.tar.xz
wide-dhcpv6-f504d0d8a469f3f913a853e97020112fcf262c1b.zip
Adding debian version 20080615-23.debian/20080615-23debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/0001-Fix-manpages.patch164
-rw-r--r--debian/patches/0002-Don-t-strip-binaries.patch24
-rw-r--r--debian/patches/0003-Close-inherited-file-descriptors.patch76
-rw-r--r--debian/patches/0004-GNU-libc6-fixes.patch6706
-rw-r--r--debian/patches/0005-Update-ifid-on-interface-restart.patch33
-rw-r--r--debian/patches/0006-Add-new-feature-dhcp6c-profiles.patch626
-rw-r--r--debian/patches/0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch146
-rw-r--r--debian/patches/0008-Close-file-descriptors-on-exec.patch219
-rw-r--r--debian/patches/0009-Fix-renewal-of-IA-NA.patch23
-rw-r--r--debian/patches/0010-Call-client-script-after-interfaces-have-been-update.patch47
-rw-r--r--debian/patches/0011-resolv-warnings-so-as-to-make-blhc-and-gcc-both-happ.patch137
-rw-r--r--debian/patches/0012-fix-a-redefined-YYDEBUG-warning-of-gcc-for-the-code-.patch24
-rw-r--r--debian/patches/0013-added-several-comments-examples-by-Stefan-Sperling.patch155
-rw-r--r--debian/patches/0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch421
-rw-r--r--debian/patches/0015-a-bit-info-to-logger-when-get-OPTION_RECONF_ACCEPT.patch57
-rw-r--r--debian/patches/0016-fix-typo-in-dhcp6c.8-manpage.patch22
-rw-r--r--debian/patches/0017-Remove-unused-linking-with-libfl.patch43
-rw-r--r--debian/patches/0018-dhcpv6-ignore-advertise-messages-with-none-of-reques.patch137
-rw-r--r--debian/patches/0019-Server-should-not-bind-control-port-if-there-is-no-s.patch66
-rw-r--r--debian/patches/0020-Adding-option-to-randomize-interface-id.patch120
-rw-r--r--debian/patches/0021-Make-sla-len-config-optional.patch32
-rw-r--r--debian/patches/0022-Make-sla-id-config-optional.patch72
-rw-r--r--debian/patches/series22
23 files changed, 9372 insertions, 0 deletions
diff --git a/debian/patches/0001-Fix-manpages.patch b/debian/patches/0001-Fix-manpages.patch
new file mode 100644
index 0000000..a4a0e96
--- /dev/null
+++ b/debian/patches/0001-Fix-manpages.patch
@@ -0,0 +1,164 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:03 +0200
+Subject: Fix manpages
+
+This patch fixes wide-dhcpv6 manpages (paths, typos, ...).
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ dhcp6c.8 | 8 ++++----
+ dhcp6c.conf.5 | 4 ++--
+ dhcp6ctl.8 | 13 ++++++-------
+ dhcp6relay.8 | 1 -
+ dhcp6s.8 | 10 +++++-----
+ dhcp6s.conf.5 | 2 +-
+ 6 files changed, 18 insertions(+), 20 deletions(-)
+
+diff --git a/dhcp6c.8 b/dhcp6c.8
+index 6824ae0..1d69c9d 100644
+--- a/dhcp6c.8
++++ b/dhcp6c.8
+@@ -114,13 +114,13 @@ In either case,
+ will send DHCPv6 Release messages to release resources assigned from servers.
+ .\"
+ .Sh FILES
+-.Bl -tag -width /usr/local/etc/dhcp6c.conf -compact
++.Bl -tag -width /etc/wide-dhcpv6/dhcp6c.conf -compact
+ .It Pa /var/run/dhcp6c.pid
+ is the default file that contains pid of the currently running
+ .Nm dhcp6c .
+-.It Pa /usr/local/etc/dhcp6c.conf
++.It Pa /etc/wide-dhcpv6/dhcp6c.conf
+ is the default configuration file.
+-.It Pa /var/db/dhcp6c_duid
++.It Pa /var/lib/dhcpv6/dhcp6c_duid
+ is the file to store the client's DUID.
+ .El
+ .Sh Configuration Script
+@@ -203,6 +203,6 @@ command first appeared in WIDE/KAME IPv6 protocol stack kit.
+ is incomplete and violates DHCPv6 protocol spec, in several aspects.
+ In particular, temporary address assignment is intentionally omitted.
+ .Pp
+-Information Refresh Time Option is not recognied in Info-req mode, since
++Information Refresh Time Option is not recognized in Info-req mode, since
+ .Nm
+ terminates after it receives a REPLY message.
+diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5
+index 611ab4f..5fc03d3 100644
+--- a/dhcp6c.conf.5
++++ b/dhcp6c.conf.5
+@@ -36,7 +36,7 @@
+ .Nd DHCPv6 client configuration file
+ .\"
+ .Sh SYNOPSIS
+-.Pa /usr/local/etc/dhcp6c.conf
++.Pa /etc/wide-dhcpv6/dhcp6c.conf
+ .\"
+ .Sh DESCRIPTION
+ The
+@@ -630,7 +630,7 @@ execute the
+ .Xr openssl 1
+ command (when available) as follows,
+ .Bd -literal -offset
+-% openssl rand -base64 16
++% openssl rand \-base64 16
+ .Ed
+ .Pp
+ and copy the output to the
+diff --git a/dhcp6ctl.8 b/dhcp6ctl.8
+index 86ea0e1..e11889b 100644
+--- a/dhcp6ctl.8
++++ b/dhcp6ctl.8
+@@ -85,12 +85,11 @@ Use
+ .Ar keyfile
+ to provide the shared secret to communicate with the process.
+ The default file name used when unspecified is
+-.Pa /usr/local/etc/dhcp6cctlkey
++.Pa /etc/wide-dhcpv6/dhcp6cctlkey
+ with a client,
+ and
+-.Pa /usr/local/etc/dhcp6sctlkey
++.Pa /etc/wide-dhcpv6/dhcp6sctlkey
+ with a server.
+-
+ .It Fl p Ar port
+ Specify
+ .Ar port
+@@ -99,7 +98,7 @@ The default port number used when unspecified is 5546 for a client,
+ and 5547 for a server.
+ .It Fl s Ar address
+ Specify
+-.A address
++.Ar address
+ as the listening address of the process.
+ The default address used when unspecified is ::1.
+ .El
+@@ -183,10 +182,10 @@ information (if any) and exits.
+ .El
+ .\"
+ .Sh FILES
+-.Bl -tag -width /usr/local/etc/dhcp6cctlkey -compact
+-.It Pa /usr/local/etc/dhcp6cctlkey
++.Bl -tag -width /etc/wide-dhcpv6/dhcp6cctlkey -compact
++.It Pa /etc/wide-dhcpv6/dhcp6cctlkey
+ is the default key file to communicate with a client.
+-.It Pa /usr/local/etc/dhcp6sctlkey
++.It Pa /etc/wide-dhcpv6/dhcp6sctlkey
+ is the default key file to communicate with a server.
+ .El
+ .\"
+diff --git a/dhcp6relay.8 b/dhcp6relay.8
+index 4f761b0..7ad8ada 100644
+--- a/dhcp6relay.8
++++ b/dhcp6relay.8
+@@ -107,7 +107,6 @@ to dump the process ID of
+ is the default file that contains pid of the currently running
+ .Nm .
+ .El
+-
+ .Sh SEE ALSO
+ .Xr dhcp6c 8 ,
+ .Xr dhcp6s 8
+diff --git a/dhcp6s.8 b/dhcp6s.8
+index 888117a..29dcc7b 100644
+--- a/dhcp6s.8
++++ b/dhcp6s.8
+@@ -102,7 +102,7 @@ Use
+ to store the shared secret to authenticate the communication with
+ .Nm dhcp6ctl .
+ The default file name used when unspecified is
+-.Pa /usr/local/etc/dhcp6sctlkey .
++.Pa /etc/wide-dhcpv6/dhcp6sctlkey .
+ The default name is intentionally same as that for
+ .Nm dhcp6ctl
+ so that the server and the control command can share the file when
+@@ -122,12 +122,12 @@ to dump the process ID of
+ .El
+ .\"
+ .Sh FILES
+-.Bl -tag -width /usr/local/etc/dhcp6s.conf -compact
+-.It Pa /usr/local/etc/dhcp6s.conf
++.Bl -tag -width /etc/wide-dhcpv6/dhcp6s.conf -compact
++.It Pa /etc/wide-dhcpv6/dhcp6s.conf
+ is the default configuration file.
+-.It Pa /var/db/dhcp6s_duid
++.It Pa /var/lib/dhcpv6/dhcp6s_duid
+ is the default file to store the server's DUID.
+-.It Pa /usr/local/etc/dhcp6sctlkey
++.It Pa /etc/wide-dhcpv6/dhcp6sctlkey
+ is the default key file to communicate with the control command.
+ See
+ .Xr dhcp6ctl 8
+diff --git a/dhcp6s.conf.5 b/dhcp6s.conf.5
+index 1206764..2cb08ce 100644
+--- a/dhcp6s.conf.5
++++ b/dhcp6s.conf.5
+@@ -36,7 +36,7 @@
+ .Nd DHCPv6 server configuration file
+ .\"
+ .Sh SYNOPSIS
+-.Pa /usr/local/etc/dhcp6s.conf
++.Pa /etc/wide-dhcpv6/dhcp6s.conf
+ .\"
+ .Sh DESCRIPTION
+ The
diff --git a/debian/patches/0002-Don-t-strip-binaries.patch b/debian/patches/0002-Don-t-strip-binaries.patch
new file mode 100644
index 0000000..1e6b58f
--- /dev/null
+++ b/debian/patches/0002-Don-t-strip-binaries.patch
@@ -0,0 +1,24 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:06 +0200
+Subject: Don't strip binaries
+
+This patch prevents wide-dhcpv6 build system from stripping built binaries.
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index a39596f..de25f48 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -103,7 +103,7 @@ $(srcdir)/ianaopts.h: gentab.pl bootp-dhcp-parameters
+
+ install::
+ -mkdir -p $(sbindir) $(mandir)/man5 $(mandir)/man8
+- $(INSTALL_PROGRAM) -s -o $(user) -g $(group) $(TARGET) $(sbindir)
++ $(INSTALL_PROGRAM) -o $(user) -g $(group) $(TARGET) $(sbindir)
+ $(INSTALL_DATA) -o $(user) -g $(group) dhcp6c.8 $(mandir)/man8
+ $(INSTALL_DATA) -o $(user) -g $(group) dhcp6s.8 $(mandir)/man8
+ $(INSTALL_DATA) -o $(user) -g $(group) dhcp6relay.8 $(mandir)/man8
diff --git a/debian/patches/0003-Close-inherited-file-descriptors.patch b/debian/patches/0003-Close-inherited-file-descriptors.patch
new file mode 100644
index 0000000..9437ed7
--- /dev/null
+++ b/debian/patches/0003-Close-inherited-file-descriptors.patch
@@ -0,0 +1,76 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:08 +0200
+Subject: Close inherited file descriptors
+
+wide-dhcpv6 binaries should close inherited fds.
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ dhcp6c.c | 7 ++++++-
+ dhcp6relay.c | 6 ++++++
+ dhcp6s.c | 5 +++++
+ 3 files changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/dhcp6c.c b/dhcp6c.c
+index 1caaaa5..b5f5ed7 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -159,6 +159,7 @@ main(argc, argv)
+ char *progname;
+ FILE *pidfp;
+ struct dhcp6_if *ifp;
++ int fd;
+
+ #ifndef HAVE_ARC4RANDOM
+ srandom(time(NULL) & getpid());
+@@ -205,8 +206,12 @@ main(argc, argv)
+ exit(0);
+ }
+
+- if (foreground == 0)
++ if (foreground == 0) {
++ for (fd = 3; fd < 1024; fd++)
++ close(fd);
++
+ openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON);
++ }
+
+ setloglevel(debug);
+
+diff --git a/dhcp6relay.c b/dhcp6relay.c
+index fb84ce3..eb0bce9 100644
+--- a/dhcp6relay.c
++++ b/dhcp6relay.c
+@@ -207,8 +207,14 @@ main(argc, argv)
+ }
+
+ if (foreground == 0) {
++ int fd;
++
+ if (daemon(0, 0) < 0)
+ err(1, "daemon");
++
++ for (fd = 3; fd < 1024; fd++)
++ close(fd);
++
+ openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ }
+ setloglevel(debug);
+diff --git a/dhcp6s.c b/dhcp6s.c
+index 544afff..494e571 100644
+--- a/dhcp6s.c
++++ b/dhcp6s.c
+@@ -316,8 +316,13 @@ main(argc, argv)
+ }
+
+ if (foreground == 0) {
++ int fd;
++
+ if (daemon(0, 0) < 0)
+ err(1, "daemon");
++
++ for (fd = 3; fd < 1024; fd++)
++ close(fd);
+ }
+
+ /* dump current PID */
diff --git a/debian/patches/0004-GNU-libc6-fixes.patch b/debian/patches/0004-GNU-libc6-fixes.patch
new file mode 100644
index 0000000..5b39d41
--- /dev/null
+++ b/debian/patches/0004-GNU-libc6-fixes.patch
@@ -0,0 +1,6706 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:10 +0200
+Subject: GNU libc6 fixes
+
+Fixes for recent libc releases.
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ addrconf.c | 16 +-
+ cftoken.c | 12 +-
+ cftoken.l | 12 +-
+ common.c | 226 +++++++++++++-------------
+ common.h | 2 +-
+ config.c | 268 +++++++++++++++----------------
+ configure | 50 +++++-
+ configure.in | 7 +
+ dhcp6.h | 7 +
+ dhcp6_ctl.c | 40 ++---
+ dhcp6c.c | 246 ++++++++++++++---------------
+ dhcp6c_ia.c | 86 +++++-----
+ dhcp6c_script.c | 36 ++---
+ dhcp6relay.c | 118 +++++++-------
+ dhcp6relay_script.c | 28 ++--
+ dhcp6s.c | 446 ++++++++++++++++++++++++++--------------------------
+ if.c | 12 +-
+ lease.c | 14 +-
+ prefixconf.c | 24 +--
+ timer.c | 6 +-
+ 20 files changed, 859 insertions(+), 797 deletions(-)
+
+diff --git a/addrconf.c b/addrconf.c
+index d98373f..98d03e5 100644
+--- a/addrconf.c
++++ b/addrconf.c
+@@ -122,7 +122,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+ if (addr->vltime != DHCP6_DURATION_INFINITE &&
+ (addr->pltime == DHCP6_DURATION_INFINITE ||
+ addr->pltime > addr->vltime)) {
+- dprintf(LOG_INFO, FNAME, "invalid address %s: "
++ debug_printf(LOG_INFO, FNAME, "invalid address %s: "
+ "pltime (%lu) is larger than vltime (%lu)",
+ in6addr2str(&addr->addr, 0),
+ addr->pltime, addr->vltime);
+@@ -131,7 +131,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+
+ if (iac_na == NULL) {
+ if ((iac_na = malloc(sizeof(*iac_na))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "memory allocation failed");
++ debug_printf(LOG_NOTICE, FNAME, "memory allocation failed");
+ return (-1);
+ }
+ memset(iac_na, 0, sizeof(*iac_na));
+@@ -152,7 +152,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+ /* search for the given address, and make a new one if it fails */
+ if ((sa = find_addr(&iac_na->statefuladdr_head, addr)) == NULL) {
+ if ((sa = malloc(sizeof(*sa))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "memory allocation failed");
++ debug_printf(LOG_NOTICE, FNAME, "memory allocation failed");
+ return (-1);
+ }
+ memset(sa, 0, sizeof(*sa));
+@@ -169,7 +169,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+ sa->addr.pltime = addr->pltime;
+ sa->addr.vltime = addr->vltime;
+ sa->dhcpif = dhcpifp;
+- dprintf(LOG_DEBUG, FNAME, "%s an address %s pltime=%lu, vltime=%lu",
++ debug_printf(LOG_DEBUG, FNAME, "%s an address %s pltime=%lu, vltime=%lu",
+ sacreate ? "create" : "update",
+ in6addr2str(&addr->addr, 0), addr->pltime, addr->vltime);
+
+@@ -194,7 +194,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+ if (sa->timer == NULL) {
+ sa->timer = dhcp6_add_timer(addr_timo, sa);
+ if (sa->timer == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to add stateful addr timer");
+ remove_addr(sa); /* XXX */
+ return (-1);
+@@ -233,7 +233,7 @@ remove_addr(sa)
+ {
+ int ret;
+
+- dprintf(LOG_DEBUG, FNAME, "remove an address %s",
++ debug_printf(LOG_DEBUG, FNAME, "remove an address %s",
+ in6addr2str(&sa->addr.addr, 0));
+
+ if (sa->timer)
+@@ -343,7 +343,7 @@ na_renew_data_free(evd)
+ struct dhcp6_list *ial;
+
+ if (evd->type != DHCP6_EVDATA_IANA) {
+- dprintf(LOG_ERR, FNAME, "assumption failure");
++ debug_printf(LOG_ERR, FNAME, "assumption failure");
+ exit(1);
+ }
+
+@@ -362,7 +362,7 @@ addr_timo(arg)
+ struct ia *ia;
+ void (*callback)__P((struct ia *));
+
+- dprintf(LOG_DEBUG, FNAME, "address timeout for %s",
++ debug_printf(LOG_DEBUG, FNAME, "address timeout for %s",
+ in6addr2str(&sa->addr.addr, 0));
+
+ ia = sa->ctl->iacna_ia;
+diff --git a/cftoken.c b/cftoken.c
+index fcccc5a..0f6c1bf 100644
+--- a/cftoken.c
++++ b/cftoken.c
+@@ -2475,10 +2475,10 @@ cfdebug_print(w, t, l)
+ int l;
+ {
+ if (w) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "<%d>%s [%s] (%d)", yy_start, w, t, l);
+ } else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "<%d>[%s] (%d)", yy_start, t, l);
+ }
+ }
+@@ -2494,7 +2494,7 @@ yyerror0(int level, char *s, va_list ap)
+ if (bp < ep)
+ bp += vsnprintf(bp, ep - bp, s, ap);
+
+- dprintf(level, FNAME, ebuf);
++ debug_printf(level, FNAME, ebuf);
+ }
+
+ void
+@@ -2532,7 +2532,7 @@ cfswitch_buffer(incl)
+ FILE *fp;
+
+ if (incstackp >= MAX_INCLUDE_DEPTH) {
+- dprintf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
++ debug_printf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
+ return (-1);
+ }
+ incstack[incstackp].path = configfilename;
+@@ -2541,7 +2541,7 @@ cfswitch_buffer(incl)
+
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+- dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ path, strerror(errno));
+ if (errno == ENOENT)
+ return (0);
+@@ -2563,7 +2563,7 @@ cfparse(conf)
+ {
+ configfilename = conf;
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
+- dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ configfilename, strerror(errno));
+ if (errno == ENOENT)
+ return (0);
+diff --git a/cftoken.l b/cftoken.l
+index ece7fbb..ad4128d 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -340,10 +340,10 @@ cfdebug_print(w, t, l)
+ int l;
+ {
+ if (w) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "<%d>%s [%s] (%d)", yy_start, w, t, l);
+ } else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "<%d>[%s] (%d)", yy_start, t, l);
+ }
+ }
+@@ -359,7 +359,7 @@ yyerror0(int level, char *s, va_list ap)
+ if (bp < ep)
+ bp += vsnprintf(bp, ep - bp, s, ap);
+
+- dprintf(level, FNAME, ebuf);
++ debug_printf(level, FNAME, ebuf);
+ }
+
+ void
+@@ -397,7 +397,7 @@ cfswitch_buffer(incl)
+ FILE *fp;
+
+ if (incstackp >= MAX_INCLUDE_DEPTH) {
+- dprintf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
++ debug_printf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
+ return (-1);
+ }
+ incstack[incstackp].path = configfilename;
+@@ -406,7 +406,7 @@ cfswitch_buffer(incl)
+
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+- dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ path, strerror(errno));
+ if (errno == ENOENT)
+ return (0);
+@@ -428,7 +428,7 @@ cfparse(conf)
+ {
+ configfilename = conf;
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
+- dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ configfilename, strerror(errno));
+ if (errno == ENOENT)
+ return (0);
+diff --git a/common.c b/common.c
+index f35399c..cc4abcc 100644
+--- a/common.c
++++ b/common.c
+@@ -265,7 +265,7 @@ dhcp6_add_listval(head, type, val, sublist)
+ struct dhcp6_listval *lv = NULL;
+
+ if ((lv = malloc(sizeof(*lv))) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to allocate memory for list entry");
+ goto fail;
+ }
+@@ -298,7 +298,7 @@ dhcp6_add_listval(head, type, val, sublist)
+ goto fail;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "unexpected list value type (%d)", type);
+ goto fail;
+ }
+@@ -361,7 +361,7 @@ dhcp6_get_addr(optlen, cp, type, list)
+ void *val;
+
+ if (optlen % sizeof(struct in6_addr) || optlen == 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "malformed DHCP option: type %d, len %d", type, optlen);
+ return -1;
+ }
+@@ -371,14 +371,14 @@ dhcp6_get_addr(optlen, cp, type, list)
+ memcpy(&valaddr, val, sizeof(valaddr));
+ if (dhcp6_find_listval(list,
+ DHCP6_LISTVAL_ADDR6, &valaddr, 0)) {
+- dprintf(LOG_INFO, FNAME, "duplicated %s address (%s)",
++ debug_printf(LOG_INFO, FNAME, "duplicated %s address (%s)",
+ dhcp6optstr(type), in6addr2str(&valaddr, 0));
+ continue;
+ }
+
+ if (dhcp6_add_listval(list, DHCP6_LISTVAL_ADDR6,
+ &valaddr, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy %s address", dhcp6optstr(type));
+ return -1;
+ }
+@@ -405,7 +405,7 @@ dhcp6_set_addr(type, list, p, optep, len)
+ tmpbuf = NULL;
+ optlen = dhcp6_count_list(list) * sizeof(struct in6_addr);
+ if ((tmpbuf = malloc(optlen)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation failed for %s options",
+ dhcp6optstr(type));
+ return -1;
+@@ -438,10 +438,10 @@ dhcp6_get_domain(optlen, cp, type, list)
+
+ if (dnsdecode((u_char **)(void *)&val,
+ (u_char *)(cp + optlen), name, sizeof(name)) == NULL) {
+- dprintf(LOG_INFO, FNAME, "failed to "
++ debug_printf(LOG_INFO, FNAME, "failed to "
+ "decode a %s domain name",
+ dhcp6optstr(type));
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "malformed DHCP option: type %d, len %d",
+ type, optlen);
+ return -1;
+@@ -452,7 +452,7 @@ dhcp6_get_domain(optlen, cp, type, list)
+
+ if (dhcp6_add_listval(list,
+ DHCP6_LISTVAL_VBUF, &vb, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to "
++ debug_printf(LOG_ERR, FNAME, "failed to "
+ "copy a %s domain name", dhcp6optstr(type));
+ return -1;
+ }
+@@ -485,7 +485,7 @@ dhcp6_set_domain(type, list, p, optep, len)
+
+ tmpbuf = NULL;
+ if ((tmpbuf = malloc(optlen)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed for "
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed for "
+ "%s domain options", dhcp6optstr(type));
+ return -1;
+ }
+@@ -497,14 +497,14 @@ dhcp6_set_domain(type, list, p, optep, len)
+ nlen = dnsencode((const char *)d->val_vbuf.dv_buf,
+ name, sizeof (name));
+ if (nlen < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to encode a %s domain name",
+ dhcp6optstr(type));
+ free(tmpbuf);
+ return -1;
+ }
+ if (ep - cp < nlen) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "buffer length for %s domain name is too short",
+ dhcp6optstr(type));
+ free(tmpbuf);
+@@ -530,7 +530,7 @@ dhcp6_create_event(ifp, state)
+ struct dhcp6_event *ev;
+
+ if ((ev = malloc(sizeof(*ev))) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to allocate memory for an event");
+ return (NULL);
+ }
+@@ -548,7 +548,7 @@ dhcp6_remove_event(ev)
+ {
+ struct dhcp6_serverinfo *sp, *sp_next;
+
+- dprintf(LOG_DEBUG, FNAME, "removing an event on %s, state=%s",
++ debug_printf(LOG_DEBUG, FNAME, "removing an event on %s, state=%s",
+ ev->ifp->ifname, dhcp6_event_statestr(ev));
+
+ dhcp6_remove_evdata(ev);
+@@ -562,7 +562,7 @@ dhcp6_remove_event(ev)
+ for (sp = ev->servers; sp; sp = sp_next) {
+ sp_next = sp->next;
+
+- dprintf(LOG_DEBUG, FNAME, "removing server (ID: %s)",
++ debug_printf(LOG_DEBUG, FNAME, "removing server (ID: %s)",
+ duidstr(&sp->optinfo.serverID));
+ dhcp6_clear_options(&sp->optinfo);
+ if (sp->authparam != NULL)
+@@ -649,14 +649,14 @@ dhcp6_auth_replaycheck(method, prev, current)
+ char bufcurrent[] = "ffff ffff ffff ffff";
+
+ if (method != DHCP6_AUTHRDM_MONOCOUNTER) {
+- dprintf(LOG_ERR, FNAME, "unsupported replay detection "
++ debug_printf(LOG_ERR, FNAME, "unsupported replay detection "
+ "method (%d)", method);
+ return (-1);
+ }
+
+ (void)sprint_uint64(bufprev, sizeof(bufprev), prev);
+ (void)sprint_uint64(bufcurrent, sizeof(bufcurrent), current);
+- dprintf(LOG_DEBUG, FNAME, "previous: %s, current: %s",
++ debug_printf(LOG_DEBUG, FNAME, "previous: %s, current: %s",
+ bufprev, bufcurrent);
+
+ prev = ntohq(prev);
+@@ -667,7 +667,7 @@ dhcp6_auth_replaycheck(method, prev, current)
+ * whether the serial number is increasing or not.
+ */
+ if (prev == (current ^ 0x8000000000000000ULL)) {
+- dprintf(LOG_INFO, FNAME, "detected a singular point");
++ debug_printf(LOG_INFO, FNAME, "detected a singular point");
+ return (1);
+ }
+
+@@ -688,7 +688,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
+ int error = -1;
+
+ if (getifaddrs(&ifap) != 0) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "getifaddrs failed: %s", strerror(errno));
+ return (-1);
+ }
+@@ -765,7 +765,7 @@ getifidfromaddr(addr, ifidp)
+ int retval = -1;
+
+ if (getifaddrs(&ifap) != 0) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "getifaddrs failed: %s", strerror(errno));
+ return (-1);
+ }
+@@ -781,7 +781,7 @@ getifidfromaddr(addr, ifidp)
+
+ if (ifa != NULL) {
+ if ((ifid = if_nametoindex(ifa->ifa_name)) == 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "if_nametoindex failed for %s", ifa->ifa_name);
+ goto end;
+ }
+@@ -999,20 +999,20 @@ get_duid(idfile, duid)
+ char tmpbuf[256]; /* DUID should be no more than 256 bytes */
+
+ if ((fp = fopen(idfile, "r")) == NULL && errno != ENOENT)
+- dprintf(LOG_NOTICE, FNAME, "failed to open DUID file: %s",
++ debug_printf(LOG_NOTICE, FNAME, "failed to open DUID file: %s",
+ idfile);
+
+ if (fp) {
+ /* decode length */
+ if (fread(&len, sizeof(len), 1, fp) != 1) {
+- dprintf(LOG_ERR, FNAME, "DUID file corrupted");
++ debug_printf(LOG_ERR, FNAME, "DUID file corrupted");
+ goto fail;
+ }
+ } else {
+ int l;
+
+ if ((l = gethwid(tmpbuf, sizeof(tmpbuf), NULL, &hwtype)) < 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "failed to get a hardware address");
+ goto fail;
+ }
+@@ -1022,18 +1022,18 @@ get_duid(idfile, duid)
+ memset(duid, 0, sizeof(*duid));
+ duid->duid_len = len;
+ if ((duid->duid_id = (char *)malloc(len)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to allocate memory");
++ debug_printf(LOG_ERR, FNAME, "failed to allocate memory");
+ goto fail;
+ }
+
+ /* copy (and fill) the ID */
+ if (fp) {
+ if (fread(duid->duid_id, len, 1, fp) != 1) {
+- dprintf(LOG_ERR, FNAME, "DUID file corrupted");
++ debug_printf(LOG_ERR, FNAME, "DUID file corrupted");
+ goto fail;
+ }
+
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "extracted an existing DUID from %s: %s",
+ idfile, duidstr(duid));
+ } else {
+@@ -1047,27 +1047,27 @@ get_duid(idfile, duid)
+ dp->dh6_duid1_time = htonl((u_long)(t64 & 0xffffffff));
+ memcpy((void *)(dp + 1), tmpbuf, (len - sizeof(*dp)));
+
+- dprintf(LOG_DEBUG, FNAME, "generated a new DUID: %s",
++ debug_printf(LOG_DEBUG, FNAME, "generated a new DUID: %s",
+ duidstr(duid));
+ }
+
+ /* save the (new) ID to the file for next time */
+ if (!fp) {
+ if ((fp = fopen(idfile, "w+")) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to open DUID file for save");
+ goto fail;
+ }
+ if ((fwrite(&len, sizeof(len), 1, fp)) != 1) {
+- dprintf(LOG_ERR, FNAME, "failed to save DUID");
++ debug_printf(LOG_ERR, FNAME, "failed to save DUID");
+ goto fail;
+ }
+ if ((fwrite(duid->duid_id, len, 1, fp)) != 1) {
+- dprintf(LOG_ERR, FNAME, "failed to save DUID");
++ debug_printf(LOG_ERR, FNAME, "failed to save DUID");
+ goto fail;
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "saved generated DUID to %s",
++ debug_printf(LOG_DEBUG, FNAME, "saved generated DUID to %s",
+ idfile);
+ }
+
+@@ -1104,7 +1104,7 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
+ dl_phys_addr_req_t dlpar;
+ dl_phys_addr_ack_t *dlpaa;
+
+- dprintf(LOG_DEBUG, FNAME, "trying %s ppa %d", ifname, ppa);
++ debug_printf(LOG_DEBUG, FNAME, "trying %s ppa %d", ifname, ppa);
+
+ if (ifname[0] == '\0')
+ return (-1);
+@@ -1239,7 +1239,7 @@ gethwid(buf, len, ifname, hwtypep)
+
+ if ((root = di_init("/", DINFOSUBTREE | DINFOMINOR |
+ DINFOPROP)) == DI_NODE_NIL) {
+- dprintf(LOG_INFO, FNAME, "di_init failed");
++ debug_printf(LOG_INFO, FNAME, "di_init failed");
+ return (-1);
+ }
+ parms.buf = buf;
+@@ -1283,7 +1283,7 @@ gethwid(buf, len, ifname, hwtypep)
+ default:
+ continue; /* XXX */
+ }
+- dprintf(LOG_DEBUG, FNAME, "found an interface %s for DUID",
++ debug_printf(LOG_DEBUG, FNAME, "found an interface %s for DUID",
+ ifa->ifa_name);
+ memcpy(buf, LLADDR(sdl), sdl->sdl_alen);
+ l = sdl->sdl_alen; /* sdl will soon be freed */
+@@ -1296,7 +1296,7 @@ gethwid(buf, len, ifname, hwtypep)
+ if (sll->sll_hatype != ARPHRD_ETHER)
+ continue;
+ *hwtypep = ARPHRD_ETHER;
+- dprintf(LOG_DEBUG, FNAME, "found an interface %s for DUID",
++ debug_printf(LOG_DEBUG, FNAME, "found an interface %s for DUID",
+ ifa->ifa_name);
+ memcpy(buf, sll->sll_addr, sll->sll_halen);
+ l = sll->sll_halen; /* sll will soon be freed */
+@@ -1512,12 +1512,12 @@ dhcp6_get_options(p, ep, optinfo)
+ cp = (char *)(p + 1);
+ np = (struct dhcp6opt *)(cp + optlen);
+
+- dprintf(LOG_DEBUG, FNAME, "get DHCP option %s, len %d",
++ debug_printf(LOG_DEBUG, FNAME, "get DHCP option %s, len %d",
+ dhcp6optstr(opt), optlen);
+
+ /* option length field overrun */
+ if (np > ep) {
+- dprintf(LOG_INFO, FNAME, "malformed DHCP options");
++ debug_printf(LOG_INFO, FNAME, "malformed DHCP options");
+ goto fail;
+ }
+
+@@ -1527,10 +1527,10 @@ dhcp6_get_options(p, ep, optinfo)
+ goto malformed;
+ duid0.duid_len = optlen;
+ duid0.duid_id = cp;
+- dprintf(LOG_DEBUG, "",
++ debug_printf(LOG_DEBUG, "",
+ " DUID: %s", duidstr(&duid0));
+ if (duidcpy(&optinfo->clientID, &duid0)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy DUID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy DUID");
+ goto fail;
+ }
+ break;
+@@ -1539,9 +1539,9 @@ dhcp6_get_options(p, ep, optinfo)
+ goto malformed;
+ duid0.duid_len = optlen;
+ duid0.duid_id = cp;
+- dprintf(LOG_DEBUG, "", " DUID: %s", duidstr(&duid0));
++ debug_printf(LOG_DEBUG, "", " DUID: %s", duidstr(&duid0));
+ if (duidcpy(&optinfo->serverID, &duid0)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy DUID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy DUID");
+ goto fail;
+ }
+ break;
+@@ -1550,14 +1550,14 @@ dhcp6_get_options(p, ep, optinfo)
+ goto malformed;
+ memcpy(&val16, cp, sizeof(val16));
+ num16 = ntohs(val16);
+- dprintf(LOG_DEBUG, "", " status code: %s",
++ debug_printf(LOG_DEBUG, "", " status code: %s",
+ dhcp6_stcodestr(num16));
+
+ /* need to check duplication? */
+
+ if (dhcp6_add_listval(&optinfo->stcode_list,
+ DHCP6_LISTVAL_STCODE, &num16, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy "
++ debug_printf(LOG_ERR, FNAME, "failed to copy "
+ "status code");
+ goto fail;
+ }
+@@ -1574,13 +1574,13 @@ dhcp6_get_options(p, ep, optinfo)
+ memcpy(&opttype, val, sizeof(u_int16_t));
+ num = (int)ntohs(opttype);
+
+- dprintf(LOG_DEBUG, "",
++ debug_printf(LOG_DEBUG, "",
+ " requested option: %s",
+ dhcp6optstr(num));
+
+ if (dhcp6_find_listval(&optinfo->reqopt_list,
+ DHCP6_LISTVAL_NUM, &num, 0)) {
+- dprintf(LOG_INFO, FNAME, "duplicated "
++ debug_printf(LOG_INFO, FNAME, "duplicated "
+ "option type (%s)",
+ dhcp6optstr(opttype));
+ goto nextoption;
+@@ -1588,7 +1588,7 @@ dhcp6_get_options(p, ep, optinfo)
+
+ if (dhcp6_add_listval(&optinfo->reqopt_list,
+ DHCP6_LISTVAL_NUM, &num, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy requested option");
+ goto fail;
+ }
+@@ -1599,10 +1599,10 @@ dhcp6_get_options(p, ep, optinfo)
+ case DH6OPT_PREFERENCE:
+ if (optlen != 1)
+ goto malformed;
+- dprintf(LOG_DEBUG, "", " preference: %d",
++ debug_printf(LOG_DEBUG, "", " preference: %d",
+ (int)*(u_char *)cp);
+ if (optinfo->pref != DH6OPT_PREF_UNDEF) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated preference option");
+ } else
+ optinfo->pref = (int)*(u_char *)cp;
+@@ -1612,11 +1612,11 @@ dhcp6_get_options(p, ep, optinfo)
+ goto malformed;
+ memcpy(&val16, cp, sizeof(val16));
+ val16 = ntohs(val16);
+- dprintf(LOG_DEBUG, "", " elapsed time: %lu",
++ debug_printf(LOG_DEBUG, "", " elapsed time: %lu",
+ (u_int32_t)val16);
+ if (optinfo->elapsed_time !=
+ DH6OPT_ELAPSED_TIME_UNDEF) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated elapsed time option");
+ } else
+ optinfo->elapsed_time = val16;
+@@ -1637,7 +1637,7 @@ dhcp6_get_options(p, ep, optinfo)
+ * [RFC3315 Section 21.4.2]
+ */
+ if (optinfo->authproto != DHCP6_AUTHPROTO_UNDEF) {
+- dprintf(LOG_INFO, FNAME, "found more than one "
++ debug_printf(LOG_INFO, FNAME, "found more than one "
+ "authentication option");
+ goto fail;
+ }
+@@ -1648,7 +1648,7 @@ dhcp6_get_options(p, ep, optinfo)
+ memcpy(&optinfo->authrd, cp, sizeof(optinfo->authrd));
+ cp += sizeof(optinfo->authrd);
+
+- dprintf(LOG_DEBUG, "", " %s", sprint_auth(optinfo));
++ debug_printf(LOG_DEBUG, "", " %s", sprint_auth(optinfo));
+
+ authinfolen =
+ optlen - (sizeof(struct dhcp6opt_auth) - 4);
+@@ -1670,7 +1670,7 @@ dhcp6_get_options(p, ep, optinfo)
+ optinfo->delayedauth_realmval =
+ malloc(optinfo->delayedauth_realmlen);
+ if (optinfo->delayedauth_realmval == NULL) {
+- dprintf(LOG_WARNING, FNAME, "failed "
++ debug_printf(LOG_WARNING, FNAME, "failed "
+ "allocate memory for auth realm");
+ goto fail;
+ }
+@@ -1687,7 +1687,7 @@ dhcp6_get_options(p, ep, optinfo)
+ optinfo->delayedauth_offset = cp - bp;
+ cp += 16;
+
+- dprintf(LOG_DEBUG, "", " auth key ID: %x, "
++ debug_printf(LOG_DEBUG, "", " auth key ID: %x, "
+ "offset=%d, realmlen=%d",
+ optinfo->delayedauth_keyid,
+ optinfo->delayedauth_offset,
+@@ -1698,7 +1698,7 @@ dhcp6_get_options(p, ep, optinfo)
+ break;
+ #endif
+ default:
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unsupported authentication protocol: %d",
+ *cp);
+ goto fail;
+@@ -1779,14 +1779,14 @@ dhcp6_get_options(p, ep, optinfo)
+ ia.t1 = ntohl(optia.dh6_ia_t1);
+ ia.t2 = ntohl(optia.dh6_ia_t2);
+
+- dprintf(LOG_DEBUG, "",
++ debug_printf(LOG_DEBUG, "",
+ " IA_PD: ID=%lu, T1=%lu, T2=%lu",
+ ia.iaid, ia.t1, ia.t2);
+
+ /* duplication check */
+ if (dhcp6_find_listval(&optinfo->iapd_list,
+ DHCP6_LISTVAL_IAPD, &ia, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated IA_PD %lu", ia.iaid);
+ break; /* ignore this IA_PD */
+ }
+@@ -1813,7 +1813,7 @@ dhcp6_get_options(p, ep, optinfo)
+ goto malformed;
+ memcpy(&val32, cp, sizeof(val32));
+ val32 = ntohl(val32);
+- dprintf(LOG_DEBUG, "",
++ debug_printf(LOG_DEBUG, "",
+ " information refresh time: %lu", val32);
+ if (val32 < DHCP6_IRT_MINIMUM) {
+ /*
+@@ -1823,13 +1823,13 @@ dhcp6_get_options(p, ep, optinfo)
+ * [draft-ietf-dhc-lifetime-02.txt,
+ * Section 3.2]
+ */
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "refresh time is too small (%d), adjusted",
+ val32);
+ val32 = DHCP6_IRT_MINIMUM;
+ }
+ if (optinfo->refreshtime != DH6OPT_REFRESHTIME_UNDEF) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated refresh time option");
+ } else
+ optinfo->refreshtime = (int64_t)val32;
+@@ -1843,14 +1843,14 @@ dhcp6_get_options(p, ep, optinfo)
+ ia.t1 = ntohl(optia.dh6_ia_t1);
+ ia.t2 = ntohl(optia.dh6_ia_t2);
+
+- dprintf(LOG_DEBUG, "",
++ debug_printf(LOG_DEBUG, "",
+ " IA_NA: ID=%lu, T1=%lu, T2=%lu",
+ ia.iaid, ia.t1, ia.t2);
+
+ /* duplication check */
+ if (dhcp6_find_listval(&optinfo->iana_list,
+ DHCP6_LISTVAL_IANA, &ia, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated IA_NA %lu", ia.iaid);
+ break; /* ignore this IA_NA */
+ }
+@@ -1874,7 +1874,7 @@ dhcp6_get_options(p, ep, optinfo)
+ break;
+ default:
+ /* no option specific behavior */
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unknown or unexpected DHCP6 option %s, len %d",
+ dhcp6optstr(opt), optlen);
+ break;
+@@ -1884,7 +1884,7 @@ dhcp6_get_options(p, ep, optinfo)
+ return (0);
+
+ malformed:
+- dprintf(LOG_INFO, FNAME, "malformed DHCP option: type %d, len %d",
++ debug_printf(LOG_INFO, FNAME, "malformed DHCP option: type %d, len %d",
+ opt, optlen);
+ fail:
+ dhcp6_clear_options(optinfo);
+@@ -1967,11 +1967,11 @@ copyin_option(type, p, ep, list)
+ cp = (char *)(p + 1);
+ np = (struct dhcp6opt *)(cp + optlen);
+
+- dprintf(LOG_DEBUG, FNAME, "get DHCP option %s, len %d",
++ debug_printf(LOG_DEBUG, FNAME, "get DHCP option %s, len %d",
+ dhcp6optstr(opt), optlen);
+
+ if (np > ep) {
+- dprintf(LOG_INFO, FNAME, "malformed DHCP option");
++ debug_printf(LOG_INFO, FNAME, "malformed DHCP option");
+ goto fail;
+ }
+
+@@ -1979,7 +1979,7 @@ copyin_option(type, p, ep, list)
+ case DH6OPT_IA_PD_PREFIX:
+ /* check option context */
+ if (type != DH6OPT_IA_PD) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s is an invalid position for %s",
+ dhcp6optstr(type), dhcp6optstr(opt));
+ goto fail;
+@@ -1991,7 +1991,7 @@ copyin_option(type, p, ep, list)
+ /* copy and convert option values */
+ memcpy(&opt_iapd_prefix, p, sizeof(opt_iapd_prefix));
+ if (opt_iapd_prefix.dh6_iapd_prefix_prefix_len > 128) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "invalid prefix length (%d)",
+ opt_iapd_prefix.dh6_iapd_prefix_prefix_len);
+ goto malformed;
+@@ -2006,7 +2006,7 @@ copyin_option(type, p, ep, list)
+ /* clear padding bits in the prefix address */
+ prefix6_mask(&iapd_prefix.addr, iapd_prefix.plen);
+
+- dprintf(LOG_DEBUG, FNAME, " IA_PD prefix: "
++ debug_printf(LOG_DEBUG, FNAME, " IA_PD prefix: "
+ "%s/%d pltime=%lu vltime=%lu",
+ in6addr2str(&iapd_prefix.addr, 0),
+ iapd_prefix.plen,
+@@ -2014,7 +2014,7 @@ copyin_option(type, p, ep, list)
+
+ if (dhcp6_find_listval(list, DHCP6_LISTVAL_PREFIX6,
+ &iapd_prefix, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated IA_PD prefix "
+ "%s/%d pltime=%lu vltime=%lu",
+ in6addr2str(&iapd_prefix.addr, 0),
+@@ -2041,7 +2041,7 @@ copyin_option(type, p, ep, list)
+ case DH6OPT_IAADDR:
+ /* check option context */
+ if (type != DH6OPT_IA_NA) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s is an invalid position for %s",
+ dhcp6optstr(type), dhcp6optstr(opt));
+ goto fail;
+@@ -2057,14 +2057,14 @@ copyin_option(type, p, ep, list)
+ memcpy(&ia_addr.addr, &opt_ia_addr.dh6_ia_addr_addr,
+ sizeof(ia_addr.addr));
+
+- dprintf(LOG_DEBUG, FNAME, " IA_NA address: "
++ debug_printf(LOG_DEBUG, FNAME, " IA_NA address: "
+ "%s pltime=%lu vltime=%lu",
+ in6addr2str(&ia_addr.addr, 0),
+ ia_addr.pltime, ia_addr.vltime);
+
+ if (dhcp6_find_listval(list,
+ DHCP6_LISTVAL_STATEFULADDR6, &ia_addr, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated IA_NA address"
+ "%s pltime=%lu vltime=%lu",
+ in6addr2str(&ia_addr.addr, 0),
+@@ -2093,7 +2093,7 @@ copyin_option(type, p, ep, list)
+ type != DH6OPT_IA_PD_PREFIX &&
+ type != DH6OPT_IA_NA &&
+ type != DH6OPT_IAADDR) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s is an invalid position for %s",
+ dhcp6optstr(type), dhcp6optstr(opt));
+ goto nextoption; /* or discard the message? */
+@@ -2107,13 +2107,13 @@ copyin_option(type, p, ep, list)
+ opt_stcode.dh6_stcode_code =
+ ntohs(opt_stcode.dh6_stcode_code);
+
+- dprintf(LOG_DEBUG, "", " status code: %s",
++ debug_printf(LOG_DEBUG, "", " status code: %s",
+ dhcp6_stcodestr(opt_stcode.dh6_stcode_code));
+
+ /* duplication check */
+ if (dhcp6_find_listval(list, DHCP6_LISTVAL_STCODE,
+ &opt_stcode.dh6_stcode_code, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated status code (%d)",
+ opt_stcode.dh6_stcode_code);
+ goto nextoption;
+@@ -2133,7 +2133,7 @@ copyin_option(type, p, ep, list)
+ return (0);
+
+ malformed:
+- dprintf(LOG_INFO, "", " malformed DHCP option: type %d", opt);
++ debug_printf(LOG_INFO, "", " malformed DHCP option: type %d", opt);
+
+ fail:
+ dhcp6_clear_list(&sublist);
+@@ -2221,7 +2221,7 @@ copy_option(type, len, val, optp, ep, totallenp)
+ struct dhcp6opt *opt = *optp, opth;
+
+ if ((void *)ep - (void *)optp < len + sizeof(struct dhcp6opt)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "option buffer short for %s", dhcp6optstr(type));
+ return (-1);
+ }
+@@ -2233,7 +2233,7 @@ copy_option(type, len, val, optp, ep, totallenp)
+
+ *optp = (struct dhcp6opt *)((char *)(opt + 1) + len);
+ *totallenp += sizeof(struct dhcp6opt) + len;
+- dprintf(LOG_DEBUG, FNAME, "set %s (len %d)", dhcp6optstr(type), len);
++ debug_printf(LOG_DEBUG, FNAME, "set %s (len %d)", dhcp6optstr(type), len);
+
+ return (0);
+ }
+@@ -2269,21 +2269,21 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+
+ tmpbuf = NULL;
+ if ((optlen = copyout_option(NULL, NULL, op)) < 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "failed to count option length");
+ goto fail;
+ }
+ if ((void *)optep - (void *)p < optlen) {
+- dprintf(LOG_INFO, FNAME, "short buffer");
++ debug_printf(LOG_INFO, FNAME, "short buffer");
+ goto fail;
+ }
+ if ((tmpbuf = malloc(optlen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "memory allocation failed for IA_NA options");
+ goto fail;
+ }
+ if (copyout_option(tmpbuf, tmpbuf + optlen, op) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to construct an IA_NA option");
+ goto fail;
+ }
+@@ -2340,7 +2340,7 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+ buflen = dhcp6_count_list(&optinfo->reqopt_list) *
+ sizeof(u_int16_t);
+ if ((tmpbuf = malloc(buflen)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation failed for options");
+ goto fail;
+ }
+@@ -2355,7 +2355,7 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+ */
+ if (opt->val_num == DH6OPT_REFRESHTIME &&
+ type != DH6_INFORM_REQ) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "refresh time option is not requested "
+ "for %s", dhcp6msgstr(type));
+ }
+@@ -2423,21 +2423,21 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+
+ tmpbuf = NULL;
+ if ((optlen = copyout_option(NULL, NULL, op)) < 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "failed to count option length");
+ goto fail;
+ }
+ if ((void *)optep - (void *)p < optlen) {
+- dprintf(LOG_INFO, FNAME, "short buffer");
++ debug_printf(LOG_INFO, FNAME, "short buffer");
+ goto fail;
+ }
+ if ((tmpbuf = malloc(optlen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "memory allocation failed for IA_PD options");
+ goto fail;
+ }
+ if (copyout_option(tmpbuf, tmpbuf + optlen, op) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to construct an IA_PD option");
+ goto fail;
+ }
+@@ -2492,13 +2492,13 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+ break;
+ #endif
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "unexpected authentication protocol");
+ goto fail;
+ }
+ }
+ if ((auth = malloc(authlen)) == NULL) {
+- dprintf(LOG_WARNING, FNAME, "failed to allocate "
++ debug_printf(LOG_WARNING, FNAME, "failed to allocate "
+ "memory for authentication information");
+ goto fail;
+ }
+@@ -2534,7 +2534,7 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+ optinfo->delayedauth_offset =
+ ((char *)p - (char *)optbp) + authlen - 16;
+
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "key ID %x, offset %d",
+ optinfo->delayedauth_keyid,
+ optinfo->delayedauth_offset);
+@@ -2543,7 +2543,7 @@ dhcp6_set_options(type, optbp, optep, optinfo)
+ case DHCP6_AUTHPROTO_RECONFIG:
+ #endif
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "unexpected authentication protocol");
+ free(auth);
+ goto fail;
+@@ -2695,7 +2695,7 @@ copyout_option(p, ep, optval)
+ * we encounter an unknown option. this should be an internal
+ * error.
+ */
+- dprintf(LOG_ERR, FNAME, "unknown option: code %d",
++ debug_printf(LOG_ERR, FNAME, "unknown option: code %d",
+ optval->type);
+ return (-1);
+ }
+@@ -2721,7 +2721,7 @@ copyout_option(p, ep, optval)
+ if (!p)
+ return(optlen);
+
+- dprintf(LOG_DEBUG, FNAME, "set %s", dhcp6optstr(opttype));
++ debug_printf(LOG_DEBUG, FNAME, "set %s", dhcp6optstr(opttype));
+ if (ep - p < headlen) /* check it just in case */
+ return (-1);
+
+@@ -2812,7 +2812,7 @@ dhcp6_set_timeoparam(ev)
+ ev->max_retrans_cnt = REL_MAX_RC;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unexpected event state %d on %s",
++ debug_printf(LOG_ERR, FNAME, "unexpected event state %d on %s",
+ ev->state, ev->ifp->ifname);
+ exit(1);
+ }
+@@ -2870,7 +2870,7 @@ dhcp6_reset_timer(ev)
+
+ statestr = dhcp6_event_statestr(ev);
+
+- dprintf(LOG_DEBUG, FNAME, "reset a timer on %s, "
++ debug_printf(LOG_DEBUG, FNAME, "reset a timer on %s, "
+ "state=%s, timeo=%d, retrans=%d",
+ ev->ifp->ifname, statestr, ev->timeouts, ev->retrans);
+ }
+@@ -2881,7 +2881,7 @@ duidcpy(dd, ds)
+ {
+ dd->duid_len = ds->duid_len;
+ if ((dd->duid_id = malloc(dd->duid_len)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ return (-1);
+ }
+ memcpy(dd->duid_id, ds->duid_id, dd->duid_len);
+@@ -2929,17 +2929,17 @@ get_rdvalue(rdm, rdvalue, rdsize)
+ u_int32_t u32, l32;
+
+ if (rdm != DHCP6_AUTHRDM_MONOCOUNTER) {
+- dprintf(LOG_INFO, FNAME, "unsupported RDM (%d)", rdm);
++ debug_printf(LOG_INFO, FNAME, "unsupported RDM (%d)", rdm);
+ return (-1);
+ }
+ if (rdsize != sizeof(u_int64_t)) {
+- dprintf(LOG_INFO, FNAME, "unsupported RD size (%d)", rdsize);
++ debug_printf(LOG_INFO, FNAME, "unsupported RD size (%d)", rdsize);
+ return (-1);
+ }
+
+ #if defined(HAVE_CLOCK_GETTIME)
+ if (clock_gettime(CLOCK_REALTIME, &tp)) {
+- dprintf(LOG_WARNING, FNAME, "clock_gettime failed: %s",
++ debug_printf(LOG_WARNING, FNAME, "clock_gettime failed: %s",
+ strerror(errno));
+ return (-1);
+ }
+@@ -2952,7 +2952,7 @@ get_rdvalue(rdm, rdvalue, rdsize)
+ l32 = (u_int32_t)nsec;
+ #else
+ if (gettimeofday(&tv, NULL) != 0) {
+- dprintf(LOG_WARNING, FNAME, "gettimeofday failed: %s",
++ debug_printf(LOG_WARNING, FNAME, "gettimeofday failed: %s",
+ strerror(errno));
+ return (-1);
+ }
+@@ -3207,7 +3207,7 @@ setloglevel(debuglevel)
+ }
+
+ void
+-dprintf(int level, const char *fname, const char *fmt, ...)
++debug_printf(int level, const char *fname, const char *fmt, ...)
+ {
+ va_list ap;
+ char logbuf[LINE_MAX];
+@@ -3293,7 +3293,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ }
+
+ if ((s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+- dprintf(LOG_ERR, FNAME, "can't open a temporary socket: %s",
++ debug_printf(LOG_ERR, FNAME, "can't open a temporary socket: %s",
+ strerror(errno));
+ return (-1);
+ }
+@@ -3311,7 +3311,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
+ if (ioctl(s, SIOGIFINDEX, &ifr) < 0) {
+- dprintf(LOG_NOTICE, FNAME, "failed to get the index of %s: %s",
++ debug_printf(LOG_NOTICE, FNAME, "failed to get the index of %s: %s",
+ ifname, strerror(errno));
+ close(s);
+ return (-1);
+@@ -3325,7 +3325,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ #endif
+
+ if (ioctl(s, ioctl_cmd, &req)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to %s an address on %s: %s",
++ debug_printf(LOG_NOTICE, FNAME, "failed to %s an address on %s: %s",
+ cmdstr, ifname, strerror(errno));
+ close(s);
+ return (-1);
+@@ -3334,14 +3334,14 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ #ifdef __sun__
+ memcpy(&req.lifr_addr, addr, sizeof (*addr));
+ if (ioctl(s, SIOCSLIFADDR, &req) == -1) {
+- dprintf(LOG_NOTICE, FNAME, "failed to %s new address on %s: %s",
++ debug_printf(LOG_NOTICE, FNAME, "failed to %s new address on %s: %s",
+ cmdstr, ifname, strerror(errno));
+ close(s);
+ return (-1);
+ }
+ #endif
+
+- dprintf(LOG_DEBUG, FNAME, "%s an address %s/%d on %s", cmdstr,
++ debug_printf(LOG_DEBUG, FNAME, "%s an address %s/%d on %s", cmdstr,
+ addr2str((struct sockaddr *)addr), plen, ifname);
+
+ close(s);
+@@ -3357,13 +3357,13 @@ safefile(path)
+
+ /* no setuid */
+ if (getuid() != geteuid()) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "setuid'ed execution not allowed");
+ return (-1);
+ }
+
+ if (lstat(path, &s) != 0) {
+- dprintf(LOG_NOTICE, FNAME, "lstat failed: %s",
++ debug_printf(LOG_NOTICE, FNAME, "lstat failed: %s",
+ strerror(errno));
+ return (-1);
+ }
+@@ -3371,7 +3371,7 @@ safefile(path)
+ /* the file must be owned by the running uid */
+ myuid = getuid();
+ if (s.st_uid != myuid) {
+- dprintf(LOG_NOTICE, FNAME, "%s has invalid owner uid", path);
++ debug_printf(LOG_NOTICE, FNAME, "%s has invalid owner uid", path);
+ return (-1);
+ }
+
+@@ -3379,7 +3379,7 @@ safefile(path)
+ case S_IFREG:
+ break;
+ default:
+- dprintf(LOG_NOTICE, FNAME, "%s is an invalid file type 0x%o",
++ debug_printf(LOG_NOTICE, FNAME, "%s is an invalid file type 0x%o",
+ path, (s.st_mode & S_IFMT));
+ return (-1);
+ }
+diff --git a/common.h b/common.h
+index 7366c25..9fd8008 100644
+--- a/common.h
++++ b/common.h
+@@ -155,7 +155,7 @@ extern char *in6addr2str __P((struct in6_addr *, int));
+ extern int in6_addrscopebyif __P((struct in6_addr *, char *));
+ extern int in6_scope __P((struct in6_addr *));
+ extern void setloglevel __P((int));
+-extern void dprintf __P((int, const char *, const char *, ...));
++extern void debug_printf __P((int, const char *, const char *, ...));
+ extern int get_duid __P((char *, struct duid *));
+ extern void dhcp6_init_options __P((struct dhcp6_optinfo *));
+ extern void dhcp6_clear_options __P((struct dhcp6_optinfo *));
+diff --git a/config.c b/config.c
+index 383c12a..3721545 100644
+--- a/config.c
++++ b/config.c
+@@ -156,13 +156,13 @@ configure_interface(iflist)
+ struct cf_list *cfl;
+
+ if (if_nametoindex(ifp->name) == 0) {
+- dprintf(LOG_ERR, FNAME, "invalid interface(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "invalid interface(%s): %s",
+ ifp->name, strerror(errno));
+ goto bad;
+ }
+
+ if ((ifc = malloc(sizeof(*ifc))) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation for %s failed", ifp->name);
+ goto bad;
+ }
+@@ -171,7 +171,7 @@ configure_interface(iflist)
+ dhcp6_ifconflist = ifc;
+
+ if ((ifc->ifname = strdup(ifp->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy ifname");
++ debug_printf(LOG_ERR, FNAME, "failed to copy ifname");
+ goto bad;
+ }
+
+@@ -183,7 +183,7 @@ configure_interface(iflist)
+ switch(cfl->type) {
+ case DECL_REQUEST:
+ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- dprintf(LOG_INFO, FNAME, "%s:%d "
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
+ "client-only configuration",
+ configfilename,
+ cfl->line);
+@@ -208,7 +208,7 @@ configure_interface(iflist)
+ break;
+ case DECL_INFO_ONLY:
+ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- dprintf(LOG_INFO, FNAME, "%s:%d "
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
+ "client-only configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -217,7 +217,7 @@ configure_interface(iflist)
+ break;
+ case DECL_PREFERENCE:
+ if (dhcp6_mode != DHCP6_MODE_SERVER) {
+- dprintf(LOG_INFO, FNAME, "%s:%d "
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
+ "server-only configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -225,7 +225,7 @@ configure_interface(iflist)
+ ifc->server_pref = (int)cfl->num;
+ if (ifc->server_pref < 0 ||
+ ifc->server_pref > 255) {
+- dprintf(LOG_INFO, FNAME, "%s:%d "
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
+ "bad value: %d",
+ configfilename, cfl->line,
+ ifc->server_pref);
+@@ -234,13 +234,13 @@ configure_interface(iflist)
+ break;
+ case DECL_SCRIPT:
+ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- dprintf(LOG_INFO, FNAME, "%s:%d "
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
+ "client-only configuration",
+ configfilename, cfl->line);
+ goto bad;
+ }
+ if (ifc->scriptpath) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s:%d duplicated configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -248,13 +248,13 @@ configure_interface(iflist)
+ cp = cfl->ptr;
+ ifc->scriptpath = strdup(cp + 1);
+ if (ifc->scriptpath == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to copy script path");
+ goto bad;
+ }
+ cp = ifc->scriptpath;
+ if (*cp != '/') {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "script must be an absolute path");
+ goto bad;
+ }
+@@ -272,7 +272,7 @@ configure_interface(iflist)
+ if (strcmp(spec->name, pool->name) == 0)
+ break;
+ if (pool == NULL) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "pool '%s' not found",
+ configfilename, cfl->line,
+ spec->name);
+@@ -281,7 +281,7 @@ configure_interface(iflist)
+ if (spec->vltime != DHCP6_DURATION_INFINITE &&
+ (spec->pltime == DHCP6_DURATION_INFINITE ||
+ spec->pltime > spec->vltime)) {
+- dprintf(LOG_ERR, FNAME, "%s:%d ",
++ debug_printf(LOG_ERR, FNAME, "%s:%d ",
+ configfilename, cfl->line,
+ "specified a larger preferred lifetime "
+ "than valid lifetime");
+@@ -289,17 +289,17 @@ configure_interface(iflist)
+ }
+ ifc->pool = *spec;
+ if ((ifc->pool.name = strdup(spec->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation failed");
+ goto bad;
+ }
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "pool '%s' is specified to the interface '%s'",
+ ifc->pool.name, ifc->ifname);
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid interface configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -338,7 +338,7 @@ configure_ia(ialist, iatype)
+ confsize = sizeof(struct iana_conf);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "internal error");
++ debug_printf(LOG_ERR, FNAME, "internal error");
+ goto bad;
+ }
+
+@@ -346,7 +346,7 @@ configure_ia(ialist, iatype)
+ struct cf_list *cfl;
+
+ if ((iac = malloc(confsize)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation for IA %s failed",
+ iap->name);
+ goto bad;
+@@ -386,13 +386,13 @@ configure_ia(ialist, iatype)
+ if (add_prefix(&pdp->iapd_prefix_list,
+ "IAPD", DHCP6_LISTVAL_PREFIX6,
+ cfl->ptr)) {
+- dprintf(LOG_NOTICE, FNAME, "failed "
++ debug_printf(LOG_NOTICE, FNAME, "failed "
+ "to configure prefix");
+ goto bad;
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -404,20 +404,20 @@ configure_ia(ialist, iatype)
+ if (add_prefix(&nap->iana_address_list,
+ "IANA", DHCP6_LISTVAL_STATEFULADDR6,
+ cfl->ptr)) {
+- dprintf(LOG_NOTICE, FNAME, "failed "
++ debug_printf(LOG_NOTICE, FNAME, "failed "
+ "to configure address");
+ goto bad;
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid configuration",
+ configfilename, cfl->line);
+ goto bad;
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid iatype %d",
+ configfilename, cfl->line, iatype);
+ goto bad;
+@@ -443,7 +443,7 @@ add_pd_pif(iapdc, cfl0)
+ for (pif = TAILQ_FIRST(&iapdc->iapd_pif_list); pif;
+ pif = TAILQ_NEXT(pif, link)) {
+ if (strcmp(pif->ifname, cfl0->ptr) == 0) {
+- dprintf(LOG_NOTICE, FNAME, "%s:%d "
++ debug_printf(LOG_NOTICE, FNAME, "%s:%d "
+ "duplicated prefix interface: %s",
+ configfilename, cfl0->line, cfl0->ptr);
+ return (0); /* ignore it */
+@@ -451,7 +451,7 @@ add_pd_pif(iapdc, cfl0)
+ }
+
+ if ((pif = malloc(sizeof(*pif))) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation for %s failed", cfl0->ptr);
+ goto bad;
+ }
+@@ -459,20 +459,20 @@ add_pd_pif(iapdc, cfl0)
+
+ /* validate and copy ifname */
+ if (if_nametoindex(cfl0->ptr) == 0) {
+- dprintf(LOG_ERR, FNAME, "%s:%d invalid interface (%s): %s",
++ debug_printf(LOG_ERR, FNAME, "%s:%d invalid interface (%s): %s",
+ configfilename, cfl0->line,
+ cfl0->ptr, strerror(errno));
+ goto bad;
+ }
+ if ((pif->ifname = strdup(cfl0->ptr)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy ifname");
++ debug_printf(LOG_ERR, FNAME, "failed to copy ifname");
+ goto bad;
+ }
+
+ pif->ifid_len = IFID_LEN_DEFAULT;
+ pif->sla_len = SLA_LEN_DEFAULT;
+ if (get_default_ifid(pif)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to get default IF ID for %s", pif->ifname);
+ goto bad;
+ }
+@@ -485,14 +485,14 @@ add_pd_pif(iapdc, cfl0)
+ case IFPARAM_SLA_LEN:
+ pif->sla_len = (int)cfl->num;
+ if (pif->sla_len < 0 || pif->sla_len > 128) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid SLA length: %d",
+ configfilename, cfl->line, pif->sla_len);
+ goto bad;
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d internal error: "
++ debug_printf(LOG_ERR, FNAME, "%s:%d internal error: "
+ "invalid configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -520,7 +520,7 @@ configure_host(hostlist)
+ struct cf_list *cfl;
+
+ if ((hconf = malloc(sizeof(*hconf))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed "
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed "
+ "for host %s", host->name);
+ goto bad;
+ }
+@@ -531,7 +531,7 @@ configure_host(hostlist)
+ host_conflist0 = hconf;
+
+ if ((hconf->name = strdup(host->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy host name: %s",
++ debug_printf(LOG_ERR, FNAME, "failed to copy host name: %s",
+ host->name);
+ goto bad;
+ }
+@@ -540,7 +540,7 @@ configure_host(hostlist)
+ switch(cfl->type) {
+ case DECL_DUID:
+ if (hconf->duid.duid_id) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "duplicated DUID for %s",
+ configfilename,
+ cfl->line, host->name);
+@@ -548,14 +548,14 @@ configure_host(hostlist)
+ }
+ if ((configure_duid((char *)cfl->ptr,
+ &hconf->duid)) != 0) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "failed to configure "
+ "DUID for %s",
+ configfilename, cfl->line,
+ host->name);
+ goto bad;
+ }
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "configure DUID for %s: %s",
+ host->name, duidstr(&hconf->duid));
+ break;
+@@ -563,7 +563,7 @@ configure_host(hostlist)
+ if (add_prefix(&hconf->prefix_list,
+ hconf->name, DHCP6_LISTVAL_PREFIX6,
+ cfl->ptr)) {
+- dprintf(LOG_ERR, FNAME, "failed "
++ debug_printf(LOG_ERR, FNAME, "failed "
+ "to configure prefix for %s",
+ host->name);
+ goto bad;
+@@ -573,7 +573,7 @@ configure_host(hostlist)
+ if (add_prefix(&hconf->addr_list,
+ hconf->name, DHCP6_LISTVAL_STATEFULADDR6,
+ cfl->ptr)) {
+- dprintf(LOG_ERR, FNAME, "failed "
++ debug_printf(LOG_ERR, FNAME, "failed "
+ "to configure address for %s",
+ host->name);
+ goto bad;
+@@ -581,7 +581,7 @@ configure_host(hostlist)
+ break;
+ case DECL_DELAYEDKEY:
+ if (hconf->delayedkey != NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d: duplicate key %s for %s"
+ " (ignored)", configfilename,
+ cfl->line, cfl->ptr, host->name);
+@@ -590,12 +590,12 @@ configure_host(hostlist)
+ if ((hconf->delayedkey =
+ find_keybyname(key_list0, cfl->ptr))
+ == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to "
++ debug_printf(LOG_ERR, FNAME, "failed to "
+ "find key information for %s",
+ cfl->ptr);
+ goto bad;
+ }
+- dprintf(LOG_DEBUG, FNAME, "configure key for "
++ debug_printf(LOG_DEBUG, FNAME, "configure key for "
+ "delayed auth with %s (keyid=%08x)",
+ host->name, hconf->delayedkey->keyid);
+ break;
+@@ -610,7 +610,7 @@ configure_host(hostlist)
+ if (strcmp(spec->name, pool->name) == 0)
+ break;
+ if (pool == NULL) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "pool '%s' not found",
+ configfilename, cfl->line,
+ spec->name);
+@@ -619,7 +619,7 @@ configure_host(hostlist)
+ if (spec->vltime != DHCP6_DURATION_INFINITE &&
+ (spec->pltime == DHCP6_DURATION_INFINITE ||
+ spec->pltime > spec->vltime)) {
+- dprintf(LOG_ERR, FNAME, "%s:%d ",
++ debug_printf(LOG_ERR, FNAME, "%s:%d ",
+ configfilename, cfl->line,
+ "specified a larger preferred lifetime "
+ "than valid lifetime");
+@@ -627,17 +627,17 @@ configure_host(hostlist)
+ }
+ hconf->pool = *spec;
+ if ((hconf->pool.name = strdup(spec->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "memory allocation failed");
+ goto bad;
+ }
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "pool '%s' is specified to the host '%s'",
+ hconf->pool.name, hconf->name);
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid host configuration for %s",
+ configfilename, cfl->line,
+ host->name);
+@@ -669,7 +669,7 @@ configure_keys(keylist)
+ struct cf_list *cfl;
+
+ if ((kinfo = malloc(sizeof(*kinfo))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed "
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed "
+ "for key %s", key->name);
+ goto bad;
+ }
+@@ -678,7 +678,7 @@ configure_keys(keylist)
+ key_list0 = kinfo;
+
+ if ((kinfo->name = strdup(key->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy key name: %s",
++ debug_printf(LOG_ERR, FNAME, "failed to copy key name: %s",
+ key->name);
+ goto bad;
+ }
+@@ -689,7 +689,7 @@ configure_keys(keylist)
+ switch (cfl->type) {
+ case KEYPARAM_REALM:
+ if (kinfo->realm != NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate realm for key %s "
+ "(ignored)", configfilename,
+ cfl->line, key->name);
+@@ -697,7 +697,7 @@ configure_keys(keylist)
+ }
+ kinfo->realm = qstrdup(cfl->ptr);
+ if (kinfo->realm == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to allocate memory for "
+ "realm");
+ goto bad;
+@@ -706,7 +706,7 @@ configure_keys(keylist)
+ break;
+ case KEYPARAM_KEYID:
+ if (keyid != -1) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate realm for key %s "
+ "(ignored)",
+ configfilename, cfl->line);
+@@ -714,7 +714,7 @@ configure_keys(keylist)
+ }
+ keyid = cfl->num;
+ if (keyid < 0 || keyid > 0xffffffff) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d key ID overflow",
+ configfilename, cfl->line);
+ goto bad;
+@@ -723,7 +723,7 @@ configure_keys(keylist)
+ case KEYPARAM_SECRET:
+ /* duplicate check */
+ if (kinfo->secret != NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate secret "
+ "for key %s (ignored)",
+ configfilename, cfl->line,
+@@ -733,7 +733,7 @@ configure_keys(keylist)
+
+ /* convert base64 string to binary secret */
+ if ((secretstr = qstrdup(cfl->ptr)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to make a copy of secret");
+ goto bad;
+ }
+@@ -741,7 +741,7 @@ configure_keys(keylist)
+ secretlen = base64_decodestring(secretstr,
+ secret, sizeof(secret));
+ if (secretlen < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "%s:%d failed to parse base64 key",
+ configfilename, cfl->line);
+ free(secretstr);
+@@ -752,7 +752,7 @@ configure_keys(keylist)
+ /* set the binary secret */
+ kinfo->secret = malloc(secretlen);
+ if (kinfo->secret == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to allocate memory "
+ "for secret");
+ goto bad;
+@@ -762,7 +762,7 @@ configure_keys(keylist)
+ break;
+ case KEYPARAM_EXPIRE:
+ if (expire != NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate expire for key "
+ "%s (ignored)", configfilename,
+ cfl->line, key->name);
+@@ -771,7 +771,7 @@ configure_keys(keylist)
+ expire = qstrdup(cfl->ptr);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "%s:%d invalid key parameter for %s",
+ configfilename, cfl->line, key->name);
+ goto bad;
+@@ -780,18 +780,18 @@ configure_keys(keylist)
+
+ /* check for mandatory parameters or use default */
+ if (kinfo->realm == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "realm not specified for key %s", key->name);
+ goto bad;
+ }
+ if (keyid == -1) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "key ID not specified for key %s", key->name);
+ goto bad;
+ }
+ kinfo->keyid = keyid;
+ if (kinfo->secret == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "secret not specified for key %s", key->name);
+ goto bad;
+ }
+@@ -802,7 +802,7 @@ configure_keys(keylist)
+ struct tm *lt;
+
+ if (time(&now) == -1) {
+- dprintf(LOG_ERR, FNAME, "cannot get "
++ debug_printf(LOG_ERR, FNAME, "cannot get "
+ "current time: %s",
+ strerror(errno));
+ goto bad;
+@@ -815,14 +815,14 @@ configure_keys(keylist)
+ strptime(expire, "%m-%d %H:%M", lt)
+ == NULL &&
+ strptime(expire, "%H:%M", lt) == NULL) {
+- dprintf(LOG_ERR, FNAME, "invalid "
++ debug_printf(LOG_ERR, FNAME, "invalid "
+ "expiration time: %s");
+ goto bad;
+ }
+
+ expire_time = mktime(lt);
+ if (expire_time < now) {
+- dprintf(LOG_ERR, FNAME, "past "
++ debug_printf(LOG_ERR, FNAME, "past "
+ "expiration time specified: %s",
+ expire);
+ goto bad;
+@@ -867,7 +867,7 @@ configure_authinfo(authlist)
+ struct cf_list *cfl;
+
+ if ((ainfo = malloc(sizeof(*ainfo))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed "
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed "
+ "for auth info %s", auth->name);
+ goto bad;
+ }
+@@ -879,7 +879,7 @@ configure_authinfo(authlist)
+ ainfo->rdm = DHCP6_AUTHRDM_UNDEF;
+
+ if ((ainfo->name = strdup(auth->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy auth info name: %s", auth->name);
+ goto bad;
+ }
+@@ -888,7 +888,7 @@ configure_authinfo(authlist)
+ switch (cfl->type) {
+ case AUTHPARAM_PROTO:
+ if (ainfo->protocol != DHCP6_AUTHPROTO_UNDEF) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate protocol "
+ "for auth info %s "
+ "(ignored)",
+@@ -900,7 +900,7 @@ configure_authinfo(authlist)
+ break;
+ case AUTHPARAM_ALG:
+ if (ainfo->algorithm != DHCP6_AUTHALG_UNDEF) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate algorithm "
+ "for auth info %s "
+ "(ignored)",
+@@ -912,7 +912,7 @@ configure_authinfo(authlist)
+ break;
+ case AUTHPARAM_RDM:
+ if (ainfo->rdm != DHCP6_AUTHRDM_UNDEF) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d duplicate RDM "
+ "for auth info %s "
+ "(ignored)",
+@@ -923,13 +923,13 @@ configure_authinfo(authlist)
+ ainfo->rdm = (int)cfl->num;
+ break;
+ case AUTHPARAM_KEY:
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "%s:%d auth info specific keys "
+ "are not supported",
+ configfilename, cfl->line);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "%s:%d invalid auth info parameter for %s",
+ configfilename, cfl->line, auth->name);
+ goto bad;
+@@ -939,20 +939,20 @@ configure_authinfo(authlist)
+ /* check for mandatory parameters and consistency */
+ switch (ainfo->protocol) {
+ case DHCP6_AUTHPROTO_UNDEF:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "auth protocol is not specified for %s",
+ auth->name);
+ goto bad;
+ case DHCP6_AUTHPROTO_DELAYED:
+ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "client-only auth protocol is specified");
+ goto bad;
+ }
+ break;
+ case DHCP6_AUTHPROTO_RECONFIG:
+ if (dhcp6_mode != DHCP6_MODE_SERVER) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "server-only auth protocol is specified");
+ goto bad;
+ }
+@@ -1039,7 +1039,7 @@ configure_addr(cf_addr_list, list0, optname)
+
+ /* check against configuration restriction */
+ if (cf_addr_list != NULL && dhcp6_mode != DHCP6_MODE_SERVER) {
+- dprintf(LOG_INFO, FNAME, "%s:%d server-only configuration",
++ debug_printf(LOG_INFO, FNAME, "%s:%d server-only configuration",
+ configfilename, cf_addr_list->line);
+ return -1;
+ }
+@@ -1049,7 +1049,7 @@ configure_addr(cf_addr_list, list0, optname)
+ /* duplication check */
+ if (dhcp6_find_listval(list0, DHCP6_LISTVAL_ADDR6,
+ cl->ptr, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s:%d duplicated %s server: %s",
+ configfilename, cl->line,
+ optname,
+@@ -1058,7 +1058,7 @@ configure_addr(cf_addr_list, list0, optname)
+ }
+ if (dhcp6_add_listval(list0, DHCP6_LISTVAL_ADDR6,
+ cl->ptr, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a %s server",
++ debug_printf(LOG_ERR, FNAME, "failed to add a %s server",
+ optname);
+ return -1;
+ }
+@@ -1077,7 +1077,7 @@ configure_domain(cf_name_list, list0, optname)
+
+ /* check against configuration restriction */
+ if (cf_name_list != NULL && dhcp6_mode != DHCP6_MODE_SERVER) {
+- dprintf(LOG_INFO, FNAME, "%s:%d server-only configuration",
++ debug_printf(LOG_INFO, FNAME, "%s:%d server-only configuration",
+ configfilename, cf_name_list->line);
+ return -1;
+ }
+@@ -1089,7 +1089,7 @@ configure_domain(cf_name_list, list0, optname)
+
+ name = strdup(cl->ptr + 1);
+ if (name == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy a %s domain name",
+ optname);
+ return -1;
+@@ -1103,7 +1103,7 @@ configure_domain(cf_name_list, list0, optname)
+ /* duplication check */
+ if (dhcp6_find_listval(list0, DHCP6_LISTVAL_VBUF,
+ &name_vbuf, 0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s:%d duplicated %s name: %s",
+ configfilename, cl->line, optname,
+ name_vbuf.dv_buf);
+@@ -1114,7 +1114,7 @@ configure_domain(cf_name_list, list0, optname)
+ /* add the name */
+ if (dhcp6_add_listval(list0, DHCP6_LISTVAL_VBUF,
+ &name_vbuf, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a %s name",
++ debug_printf(LOG_ERR, FNAME, "failed to add a %s name",
+ optname);
+ dhcp6_vbuf_free(&name_vbuf);
+ return -1;
+@@ -1145,12 +1145,12 @@ configure_duid(str, duid)
+ goto bad;
+ duidlen += (slen / 3);
+ if (duidlen > 128) {
+- dprintf(LOG_ERR, FNAME, "too long DUID (%d)", duidlen);
++ debug_printf(LOG_ERR, FNAME, "too long DUID (%d)", duidlen);
+ return (-1);
+ }
+
+ if ((idbuf = malloc(duidlen)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ return (-1);
+ }
+
+@@ -1175,7 +1175,7 @@ configure_duid(str, duid)
+ bad:
+ if (idbuf)
+ free(idbuf);
+- dprintf(LOG_ERR, FNAME, "assumption failure (bad string)");
++ debug_printf(LOG_ERR, FNAME, "assumption failure (bad string)");
+ return (-1);
+ }
+
+@@ -1193,12 +1193,12 @@ get_default_ifid(pif)
+ #endif
+
+ if (pif->ifid_len < 64) {
+- dprintf(LOG_NOTICE, FNAME, "ID length too short");
++ debug_printf(LOG_NOTICE, FNAME, "ID length too short");
+ return (-1);
+ }
+
+ if (getifaddrs(&ifap) < 0) {
+- dprintf(LOG_ERR, FNAME, "getifaddrs failed: %s",
++ debug_printf(LOG_ERR, FNAME, "getifaddrs failed: %s",
+ strerror(errno));
+ return (-1);
+ }
+@@ -1218,7 +1218,7 @@ get_default_ifid(pif)
+
+ sdl = (struct sockaddr_dl *)ifa->ifa_addr;
+ if (sdl->sdl_alen < 6) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "link layer address is too short (%s)",
+ pif->ifname);
+ goto fail;
+@@ -1233,7 +1233,7 @@ get_default_ifid(pif)
+
+ sll = (struct sockaddr_ll *)ifa->ifa_addr;
+ if (sll->sll_halen < 6) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "link layer address is too short (%s)",
+ pif->ifname);
+ goto fail;
+@@ -1256,7 +1256,7 @@ get_default_ifid(pif)
+ }
+
+ if (ifa == NULL) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "cannot find interface information for %s", pif->ifname);
+ goto fail;
+ }
+@@ -1352,7 +1352,7 @@ configure_commit()
+
+ /* clear unused IA configuration */
+ if (!TAILQ_EMPTY(&ia_conflist0)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "some IA configuration defined but not used");
+ }
+ clear_iaconf(&ia_conflist0);
+@@ -1475,7 +1475,7 @@ clear_iaconf(ialist)
+ switch(iac->type) {
+ case IATYPE_PD:
+ if (!TAILQ_EMPTY(&iac->iadata)) {
+- dprintf(LOG_ERR, FNAME, "assumption failure");
++ debug_printf(LOG_ERR, FNAME, "assumption failure");
+ exit(1);
+ }
+ clear_pd_pif((struct iapd_conf *)iac);
+@@ -1557,7 +1557,7 @@ add_options(opcode, ifc, cfl0)
+ ifc->allow_flags |= DHCIFF_RAPID_COMMIT;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid operation (%d) "
+ "for option type (%d)",
+ opcode, cfl->type);
+@@ -1566,7 +1566,7 @@ add_options(opcode, ifc, cfl0)
+ break;
+ case DHCPOPT_AUTHINFO:
+ if (opcode != DHCPOPTCODE_SEND) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid operation (%d) "
+ "for option type (%d)",
+ opcode, cfl->type);
+@@ -1574,14 +1574,14 @@ add_options(opcode, ifc, cfl0)
+ }
+ ainfo = find_authinfo(auth_list0, cfl->ptr);
+ if (ainfo == NULL) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "auth info (%s) is not defined",
+ configfilename, cfl->line,
+ (char *)cfl->ptr);
+ return (-1);
+ }
+ if (ifc->authinfo != NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "%s:%d authinfo is doubly specified on %s",
+ configfilename, cfl->line, ifc->ifname);
+ return (-1);
+@@ -1594,7 +1594,7 @@ add_options(opcode, ifc, cfl0)
+ iac = find_iaconf(&ia_conflist0, IATYPE_PD,
+ (u_int32_t)cfl->num);
+ if (iac == NULL) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "IA_PD (%lu) is not defined",
+ configfilename, cfl->line,
+ (u_long)cfl->num);
+@@ -1607,7 +1607,7 @@ add_options(opcode, ifc, cfl0)
+
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid operation (%d) "
+ "for option type (%d)", opcode, cfl->type);
+ break;
+@@ -1619,7 +1619,7 @@ add_options(opcode, ifc, cfl0)
+ iac = find_iaconf(&ia_conflist0, IATYPE_NA,
+ (u_int32_t)cfl->num);
+ if (iac == NULL) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "IA_NA (%lu) is not defined",
+ configfilename, cfl->line,
+ (u_long)cfl->num);
+@@ -1632,7 +1632,7 @@ add_options(opcode, ifc, cfl0)
+
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid operation (%d) "
+ "for option type (%d)", opcode, cfl->type);
+ break;
+@@ -1693,7 +1693,7 @@ add_options(opcode, ifc, cfl0)
+ if (dhcp6_find_listval(&ifc->reqopt_list,
+ DHCP6_LISTVAL_NUM, &opttype, 0)
+ != NULL) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "duplicated requested option: %s",
+ dhcp6optstr(opttype));
+ goto next; /* ignore it */
+@@ -1701,20 +1701,20 @@ add_options(opcode, ifc, cfl0)
+ if (dhcp6_add_listval(&ifc->reqopt_list,
+ DHCP6_LISTVAL_NUM, &opttype, NULL)
+ == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to "
++ debug_printf(LOG_ERR, FNAME, "failed to "
+ "configure an option");
+ return (-1);
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid operation (%d) "
+ "for option type (%d)", opcode, cfl->type);
+ break;
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "%s:%d unsupported option type: %d",
+ configfilename, cfl->line, cfl->type);
+ return (-1);
+@@ -1740,13 +1740,13 @@ add_prefix(head, name, type, prefix0)
+
+ /* additional validation of parameters */
+ if (oprefix.plen < 0 || oprefix.plen > 128) {
+- dprintf(LOG_ERR, FNAME, "invalid prefix: %d", oprefix.plen);
++ debug_printf(LOG_ERR, FNAME, "invalid prefix: %d", oprefix.plen);
+ return (-1);
+ }
+ /* clear trailing bits */
+ prefix6_mask(&oprefix.addr, oprefix.plen);
+ if (!IN6_ARE_ADDR_EQUAL(&prefix0->addr, &oprefix.addr)) {
+- dprintf(LOG_WARNING, FNAME, "prefix %s/%d for %s "
++ debug_printf(LOG_WARNING, FNAME, "prefix %s/%d for %s "
+ "has a trailing garbage. It should be %s/%d",
+ in6addr2str(&prefix0->addr, 0), prefix0->plen,
+ name, in6addr2str(&oprefix.addr, 0), oprefix.plen);
+@@ -1757,7 +1757,7 @@ add_prefix(head, name, type, prefix0)
+ if (IN6_IS_ADDR_MULTICAST(&oprefix.addr) ||
+ IN6_IS_ADDR_LINKLOCAL(&oprefix.addr) ||
+ IN6_IS_ADDR_SITELOCAL(&oprefix.addr)) {
+- dprintf(LOG_ERR, FNAME, "invalid prefix address: %s",
++ debug_printf(LOG_ERR, FNAME, "invalid prefix address: %s",
+ in6addr2str(&oprefix.addr, 0));
+ return (-1);
+ }
+@@ -1765,11 +1765,11 @@ add_prefix(head, name, type, prefix0)
+ /* prefix duplication check */
+ if (dhcp6_find_listval(head, type, &oprefix, 0)) {
+ if (type == DHCP6_LISTVAL_PREFIX6) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "duplicated prefix: %s/%d for %s",
+ in6addr2str(&oprefix.addr, 0), oprefix.plen, name);
+ } else {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "duplicated address: %s for %s",
+ in6addr2str(&oprefix.addr, 0), name);
+ }
+@@ -1781,12 +1781,12 @@ add_prefix(head, name, type, prefix0)
+ (oprefix.pltime == DHCP6_DURATION_INFINITE ||
+ oprefix.pltime > oprefix.vltime)) {
+ if (type == DHCP6_LISTVAL_PREFIX6) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "%s/%d has larger preferred lifetime "
+ "than valid lifetime",
+ in6addr2str(&oprefix.addr, 0), oprefix.plen);
+ } else {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "%s has larger preferred lifetime "
+ "than valid lifetime",
+ in6addr2str(&oprefix.addr, 0));
+@@ -1915,10 +1915,10 @@ configure_pool(poollist)
+ {
+ struct cf_namelist *plp;
+
+- dprintf(LOG_DEBUG, FNAME, "called");
++ debug_printf(LOG_DEBUG, FNAME, "called");
+
+ if (poollist && dhcp6_mode != DHCP6_MODE_SERVER) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "pool statement is server-only",
+ configfilename, poollist->line);
+ goto bad;
+@@ -1935,7 +1935,7 @@ configure_pool(poollist)
+ range = cfl->ptr;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "invalid pool configuration",
+ configfilename, cfl->line);
+ goto bad;
+@@ -1943,14 +1943,14 @@ configure_pool(poollist)
+ }
+
+ if (!range) {
+- dprintf(LOG_ERR, FNAME, "%s:%d "
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
+ "pool '%s' has no range declaration",
+ configfilename, plp->line,
+ plp->name);
+ goto bad;
+ }
+ if ((pool = create_pool(plp->name, range)) == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "faled to craete pool '%s'", plp->name);
+ goto bad;
+ }
+@@ -1971,7 +1971,7 @@ clear_poolconf(plist)
+ {
+ struct pool_conf *pool, *pool_next;
+
+- dprintf(LOG_DEBUG, FNAME, "called");
++ debug_printf(LOG_DEBUG, FNAME, "called");
+
+ for (pool = plist; pool; pool = pool_next) {
+ pool_next = pool->next;
+@@ -1999,7 +1999,7 @@ create_dynamic_hostconf(duid, pool)
+ if (dynamic_hostconf_count >= DHCP6_DYNAMIC_HOSTCONF_MAX) {
+ struct dynamic_hostconf_listhead *head = &dynamic_hostconf_head;
+
+- dprintf(LOG_DEBUG, FNAME, "reached to the max count (count=%lu)",
++ debug_printf(LOG_DEBUG, FNAME, "reached to the max count (count=%lu)",
+ dynamic_hostconf_count);
+
+ /* Find the last entry that doesn't need authentication */
+@@ -2013,14 +2013,14 @@ create_dynamic_hostconf(duid, pool)
+ clear_hostconf(dynconf->host);
+ } else {
+ if ((dynconf = malloc(sizeof(*dynconf))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ return (NULL);
+ }
+ }
+ memset(dynconf, 0, sizeof(*dynconf));
+
+ if ((host = malloc(sizeof(*host))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ goto bad;
+ }
+ memset(host, 0, sizeof(*host));
+@@ -2030,7 +2030,7 @@ create_dynamic_hostconf(duid, pool)
+ if ((strid = duidstr(duid)) == NULL)
+ strid = "???";
+ if ((host->name = strdup(strid)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ goto bad;
+ }
+ if (duidcpy(&host->duid, duid) != 0) {
+@@ -2038,7 +2038,7 @@ create_dynamic_hostconf(duid, pool)
+ }
+ if (pool->name) {
+ if ((host->pool.name = strdup(pool->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ goto bad;
+ }
+ }
+@@ -2049,7 +2049,7 @@ create_dynamic_hostconf(duid, pool)
+ TAILQ_INSERT_HEAD(&dynamic_hostconf_head, dynconf, link);
+ dynamic_hostconf_count++;
+
+- dprintf(LOG_DEBUG, FNAME, "created host_conf (name=%s)", host->name);
++ debug_printf(LOG_DEBUG, FNAME, "created host_conf (name=%s)", host->name);
+
+ return (host);
+
+@@ -2097,22 +2097,22 @@ create_pool(name, range)
+ return (NULL);
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "name=%s, range=%s->%s", name,
++ debug_printf(LOG_DEBUG, FNAME, "name=%s, range=%s->%s", name,
+ in6addr2str(&range->min, 0), in6addr2str(&range->max, 0));
+
+ if (in6_addr_cmp(&range->min, &range->max) > 0) {
+- dprintf(LOG_ERR, FNAME, "invalid address range %s->%s",
++ debug_printf(LOG_ERR, FNAME, "invalid address range %s->%s",
+ in6addr2str(&range->min, 0),
+ in6addr2str(&range->max, 0));
+ return (NULL);
+ }
+
+ if ((pool = malloc(sizeof(struct pool_conf))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ return (NULL);
+ }
+ if ((pool->name = strdup(name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ free(pool);
+ return (NULL);
+ }
+@@ -2131,16 +2131,16 @@ find_pool(name)
+ if (!name)
+ return (NULL);
+
+- dprintf(LOG_DEBUG, FNAME, "name=%s", name);
++ debug_printf(LOG_DEBUG, FNAME, "name=%s", name);
+
+ for (pool = pool_conflist; pool; pool = pool->next) {
+ if (strcmp(name, pool->name) == 0) {
+- dprintf(LOG_DEBUG, FNAME, "found (name=%s)", name);
++ debug_printf(LOG_DEBUG, FNAME, "found (name=%s)", name);
+ return (pool);
+ }
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "not found (name=%s)", name);
++ debug_printf(LOG_DEBUG, FNAME, "not found (name=%s)", name);
+
+ return (NULL);
+ }
+@@ -2154,7 +2154,7 @@ get_free_address_from_pool(pool, addr)
+ if (!pool || !addr)
+ return (0);
+
+- dprintf(LOG_DEBUG, FNAME, "called (pool=%s)", pool->name);
++ debug_printf(LOG_DEBUG, FNAME, "called (pool=%s)", pool->name);
+
+ for (cur = pool->min; in6_addr_cmp(&cur, &pool->max) <= 0;
+ in6_addr_inc(&cur)) {
+@@ -2162,17 +2162,17 @@ get_free_address_from_pool(pool, addr)
+ !IN6_IS_ADDR_MULTICAST(&cur) &&
+ !IN6_IS_ADDR_LINKLOCAL(&cur) &&
+ !IN6_IS_ADDR_SITELOCAL(&cur)) {
+- dprintf(LOG_DEBUG, FNAME, "found %s",
++ debug_printf(LOG_DEBUG, FNAME, "found %s",
+ in6addr2str(&cur, 0));
+ *addr= cur;
+ return 1;
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "next address %s",
++ debug_printf(LOG_DEBUG, FNAME, "next address %s",
+ in6addr2str(&cur, 0));
+ }
+
+- dprintf(LOG_NOTICE, FNAME, "no available address");
++ debug_printf(LOG_NOTICE, FNAME, "no available address");
+ return 0;
+ }
+
+@@ -2184,7 +2184,7 @@ is_available_in_pool(pool, addr)
+ if (!pool || !addr)
+ return (0);
+
+- dprintf(LOG_DEBUG, FNAME, "pool=%s, addr=%s",
++ debug_printf(LOG_DEBUG, FNAME, "pool=%s, addr=%s",
+ pool->name, in6addr2str(addr, 0));
+
+ if (in6_addr_cmp(addr, &pool->min) >= 0 &&
+@@ -2196,7 +2196,7 @@ is_available_in_pool(pool, addr)
+ return (1);
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "unavailable address (pool=%s, addr=%s)",
++ debug_printf(LOG_DEBUG, FNAME, "unavailable address (pool=%s, addr=%s)",
+ pool->name, in6addr2str(addr, 0));
+
+ return (0);
+diff --git a/configure b/configure
+index 6f50634..4722b7b 100755
+--- a/configure
++++ b/configure
+@@ -6013,7 +6013,55 @@ fi
+ done
+
+
+- ac_config_files="$ac_config_files Makefile"
++{ echo "$as_me:$LINENO: checking whether libc defines struct in6_pktinfo" >&5
++echo $ECHO_N "checking whether libc defines struct in6_pktinfo... $ECHO_C" >&6; }
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <netinet/in.h>
++int
++main ()
++{
++struct in6_pktinfo p6;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (ac_try="$ac_compile"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
++ (eval "$ac_compile") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest.$ac_objext; then
++ { echo "$as_me:$LINENO: result: yes" >&5
++echo "${ECHO_T}yes" >&6; }
++ CFLAGS="$CFLAGS -DHAVE_IN6_PKTINFO"
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ { echo "$as_me:$LINENO: result: no" >&5
++echo "${ECHO_T}no" >&6; }
++fi
++
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++
++ac_config_files="$ac_config_files Makefile"
++
+ cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+ # tests run on this system so they can be shared between configure
+diff --git a/configure.in b/configure.in
+index 59dd84e..6da9af5 100644
+--- a/configure.in
++++ b/configure.in
+@@ -236,4 +236,11 @@ AC_SUBST(group)
+
+ AC_CHECK_HEADERS(stdarg.h)
+
++AC_MSG_CHECKING(whether libc defines struct in6_pktinfo)
++AC_TRY_COMPILE([#include <netinet/in.h>],
++ [struct in6_pktinfo p6;],
++ [AC_MSG_RESULT(yes)
++ CFLAGS="$CFLAGS -DHAVE_IN6_PKTINFO"],
++ [AC_MSG_RESULT(no)])
++
+ AC_OUTPUT(Makefile)
+diff --git a/dhcp6.h b/dhcp6.h
+index 6afb517..9f3a62d 100644
+--- a/dhcp6.h
++++ b/dhcp6.h
+@@ -108,6 +108,13 @@ typedef uint64_t u_int64_t;
+ #define DHCP6_IRT_DEFAULT 86400 /* 1 day */
+ #define DHCP6_IRT_MINIMUM 600
+
++#ifndef HAVE_IN6_PKTINFO
++struct in6_pktinfo {
++ struct in6_addr ipi6_addr; /* src/dst IPv6 address */
++ unsigned int ipi6_ifindex; /* send/recv interface index */
++};
++#endif
++
+ /* DUID: DHCP unique Identifier */
+ struct duid {
+ size_t duid_len; /* length */
+diff --git a/dhcp6_ctl.c b/dhcp6_ctl.c
+index ab1f18d..a12f82a 100644
+--- a/dhcp6_ctl.c
++++ b/dhcp6_ctl.c
+@@ -93,32 +93,32 @@ dhcp6_ctl_init(addr, port, max, sockp)
+ hints.ai_protocol = IPPROTO_TCP;
+ error = getaddrinfo(addr, port, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ return (-1);
+ }
+ ctlsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (ctlsock < 0) {
+- dprintf(LOG_ERR, FNAME, "socket(control sock): %s",
++ debug_printf(LOG_ERR, FNAME, "socket(control sock): %s",
+ strerror(errno));
+ goto fail;
+ }
+ on = 1;
+ if (setsockopt(ctlsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))
+ < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(control sock, SO_REUSEADDR: %s",
+ strerror(errno));
+ goto fail;
+ }
+ if (bind(ctlsock, res->ai_addr, res->ai_addrlen) < 0) {
+- dprintf(LOG_ERR, FNAME, "bind(control sock): %s",
++ debug_printf(LOG_ERR, FNAME, "bind(control sock): %s",
+ strerror(errno));
+ goto fail;
+ }
+ freeaddrinfo(res);
+ if (listen(ctlsock, 1)) {
+- dprintf(LOG_ERR, FNAME, "listen(control sock): %s",
++ debug_printf(LOG_ERR, FNAME, "listen(control sock): %s",
+ strerror(errno));
+ goto fail;
+ }
+@@ -126,7 +126,7 @@ dhcp6_ctl_init(addr, port, max, sockp)
+ TAILQ_INIT(&commandqueue_head);
+
+ if (max <= 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "invalid maximum number of commands (%d)", max_commands);
+ goto fail;
+ }
+@@ -159,27 +159,27 @@ dhcp6_ctl_authinit(keyfile, keyinfop, digestlenp)
+ *digestlenp = MD5_DIGESTLENGTH;
+
+ if ((fp = fopen(keyfile, "r")) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to open %s: %s", keyfile,
++ debug_printf(LOG_ERR, FNAME, "failed to open %s: %s", keyfile,
+ strerror(errno));
+ return (-1);
+ }
+ if (fgets(line, sizeof(line), fp) == NULL && ferror(fp)) {
+- dprintf(LOG_ERR, FNAME, "failed to read key file: %s",
++ debug_printf(LOG_ERR, FNAME, "failed to read key file: %s",
+ strerror(errno));
+ goto fail;
+ }
+ if ((secretlen = base64_decodestring(line, secret, sizeof(secret)))
+ < 0) {
+- dprintf(LOG_ERR, FNAME, "failed to decode base64 string");
++ debug_printf(LOG_ERR, FNAME, "failed to decode base64 string");
+ goto fail;
+ }
+ if ((ctlkey = malloc(sizeof(*ctlkey))) == NULL) {
+- dprintf(LOG_WARNING, FNAME, "failed to allocate control key");
++ debug_printf(LOG_WARNING, FNAME, "failed to allocate control key");
+ goto fail;
+ }
+ memset(ctlkey, 0, sizeof(*ctlkey));
+ if ((ctlkey->secret = malloc(secretlen)) == NULL) {
+- dprintf(LOG_WARNING, FNAME, "failed to allocate secret key");
++ debug_printf(LOG_WARNING, FNAME, "failed to allocate secret key");
+ goto fail;
+ }
+ ctlkey->secretlen = (size_t)secretlen;
+@@ -214,24 +214,24 @@ dhcp6_ctl_acceptcommand(sl, callback)
+
+ fromlen = sizeof(from_ss);
+ if ((s = accept(sl, from, &fromlen)) < 0) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to accept control connection: %s",
+ strerror(errno));
+ return (-1);
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "accept control connection from %s",
++ debug_printf(LOG_DEBUG, FNAME, "accept control connection from %s",
+ addr2str(from));
+
+ if (max_commands <= 0) {
+- dprintf(LOG_ERR, FNAME, "command queue is not initialized");
++ debug_printf(LOG_ERR, FNAME, "command queue is not initialized");
+ close(s);
+ return (-1);
+ }
+
+ new = malloc(sizeof(*new));
+ if (new == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to allocate new command context");
+ goto fail;
+ }
+@@ -240,7 +240,7 @@ dhcp6_ctl_acceptcommand(sl, callback)
+ if (commands == max_commands) {
+ ctx = TAILQ_FIRST(&commandqueue_head);
+
+- dprintf(LOG_INFO, FNAME, "command queue is full. "
++ debug_printf(LOG_INFO, FNAME, "command queue is full. "
+ "drop the oldest one (fd=%d)", ctx->s);
+
+ TAILQ_REMOVE(&commandqueue_head, ctx, link);
+@@ -271,7 +271,7 @@ dhcp6_ctl_closecommand(ctx)
+ free(ctx);
+
+ if (commands == 0) {
+- dprintf(LOG_ERR, FNAME, "assumption error: "
++ debug_printf(LOG_ERR, FNAME, "assumption error: "
+ "command queue is empty?");
+ exit(1); /* XXX */
+ }
+@@ -299,12 +299,12 @@ dhcp6_ctl_readcommand(read_fds)
+
+ cc = read(ctx->s, cp, resid);
+ if (cc < 0) {
+- dprintf(LOG_WARNING, FNAME, "read failed: %s",
++ debug_printf(LOG_WARNING, FNAME, "read failed: %s",
+ strerror(errno));
+ goto closecommand;
+ }
+ if (cc == 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "control channel was reset by peer");
+ goto closecommand;
+ }
+@@ -330,7 +330,7 @@ dhcp6_ctl_readcommand(read_fds)
+ break;
+ }
+ } else if (ctx->input_len > sizeof(ctx->inputbuf)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "too large command (%d bytes)",
+ ctx->input_len);
+ goto closecommand;
+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);
+
+diff --git a/dhcp6c_ia.c b/dhcp6c_ia.c
+index 6877c20..1dc37d3 100644
+--- a/dhcp6c_ia.c
++++ b/dhcp6c_ia.c
+@@ -122,7 +122,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ * We apply the same rule to IA_PD as well.
+ */
+ if (iav->val_ia.t2 != 0 && iav->val_ia.t1 > iav->val_ia.t2) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "invalid IA: T1(%lu) > T2(%lu)",
+ iav->val_ia.t1, iav->val_ia.t2);
+ continue;
+@@ -131,14 +131,14 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ /* locate the local IA or make a new one */
+ ia = get_ia(iatype, ifp, iac, iav, serverid);
+ if (ia == NULL) {
+- dprintf(LOG_WARNING, FNAME, "failed to get an IA "
++ debug_printf(LOG_WARNING, FNAME, "failed to get an IA "
+ "type: %s, ID: %u", iastr(iac->type), iac->iaid);
+ continue;
+ }
+
+ /* update authentication parameters */
+ if (update_authparam(ia, authparam)) {
+- dprintf(LOG_WARNING, FNAME, "failed to update "
++ debug_printf(LOG_WARNING, FNAME, "failed to update "
+ "authentication param for IA "
+ "type: %s, ID: %u", iastr(iac->type), iac->iaid);
+ remove_ia(ia);
+@@ -155,7 +155,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ if (update_prefix(ia, &siav->val_prefix6,
+ &iapdc->iapd_pif_list, ifp, &ia->ctl,
+ callback)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to update a prefix %s/%d",
+ in6addr2str(&siav->val_prefix6.addr, 0),
+ siav->val_prefix6.plen);
+@@ -165,13 +165,13 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ ianac = (struct iana_conf *)iac;
+ if (update_address(ia, &siav->val_statefuladdr6,
+ ifp, &ia->ctl, callback)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to update an address %s",
+ in6addr2str(&siav->val_statefuladdr6.addr, 0));
+ }
+ break;
+ case DHCP6_LISTVAL_STCODE:
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "status code for %s-%lu: %s",
+ iastr(iatype), iav->val_ia.iaid,
+ dhcp6_stcodestr(siav->val_num16));
+@@ -187,7 +187,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ * [RFC3315 18.1.8]
+ * XXX: what about the PD case?
+ */
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "receive NoBinding against "
+ "renew/rebind for %s-%lu",
+ iastr(ia->conf->type),
+@@ -197,14 +197,14 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "impossible case");
++ debug_printf(LOG_ERR, FNAME, "impossible case");
+ goto nextia;
+ }
+ }
+
+ /* see if this IA is still valid. if not, remove it. */
+ if (ia->ctl == NULL || !(*ia->ctl->isvalid)(ia->ctl)) {
+- dprintf(LOG_DEBUG, FNAME, "IA %s-%lu is invalidated",
++ debug_printf(LOG_DEBUG, FNAME, "IA %s-%lu is invalidated",
+ iastr(ia->conf->type), ia->conf->iaid);
+ remove_ia(ia);
+ continue;
+@@ -236,7 +236,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ if (ia->t1 > ia->t2)
+ ia->t1 = ia->t2 * 5 / 8;
+
+- dprintf(LOG_INFO, FNAME, "T1(%lu) and/or T2(%lu) "
++ debug_printf(LOG_INFO, FNAME, "T1(%lu) and/or T2(%lu) "
+ "is locally determined", ia->t1, ia->t2);
+ }
+
+@@ -246,11 +246,11 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ * without renewal.
+ */
+ if (ia->t2 < DHCP6_DURATION_MIN) {
+- dprintf(LOG_INFO, FNAME, "T1 (%lu) or T2 (%lu) "
++ debug_printf(LOG_INFO, FNAME, "T1 (%lu) or T2 (%lu) "
+ "is too small", ia->t1, ia->t2);
+ ia->t2 = DHCP6_DURATION_MIN;
+ ia->t1 = ia->t2 * 5 / 8;
+- dprintf(LOG_INFO, "", " adjusted to %lu and %lu",
++ debug_printf(LOG_INFO, "", " adjusted to %lu and %lu",
+ ia->t1, ia->t2);
+ }
+
+@@ -262,7 +262,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
+ if (ia->timer == NULL)
+ ia->timer = dhcp6_add_timer(ia_timo, ia);
+ if (ia->timer == NULL) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to add IA timer");
+ remove_ia(ia); /* XXX */
+ continue;
+@@ -289,7 +289,7 @@ update_authparam(ia, authparam)
+
+ if (ia->authparam == NULL) {
+ if ((ia->authparam = copy_authparam(authparam)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to copy authparam");
+ return (-1);
+ }
+@@ -311,11 +311,11 @@ reestablish_ia(ia)
+ struct dhcp6_event *ev;
+ struct dhcp6_eventdata *evd;
+
+- dprintf(LOG_DEBUG, FNAME, "re-establishing IA: %s-%lu",
++ debug_printf(LOG_DEBUG, FNAME, "re-establishing IA: %s-%lu",
+ iastr(ia->conf->type), ia->conf->iaid);
+
+ if (ia->state != IAS_RENEW && ia->state != IAS_REBIND) {
+- dprintf(LOG_ERR, FNAME, "internal error (invalid IA status)");
++ debug_printf(LOG_ERR, FNAME, "internal error (invalid IA status)");
+ exit(1); /* XXX */
+ }
+
+@@ -333,19 +333,19 @@ reestablish_ia(ia)
+ dhcp6_remove_timer(&ia->timer);
+
+ if ((ev = dhcp6_create_event(ia->ifp, DHCP6S_REQUEST)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to create a new event");
++ debug_printf(LOG_NOTICE, FNAME, "failed to create a new event");
+ goto fail;
+ }
+ TAILQ_INSERT_TAIL(&ia->ifp->event_list, ev, link);
+
+ if ((ev->timer = dhcp6_add_timer(client6_timo, ev)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event timer");
+ goto fail;
+ }
+
+ if ((evd = malloc(sizeof(*evd))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event data");
+ goto fail;
+ }
+@@ -354,7 +354,7 @@ reestablish_ia(ia)
+ TAILQ_INSERT_TAIL(&ev->data_list, evd, link);
+
+ if (duidcpy(&ev->serverid, &ia->serverid)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to copy server ID");
++ debug_printf(LOG_NOTICE, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+
+@@ -365,7 +365,7 @@ reestablish_ia(ia)
+ if (ia->ctl && ia->ctl->reestablish_data) {
+ if ((*ia->ctl->reestablish_data)(ia->ctl, &iaparam,
+ &ia->evdata, evd)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make reestablish data");
+ goto fail;
+ }
+@@ -373,7 +373,7 @@ reestablish_ia(ia)
+
+ if (ia->authparam != NULL) {
+ if ((ev->authparam = copy_authparam(ia->authparam)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to copy authparam");
+ goto fail;
+ }
+@@ -402,7 +402,7 @@ callback(ia)
+ {
+ /* see if this IA is still valid. if not, remove it. */
+ if (ia->ctl == NULL || !(*ia->ctl->isvalid)(ia->ctl)) {
+- dprintf(LOG_DEBUG, FNAME, "IA %s-%lu is invalidated",
++ debug_printf(LOG_DEBUG, FNAME, "IA %s-%lu is invalidated",
+ iastr(ia->conf->type), ia->conf->iaid);
+ remove_ia(ia);
+ }
+@@ -441,30 +441,30 @@ release_ia(ia)
+ struct dhcp6_event *ev;
+ struct dhcp6_eventdata *evd;
+
+- dprintf(LOG_DEBUG, FNAME, "release an IA: %s-%lu",
++ debug_printf(LOG_DEBUG, FNAME, "release an IA: %s-%lu",
+ iastr(ia->conf->type), ia->conf->iaid);
+
+ if ((ev = dhcp6_create_event(ia->ifp, DHCP6S_RELEASE))
+ == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to create a new event");
++ debug_printf(LOG_NOTICE, FNAME, "failed to create a new event");
+ goto fail;
+ }
+ TAILQ_INSERT_TAIL(&ia->ifp->event_list, ev, link);
+
+
+ if ((ev->timer = dhcp6_add_timer(client6_timo, ev)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event timer");
+ goto fail;
+ }
+
+ if (duidcpy(&ev->serverid, &ia->serverid)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to copy server ID");
++ debug_printf(LOG_NOTICE, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+
+ if ((evd = malloc(sizeof(*evd))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event data");
+ goto fail;
+ }
+@@ -476,7 +476,7 @@ release_ia(ia)
+
+ if (ia->ctl && ia->ctl->release_data) {
+ if ((*ia->ctl->release_data)(ia->ctl, &iaparam, NULL, evd)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make release data");
+ goto fail;
+ }
+@@ -489,7 +489,7 @@ release_ia(ia)
+
+ if (ia->authparam != NULL) {
+ if ((ev->authparam = copy_authparam(ia->authparam)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to copy authparam");
+ goto fail;
+ }
+@@ -513,7 +513,7 @@ remove_ia(ia)
+ struct ia_conf *iac = ia->conf;
+ struct dhcp6_if *ifp = ia->ifp;
+
+- dprintf(LOG_DEBUG, FNAME, "remove an IA: %s-%lu",
++ debug_printf(LOG_DEBUG, FNAME, "remove an IA: %s-%lu",
+ iastr(ia->conf->type), ia->conf->iaid);
+
+ TAILQ_REMOVE(&iac->iadata, ia, link);
+@@ -553,7 +553,7 @@ ia_timo(arg)
+ struct timeval timo;
+ int dhcpstate;
+
+- dprintf(LOG_DEBUG, FNAME, "IA timeout for %s-%lu, state=%s",
++ debug_printf(LOG_DEBUG, FNAME, "IA timeout for %s-%lu, state=%s",
+ iastr(ia->conf->type), ia->conf->iaid, statestr(ia->state));
+
+ /* cancel the current event for the prefix. */
+@@ -586,25 +586,25 @@ ia_timo(arg)
+ dhcp6_remove_timer(&ia->timer);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "invalid IA state (%d)",
++ debug_printf(LOG_ERR, FNAME, "invalid IA state (%d)",
+ (int)ia->state);
+ return (NULL); /* XXX */
+ }
+
+ if ((ev = dhcp6_create_event(ia->ifp, dhcpstate)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to create a new event");
++ debug_printf(LOG_NOTICE, FNAME, "failed to create a new event");
+ goto fail;
+ }
+ TAILQ_INSERT_TAIL(&ia->ifp->event_list, ev, link);
+
+ if ((ev->timer = dhcp6_add_timer(client6_timo, ev)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event timer");
+ goto fail;
+ }
+
+ if ((evd = malloc(sizeof(*evd))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to create a new event data");
+ goto fail;
+ }
+@@ -614,7 +614,7 @@ ia_timo(arg)
+
+ if (ia->state == IAS_RENEW) {
+ if (duidcpy(&ev->serverid, &ia->serverid)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to copy server ID");
++ debug_printf(LOG_NOTICE, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ }
+@@ -627,7 +627,7 @@ ia_timo(arg)
+ if (ia->ctl && ia->ctl->renew_data) {
+ if ((*ia->ctl->renew_data)(ia->ctl, &iaparam,
+ &ia->evdata, evd)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make renew data");
+ goto fail;
+ }
+@@ -637,7 +637,7 @@ ia_timo(arg)
+ if (ia->ctl && ia->ctl->rebind_data) {
+ if ((*ia->ctl->rebind_data)(ia->ctl, &iaparam,
+ &ia->evdata, evd)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make rebind data");
+ goto fail;
+ }
+@@ -653,7 +653,7 @@ ia_timo(arg)
+
+ if (ia->authparam != NULL) {
+ if ((ev->authparam = copy_authparam(ia->authparam)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to copy authparam");
+ goto fail;
+ }
+@@ -693,13 +693,13 @@ get_ia(type, ifp, iac, iaparam, serverid)
+ int create = 0;
+
+ if (duidcpy(&newserver, serverid)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to copy server ID");
++ debug_printf(LOG_NOTICE, FNAME, "failed to copy server ID");
+ return (NULL);
+ }
+
+ if ((ia = find_ia(iac, type, iaparam->val_ia.iaid)) == NULL) {
+ if ((ia = malloc(sizeof(*ia))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "memory allocation failed");
++ debug_printf(LOG_NOTICE, FNAME, "memory allocation failed");
+ duidfree(&newserver); /* XXX */
+ return (NULL);
+ }
+@@ -718,7 +718,7 @@ get_ia(type, ifp, iac, iaparam, serverid)
+ ia->ifp = ifp;
+ ia->serverid = newserver;
+
+- dprintf(LOG_DEBUG, FNAME, "%s an IA: %s-%lu",
++ debug_printf(LOG_DEBUG, FNAME, "%s an IA: %s-%lu",
+ create ? "make" : "update", iastr(type), ia->conf->iaid);
+
+ return (ia);
+diff --git a/dhcp6c_script.c b/dhcp6c_script.c
+index 05ccf8c..583ac7d 100644
+--- a/dhcp6c_script.c
++++ b/dhcp6c_script.c
+@@ -156,7 +156,7 @@ client6_script(scriptpath, state, optinfo)
+
+ /* allocate an environments array */
+ if ((envp = malloc(sizeof (char *) * envc)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate environment buffer");
+ return -1;
+ }
+@@ -168,7 +168,7 @@ client6_script(scriptpath, state, optinfo)
+ i = 0;
+ /* reason */
+ if ((envp[i++] = strdup(reason)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate reason strings");
+ ret = -1;
+ goto clean;
+@@ -178,7 +178,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (dnsserver_str) +
+ (INET6_ADDRSTRLEN + 1) * dnsservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for DNS servers");
+ ret = -1;
+ goto clean;
+@@ -198,7 +198,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (ntpserver_str) +
+ (INET6_ADDRSTRLEN + 1) * ntpservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for NTP servers");
+ ret = -1;
+ goto clean;
+@@ -218,7 +218,7 @@ client6_script(scriptpath, state, optinfo)
+ if (dnsnamelen) {
+ elen = sizeof (dnsname_str) + dnsnamelen + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for DNS name");
+ ret = -1;
+ goto clean;
+@@ -236,7 +236,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (sipserver_str) +
+ (INET6_ADDRSTRLEN + 1) * sipservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for SIP servers");
+ ret = -1;
+ goto clean;
+@@ -255,7 +255,7 @@ client6_script(scriptpath, state, optinfo)
+ if (sipnamelen) {
+ elen = sizeof (sipname_str) + sipnamelen + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for SIP domain name");
+ ret = -1;
+ goto clean;
+@@ -273,7 +273,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (nisserver_str) +
+ (INET6_ADDRSTRLEN + 1) * nisservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for NIS servers");
+ ret = -1;
+ goto clean;
+@@ -292,7 +292,7 @@ client6_script(scriptpath, state, optinfo)
+ if (nisnamelen) {
+ elen = sizeof (nisname_str) + nisnamelen + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for NIS domain name");
+ ret = -1;
+ goto clean;
+@@ -310,7 +310,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (nispserver_str) +
+ (INET6_ADDRSTRLEN + 1) * nispservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for NIS+ servers");
+ ret = -1;
+ goto clean;
+@@ -329,7 +329,7 @@ client6_script(scriptpath, state, optinfo)
+ if (nispnamelen) {
+ elen = sizeof (nispname_str) + nispnamelen + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for NIS+ domain name");
+ ret = -1;
+ goto clean;
+@@ -347,7 +347,7 @@ client6_script(scriptpath, state, optinfo)
+ elen = sizeof (bcmcsserver_str) +
+ (INET6_ADDRSTRLEN + 1) * bcmcsservers + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for BCMC servers");
+ ret = -1;
+ goto clean;
+@@ -366,7 +366,7 @@ client6_script(scriptpath, state, optinfo)
+ if (bcmcsnamelen) {
+ elen = sizeof (bcmcsname_str) + bcmcsnamelen + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate strings for BCMC domain name");
+ ret = -1;
+ goto clean;
+@@ -383,7 +383,7 @@ client6_script(scriptpath, state, optinfo)
+ /* launch the script */
+ pid = fork();
+ if (pid < 0) {
+- dprintf(LOG_ERR, FNAME, "failed to fork: %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "failed to fork: %s", strerror(errno));
+ ret = -1;
+ goto clean;
+ } else if (pid) {
+@@ -394,9 +394,9 @@ client6_script(scriptpath, state, optinfo)
+ } while (wpid != pid && wpid > 0);
+
+ if (wpid < 0)
+- dprintf(LOG_ERR, FNAME, "wait: %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "wait: %s", strerror(errno));
+ else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "script \"%s\" terminated", scriptpath);
+ }
+ } else {
+@@ -407,7 +407,7 @@ client6_script(scriptpath, state, optinfo)
+ argv[1] = NULL;
+
+ if (safefile(scriptpath)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "script \"%s\" cannot be executed safely",
+ scriptpath);
+ exit(1);
+@@ -423,7 +423,7 @@ client6_script(scriptpath, state, optinfo)
+
+ execve(scriptpath, argv, envp);
+
+- dprintf(LOG_ERR, FNAME, "child: exec failed: %s",
++ debug_printf(LOG_ERR, FNAME, "child: exec failed: %s",
+ strerror(errno));
+ exit(0);
+ }
+diff --git a/dhcp6relay.c b/dhcp6relay.c
+index eb0bce9..99b1227 100644
+--- a/dhcp6relay.c
++++ b/dhcp6relay.c
+@@ -228,7 +228,7 @@ main(argc, argv)
+
+ relay6_init(argc, argv);
+
+- dprintf(LOG_INFO, FNAME, "dhcp6relay started");
++ debug_printf(LOG_INFO, FNAME, "dhcp6relay started");
+ relay6_loop();
+
+ exit(0);
+@@ -246,7 +246,7 @@ make_prefix(pstr0)
+
+ /* make a local copy for safety */
+ if (strlcpy(pstr, pstr0, sizeof (pstr)) >= sizeof (pstr)) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "prefix string too long (maybe bogus): %s", pstr0);
+ return (NULL);
+ }
+@@ -256,27 +256,27 @@ make_prefix(pstr0)
+ plen = 128; /* assumes it as a host prefix */
+ else {
+ if (p[1] == '\0') {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "no prefix length (ignored): %s", p + 1);
+ return (NULL);
+ }
+ plen = (int)strtoul(p + 1, &ep, 10);
+ if (*ep != '\0') {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "illegal prefix length (ignored): %s", p + 1);
+ return (NULL);
+ }
+ *p = '\0';
+ }
+ if (inet_pton(AF_INET6, pstr, &paddr) != 1) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "inet_pton failed for %s", pstr);
+ return (NULL);
+ }
+
+ /* allocate a new entry */
+ if ((pent = (struct prefix_list *)malloc(sizeof (*pent))) == NULL) {
+- dprintf(LOG_WARNING, FNAME, "memory allocation failed");
++ debug_printf(LOG_WARNING, FNAME, "memory allocation failed");
+ return (NULL); /* or abort? */
+ }
+
+@@ -318,14 +318,14 @@ relay6_init(int ifnum, char *iflist[])
+ hints.ai_flags = AI_PASSIVE;
+ error = getaddrinfo(serveraddr, DH6PORT_UPSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ goto failexit;
+ }
+ if (res->ai_family != PF_INET6 ||
+ res->ai_addrlen < sizeof (sa6_server)) {
+ /* this should be impossible, but check for safety */
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "getaddrinfo returned a bogus address: %s",
+ strerror(errno));
+ goto failexit;
+@@ -341,7 +341,7 @@ relay6_init(int ifnum, char *iflist[])
+ rmh.msg_iovlen = 1;
+ rmsgctllen = CMSG_SPACE(sizeof (struct in6_pktinfo));
+ if ((rmsgctlbuf = (char *)malloc(rmsgctllen)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ goto failexit;
+ }
+
+@@ -355,13 +355,13 @@ relay6_init(int ifnum, char *iflist[])
+ hints.ai_flags = AI_PASSIVE;
+ error = getaddrinfo(NULL, DH6PORT_UPSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ goto failexit;
+ }
+ csock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (csock < 0) {
+- dprintf(LOG_ERR, FNAME, "socket(csock): %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "socket(csock): %s", strerror(errno));
+ goto failexit;
+ }
+ if (csock > maxfd)
+@@ -369,20 +369,20 @@ relay6_init(int ifnum, char *iflist[])
+ on = 1;
+ if (setsockopt(csock, SOL_SOCKET, SO_REUSEPORT,
+ &on, sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(csock, SO_REUSEPORT): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(csock, SO_REUSEPORT): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #ifdef IPV6_V6ONLY
+ if (setsockopt(csock, IPPROTO_IPV6, IPV6_V6ONLY,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(csock, IPV6_V6ONLY): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(csock, IPV6_V6ONLY): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #endif
+ if (bind(csock, res->ai_addr, res->ai_addrlen) < 0) {
+- dprintf(LOG_ERR, FNAME, "bind(csock): %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "bind(csock): %s", strerror(errno));
+ goto failexit;
+ }
+ freeaddrinfo(res);
+@@ -390,14 +390,14 @@ relay6_init(int ifnum, char *iflist[])
+ #ifdef IPV6_RECVPKTINFO
+ if (setsockopt(csock, IPPROTO_IPV6, IPV6_RECVPKTINFO,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(IPV6_RECVPKTINFO): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(IPV6_RECVPKTINFO): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #else
+ if (setsockopt(csock, IPPROTO_IPV6, IPV6_PKTINFO,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(IPV6_PKTINFO): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(IPV6_PKTINFO): %s",
+ strerror(errno));
+ goto failexit;
+ }
+@@ -406,7 +406,7 @@ relay6_init(int ifnum, char *iflist[])
+ hints.ai_flags = 0;
+ error = getaddrinfo(DH6ADDR_ALLAGENT, 0, &hints, &res2);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ goto failexit;
+ }
+@@ -422,21 +422,21 @@ relay6_init(int ifnum, char *iflist[])
+
+ ifd = (struct ifid_list *)malloc(sizeof (*ifd));
+ if (ifd == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "memory allocation failed");
+ goto failexit;
+ }
+ memset(ifd, 0, sizeof (*ifd));
+ ifd->ifid = if_nametoindex(ifp);
+ if (ifd->ifid == 0) {
+- dprintf(LOG_ERR, FNAME, "invalid interface %s", ifp);
++ debug_printf(LOG_ERR, FNAME, "invalid interface %s", ifp);
+ goto failexit;
+ }
+ mreq6.ipv6mr_interface = ifd->ifid;
+
+ if (setsockopt(csock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &mreq6, sizeof (mreq6))) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(csock, IPV6_JOIN_GROUP): %s",
+ strerror(errno));
+ goto failexit;
+@@ -451,7 +451,7 @@ relay6_init(int ifnum, char *iflist[])
+ */
+ relayifid = if_nametoindex(relaydevice);
+ if (relayifid == 0)
+- dprintf(LOG_ERR, FNAME, "invalid interface %s", relaydevice);
++ debug_printf(LOG_ERR, FNAME, "invalid interface %s", relaydevice);
+ /*
+ * We are not really sure if we need to listen on the downstream
+ * port to receive packets from servers. We'll need to clarify the
+@@ -460,14 +460,14 @@ relay6_init(int ifnum, char *iflist[])
+ hints.ai_flags = AI_PASSIVE;
+ error = getaddrinfo(boundaddr, DH6PORT_DOWNSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ goto failexit;
+ }
+ memcpy(&sa6_client, res->ai_addr, sizeof (sa6_client));
+ ssock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (ssock < 0) {
+- dprintf(LOG_ERR, FNAME, "socket(outsock): %s",
++ debug_printf(LOG_ERR, FNAME, "socket(outsock): %s",
+ strerror(error));
+ goto failexit;
+ }
+@@ -480,7 +480,7 @@ relay6_init(int ifnum, char *iflist[])
+ */
+ if (setsockopt(ssock, SOL_SOCKET, SO_REUSEPORT,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(ssock, SO_REUSEPORT): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(ssock, SO_REUSEPORT): %s",
+ strerror(errno));
+ goto failexit;
+ }
+@@ -488,13 +488,13 @@ relay6_init(int ifnum, char *iflist[])
+ #ifdef IPV6_V6ONLY
+ if (setsockopt(ssock, IPPROTO_IPV6, IPV6_V6ONLY,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(ssock, IPV6_V6ONLY): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(ssock, IPV6_V6ONLY): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #endif
+ if (bind(ssock, res->ai_addr, res->ai_addrlen) < 0) {
+- dprintf(LOG_ERR, FNAME, "bind(ssock): %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "bind(ssock): %s", strerror(errno));
+ goto failexit;
+ }
+ freeaddrinfo(res);
+@@ -503,21 +503,21 @@ relay6_init(int ifnum, char *iflist[])
+ #ifdef IPV6_RECVPKTINFO
+ if (setsockopt(ssock, IPPROTO_IPV6, IPV6_RECVPKTINFO,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(IPV6_RECVPKTINFO): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(IPV6_RECVPKTINFO): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #else
+ if (setsockopt(ssock, IPPROTO_IPV6, IPV6_PKTINFO,
+ &on, sizeof (on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(IPV6_PKTINFO): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(IPV6_PKTINFO): %s",
+ strerror(errno));
+ goto failexit;
+ }
+ #endif
+
+ if (signal(SIGTERM, relay6_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);
+ }
+@@ -605,15 +605,15 @@ relay6_recv(s, fromclient)
+ rmh.msg_namelen = sizeof (from);
+
+ if ((len = recvmsg(s, &rmh, 0)) < 0) {
+- dprintf(LOG_WARNING, FNAME, "recvmsg: %s", strerror(errno));
++ debug_printf(LOG_WARNING, FNAME, "recvmsg: %s", strerror(errno));
+ return;
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "from %s, size %d",
++ debug_printf(LOG_DEBUG, FNAME, "from %s, size %d",
+ addr2str((struct sockaddr *)&from), len);
+
+ if (((struct sockaddr *)&from)->sa_family != AF_INET6) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "non-IPv6 packet is received (AF %d) ",
+ ((struct sockaddr *)&from)->sa_family);
+ return;
+@@ -632,7 +632,7 @@ relay6_recv(s, fromclient)
+ }
+ }
+ if (pi == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to get the arrival interface");
+ return;
+ }
+@@ -649,7 +649,7 @@ relay6_recv(s, fromclient)
+ if (ifd == NULL && pi->ipi6_ifindex != relayifid)
+ return;
+ if (if_indextoname(pi->ipi6_ifindex, ifname) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "if_indextoname(id = %d): %s",
+ pi->ipi6_ifindex, strerror(errno));
+ return;
+@@ -657,12 +657,12 @@ relay6_recv(s, fromclient)
+
+ /* packet validation */
+ 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 *)rdatabuf;
+- dprintf(LOG_DEBUG, FNAME, "received %s from %s",
++ debug_printf(LOG_DEBUG, FNAME, "received %s from %s",
+ dhcp6msgstr(dh6->dh6_msgtype), addr2str((struct sockaddr *)&from));
+
+ /*
+@@ -694,7 +694,7 @@ relay6_recv(s, fromclient)
+ (struct sockaddr *)&from);
+ break;
+ default:
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unexpected message (%s) on the client side "
+ "from %s", dhcp6msgstr(dh6->dh6_msgtype),
+ addr2str((struct sockaddr *)&from));
+@@ -702,7 +702,7 @@ relay6_recv(s, fromclient)
+ }
+ } else {
+ if (dh6->dh6_msgtype != DH6_RELAY_REPLY) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unexpected message (%s) on the server side"
+ "from %s", dhcp6msgstr(dh6->dh6_msgtype),
+ addr2str((struct sockaddr *)&from));
+@@ -787,7 +787,7 @@ relay_to_server(dh6, len, from, ifname, ifid)
+
+ /* Relay message */
+ if ((optinfo.relaymsg_msg = malloc(len)) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to allocate memory to copy the original packet: "
+ "%s", strerror(errno));
+ goto out;
+@@ -797,7 +797,7 @@ relay_to_server(dh6, len, from, ifname, ifid)
+
+ /* Interface-id. We always use this option. */
+ if ((optinfo.ifidopt_id = malloc(sizeof (ifid))) == NULL) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to allocate memory for IFID: %s", strerror(errno));
+ goto out;
+ }
+@@ -823,7 +823,7 @@ relay_to_server(dh6, len, from, ifname, ifid)
+ break;
+ }
+ if (p == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to find a global address on %s", ifname);
+
+ /*
+@@ -848,7 +848,7 @@ relay_to_server(dh6, len, from, ifname, ifid)
+ * [RFC3315 Section 20.1.2]
+ */
+ if (dh6relay0->dh6relay_hcnt >= DHCP6_RELAY_HOP_COUNT_LIMIT) {
+- dprintf(LOG_INFO, FNAME, "too many relay forwardings");
++ debug_printf(LOG_INFO, FNAME, "too many relay forwardings");
+ goto out;
+ }
+
+@@ -871,7 +871,7 @@ relay_to_server(dh6, len, from, ifname, ifid)
+ (struct dhcp6opt *)(dh6relay + 1),
+ (struct dhcp6opt *)(relaybuf + sizeof (relaybuf)),
+ &optinfo)) < 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "failed to construct relay options");
+ goto out;
+ }
+@@ -892,22 +892,22 @@ relay_to_server(dh6, len, from, ifname, ifid)
+ pktinfo.ipi6_ifindex = relayifid;
+ if (make_msgcontrol(&mh, ctlbuf, sizeof (ctlbuf),
+ &pktinfo, mhops)) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to make message control data");
+ goto out;
+ }
+ }
+
+ if ((cc = sendmsg(ssock, &mh, 0)) < 0) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "sendmsg %s failed: %s",
+ addr2str((struct sockaddr *)&sa6_server), strerror(errno));
+ } else if (cc != relaylen) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to send a complete packet to %s",
+ addr2str((struct sockaddr *)&sa6_server));
+ } else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "relay a message to a server %s",
+ addr2str((struct sockaddr *)&sa6_server));
+ }
+@@ -934,7 +934,7 @@ relay_to_client(dh6relay, len, from)
+ static struct iovec iov[2];
+ char ctlbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
+
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "dhcp6 relay reply: hop=%d, linkaddr=%s, peeraddr=%s",
+ dh6relay->dh6relay_hcnt,
+ in6addr2str(&dh6relay->dh6relay_linkaddr, 0),
+@@ -946,20 +946,20 @@ relay_to_client(dh6relay, len, from)
+ dhcp6_init_options(&optinfo);
+ if (dhcp6_get_options((struct dhcp6opt *)(dh6relay + 1),
+ (struct dhcp6opt *)((char *)dh6relay + len), &optinfo) < 0) {
+- dprintf(LOG_INFO, FNAME, "failed to parse options");
++ debug_printf(LOG_INFO, FNAME, "failed to parse options");
+ return;
+ }
+
+ /* A relay reply message must include a relay message option */
+ if (optinfo.relaymsg_msg == NULL) {
+- dprintf(LOG_INFO, FNAME, "relay reply message from %s "
++ debug_printf(LOG_INFO, FNAME, "relay reply message from %s "
+ "without a relay message", addr2str(from));
+ goto out;
+ }
+
+ /* minimum validation for the inner message */
+ if (optinfo.relaymsg_len < sizeof (struct dhcp6)) {
+- dprintf(LOG_INFO, FNAME, "short relay message from %s",
++ debug_printf(LOG_INFO, FNAME, "short relay message from %s",
+ addr2str(from));
+ goto out;
+ }
+@@ -971,7 +971,7 @@ relay_to_client(dh6relay, len, from)
+ ifid = 0;
+ if (optinfo.ifidopt_id) {
+ if (optinfo.ifidopt_len != sizeof (ifid)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unexpected length (%d) for Interface ID from %s",
+ optinfo.ifidopt_len, addr2str(from));
+ goto out;
+@@ -981,13 +981,13 @@ relay_to_client(dh6relay, len, from)
+
+ /* validation for ID */
+ if ((if_indextoname(ifid, ifnamebuf)) == NULL) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "invalid interface ID: %x", ifid);
+ goto out;
+ }
+ }
+ } else {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "Interface ID is not included from %s", addr2str(from));
+ /*
+ * the responding server should be buggy, but we deal with it.
+@@ -1005,7 +1005,7 @@ relay_to_client(dh6relay, len, from)
+ }
+
+ if (ifid == 0) {
+- dprintf(LOG_INFO, FNAME, "failed to determine relay link");
++ debug_printf(LOG_INFO, FNAME, "failed to determine relay link");
+ goto out;
+ }
+
+@@ -1036,22 +1036,22 @@ relay_to_client(dh6relay, len, from)
+ memset(&pktinfo, 0, sizeof (pktinfo));
+ pktinfo.ipi6_ifindex = ifid;
+ if (make_msgcontrol(&mh, ctlbuf, sizeof (ctlbuf), &pktinfo, 0)) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to make message control data");
+ goto out;
+ }
+
+ /* send packet */
+ if ((cc = sendmsg(csock, &mh, 0)) < 0) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "sendmsg to %s failed: %s",
+ addr2str((struct sockaddr *)&peer), strerror(errno));
+ } else if (cc != optinfo.relaymsg_len) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "failed to send a complete packet to %s",
+ addr2str((struct sockaddr *)&peer));
+ } else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "relay a message to a client %s",
+ addr2str((struct sockaddr *)&peer));
+ }
+diff --git a/dhcp6relay_script.c b/dhcp6relay_script.c
+index 82f5eab..7444b54 100644
+--- a/dhcp6relay_script.c
++++ b/dhcp6relay_script.c
+@@ -87,7 +87,7 @@ relay6_script(scriptpath, client, dh6, len)
+ /* only replies are interesting */
+ if (dh6->dh6_msgtype != DH6_REPLY) {
+ if (dh6->dh6_msgtype != DH6_ADVERTISE) {
+- dprintf(LOG_INFO, FNAME, "forward msg#%d to client?",
++ debug_printf(LOG_INFO, FNAME, "forward msg#%d to client?",
+ dh6->dh6_msgtype);
+ return -1;
+ }
+@@ -99,7 +99,7 @@ relay6_script(scriptpath, client, dh6, len)
+ dhcp6_init_options(&optinfo);
+ if (dhcp6_get_options((struct dhcp6opt *)(dh6 + 1), optend,
+ &optinfo) < 0) {
+- dprintf(LOG_INFO, FNAME, "failed to parse options");
++ debug_printf(LOG_INFO, FNAME, "failed to parse options");
+ return -1;
+ }
+
+@@ -118,7 +118,7 @@ relay6_script(scriptpath, client, dh6, len)
+
+ /* allocate an environments array */
+ if ((envp = malloc(sizeof (char *) * envc)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate environment buffer");
+ dhcp6_clear_options(&optinfo);
+ return -1;
+@@ -132,14 +132,14 @@ relay6_script(scriptpath, client, dh6, len)
+ /* address */
+ t = addr2str((struct sockaddr *) client);
+ if (t == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to get address of client");
+ ret = -1;
+ goto clean;
+ }
+ elen = sizeof (client_str) + 1 + strlen(t) + 1;
+ if ((s = envp[i++] = malloc(elen)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate string for client");
+ ret = -1;
+ goto clean;
+@@ -167,7 +167,7 @@ relay6_script(scriptpath, client, dh6, len)
+ /* launch the script */
+ pid = fork();
+ if (pid < 0) {
+- dprintf(LOG_ERR, FNAME, "failed to fork: %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "failed to fork: %s", strerror(errno));
+ ret = -1;
+ goto clean;
+ } else if (pid) {
+@@ -178,9 +178,9 @@ relay6_script(scriptpath, client, dh6, len)
+ } while (wpid != pid && wpid > 0);
+
+ if (wpid < 0)
+- dprintf(LOG_ERR, FNAME, "wait: %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "wait: %s", strerror(errno));
+ else {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "script \"%s\" terminated", scriptpath);
+ }
+ } else {
+@@ -191,7 +191,7 @@ relay6_script(scriptpath, client, dh6, len)
+ argv[1] = NULL;
+
+ if (safefile(scriptpath)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "script \"%s\" cannot be executed safely",
+ scriptpath);
+ exit(1);
+@@ -208,7 +208,7 @@ relay6_script(scriptpath, client, dh6, len)
+
+ execve(scriptpath, argv, envp);
+
+- dprintf(LOG_ERR, FNAME, "child: exec failed: %s",
++ debug_printf(LOG_ERR, FNAME, "child: exec failed: %s",
+ strerror(errno));
+ exit(0);
+ }
+@@ -254,12 +254,12 @@ iapd2str(num, iav)
+ break;
+
+ default:
+- dprintf(LOG_ERR, FNAME, "impossible subopt");
++ debug_printf(LOG_ERR, FNAME, "impossible subopt");
+ }
+ }
+
+ if ((r = strdup(s)) == NULL)
+- dprintf(LOG_ERR, FNAME, "failed to allocate iapd_%d", num);
++ debug_printf(LOG_ERR, FNAME, "failed to allocate iapd_%d", num);
+ return r;
+ }
+
+@@ -294,11 +294,11 @@ iana2str(num, iav)
+ break;
+
+ default:
+- dprintf(LOG_ERR, FNAME, "impossible subopt");
++ debug_printf(LOG_ERR, FNAME, "impossible subopt");
+ }
+ }
+
+ if ((r = strdup(s)) == NULL)
+- dprintf(LOG_ERR, FNAME, "failed to allocate iana_%d", num);
++ debug_printf(LOG_ERR, FNAME, "failed to allocate iana_%d", num);
+ return r;
+ }
+diff --git a/dhcp6s.c b/dhcp6s.c
+index 494e571..ff8b17d 100644
+--- a/dhcp6s.c
++++ b/dhcp6s.c
+@@ -311,7 +311,7 @@ main(argc, argv)
+ exit(1);
+
+ if ((cfparse(conffile)) != 0) {
+- dprintf(LOG_ERR, FNAME, "failed to parse configuration file");
++ debug_printf(LOG_ERR, FNAME, "failed to parse configuration file");
+ exit(1);
+ }
+
+@@ -335,7 +335,7 @@ main(argc, argv)
+ /* prohibit a mixture of old and new style of DNS server config */
+ if (!TAILQ_EMPTY(&arg_dnslist)) {
+ if (!TAILQ_EMPTY(&dnslist)) {
+- dprintf(LOG_INFO, FNAME, "do not specify DNS servers "
++ debug_printf(LOG_INFO, FNAME, "do not specify DNS servers "
+ "both by command line and by configuration file.");
+ exit(1);
+ }
+@@ -374,24 +374,24 @@ server6_init()
+
+ TAILQ_INIT(&dhcp6_binding_head);
+ if (lease_init() != 0) {
+- dprintf(LOG_ERR, FNAME, "failed to initialize the lease table");
++ debug_printf(LOG_ERR, FNAME, "failed to initialize the lease table");
+ exit(1);
+ }
+
+ ifidx = if_nametoindex(device);
+ if (ifidx == 0) {
+- dprintf(LOG_ERR, FNAME, "invalid interface %s", device);
++ debug_printf(LOG_ERR, FNAME, "invalid interface %s", device);
+ exit(1);
+ }
+
+ /* get our DUID */
+ if (get_duid(DUID_FILE, &server_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 to initialize control message authentication");
+ /* run the server anyway */
+ }
+@@ -403,7 +403,7 @@ server6_init()
+ rmh.msg_iovlen = 1;
+ rmsgctllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
+ if ((rmsgctlbuf = (char *)malloc(rmsgctllen)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "memory allocation failed");
++ debug_printf(LOG_ERR, FNAME, "memory allocation failed");
+ exit(1);
+ }
+
+@@ -415,32 +415,32 @@ server6_init()
+ hints.ai_flags = AI_PASSIVE;
+ error = getaddrinfo(NULL, DH6PORT_UPSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ exit(1);
+ }
+ insock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (insock < 0) {
+- dprintf(LOG_ERR, FNAME, "socket(insock): %s",
++ debug_printf(LOG_ERR, FNAME, "socket(insock): %s",
+ strerror(errno));
+ exit(1);
+ }
+ if (setsockopt(insock, SOL_SOCKET, SO_REUSEPORT, &on,
+ sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(insock, SO_REUSEPORT): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(insock, SO_REUSEPORT): %s",
+ strerror(errno));
+ exit(1);
+ }
+ if (setsockopt(insock, SOL_SOCKET, SO_REUSEADDR, &on,
+ sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME, "setsockopt(insock, SO_REUSEADDR): %s",
++ debug_printf(LOG_ERR, FNAME, "setsockopt(insock, SO_REUSEADDR): %s",
+ strerror(errno));
+ exit(1);
+ }
+ #ifdef IPV6_RECVPKTINFO
+ if (setsockopt(insock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
+ sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(inbound, IPV6_RECVPKTINFO): %s",
+ strerror(errno));
+ exit(1);
+@@ -448,7 +448,7 @@ server6_init()
+ #else
+ if (setsockopt(insock, IPPROTO_IPV6, IPV6_PKTINFO, &on,
+ sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(inbound, IPV6_PKTINFO): %s",
+ strerror(errno));
+ exit(1);
+@@ -457,13 +457,13 @@ server6_init()
+ #ifdef IPV6_V6ONLY
+ if (setsockopt(insock, IPPROTO_IPV6, IPV6_V6ONLY,
+ &on, sizeof(on)) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(inbound, IPV6_V6ONLY): %s", strerror(errno));
+ exit(1);
+ }
+ #endif
+ if (bind(insock, res->ai_addr, res->ai_addrlen) < 0) {
+- dprintf(LOG_ERR, FNAME, "bind(insock): %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "bind(insock): %s", strerror(errno));
+ exit(1);
+ }
+ freeaddrinfo(res);
+@@ -471,7 +471,7 @@ server6_init()
+ hints.ai_flags = 0;
+ error = getaddrinfo(DH6ADDR_ALLAGENT, DH6PORT_UPSTREAM, &hints, &res2);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ exit(1);
+ }
+@@ -482,7 +482,7 @@ server6_init()
+ sizeof(mreq6.ipv6mr_multiaddr));
+ if (setsockopt(insock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &mreq6, sizeof(mreq6))) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(insock, IPV6_JOIN_GROUP): %s",
+ strerror(errno));
+ exit(1);
+@@ -493,7 +493,7 @@ server6_init()
+ error = getaddrinfo(DH6ADDR_ALLSERVER, DH6PORT_UPSTREAM,
+ &hints, &res2);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ exit(1);
+ }
+@@ -504,7 +504,7 @@ server6_init()
+ sizeof(mreq6.ipv6mr_multiaddr));
+ if (setsockopt(insock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &mreq6, sizeof(mreq6))) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(insock, IPV6_JOIN_GROUP): %s",
+ strerror(errno));
+ exit(1);
+@@ -514,20 +514,20 @@ server6_init()
+ hints.ai_flags = 0;
+ 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);
+ }
+ outsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (outsock < 0) {
+- dprintf(LOG_ERR, FNAME, "socket(outsock): %s",
++ debug_printf(LOG_ERR, FNAME, "socket(outsock): %s",
+ strerror(errno));
+ exit(1);
+ }
+ /* set outgoing interface of multicast packets for DHCP reconfig */
+ if (setsockopt(outsock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+ &ifidx, sizeof(ifidx)) < 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "setsockopt(outsock, IPV6_MULTICAST_IF): %s",
+ strerror(errno));
+ exit(1);
+@@ -535,7 +535,7 @@ server6_init()
+ #if !defined(__linux__) && !defined(__sun__)
+ /* make the socket write-only */
+ if (shutdown(outsock, 0)) {
+- dprintf(LOG_ERR, FNAME, "shutdown(outbound, 0): %s",
++ debug_printf(LOG_ERR, FNAME, "shutdown(outbound, 0): %s",
+ strerror(errno));
+ exit(1);
+ }
+@@ -548,7 +548,7 @@ server6_init()
+ hints.ai_protocol = IPPROTO_UDP;
+ error = getaddrinfo("::", DH6PORT_DOWNSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ exit(1);
+ }
+@@ -563,7 +563,7 @@ server6_init()
+ hints.ai_protocol = IPPROTO_UDP;
+ error = getaddrinfo("::", DH6PORT_UPSTREAM, &hints, &res);
+ if (error) {
+- dprintf(LOG_ERR, FNAME, "getaddrinfo: %s",
++ debug_printf(LOG_ERR, FNAME, "getaddrinfo: %s",
+ gai_strerror(error));
+ exit(1);
+ }
+@@ -574,16 +574,16 @@ server6_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(SIGTERM, server6_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);
+ }
+@@ -627,7 +627,7 @@ server6_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);
+ }
+@@ -714,31 +714,31 @@ server6_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);
+ }
+
+@@ -746,14 +746,14 @@ server6_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);
+ }
+@@ -761,7 +761,7 @@ server6_do_ctlcommand(buf, len)
+ break;
+ case DHCP6CTL_COMMAND_STOP:
+ if (commandlen != 0) {
+- dprintf(LOG_INFO, FNAME, "invalid command length "
++ debug_printf(LOG_INFO, FNAME, "invalid command length "
+ "for stop: %d", commandlen);
+ return (DHCP6CTL_R_DONE);
+ }
+@@ -771,7 +771,7 @@ server6_do_ctlcommand(buf, len)
+ if (get_val32(&bp, &commandlen, &p32))
+ return (DHCP6CTL_R_FAILURE);
+ if (p32 != DHCP6CTL_BINDING) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unknown remove target: %ul", p32);
+ return (DHCP6CTL_R_FAILURE);
+ }
+@@ -779,7 +779,7 @@ server6_do_ctlcommand(buf, len)
+ if (get_val32(&bp, &commandlen, &p32))
+ return (DHCP6CTL_R_FAILURE);
+ if (p32 != DHCP6CTL_BINDING_IA) {
+- dprintf(LOG_INFO, FNAME, "unknown binding type: %ul",
++ debug_printf(LOG_INFO, FNAME, "unknown binding type: %ul",
+ p32);
+ return (DHCP6CTL_R_FAILURE);
+ }
+@@ -788,7 +788,7 @@ server6_do_ctlcommand(buf, len)
+ return (DHCP6CTL_R_FAILURE);
+ if (ntohl(iaspec.type) != DHCP6CTL_IA_PD &&
+ ntohl(iaspec.type) != DHCP6CTL_IA_NA) {
+- dprintf(LOG_INFO, FNAME, "unknown IA type: %ul",
++ debug_printf(LOG_INFO, FNAME, "unknown IA type: %ul",
+ ntohl(iaspec.type));
+ return (DHCP6CTL_R_FAILURE);
+ }
+@@ -796,7 +796,7 @@ server6_do_ctlcommand(buf, len)
+ duidlen = ntohl(iaspec.duidlen);
+
+ if (duidlen > commandlen) {
+- dprintf(LOG_INFO, FNAME, "DUID length mismatch");
++ debug_printf(LOG_INFO, FNAME, "DUID length mismatch");
+ return (DHCP6CTL_R_FAILURE);
+ }
+
+@@ -809,7 +809,7 @@ server6_do_ctlcommand(buf, len)
+ binding = find_binding(&duid, DHCP6_BINDING_IA,
+ DHCP6_LISTVAL_IANA, iaid);
+ if (binding == NULL) {
+- dprintf(LOG_INFO, FNAME, "no such binding");
++ debug_printf(LOG_INFO, FNAME, "no such binding");
+ return (DHCP6CTL_R_FAILURE);
+ }
+ }
+@@ -817,7 +817,7 @@ server6_do_ctlcommand(buf, len)
+
+ break;
+ default:
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unknown control command: %d (len=%d)",
+ (int)command, commandlen);
+ return (DHCP6CTL_R_FAILURE);
+@@ -831,12 +831,12 @@ server6_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, "server reloaded");
++ debug_printf(LOG_NOTICE, FNAME, "server reloaded");
+
+ return;
+ }
+@@ -846,7 +846,7 @@ server6_stop()
+ {
+ /* Right now, we simply stop running */
+
+- dprintf(LOG_NOTICE, FNAME, "exiting");
++ debug_printf(LOG_NOTICE, FNAME, "exiting");
+
+ exit (0);
+ }
+@@ -885,7 +885,7 @@ server6_recv(s)
+ mhdr.msg_controllen = sizeof(cmsgbuf);
+
+ if ((len = recvmsg(insock, &mhdr, 0)) < 0) {
+- dprintf(LOG_ERR, FNAME, "recvmsg: %s", strerror(errno));
++ debug_printf(LOG_ERR, FNAME, "recvmsg: %s", strerror(errno));
+ return;
+ }
+ fromlen = mhdr.msg_namelen;
+@@ -899,7 +899,7 @@ server6_recv(s)
+ }
+ }
+ if (pi == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to get packet info");
++ debug_printf(LOG_NOTICE, FNAME, "failed to get packet info");
+ return;
+ }
+ /*
+@@ -910,7 +910,7 @@ server6_recv(s)
+ if (pi->ipi6_ifindex != ifidx)
+ 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;
+ }
+@@ -918,11 +918,11 @@ server6_recv(s)
+ dh6 = (struct dhcp6 *)rdatabuf;
+
+ if (len < sizeof(*dh6)) {
+- dprintf(LOG_INFO, FNAME, "short packet (%d bytes)", len);
++ debug_printf(LOG_INFO, FNAME, "short packet (%d bytes)", len);
+ return;
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "received %s from %s",
++ debug_printf(LOG_DEBUG, FNAME, "received %s from %s",
+ dhcp6msgstr(dh6->dh6_msgtype),
+ addr2str((struct sockaddr *)&from));
+
+@@ -937,7 +937,7 @@ server6_recv(s)
+ dh6->dh6_msgtype == DH6_CONFIRM ||
+ dh6->dh6_msgtype == DH6_REBIND ||
+ dh6->dh6_msgtype == DH6_INFORM_REQ)) {
+- dprintf(LOG_INFO, FNAME, "invalid unicast message");
++ debug_printf(LOG_INFO, FNAME, "invalid unicast message");
+ return;
+ }
+
+@@ -947,7 +947,7 @@ server6_recv(s)
+ * reject them here.
+ */
+ if (dh6->dh6_msgtype == DH6_RELAY_REPLY) {
+- dprintf(LOG_INFO, FNAME, "relay reply message from %s",
++ debug_printf(LOG_INFO, FNAME, "relay reply message from %s",
+ addr2str((struct sockaddr *)&from));
+ return;
+
+@@ -969,7 +969,7 @@ server6_recv(s)
+ dhcp6_init_options(&optinfo);
+ if (dhcp6_get_options((struct dhcp6opt *)(dh6 + 1),
+ optend, &optinfo) < 0) {
+- dprintf(LOG_INFO, FNAME, "failed to parse options");
++ debug_printf(LOG_INFO, FNAME, "failed to parse options");
+ goto end;
+ }
+
+@@ -1007,7 +1007,7 @@ server6_recv(s)
+ (struct sockaddr *)&from, fromlen, &relayinfohead);
+ break;
+ default:
+- dprintf(LOG_INFO, FNAME, "unknown or unsupported msgtype (%s)",
++ debug_printf(LOG_INFO, FNAME, "unknown or unsupported msgtype (%s)",
+ dhcp6msgstr(dh6->dh6_msgtype));
+ break;
+ }
+@@ -1052,11 +1052,11 @@ process_relayforw(dh6p, optendp, relayinfohead, from)
+ again:
+ len = (void *)optend - (void *)dh6relay;
+ if (len < sizeof (*dh6relay)) {
+- dprintf(LOG_INFO, FNAME, "short relay message from %s",
++ debug_printf(LOG_INFO, FNAME, "short relay message from %s",
+ addr2str(from));
+ return (-1);
+ }
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "dhcp6 relay: hop=%d, linkaddr=%s, peeraddr=%s",
+ dh6relay->dh6relay_hcnt,
+ in6addr2str(&dh6relay->dh6relay_linkaddr, 0),
+@@ -1068,13 +1068,13 @@ process_relayforw(dh6p, optendp, relayinfohead, from)
+ dhcp6_init_options(&optinfo);
+ if (dhcp6_get_options((struct dhcp6opt *)(dh6relay + 1),
+ optend, &optinfo) < 0) {
+- dprintf(LOG_INFO, FNAME, "failed to parse options");
++ debug_printf(LOG_INFO, FNAME, "failed to parse options");
+ return (-1);
+ }
+
+ /* A relay forward message must include a relay message option */
+ if (optinfo.relaymsg_msg == NULL) {
+- dprintf(LOG_INFO, FNAME, "relay forward from %s "
++ debug_printf(LOG_INFO, FNAME, "relay forward from %s "
+ "without a relay message", addr2str(from));
+ return (-1);
+ }
+@@ -1082,13 +1082,13 @@ process_relayforw(dh6p, optendp, relayinfohead, from)
+ /* relay message must contain a DHCPv6 message. */
+ len = optinfo.relaymsg_len;
+ if (len < sizeof (struct dhcp6)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "short packet (%d bytes) in relay message", len);
+ return (-1);
+ }
+
+ if ((relayinfo = malloc(sizeof (*relayinfo))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to allocate relay info");
++ debug_printf(LOG_ERR, FNAME, "failed to allocate relay info");
+ return (-1);
+ }
+ memset(relayinfo, 0, sizeof (*relayinfo));
+@@ -1139,71 +1139,71 @@ set_statelessinfo(type, optinfo)
+ {
+ /* SIP domain name */
+ if (dhcp6_copy_list(&optinfo->sipname_list, &sipnamelist)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy SIP domain list");
+ return (-1);
+ }
+
+ /* SIP server */
+ if (dhcp6_copy_list(&optinfo->sip_list, &siplist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy SIP servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy SIP servers");
+ return (-1);
+ }
+
+ /* DNS server */
+ if (dhcp6_copy_list(&optinfo->dns_list, &dnslist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy DNS servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy DNS servers");
+ return (-1);
+ }
+
+ /* DNS search list */
+ if (dhcp6_copy_list(&optinfo->dnsname_list, &dnsnamelist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy DNS search list");
++ debug_printf(LOG_ERR, FNAME, "failed to copy DNS search list");
+ return (-1);
+ }
+
+ /* NTP server */
+ if (dhcp6_copy_list(&optinfo->ntp_list, &ntplist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy NTP servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy NTP servers");
+ return (-1);
+ }
+
+ /* NIS domain name */
+ if (dhcp6_copy_list(&optinfo->nisname_list, &nisnamelist)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy NIS domain list");
+ return (-1);
+ }
+
+ /* NIS server */
+ if (dhcp6_copy_list(&optinfo->nis_list, &nislist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy NIS servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy NIS servers");
+ return (-1);
+ }
+
+ /* NIS+ domain name */
+ if (dhcp6_copy_list(&optinfo->nispname_list, &nispnamelist)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy NIS+ domain list");
+ return (-1);
+ }
+
+ /* NIS+ server */
+ if (dhcp6_copy_list(&optinfo->nisp_list, &nisplist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy NIS+ servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy NIS+ servers");
+ return (-1);
+ }
+
+ /* BCMCS domain name */
+ if (dhcp6_copy_list(&optinfo->bcmcsname_list, &bcmcsnamelist)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to copy BCMCS domain list");
+ return (-1);
+ }
+
+ /* BCMCS server */
+ if (dhcp6_copy_list(&optinfo->bcmcs_list, &bcmcslist)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy BCMCS servers");
++ debug_printf(LOG_ERR, FNAME, "failed to copy BCMCS servers");
+ return (-1);
+ }
+
+@@ -1239,10 +1239,10 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ * [RFC3315 Section 15.2]
+ */
+ 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);
+ } else {
+- dprintf(LOG_DEBUG, FNAME, "client ID %s",
++ debug_printf(LOG_DEBUG, FNAME, "client ID %s",
+ duidstr(&optinfo->clientID));
+ }
+
+@@ -1252,13 +1252,13 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ * [RFC3315 Section 15.2]
+ */
+ if (optinfo->serverID.duid_len) {
+- dprintf(LOG_INFO, FNAME, "server ID option found");
++ debug_printf(LOG_INFO, FNAME, "server ID option found");
+ return (-1);
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME, "found a host configuration for %s",
++ debug_printf(LOG_DEBUG, FNAME, "found a host configuration for %s",
+ client_conf->name);
+ }
+
+@@ -1269,7 +1269,7 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -1277,13 +1277,13 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+@@ -1293,7 +1293,7 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* add other configuration information */
+ if (set_statelessinfo(DH6_SOLICIT, &roptinfo)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to set other stateless information");
+ goto fail;
+ }
+@@ -1320,7 +1320,7 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ /* make a local copy of the configured prefixes */
+ if (client_conf &&
+ dhcp6_copy_list(&conflist, &client_conf->prefix_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make local data");
+ goto fail;
+ }
+@@ -1366,7 +1366,7 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ if (client_conf == NULL && ifp->pool.name) {
+ if ((client_conf = create_dynamic_hostconf(&optinfo->clientID,
+ &ifp->pool)) == NULL)
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make host configuration");
+ }
+ TAILQ_INIT(&conflist);
+@@ -1374,7 +1374,7 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ /* make a local copy of the configured addresses */
+ if (client_conf &&
+ dhcp6_copy_list(&conflist, &client_conf->addr_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make local data");
+ goto fail;
+ }
+@@ -1444,17 +1444,17 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message must include a Server Identifier 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);
+ }
+ /* the contents of the Server Identifier option must match ours */
+ if (duidcmp(&optinfo->serverID, &server_duid)) {
+- dprintf(LOG_INFO, FNAME, "server ID mismatch");
++ debug_printf(LOG_INFO, FNAME, "server ID mismatch");
+ return (-1);
+ }
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+@@ -1465,24 +1465,24 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -1504,11 +1504,11 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ TAILQ_EMPTY(relayinfohead)) {
+ u_int16_t stcode = DH6OPT_STCODE_USEMULTICAST;
+
+- dprintf(LOG_INFO, FNAME, "unexpected unicast message from %s",
++ debug_printf(LOG_INFO, FNAME, "unexpected unicast message from %s",
+ addr2str(from));
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a status code");
++ debug_printf(LOG_ERR, FNAME, "failed to add a status code");
+ goto fail;
+ }
+ server6_send(DH6_REPLY, ifp, dh6, optinfo, from,
+@@ -1538,7 +1538,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ /* make a local copy of the configured prefixes */
+ if (client_conf &&
+ dhcp6_copy_list(&conflist, &client_conf->prefix_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make local data");
+ goto fail;
+ }
+@@ -1563,7 +1563,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ iapd->val_ia.iaid,
+ DH6OPT_STCODE_NOPREFIXAVAIL,
+ &roptinfo.iapd_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make an option list");
+ dhcp6_clear_list(&conflist);
+ goto fail;
+@@ -1581,7 +1581,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ if (client_conf == NULL && ifp->pool.name) {
+ if ((client_conf = create_dynamic_hostconf(&optinfo->clientID,
+ &ifp->pool)) == NULL)
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make host configuration");
+ }
+ TAILQ_INIT(&conflist);
+@@ -1589,7 +1589,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ /* make a local copy of the configured prefixes */
+ if (client_conf &&
+ dhcp6_copy_list(&conflist, &client_conf->addr_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make local data");
+ goto fail;
+ }
+@@ -1607,7 +1607,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ iana->val_ia.iaid,
+ DH6OPT_STCODE_NOADDRSAVAIL,
+ &roptinfo.iana_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make an option list");
+ dhcp6_clear_list(&conflist);
+ goto fail;
+@@ -1640,7 +1640,7 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ * information to be assigned to the client.
+ */
+ if (set_statelessinfo(DH6_REQUEST, &roptinfo)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to set other stateless information");
+ goto fail;
+ }
+@@ -1677,17 +1677,17 @@ react_renew(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message must include a Server Identifier 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);
+ }
+ /* the contents of the Server Identifier option must match ours */
+ if (duidcmp(&optinfo->serverID, &server_duid)) {
+- dprintf(LOG_INFO, FNAME, "server ID mismatch");
++ debug_printf(LOG_INFO, FNAME, "server ID mismatch");
+ return (-1);
+ }
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+@@ -1698,24 +1698,24 @@ react_renew(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -1735,11 +1735,11 @@ react_renew(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ TAILQ_EMPTY(relayinfohead)) {
+ u_int16_t stcode = DH6OPT_STCODE_USEMULTICAST;
+
+- dprintf(LOG_INFO, FNAME, "unexpected unicast message from %s",
++ debug_printf(LOG_INFO, FNAME, "unexpected unicast message from %s",
+ addr2str(from));
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a status code");
++ debug_printf(LOG_ERR, FNAME, "failed to add a status code");
+ goto fail;
+ }
+ server6_send(DH6_REPLY, ifp, dh6, optinfo, from,
+@@ -1764,7 +1764,7 @@ react_renew(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* add other configuration information */
+ if (set_statelessinfo(DH6_RENEW, &roptinfo)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to set other stateless information");
+ goto fail;
+ }
+@@ -1799,13 +1799,13 @@ react_rebind(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+ /* the message must not include a server Identifier option */
+ if (optinfo->serverID.duid_len) {
+- dprintf(LOG_INFO, FNAME, "server ID option is included in "
++ debug_printf(LOG_INFO, FNAME, "server ID option is included in "
+ "a rebind message");
+ return (-1);
+ }
+@@ -1817,24 +1817,24 @@ react_rebind(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -1866,13 +1866,13 @@ react_rebind(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ */
+ if (TAILQ_EMPTY(&roptinfo.iapd_list) &&
+ TAILQ_EMPTY(&roptinfo.iana_list)) {
+- dprintf(LOG_INFO, FNAME, "no useful information for a rebind");
++ debug_printf(LOG_INFO, FNAME, "no useful information for a rebind");
+ goto fail; /* discard the rebind */
+ }
+
+ /* add other configuration information */
+ if (set_statelessinfo(DH6_REBIND, &roptinfo)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to set other stateless information");
+ goto fail;
+ }
+@@ -1908,17 +1908,17 @@ react_release(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message must include a Server Identifier 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);
+ }
+ /* the contents of the Server Identifier option must match ours */
+ if (duidcmp(&optinfo->serverID, &server_duid)) {
+- dprintf(LOG_INFO, FNAME, "server ID mismatch");
++ debug_printf(LOG_INFO, FNAME, "server ID mismatch");
+ return (-1);
+ }
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+@@ -1929,24 +1929,24 @@ react_release(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -1966,11 +1966,11 @@ react_release(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ TAILQ_EMPTY(relayinfohead)) {
+ u_int16_t stcode = DH6OPT_STCODE_USEMULTICAST;
+
+- dprintf(LOG_INFO, FNAME, "unexpected unicast message from %s",
++ debug_printf(LOG_INFO, FNAME, "unexpected unicast message from %s",
+ addr2str(from));
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a status code");
++ debug_printf(LOG_ERR, FNAME, "failed to add a status code");
+ goto fail;
+ }
+ server6_send(DH6_REPLY, ifp, dh6, optinfo, from,
+@@ -2001,7 +2001,7 @@ react_release(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ stcode = DH6OPT_STCODE_SUCCESS;
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to add a status code");
++ debug_printf(LOG_NOTICE, FNAME, "failed to add a status code");
+ goto fail;
+ }
+
+@@ -2037,17 +2037,17 @@ react_decline(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message must include a Server Identifier 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);
+ }
+ /* the contents of the Server Identifier option must match ours */
+ if (duidcmp(&optinfo->serverID, &server_duid)) {
+- dprintf(LOG_INFO, FNAME, "server ID mismatch");
++ debug_printf(LOG_INFO, FNAME, "server ID mismatch");
+ return (-1);
+ }
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+@@ -2058,24 +2058,24 @@ react_decline(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -2095,11 +2095,11 @@ react_decline(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ TAILQ_EMPTY(relayinfohead)) {
+ stcode = DH6OPT_STCODE_USEMULTICAST;
+
+- dprintf(LOG_INFO, FNAME, "unexpected unicast message from %s",
++ debug_printf(LOG_INFO, FNAME, "unexpected unicast message from %s",
+ addr2str(from));
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to add a status code");
++ debug_printf(LOG_ERR, FNAME, "failed to add a status code");
+ goto fail;
+ }
+ server6_send(DH6_REPLY, ifp, dh6, optinfo, from,
+@@ -2126,7 +2126,7 @@ react_decline(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ stcode = DH6OPT_STCODE_SUCCESS;
+ if (dhcp6_add_listval(&roptinfo.stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, NULL) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to add a status code");
++ debug_printf(LOG_NOTICE, FNAME, "failed to add a status code");
+ goto fail;
+ }
+
+@@ -2164,12 +2164,12 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* the message may not include a Server Identifier option */
+ if (optinfo->serverID.duid_len) {
+- dprintf(LOG_INFO, FNAME, "server ID option found");
++ debug_printf(LOG_INFO, FNAME, "server ID option found");
+ return (-1);
+ }
+ /* the message must include a Client Identifier option */
+ 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);
+ }
+
+@@ -2177,24 +2177,24 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+ /* copy client information back */
+ if (duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+ /* process authentication */
+ if (process_auth(dh6, len, client_conf, optinfo, &roptinfo)) {
+- dprintf(LOG_INFO, FNAME, "failed to process authentication "
++ debug_printf(LOG_INFO, FNAME, "failed to process authentication "
+ "information for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ goto fail;
+@@ -2203,7 +2203,7 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ if (client_conf == NULL && ifp->pool.name) {
+ if ((client_conf = create_dynamic_hostconf(&optinfo->clientID,
+ &ifp->pool)) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make host configuration");
+ goto fail;
+ }
+@@ -2211,7 +2211,7 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ TAILQ_INIT(&conflist);
+ /* make a local copy of the configured addresses */
+ if (dhcp6_copy_list(&conflist, &client_conf->addr_list)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make local data");
+ goto fail;
+ }
+@@ -2221,13 +2221,13 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ * [RFC3315 18.2]. (IA-PD is just ignored [RFC3633 12.1])
+ */
+ if (TAILQ_EMPTY(&optinfo->iana_list)) {
+- dprintf(LOG_INFO, FNAME, "no IA-NA option found");
++ debug_printf(LOG_INFO, FNAME, "no IA-NA option found");
+ goto fail;
+ }
+ for (iana = TAILQ_FIRST(&optinfo->iana_list); iana;
+ iana = TAILQ_NEXT(iana, link)) {
+ if (TAILQ_EMPTY(&iana->sublist)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "no IA-ADDR option found in IA-NA %d",
+ iana->val_ia.iaid);
+ goto fail;
+@@ -2250,7 +2250,7 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ struct relayinfo *relayinfo;
+
+ if (relayinfohead == NULL) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "no link-addr found");
+ goto fail;
+ }
+@@ -2264,7 +2264,7 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ }
+
+ if (memcmp(linkaddr, confaddr, 8) != 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "%s does not seem to belong to %s's link",
+ in6addr2str(confaddr, 0),
+ in6addr2str(linkaddr, 0));
+@@ -2283,7 +2283,7 @@ react_confirm(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
+ iana = TAILQ_NEXT(iana, link)) {
+ if (make_ia(iana, &conflist, &roptinfo.iana_list,
+ client_conf, 1) == 0) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "IA-NA configuration not found");
+ goto fail;
+ }
+@@ -2326,12 +2326,12 @@ react_informreq(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ * [RFC3315 Section 15]
+ */
+ if (!TAILQ_EMPTY(&optinfo->iapd_list)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "information request contains an IA_PD option");
+ return (-1);
+ }
+ if (!TAILQ_EMPTY(&optinfo->iana_list)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "information request contains an IA_NA option");
+ return (-1);
+ }
+@@ -2339,7 +2339,7 @@ react_informreq(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+ /* if a server identifier is included, it must match ours. */
+ if (optinfo->serverID.duid_len &&
+ duidcmp(&optinfo->serverID, &server_duid)) {
+- dprintf(LOG_INFO, FNAME, "server DUID mismatch");
++ debug_printf(LOG_INFO, FNAME, "server DUID mismatch");
+ return (-1);
+ }
+
+@@ -2350,20 +2350,20 @@ react_informreq(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
+
+ /* server identifier option */
+ if (duidcpy(&roptinfo.serverID, &server_duid)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy server ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy server ID");
+ goto fail;
+ }
+
+ /* copy client information back (if provided) */
+ if (optinfo->clientID.duid_id &&
+ duidcpy(&roptinfo.clientID, &optinfo->clientID)) {
+- dprintf(LOG_ERR, FNAME, "failed to copy client ID");
++ debug_printf(LOG_ERR, FNAME, "failed to copy client ID");
+ goto fail;
+ }
+
+ /* set stateless information */
+ if (set_statelessinfo(DH6_INFORM_REQ, &roptinfo)) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "failed to set other stateless information");
+ goto fail;
+ }
+@@ -2391,7 +2391,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+
+ /* get per-host configuration for the client, if any. */
+ if ((client_conf = find_hostconf(&optinfo->clientID))) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "found a host configuration named %s", client_conf->name);
+ }
+
+@@ -2404,7 +2404,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ * Sections 18.2.3 and 18.2.4 of RFC3315, and the two sets
+ * of behavior are identical.
+ */
+- dprintf(LOG_INFO, FNAME, "no binding found for %s",
++ debug_printf(LOG_INFO, FNAME, "no binding found for %s",
+ duidstr(&optinfo->clientID));
+
+ switch (msgtype) {
+@@ -2418,7 +2418,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ */
+ if (make_ia_stcode(iap->type, iap->val_ia.iaid,
+ DH6OPT_STCODE_NOBINDING, retlist)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make an option list");
+ return (-1);
+ }
+@@ -2440,7 +2440,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ */
+ return (-1);
+ default: /* XXX: should be a bug */
+- dprintf(LOG_ERR, FNAME, "impossible message type %s",
++ debug_printf(LOG_ERR, FNAME, "impossible message type %s",
+ dhcp6msgstr(msgtype));
+ return (-1);
+ }
+@@ -2468,7 +2468,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ blv = dhcp6_find_listval(&binding->val_list,
+ DHCP6_LISTVAL_PREFIX6, &prefix, 0);
+ if (blv == NULL) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "%s/%d is not found in %s",
+ in6addr2str(&prefix.addr, 0),
+ prefix.plen, bindingstr(binding));
+@@ -2484,7 +2484,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ if (dhcp6_add_listval(&ialist,
+ DHCP6_LISTVAL_PREFIX6, &prefix, NULL)
+ == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to copy binding info");
+ dhcp6_clear_list(&ialist);
+ return (-1);
+@@ -2498,7 +2498,7 @@ update_ia(msgtype, iap, retlist, optinfo)
+ blv = dhcp6_find_listval(&binding->val_list,
+ DHCP6_LISTVAL_STATEFULADDR6, &saddr, 0);
+ if (blv == NULL) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "%s is not found in %s",
+ in6addr2str(&saddr.addr, 0),
+ bindingstr(binding));
+@@ -2514,14 +2514,14 @@ update_ia(msgtype, iap, retlist, optinfo)
+ if (dhcp6_add_listval(&ialist,
+ DHCP6_LISTVAL_STATEFULADDR6, &saddr, NULL)
+ == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to copy binding info");
+ dhcp6_clear_list(&ialist);
+ return (-1);
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unsupported IA type");
++ debug_printf(LOG_ERR, FNAME, "unsupported IA type");
+ return (-1); /* XXX */
+ }
+ }
+@@ -2560,7 +2560,7 @@ release_binding_ia(iap, retlist, optinfo)
+ */
+ if (make_ia_stcode(iap->type, iap->val_ia.iaid,
+ DH6OPT_STCODE_NOBINDING, retlist)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make an option list");
+ return (-1);
+ }
+@@ -2582,7 +2582,7 @@ release_binding_ia(iap, retlist, optinfo)
+ if ((lvia = find_binding_ia(lv, binding)) != NULL) {
+ switch (binding->iatype) {
+ case DHCP6_LISTVAL_IAPD:
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "bound prefix %s/%d "
+ "has been released",
+ in6addr2str(&lvia->val_prefix6.addr,
+@@ -2591,7 +2591,7 @@ release_binding_ia(iap, retlist, optinfo)
+ break;
+ case DHCP6_LISTVAL_IANA:
+ release_address(&lvia->val_prefix6.addr);
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "bound address %s "
+ "has been released",
+ in6addr2str(&lvia->val_prefix6.addr,
+@@ -2635,7 +2635,7 @@ decline_binding_ia(iap, retlist, optinfo)
+ */
+ if (make_ia_stcode(iap->type, iap->val_ia.iaid,
+ DH6OPT_STCODE_NOBINDING, retlist)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make an option list");
+ return (-1);
+ }
+@@ -2657,13 +2657,13 @@ decline_binding_ia(iap, retlist, optinfo)
+ }
+
+ if ((lvia = find_binding_ia(lv, binding)) == NULL) {
+- dprintf(LOG_DEBUG, FNAME, "no binding found "
++ debug_printf(LOG_DEBUG, FNAME, "no binding found "
+ "for address %s",
+ in6addr2str(&lv->val_statefuladdr6.addr, 0));
+ continue;
+ }
+
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "bound address %s has been marked as declined",
+ in6addr2str(&lvia->val_statefuladdr6.addr, 0));
+ decline_address(&lvia->val_statefuladdr6.addr);
+@@ -2688,7 +2688,7 @@ server6_signal(sig)
+ int sig;
+ {
+
+- dprintf(LOG_INFO, FNAME, "received a signal (%d)", sig);
++ debug_printf(LOG_INFO, FNAME, "received a signal (%d)", sig);
+
+ switch (sig) {
+ case SIGTERM:
+@@ -2717,7 +2717,7 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ struct relayinfo *relayinfo;
+
+ if (sizeof(struct dhcp6) > sizeof(replybuf)) {
+- dprintf(LOG_ERR, FNAME, "buffer size assumption failed");
++ debug_printf(LOG_ERR, FNAME, "buffer size assumption failed");
+ return (-1);
+ }
+
+@@ -2730,7 +2730,7 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ /* set options in the reply message */
+ if ((optlen = dhcp6_set_options(type, (struct dhcp6opt *)(dh6 + 1),
+ (struct dhcp6opt *)(replybuf + sizeof(replybuf)), roptinfo)) < 0) {
+- dprintf(LOG_INFO, FNAME, "failed to construct reply options");
++ debug_printf(LOG_INFO, FNAME, "failed to construct reply options");
+ return (-1);
+ }
+ len += optlen;
+@@ -2740,7 +2740,7 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ case DHCP6_AUTHPROTO_DELAYED:
+ if (client_conf == NULL || client_conf->delayedkey == NULL) {
+ /* This case should have been caught earlier */
+- dprintf(LOG_ERR, FNAME, "authentication required "
++ debug_printf(LOG_ERR, FNAME, "authentication required "
+ "but not key provided");
+ break;
+ }
+@@ -2748,7 +2748,7 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ roptinfo->authalgorithm,
+ roptinfo->delayedauth_offset + sizeof(*dh6),
+ client_conf->delayedkey)) {
+- dprintf(LOG_WARNING, FNAME, "failed to calculate MAC");
++ debug_printf(LOG_WARNING, FNAME, "failed to calculate MAC");
+ return (-1);
+ }
+ break;
+@@ -2792,7 +2792,7 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ (struct dhcp6opt *)(dh6relay + 1),
+ (struct dhcp6opt *)(replybuf + sizeof(replybuf)),
+ &relayopt)) < 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "failed to construct relay message");
+ dhcp6_clear_options(&relayopt);
+ return (-1);
+@@ -2808,12 +2808,12 @@ server6_send(type, ifp, origmsg, optinfo, from, fromlen,
+ dst.sin6_scope_id = ((struct sockaddr_in6 *)from)->sin6_scope_id;
+ if (transmit_sa(outsock, (struct sockaddr *)&dst,
+ replybuf, len) != 0) {
+- dprintf(LOG_ERR, FNAME, "transmit %s to %s failed",
++ debug_printf(LOG_ERR, FNAME, "transmit %s to %s failed",
+ dhcp6msgstr(type), addr2str((struct sockaddr *)&dst));
+ return (-1);
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "transmit %s to %s",
++ debug_printf(LOG_DEBUG, FNAME, "transmit %s to %s",
+ dhcp6msgstr(type), addr2str((struct sockaddr *)&dst));
+
+ return (0);
+@@ -2835,13 +2835,13 @@ make_ia_stcode(iatype, iaid, stcode, retlist)
+ TAILQ_INIT(&stcode_list);
+ if (dhcp6_add_listval(&stcode_list, DHCP6_LISTVAL_STCODE,
+ &stcode, NULL) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to make an option list");
++ debug_printf(LOG_NOTICE, FNAME, "failed to make an option list");
+ return (-1);
+ }
+
+ if (dhcp6_add_listval(retlist, iatype,
+ &ia_empty, &stcode_list) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to make an option list");
++ debug_printf(LOG_NOTICE, FNAME, "failed to make an option list");
+ dhcp6_clear_list(&stcode_list);
+ return (-1);
+ }
+@@ -2872,7 +2872,7 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
+ struct dhcp6_list *blist = &binding->val_list;
+ struct dhcp6_listval *bia, *v;
+
+- dprintf(LOG_DEBUG, FNAME, "we have a binding already: %s",
++ debug_printf(LOG_DEBUG, FNAME, "we have a binding already: %s",
+ bindingstr(binding));
+
+ update_binding(binding);
+@@ -2883,7 +2883,7 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
+ calc_ia_timo(&ia, blist, client_conf);
+ if (dhcp6_add_listval(retlist, spec->type, &ia, blist)
+ == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to copy binding info");
+ return (0);
+ }
+@@ -2959,7 +2959,7 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
+ if (do_binding) {
+ if (add_binding(&client_conf->duid, DHCP6_BINDING_IA,
+ spec->type, spec->val_ia.iaid, &ialist) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to make a binding");
+ found = 0;
+ }
+@@ -3000,7 +3000,7 @@ make_match_ia(spec, conflist, retlist)
+ match = 0;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unsupported IA type");
++ debug_printf(LOG_ERR, FNAME, "unsupported IA type");
+ return (0); /* XXX */
+ }
+ }
+@@ -3032,10 +3032,10 @@ make_iana_from_pool(poolspec, spec, retlist)
+ struct pool_conf *pool;
+ int found = 0;
+
+- dprintf(LOG_DEBUG, FNAME, "called");
++ debug_printf(LOG_DEBUG, FNAME, "called");
+
+ if ((pool = find_pool(poolspec->name)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "pool '%s' not found", poolspec->name);
++ debug_printf(LOG_ERR, FNAME, "pool '%s' not found", poolspec->name);
+ return (0);
+ }
+
+@@ -3060,7 +3060,7 @@ make_iana_from_pool(poolspec, spec, retlist)
+ }
+ }
+
+- dprintf(LOG_DEBUG, FNAME, "returns (found=%d)", found);
++ debug_printf(LOG_DEBUG, FNAME, "returns (found=%d)", found);
+
+ return (found);
+ }
+@@ -3078,7 +3078,7 @@ calc_ia_timo(ia, ialist, client_conf)
+ iatype = TAILQ_FIRST(ialist)->type;
+ for (iav = TAILQ_FIRST(ialist); iav; iav = TAILQ_NEXT(iav, link)) {
+ if (iav->type != iatype) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "assumption failure: IA list is not consistent");
+ exit (1); /* XXX */
+ }
+@@ -3144,7 +3144,7 @@ update_binding_duration(binding)
+ lifetime = iav->val_statefuladdr6.vltime;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unsupported IA type");
++ debug_printf(LOG_ERR, FNAME, "unsupported IA type");
+ return; /* XXX */
+ }
+
+@@ -3162,7 +3162,7 @@ update_binding_duration(binding)
+ break;
+ default:
+ /* should be internal error. */
+- dprintf(LOG_ERR, FNAME, "unknown binding type (%d)",
++ debug_printf(LOG_ERR, FNAME, "unknown binding type (%d)",
+ binding->type);
+ return;
+ }
+@@ -3182,13 +3182,13 @@ add_binding(clientid, btype, iatype, iaid, val0)
+ u_int32_t duration = DHCP6_DURATION_INFINITE;
+
+ if ((binding = malloc(sizeof(*binding))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to allocate memory");
++ debug_printf(LOG_NOTICE, FNAME, "failed to allocate memory");
+ return (NULL);
+ }
+ memset(binding, 0, sizeof(*binding));
+ binding->type = btype;
+ if (duidcpy(&binding->clientid, clientid)) {
+- dprintf(LOG_NOTICE, FNAME, "failed to copy DUID");
++ debug_printf(LOG_NOTICE, FNAME, "failed to copy DUID");
+ goto fail;
+ }
+ binding->iatype = iatype;
+@@ -3200,7 +3200,7 @@ add_binding(clientid, btype, iatype, iaid, val0)
+ TAILQ_INIT(&binding->val_list);
+ if (dhcp6_copy_list(&binding->val_list,
+ (struct dhcp6_list *)val0)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to copy binding data");
+ goto fail;
+ }
+@@ -3213,13 +3213,13 @@ add_binding(clientid, btype, iatype, iaid, val0)
+ lv_next = TAILQ_NEXT(lv, link);
+
+ if (lv->type != DHCP6_LISTVAL_STATEFULADDR6) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "unexpected binding value type(%d)", lv->type);
+ continue;
+ }
+
+ if (!lease_address(&lv->val_statefuladdr6.addr)) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "cannot lease address %s",
+ in6addr2str(&lv->val_statefuladdr6.addr, 0));
+ TAILQ_REMOVE(ia_list, lv, link);
+@@ -3227,13 +3227,13 @@ add_binding(clientid, btype, iatype, iaid, val0)
+ }
+ }
+ if (TAILQ_EMPTY(ia_list)) {
+- dprintf(LOG_NOTICE, FNAME, "cannot lease any address");
++ debug_printf(LOG_NOTICE, FNAME, "cannot lease any address");
+ goto fail;
+ }
+ }
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unexpected binding type(%d)", btype);
++ debug_printf(LOG_ERR, FNAME, "unexpected binding type(%d)", btype);
+ goto fail;
+ }
+
+@@ -3245,7 +3245,7 @@ add_binding(clientid, btype, iatype, iaid, val0)
+
+ binding->timer = dhcp6_add_timer(binding_timo, binding);
+ if (binding->timer == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "failed to add timer");
++ debug_printf(LOG_NOTICE, FNAME, "failed to add timer");
+ goto fail;
+ }
+ timo.tv_sec = (long)duration;
+@@ -3255,7 +3255,7 @@ add_binding(clientid, btype, iatype, iaid, val0)
+
+ TAILQ_INSERT_TAIL(&dhcp6_binding_head, binding, link);
+
+- dprintf(LOG_DEBUG, FNAME, "add a new binding %s", bindingstr(binding));
++ debug_printf(LOG_DEBUG, FNAME, "add a new binding %s", bindingstr(binding));
+
+ return (binding);
+
+@@ -3295,7 +3295,7 @@ update_binding(binding)
+ {
+ struct timeval timo;
+
+- dprintf(LOG_DEBUG, FNAME, "update binding %s for %s",
++ debug_printf(LOG_DEBUG, FNAME, "update binding %s for %s",
+ bindingstr(binding), duidstr(&binding->clientid));
+
+ /* update timestamp and calculate new duration */
+@@ -3316,7 +3316,7 @@ static void
+ remove_binding(binding)
+ struct dhcp6_binding *binding;
+ {
+- dprintf(LOG_DEBUG, FNAME, "remove a binding %s",
++ debug_printf(LOG_DEBUG, FNAME, "remove a binding %s",
+ bindingstr(binding));
+
+ if (binding->timer)
+@@ -3343,7 +3343,7 @@ free_binding(binding)
+
+ for (lv = TAILQ_FIRST(ia_list); lv; lv = TAILQ_NEXT(lv, link)) {
+ if (lv->type != DHCP6_LISTVAL_STATEFULADDR6) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "unexpected binding value type(%d)", lv->type);
+ continue;
+ }
+@@ -3353,7 +3353,7 @@ free_binding(binding)
+ dhcp6_clear_list(&binding->val_list);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unknown binding type %d",
++ debug_printf(LOG_ERR, FNAME, "unknown binding type %d",
+ binding->type);
+ break;
+ }
+@@ -3386,7 +3386,7 @@ binding_timo(arg)
+ lifetime = iav->val_prefix6.vltime;
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "internal error: "
++ debug_printf(LOG_ERR, FNAME, "internal error: "
+ "unknown binding type (%d)",
+ binding->iatype);
+ return (NULL); /* XXX */
+@@ -3394,7 +3394,7 @@ binding_timo(arg)
+
+ if (lifetime != DHCP6_DURATION_INFINITE &&
+ lifetime <= past) {
+- dprintf(LOG_DEBUG, FNAME, "bound prefix %s/%d"
++ debug_printf(LOG_DEBUG, FNAME, "bound prefix %s/%d"
+ " in %s has expired",
+ in6addr2str(&iav->val_prefix6.addr, 0),
+ iav->val_prefix6.plen,
+@@ -3414,7 +3414,7 @@ binding_timo(arg)
+
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unknown binding type %d",
++ debug_printf(LOG_ERR, FNAME, "unknown binding type %d",
+ binding->type);
+ return (NULL); /* XXX */
+ }
+@@ -3444,7 +3444,7 @@ find_binding_ia(key, binding)
+ case DHCP6_BINDING_IA:
+ return (dhcp6_find_listval(ia_list, key->type, &key->uv, 0));
+ default:
+- dprintf(LOG_ERR, FNAME, "unknown binding type %d",
++ debug_printf(LOG_ERR, FNAME, "unknown binding type %d",
+ binding->type);
+ return (NULL); /* XXX */
+ }
+@@ -3474,7 +3474,7 @@ bindingstr(binding)
+ (u_long)binding->duration);
+ break;
+ default:
+- dprintf(LOG_ERR, FNAME, "unexpected binding type(%d)",
++ debug_printf(LOG_ERR, FNAME, "unexpected binding type(%d)",
+ binding->type);
+ return ("???");
+ }
+@@ -3508,7 +3508,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ return (0);
+ case DHCP6_AUTHPROTO_DELAYED:
+ if (optinfo->authalgorithm != DHCP6_AUTHALG_HMACMD5) {
+- dprintf(LOG_INFO, FNAME, "unknown authentication "
++ debug_printf(LOG_INFO, FNAME, "unknown authentication "
+ "algorithm (%d) required by %s",
+ optinfo->authalgorithm,
+ clientstr(client_conf, &optinfo->clientID));
+@@ -3516,7 +3516,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ }
+
+ if (optinfo->authrdm != DHCP6_AUTHRDM_MONOCOUNTER) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "unknown RDM (%d) required by %s",
+ optinfo->authrdm,
+ clientstr(client_conf, &optinfo->clientID));
+@@ -3525,13 +3525,13 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+
+ /* see if we have a key for the client */
+ if (client_conf == NULL || client_conf->delayedkey == NULL) {
+- dprintf(LOG_INFO, FNAME, "client %s wanted "
++ debug_printf(LOG_INFO, FNAME, "client %s wanted "
+ "authentication, but no key found",
+ clientstr(client_conf, &optinfo->clientID));
+ break;
+ }
+ key = client_conf->delayedkey;
+- dprintf(LOG_DEBUG, FNAME, "found key %s for client %s",
++ debug_printf(LOG_DEBUG, FNAME, "found key %s for client %s",
+ key->name, clientstr(client_conf, &optinfo->clientID));
+
+ if (msgtype == DH6_SOLICIT) {
+@@ -3540,7 +3540,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ * A solicit message should not contain
+ * authentication information.
+ */
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "authentication information "
+ "provided in solicit from %s",
+ clientstr(client_conf,
+@@ -3550,7 +3550,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ } else {
+ /* replay protection */
+ if (!client_conf->saw_previous_rd) {
+- dprintf(LOG_WARNING, FNAME,
++ debug_printf(LOG_WARNING, FNAME,
+ "previous RD value for %s is unknown "
+ "(accept it)", clientstr(client_conf,
+ &optinfo->clientID));
+@@ -3558,7 +3558,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ if (dhcp6_auth_replaycheck(optinfo->authrdm,
+ client_conf->previous_rd,
+ optinfo->authrd)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "possible replay attack detected "
+ "for client %s",
+ clientstr(client_conf,
+@@ -3568,7 +3568,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ }
+
+ if ((optinfo->authflags & DHCP6OPT_AUTHFLAG_NOINFO)) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "client %s did not provide authentication "
+ "information in %s",
+ clientstr(client_conf, &optinfo->clientID),
+@@ -3588,7 +3588,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ optinfo->delayedauth_realmlen != key->realmlen ||
+ memcmp(optinfo->delayedauth_realmval, key->realm,
+ key->realmlen) != 0) {
+- dprintf(LOG_INFO, FNAME, "authentication key "
++ debug_printf(LOG_INFO, FNAME, "authentication key "
+ "mismatch with client %s",
+ clientstr(client_conf,
+ &optinfo->clientID));
+@@ -3597,7 +3597,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+
+ /* 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;
+ }
+@@ -3607,12 +3607,12 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ optinfo->authproto, optinfo->authalgorithm,
+ optinfo->delayedauth_offset + sizeof(*dh6), key)
+ == 0) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "message authentication validated for "
+ "client %s", clientstr(client_conf,
+ &optinfo->clientID));
+ } else {
+- dprintf(LOG_INFO, FNAME, "invalid message "
++ debug_printf(LOG_INFO, FNAME, "invalid message "
+ "authentication");
+ break;
+ }
+@@ -3624,7 +3624,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+
+ if (get_rdvalue(roptinfo->authrdm, &roptinfo->authrd,
+ sizeof(roptinfo->authrd))) {
+- dprintf(LOG_ERR, FNAME, "failed to get a replay "
++ debug_printf(LOG_ERR, FNAME, "failed to get a replay "
+ "detection value for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ break; /* XXX: try to recover? */
+@@ -3635,7 +3635,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+ roptinfo->delayedauth_realmval =
+ malloc(roptinfo->delayedauth_realmlen);
+ if (roptinfo->delayedauth_realmval == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to allocate memory "
++ debug_printf(LOG_ERR, FNAME, "failed to allocate memory "
+ "for authentication realm for %s",
+ clientstr(client_conf, &optinfo->clientID));
+ break;
+@@ -3647,7 +3647,7 @@ process_auth(dh6, len, client_conf, optinfo, roptinfo)
+
+ break;
+ default:
+- dprintf(LOG_INFO, FNAME, "client %s wanted authentication "
++ debug_printf(LOG_INFO, FNAME, "client %s wanted authentication "
+ "with unsupported protocol (%d)",
+ clientstr(client_conf, &optinfo->clientID),
+ optinfo->authproto);
+diff --git a/if.c b/if.c
+index 61a7fd6..c690671 100644
+--- a/if.c
++++ b/if.c
+@@ -60,12 +60,12 @@ ifinit(ifname)
+ struct dhcp6_if *ifp;
+
+ if ((ifp = find_ifconfbyname(ifname)) != NULL) {
+- dprintf(LOG_NOTICE, FNAME, "duplicated interface: %s", ifname);
++ debug_printf(LOG_NOTICE, FNAME, "duplicated interface: %s", ifname);
+ return (NULL);
+ }
+
+ if ((ifp = malloc(sizeof(*ifp))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "malloc failed");
++ debug_printf(LOG_ERR, FNAME, "malloc failed");
+ goto fail;
+ }
+ memset(ifp, 0, sizeof(*ifp));
+@@ -73,7 +73,7 @@ ifinit(ifname)
+ TAILQ_INIT(&ifp->event_list);
+
+ if ((ifp->ifname = strdup(ifname)) == NULL) {
+- dprintf(LOG_ERR, FNAME, "failed to copy ifname");
++ debug_printf(LOG_ERR, FNAME, "failed to copy ifname");
+ goto fail;
+ }
+
+@@ -92,7 +92,7 @@ ifinit(ifname)
+ struct sockaddr_in6 *sin6;
+
+ if (getifaddrs(&ifap) < 0) {
+- dprintf(LOG_ERR, FNAME, "getifaddrs failed: %s",
++ debug_printf(LOG_ERR, FNAME, "getifaddrs failed: %s",
+ strerror(errno));
+ goto fail;
+ }
+@@ -134,14 +134,14 @@ ifreset(ifp)
+ u_int32_t linkid;
+
+ if ((ifid = if_nametoindex(ifp->ifname)) == 0) {
+- dprintf(LOG_ERR, FNAME, "invalid interface(%s): %s",
++ debug_printf(LOG_ERR, FNAME, "invalid interface(%s): %s",
+ ifp->ifname, strerror(errno));
+ return (-1);
+ }
+
+ #ifdef HAVE_SCOPELIB
+ if (inet_zoneid(AF_INET6, 2, ifname, &linkid)) {
+- dprintf(LOG_ERR, FNAME, "failed to get link ID for %s",
++ debug_printf(LOG_ERR, FNAME, "failed to get link ID for %s",
+ ifname);
+ return (-1);
+ }
+diff --git a/lease.c b/lease.c
+index d46ddfd..5cb7325 100644
+--- a/lease.c
++++ b/lease.c
+@@ -93,7 +93,7 @@ static struct hash_entry * hash_table_find __P((struct hash_table *, void *));
+ int
+ lease_init(void)
+ {
+- dprintf(LOG_DEBUG, FNAME, "called");
++ debug_printf(LOG_DEBUG, FNAME, "called");
+
+ if (hash_table_init(&dhcp6_lease_table, DHCP6_LEASE_TABLE_SIZE,
+ in6_addr_hash, in6_addr_match) != 0) {
+@@ -116,10 +116,10 @@ lease_address(addr)
+ if (!addr)
+ return (FALSE);
+
+- dprintf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
++ debug_printf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
+
+ if (hash_table_find(&dhcp6_lease_table, addr)) {
+- dprintf(LOG_WARNING, FNAME, "already leased: %s",
++ debug_printf(LOG_WARNING, FNAME, "already leased: %s",
+ in6addr2str(addr, 0));
+ return (FALSE);
+ }
+@@ -138,10 +138,10 @@ release_address(addr)
+ if (!addr)
+ return;
+
+- dprintf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
++ debug_printf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
+
+ if (hash_table_remove(&dhcp6_lease_table, addr) != 0) {
+- dprintf(LOG_WARNING, FNAME, "not found: %s", in6addr2str(addr, 0));
++ debug_printf(LOG_WARNING, FNAME, "not found: %s", in6addr2str(addr, 0));
+ }
+ }
+
+@@ -154,11 +154,11 @@ decline_address(addr)
+ if (!addr)
+ return;
+
+- dprintf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
++ debug_printf(LOG_DEBUG, FNAME, "addr=%s", in6addr2str(addr, 0));
+
+ entry = hash_table_find(&dhcp6_lease_table, addr);
+ if (entry == NULL) {
+- dprintf(LOG_WARNING, FNAME, "not found: %s",
++ debug_printf(LOG_WARNING, FNAME, "not found: %s",
+ in6addr2str(addr, 0));
+ return;
+ }
+diff --git a/prefixconf.c b/prefixconf.c
+index ace6ade..9450a3f 100644
+--- a/prefixconf.c
++++ b/prefixconf.c
+@@ -141,7 +141,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+ if (pinfo->vltime != DHCP6_DURATION_INFINITE &&
+ (pinfo->pltime == DHCP6_DURATION_INFINITE ||
+ pinfo->pltime > pinfo->vltime)) {
+- dprintf(LOG_INFO, FNAME, "invalid prefix %s/%d: "
++ debug_printf(LOG_INFO, FNAME, "invalid prefix %s/%d: "
+ "pltime (%lu) is larger than vltime (%lu)",
+ in6addr2str(&pinfo->addr, 0), pinfo->plen,
+ pinfo->pltime, pinfo->vltime);
+@@ -150,7 +150,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+
+ if (iac_pd == NULL) {
+ if ((iac_pd = malloc(sizeof(*iac_pd))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "memory allocation failed");
++ debug_printf(LOG_NOTICE, FNAME, "memory allocation failed");
+ return (-1);
+ }
+ memset(iac_pd, 0, sizeof(*iac_pd));
+@@ -172,7 +172,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+ /* search for the given prefix, and make a new one if it fails */
+ if ((sp = find_siteprefix(&iac_pd->siteprefix_head, pinfo, 1)) == NULL) {
+ if ((sp = malloc(sizeof(*sp))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME, "memory allocation failed");
++ debug_printf(LOG_NOTICE, FNAME, "memory allocation failed");
+ return (-1);
+ }
+ memset(sp, 0, sizeof(*sp));
+@@ -192,7 +192,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+ /* update the prefix according to pinfo */
+ sp->prefix.pltime = pinfo->pltime;
+ sp->prefix.vltime = pinfo->vltime;
+- dprintf(LOG_DEBUG, FNAME, "%s a prefix %s/%d pltime=%lu, vltime=%lu",
++ debug_printf(LOG_DEBUG, FNAME, "%s a prefix %s/%d pltime=%lu, vltime=%lu",
+ spcreate ? "create" : "update",
+ in6addr2str(&pinfo->addr, 0), pinfo->plen,
+ pinfo->pltime, pinfo->vltime);
+@@ -209,7 +209,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+ * [RFC3633 Section 12.1]
+ */
+ if (strcmp(pif->ifname, dhcpifp->ifname) == 0) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "skip %s as a prefix interface",
+ dhcpifp->ifname);
+ continue;
+@@ -235,7 +235,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+ if (sp->timer == NULL) {
+ sp->timer = dhcp6_add_timer(siteprefix_timo, sp);
+ if (sp->timer == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to add prefix timer");
+ remove_siteprefix(sp); /* XXX */
+ return (-1);
+@@ -276,7 +276,7 @@ remove_siteprefix(sp)
+ {
+ struct dhcp6_ifprefix *ip;
+
+- dprintf(LOG_DEBUG, FNAME, "remove a site prefix %s/%d",
++ debug_printf(LOG_DEBUG, FNAME, "remove a site prefix %s/%d",
+ in6addr2str(&sp->prefix.addr, 0), sp->prefix.plen);
+
+ if (sp->timer)
+@@ -390,7 +390,7 @@ renew_data_free(evd)
+ struct dhcp6_list *ial;
+
+ if (evd->type != DHCP6_EVDATA_IAPD) {
+- dprintf(LOG_ERR, FNAME, "assumption failure");
++ debug_printf(LOG_ERR, FNAME, "assumption failure");
+ exit(1);
+ }
+
+@@ -409,7 +409,7 @@ siteprefix_timo(arg)
+ struct ia *ia;
+ void (*callback)__P((struct ia *));
+
+- dprintf(LOG_DEBUG, FNAME, "prefix timeout for %s/%d",
++ debug_printf(LOG_DEBUG, FNAME, "prefix timeout for %s/%d",
+ in6addr2str(&sp->prefix.addr, 0), sp->prefix.plen);
+
+ ia = sp->ctl->iacpd_ia;
+@@ -438,7 +438,7 @@ add_ifprefix(siteprefix, prefix, pconf)
+ int b, i;
+
+ if ((ifpfx = malloc(sizeof(*ifpfx))) == NULL) {
+- dprintf(LOG_NOTICE, FNAME,
++ debug_printf(LOG_NOTICE, FNAME,
+ "failed to allocate memory for ifprefix");
+ return (-1);
+ }
+@@ -456,13 +456,13 @@ add_ifprefix(siteprefix, prefix, pconf)
+ * XXX: our current implementation assumes ifid len is a multiple of 8
+ */
+ if ((pconf->ifid_len % 8) != 0) {
+- dprintf(LOG_ERR, FNAME,
++ debug_printf(LOG_ERR, FNAME,
+ "assumption failure on the length of interface ID");
+ goto bad;
+ }
+ if (ifpfx->plen + pconf->ifid_len < 0 ||
+ ifpfx->plen + pconf->ifid_len > 128) {
+- dprintf(LOG_INFO, FNAME,
++ debug_printf(LOG_INFO, FNAME,
+ "invalid prefix length %d + %d + %d",
+ prefix->plen, pconf->sla_len, pconf->ifid_len);
+ goto bad;
+diff --git a/timer.c b/timer.c
+index c74aa1f..c1666b4 100644
+--- a/timer.c
++++ b/timer.c
+@@ -71,14 +71,14 @@ dhcp6_add_timer(timeout, timeodata)
+ struct dhcp6_timer *newtimer;
+
+ if ((newtimer = malloc(sizeof(*newtimer))) == NULL) {
+- dprintf(LOG_ERR, FNAME, "can't allocate memory");
++ debug_printf(LOG_ERR, FNAME, "can't allocate memory");
+ return (NULL);
+ }
+
+ memset(newtimer, 0, sizeof(*newtimer));
+
+ if (timeout == NULL) {
+- dprintf(LOG_ERR, FNAME, "timeout function unspecified");
++ debug_printf(LOG_ERR, FNAME, "timeout function unspecified");
+ exit(1);
+ }
+ newtimer->expire = timeout;
+@@ -165,7 +165,7 @@ dhcp6_timer_rest(timer)
+
+ gettimeofday(&now, NULL);
+ if (TIMEVAL_LEQ(timer->tm, now)) {
+- dprintf(LOG_DEBUG, FNAME,
++ debug_printf(LOG_DEBUG, FNAME,
+ "a timer must be expired, but not yet");
+ returnval.tv_sec = returnval.tv_usec = 0;
+ } else
diff --git a/debian/patches/0005-Update-ifid-on-interface-restart.patch b/debian/patches/0005-Update-ifid-on-interface-restart.patch
new file mode 100644
index 0000000..9f479e5
--- /dev/null
+++ b/debian/patches/0005-Update-ifid-on-interface-restart.patch
@@ -0,0 +1,33 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:12 +0200
+Subject: Update ifid on interface restart
+
+Interface ID may have changed between a stop and start.
+
+[rogershimizu@gmail.com: slightly modified according to 0004-GNU-libc6-fixes.patch]
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ dhcp6c.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/dhcp6c.c b/dhcp6c.c
+index c959b7c..1e897d2 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -768,6 +768,15 @@ client6_ifctl(ifname, command)
+
+ switch(command) {
+ case DHCP6CTL_COMMAND_START:
++ /*
++ * The ifid might have changed, so reset it before releasing the
++ * lease.
++ */
++ if (ifreset(ifp)) {
++ debug_printf(LOG_NOTICE, FNAME, "failed to reset %s",
++ ifname);
++ return (-1);
++ }
+ free_resources(ifp);
+ if (client6_start(ifp)) {
+ debug_printf(LOG_NOTICE, FNAME, "failed to restart %s",
diff --git a/debian/patches/0006-Add-new-feature-dhcp6c-profiles.patch b/debian/patches/0006-Add-new-feature-dhcp6c-profiles.patch
new file mode 100644
index 0000000..e3a458a
--- /dev/null
+++ b/debian/patches/0006-Add-new-feature-dhcp6c-profiles.patch
@@ -0,0 +1,626 @@
+From: Jeremie Corbier <jeremie+debian@famille-corbier.net>
+Date: Tue, 6 Apr 2010 15:51:14 +0200
+Subject: Add new feature: dhcp6c profiles
+
+This patch enables users to define interface profiles so one can configure a
+group of interfaces the same way without having to provide an interface
+statement for each.
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ cfparse.y | 23 +++-
+ cftoken.l | 10 ++
+ config.c | 334 +++++++++++++++++++++++++++++++++-------------------------
+ config.h | 3 +
+ dhcp6c.8 | 9 ++
+ dhcp6c.c | 5 +-
+ dhcp6c.conf.5 | 7 ++
+ 7 files changed, 245 insertions(+), 146 deletions(-)
+
+diff --git a/cfparse.y b/cfparse.y
+index dcac3d7..c79d131 100644
+--- a/cfparse.y
++++ b/cfparse.y
+@@ -83,6 +83,7 @@ extern void yyerror __P((char *, ...))
+ } while (0)
+
+ static struct cf_namelist *iflist_head, *hostlist_head, *iapdlist_head;
++static struct cf_namelist *profilelist_head;
+ static struct cf_namelist *addrpoollist_head;
+ static struct cf_namelist *authinfolist_head, *keylist_head;
+ static struct cf_namelist *ianalist_head;
+@@ -102,6 +103,7 @@ static void cleanup_cflist __P((struct cf_list *));
+ %}
+
+ %token INTERFACE IFNAME
++%token PROFILE PROFILENAME
+ %token PREFIX_INTERFACE SLA_ID SLA_LEN DUID_ID
+ %token ID_ASSOC IA_PD IAID IA_NA
+ %token ADDRESS
+@@ -133,7 +135,7 @@ static void cleanup_cflist __P((struct cf_list *));
+ }
+
+ %type <str> IFNAME HOSTNAME AUTHNAME KEYNAME DUID_ID STRING QSTRING IAID
+-%type <str> POOLNAME
++%type <str> POOLNAME PROFILENAME
+ %type <num> NUMBER duration authproto authalg authrdm
+ %type <list> declaration declarations dhcpoption ifparam ifparams
+ %type <list> address_list address_list_ent dhcpoption_list
+@@ -153,6 +155,7 @@ statements:
+
+ statement:
+ interface_statement
++ | profile_statement
+ | host_statement
+ | option_statement
+ | ia_statement
+@@ -174,6 +177,18 @@ interface_statement:
+ }
+ ;
+
++profile_statement:
++ PROFILE PROFILENAME BCL declarations ECL EOS
++ {
++ struct cf_namelist *profilelist;
++
++ MAKE_NAMELIST(profilelist, $2, $4);
++
++ if (add_namelist(profilelist, &profilelist_head))
++ return (-1);
++ }
++ ;
++
+ host_statement:
+ HOST HOSTNAME BCL declarations ECL EOS
+ {
+@@ -1224,6 +1239,8 @@ cleanup()
+ {
+ cleanup_namelist(iflist_head);
+ iflist_head = NULL;
++ cleanup_namelist(profilelist_head);
++ profilelist_head = NULL;
+ cleanup_namelist(hostlist_head);
+ hostlist_head = NULL;
+ cleanup_namelist(iapdlist_head);
+@@ -1318,6 +1335,9 @@ cf_post_config()
+ if (configure_pool(addrpoollist_head))
+ config_fail();
+
++ if (configure_profile(profilelist_head))
++ config_fail();
++
+ if (configure_interface(iflist_head))
+ config_fail();
+
+@@ -1337,4 +1357,5 @@ void
+ cf_init()
+ {
+ iflist_head = NULL;
++ profilelist_head = NULL;
+ }
+diff --git a/cftoken.l b/cftoken.l
+index ad4128d..4c9ed10 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -111,6 +111,7 @@ ecl \}
+
+ %s S_CNF
+ %s S_IFACE
++%s S_PROFILE
+ %s S_PREF
+ %s S_HOST
+ %s S_DUID
+@@ -137,6 +138,15 @@ ecl \}
+ return (IFNAME);
+ }
+
++ /* profile configuration */
++<S_CNF>profile { DECHO; BEGIN S_PROFILE; return (PROFILE); }
++<S_PROFILE>{string} {
++ DECHO;
++ yylval.str = strdup(yytext);
++ BEGIN S_CNF;
++ return (PROFILENAME);
++}
++
+ /* host configuration */
+ <S_CNF>host { DECHO; BEGIN S_HOST; return (HOST); }
+ <S_HOST>{string} {
+diff --git a/config.c b/config.c
+index 3721545..23598fc 100644
+--- a/config.c
++++ b/config.c
+@@ -61,6 +61,7 @@
+ #include <lease.h>
+
+ extern int errno;
++char *profile = NULL;
+
+ struct prefix_ifconf *prefix_ifconflist;
+ struct dhcp6_list siplist, sipnamelist, dnslist, dnsnamelist, ntplist;
+@@ -70,6 +71,7 @@ struct dhcp6_list bcmcslist, bcmcsnamelist;
+ long long optrefreshtime;
+
+ static struct dhcp6_ifconf *dhcp6_ifconflist;
++static struct dhcp6_ifconf *dhcp6_profileconflist;
+ struct ia_conflist ia_conflist0;
+ static struct host_conf *host_conflist0, *host_conflist;
+ static struct keyinfo *key_list, *key_list0;
+@@ -134,6 +136,8 @@ static void clear_iaconf __P((struct ia_conflist *));
+ static void clear_hostconf __P((struct host_conf *));
+ static void clear_keys __P((struct keyinfo *));
+ static void clear_authinfo __P((struct authinfo *));
++static int configure_interface_or_profile __P((struct cf_namelist *,
++ struct dhcp6_ifconf **));
+ static int configure_duid __P((char *, struct duid *));
+ static int configure_addr __P((struct cf_list *, struct dhcp6_list *, char *));
+ static int configure_domain __P((struct cf_list *, struct dhcp6_list *, char *));
+@@ -149,170 +153,199 @@ configure_interface(iflist)
+ struct cf_namelist *iflist;
+ {
+ struct cf_namelist *ifp;
+- struct dhcp6_ifconf *ifc;
+- char *cp;
+
+ for (ifp = iflist; ifp; ifp = ifp->next) {
+- struct cf_list *cfl;
+-
+ if (if_nametoindex(ifp->name) == 0) {
+ debug_printf(LOG_ERR, FNAME, "invalid interface(%s): %s",
+ ifp->name, strerror(errno));
+ goto bad;
+ }
+
+- if ((ifc = malloc(sizeof(*ifc))) == NULL) {
+- debug_printf(LOG_ERR, FNAME,
+- "memory allocation for %s failed", ifp->name);
++ if (configure_interface_or_profile(ifp, &dhcp6_ifconflist))
+ goto bad;
+- }
+- memset(ifc, 0, sizeof(*ifc));
+- ifc->next = dhcp6_ifconflist;
+- dhcp6_ifconflist = ifc;
++ }
++
++ return (0);
++bad:
++ clear_ifconf(dhcp6_ifconflist);
++ dhcp6_ifconflist = NULL;
++ return (-1);
++}
++
++int
++configure_profile(profilelist)
++ struct cf_namelist *profilelist;
++{
++ struct cf_namelist *profp;
+
+- if ((ifc->ifname = strdup(ifp->name)) == NULL) {
+- debug_printf(LOG_ERR, FNAME, "failed to copy ifname");
++ for (profp = profilelist; profp; profp = profp->next) {
++ if (configure_interface_or_profile(profp,
++ &dhcp6_profileconflist))
+ goto bad;
+- }
++ }
+
+- ifc->server_pref = DH6OPT_PREF_UNDEF;
+- TAILQ_INIT(&ifc->reqopt_list);
+- TAILQ_INIT(&ifc->iaconf_list);
++ return (0);
++bad:
++ clear_ifconf(dhcp6_profileconflist);
++ dhcp6_profileconflist = NULL;
++ return (-1);
++}
+
+- for (cfl = ifp->params; cfl; cfl = cfl->next) {
+- switch(cfl->type) {
+- case DECL_REQUEST:
+- if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- debug_printf(LOG_INFO, FNAME, "%s:%d "
+- "client-only configuration",
+- configfilename,
+- cfl->line);
+- goto bad;
+- }
+- if (add_options(DHCPOPTCODE_REQUEST,
+- ifc, cfl->list)) {
+- goto bad;
+- }
+- break;
+- case DECL_SEND:
+- if (add_options(DHCPOPTCODE_SEND,
+- ifc, cfl->list)) {
+- goto bad;
+- }
+- break;
+- case DECL_ALLOW:
+- if (add_options(DHCPOPTCODE_ALLOW,
+- ifc, cfl->list)) {
+- goto bad;
+- }
+- break;
+- case DECL_INFO_ONLY:
+- if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- debug_printf(LOG_INFO, FNAME, "%s:%d "
+- "client-only configuration",
+- configfilename, cfl->line);
+- goto bad;
+- }
+- ifc->send_flags |= DHCIFF_INFO_ONLY;
+- break;
+- case DECL_PREFERENCE:
+- if (dhcp6_mode != DHCP6_MODE_SERVER) {
+- debug_printf(LOG_INFO, FNAME, "%s:%d "
+- "server-only configuration",
+- configfilename, cfl->line);
+- goto bad;
+- }
+- ifc->server_pref = (int)cfl->num;
+- if (ifc->server_pref < 0 ||
+- ifc->server_pref > 255) {
+- debug_printf(LOG_INFO, FNAME, "%s:%d "
+- "bad value: %d",
++static int configure_interface_or_profile(ifp, conflist)
++ struct cf_namelist *ifp;
++ struct dhcp6_ifconf **conflist;
++{
++ struct dhcp6_ifconf *conf;
++ char *cp;
++ struct cf_list *cfl;
++
++ if ((conf = malloc(sizeof(*conf))) == NULL) {
++ debug_printf(LOG_ERR, FNAME,
++ "memory allocation for %s failed", ifp->name);
++ return (-1);
++ }
++ memset(conf, 0, sizeof(*conf));
++ conf->next = *conflist;
++ *conflist = conf;
++
++ if ((conf->ifname = strdup(ifp->name)) == NULL) {
++ debug_printf(LOG_ERR, FNAME, "failed to copy interface or "
++ "profile name");
++ return (-1);
++ }
++
++ conf->server_pref = DH6OPT_PREF_UNDEF;
++ TAILQ_INIT(&conf->reqopt_list);
++ TAILQ_INIT(&conf->iaconf_list);
++
++ for (cfl = ifp->params; cfl; cfl = cfl->next) {
++ switch(cfl->type) {
++ case DECL_REQUEST:
++ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
++ "client-only configuration",
++ configfilename,
++ cfl->line);
++ return (-1);
++ }
++ if (add_options(DHCPOPTCODE_REQUEST,
++ conf, cfl->list)) {
++ return (-1);
++ }
++ break;
++ case DECL_SEND:
++ if (add_options(DHCPOPTCODE_SEND,
++ conf, cfl->list)) {
++ return (-1);
++ }
++ break;
++ case DECL_ALLOW:
++ if (add_options(DHCPOPTCODE_ALLOW,
++ conf, cfl->list)) {
++ return (-1);
++ }
++ break;
++ case DECL_INFO_ONLY:
++ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
++ "client-only configuration",
++ configfilename, cfl->line);
++ return (-1);
++ }
++ conf->send_flags |= DHCIFF_INFO_ONLY;
++ break;
++ case DECL_PREFERENCE:
++ if (dhcp6_mode != DHCP6_MODE_SERVER) {
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
++ "server-only configuration",
++ configfilename, cfl->line);
++ return (-1);
++ }
++ conf->server_pref = (int)cfl->num;
++ if (conf->server_pref < 0 ||
++ conf->server_pref > 255) {
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
++ "bad value: %d",
++ configfilename, cfl->line,
++ conf->server_pref);
++ return (-1);
++ }
++ break;
++ case DECL_SCRIPT:
++ if (dhcp6_mode != DHCP6_MODE_CLIENT) {
++ debug_printf(LOG_INFO, FNAME, "%s:%d "
++ "client-only configuration",
++ configfilename, cfl->line);
++ return (-1);
++ }
++ if (conf->scriptpath) {
++ debug_printf(LOG_INFO, FNAME,
++ "%s:%d duplicated configuration",
++ configfilename, cfl->line);
++ return (-1);
++ }
++ cp = cfl->ptr;
++ conf->scriptpath = strdup(cp + 1);
++ if (conf->scriptpath == NULL) {
++ debug_printf(LOG_NOTICE, FNAME,
++ "failed to copy script path");
++ return (-1);
++ }
++ cp = conf->scriptpath;
++ if (*cp != '/') {
++ debug_printf(LOG_INFO, FNAME,
++ "script must be an absolute path");
++ return (-1);
++ }
++ cp += strlen(conf->scriptpath) - 1;
++ *cp = '\0'; /* clear the terminating quote */
++ break;
++ case DECL_ADDRESSPOOL:
++ {
++ struct dhcp6_poolspec* spec;
++ struct pool_conf* pool;
++
++ spec = (struct dhcp6_poolspec *)cfl->ptr;
++
++ for (pool = pool_conflist0; pool; pool = pool->next)
++ if (strcmp(spec->name, pool->name) == 0)
++ break;
++ if (pool == NULL) {
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
++ "pool '%s' not found",
+ configfilename, cfl->line,
+- ifc->server_pref);
+- goto bad;
+- }
+- break;
+- case DECL_SCRIPT:
+- if (dhcp6_mode != DHCP6_MODE_CLIENT) {
+- debug_printf(LOG_INFO, FNAME, "%s:%d "
+- "client-only configuration",
+- configfilename, cfl->line);
+- goto bad;
+- }
+- if (ifc->scriptpath) {
+- debug_printf(LOG_INFO, FNAME,
+- "%s:%d duplicated configuration",
+- configfilename, cfl->line);
+- goto bad;
+- }
+- cp = cfl->ptr;
+- ifc->scriptpath = strdup(cp + 1);
+- if (ifc->scriptpath == NULL) {
+- debug_printf(LOG_NOTICE, FNAME,
+- "failed to copy script path");
+- goto bad;
++ spec->name);
++ return (-1);
+ }
+- cp = ifc->scriptpath;
+- if (*cp != '/') {
+- debug_printf(LOG_INFO, FNAME,
+- "script must be an absolute path");
+- goto bad;
++ if (spec->vltime != DHCP6_DURATION_INFINITE &&
++ (spec->pltime == DHCP6_DURATION_INFINITE ||
++ spec->pltime > spec->vltime)) {
++ debug_printf(LOG_ERR, FNAME, "%s:%d ",
++ configfilename, cfl->line,
++ "specified a larger preferred lifetime "
++ "than valid lifetime");
++ return (-1);
+ }
+- cp += strlen(ifc->scriptpath) - 1;
+- *cp = '\0'; /* clear the terminating quote */
+- break;
+- case DECL_ADDRESSPOOL:
+- {
+- struct dhcp6_poolspec* spec;
+- struct pool_conf* pool;
+-
+- spec = (struct dhcp6_poolspec *)cfl->ptr;
+-
+- for (pool = pool_conflist0; pool; pool = pool->next)
+- if (strcmp(spec->name, pool->name) == 0)
+- break;
+- if (pool == NULL) {
+- debug_printf(LOG_ERR, FNAME, "%s:%d "
+- "pool '%s' not found",
+- configfilename, cfl->line,
+- spec->name);
+- goto bad;
+- }
+- if (spec->vltime != DHCP6_DURATION_INFINITE &&
+- (spec->pltime == DHCP6_DURATION_INFINITE ||
+- spec->pltime > spec->vltime)) {
+- debug_printf(LOG_ERR, FNAME, "%s:%d ",
+- configfilename, cfl->line,
+- "specified a larger preferred lifetime "
+- "than valid lifetime");
+- goto bad;
+- }
+- ifc->pool = *spec;
+- if ((ifc->pool.name = strdup(spec->name)) == NULL) {
+- debug_printf(LOG_ERR, FNAME,
+- "memory allocation failed");
+- goto bad;
+- }
+- debug_printf(LOG_DEBUG, FNAME,
+- "pool '%s' is specified to the interface '%s'",
+- ifc->pool.name, ifc->ifname);
++ conf->pool = *spec;
++ if ((conf->pool.name = strdup(spec->name)) == NULL) {
++ debug_printf(LOG_ERR, FNAME,
++ "memory allocation failed");
++ return (-1);
+ }
+- break;
+- default:
+- debug_printf(LOG_ERR, FNAME, "%s:%d "
+- "invalid interface configuration",
+- configfilename, cfl->line);
+- goto bad;
++ debug_printf(LOG_DEBUG, FNAME,
++ "pool '%s' is specified to the interface '%s'",
++ conf->pool.name, conf->ifname);
+ }
++ break;
++ default:
++ debug_printf(LOG_ERR, FNAME, "%s:%d "
++ "invalid interface configuration",
++ configfilename, cfl->line);
++ return (-1);
+ }
+ }
+
+ return (0);
+-
+- bad:
+- clear_ifconf(dhcp6_ifconflist);
+- dhcp6_ifconflist = NULL;
+- return (-1);
+ }
+
+ int
+@@ -1275,6 +1308,8 @@ configure_cleanup()
+ clear_iaconf(&ia_conflist0);
+ clear_ifconf(dhcp6_ifconflist);
+ dhcp6_ifconflist = NULL;
++ clear_ifconf(dhcp6_profileconflist);
++ dhcp6_profileconflist = NULL;
+ clear_hostconf(host_conflist0);
+ host_conflist0 = NULL;
+ clear_keys(key_list0);
+@@ -1322,8 +1357,17 @@ configure_commit()
+ if (strcmp(ifp->ifname, ifc->ifname) == 0)
+ break;
+ }
+- if (ifc == NULL)
+- continue;
++ if (ifc == NULL) {
++ if (profile == NULL)
++ continue;
++ for (ifc = dhcp6_profileconflist; ifc;
++ ifc = ifc->next) {
++ if (strcmp(profile, ifc->ifname) == 0)
++ break;
++ }
++ if (ifc == NULL)
++ continue;
++ }
+
+ /* copy new configuration */
+ ifp->send_flags = ifc->send_flags;
+@@ -1349,6 +1393,8 @@ configure_commit()
+
+ clear_ifconf(dhcp6_ifconflist);
+ dhcp6_ifconflist = NULL;
++ clear_ifconf(dhcp6_profileconflist);
++ dhcp6_profileconflist = NULL;
+
+ /* clear unused IA configuration */
+ if (!TAILQ_EMPTY(&ia_conflist0)) {
+diff --git a/config.h b/config.h
+index bf6dae6..ea8d17c 100644
+--- a/config.h
++++ b/config.h
+@@ -285,6 +285,8 @@ dhcp6_mode_t;
+
+ extern const dhcp6_mode_t dhcp6_mode;
+
++extern char *profile;
++
+ extern struct dhcp6_if *dhcp6_if;
+ extern struct dhcp6_ifconf *dhcp6_iflist;
+ extern struct prefix_ifconf *prefix_ifconflist;
+@@ -304,6 +306,7 @@ extern long long optrefreshtime;
+ extern struct dhcp6_if *ifinit __P((char *));
+ extern int ifreset __P((struct dhcp6_if *));
+ extern int configure_interface __P((struct cf_namelist *));
++extern int configure_profile __P((struct cf_namelist *));
+ extern int configure_host __P((struct cf_namelist *));
+ extern int configure_keys __P((struct cf_namelist *));
+ extern int configure_authinfo __P((struct cf_namelist *));
+diff --git a/dhcp6c.8 b/dhcp6c.8
+index 1d69c9d..acc8f46 100644
+--- a/dhcp6c.8
++++ b/dhcp6c.8
+@@ -39,6 +39,7 @@
+ .Op Fl c Ar configfile
+ .Op Fl Ddfi
+ .Op Fl p Ar pid-file
++.Op Fl P Ar profile
+ .Ar interface
+ .Op Ar interfaces...
+ .\"
+@@ -92,6 +93,14 @@ Use
+ .Ar pid-file
+ to dump the process ID of
+ .Nm .
++.It Fl P Ar profile
++Use the given
++.Ar profile
++defined in the
++.Nm
++configuration file for
++.Ar interfaces
++which do not have a specific configuration.
+ .El
+ .Pp
+ The program will daemonize itself on invocation unless the
+diff --git a/dhcp6c.c b/dhcp6c.c
+index 1e897d2..1953f76 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -170,7 +170,7 @@ main(argc, argv)
+ else
+ progname++;
+
+- while ((ch = getopt(argc, argv, "c:dDfik:p:")) != -1) {
++ while ((ch = getopt(argc, argv, "c:dDfik:p:P:")) != -1) {
+ switch (ch) {
+ case 'c':
+ conffile = optarg;
+@@ -193,6 +193,9 @@ main(argc, argv)
+ case 'p':
+ pid_file = optarg;
+ break;
++ case 'P':
++ profile = optarg;
++ break;
+ default:
+ usage();
+ exit(0);
+diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5
+index 5fc03d3..3d5d25a 100644
+--- a/dhcp6c.conf.5
++++ b/dhcp6c.conf.5
+@@ -288,6 +288,13 @@ file, and be created by the same owner who runs the daemon.
+ .El
+ .El
+ .\"
++.Sh Profile statement
++Some setups may require to configure an interface independently from its name.
++Profiles are available for this particular purpose. They follow the same syntax
++as an interface statement except they can be arbitrarily named. It is then
++possible to choose which profile to use for a given interface on the command
++line.
++.\"
+ .Sh Identity association statement
+ Identity association
+ .Pq IA
diff --git a/debian/patches/0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch b/debian/patches/0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch
new file mode 100644
index 0000000..eb9869e
--- /dev/null
+++ b/debian/patches/0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch
@@ -0,0 +1,146 @@
+From: =?utf-8?q?Bj=C3=B8rn_Mork?= <bjorn@mork.no>
+Date: Wed, 10 Nov 2010 07:41:55 +0100
+Subject: Adding ifid option to the dhcp6c.conf prefix-interface statement
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+This adds the ability to override the default EUI-64 address selection.
+Useful for interfaces without a unique hardware address, or for creating
+more userfriendly addresses in general.
+
+Signed-off-by: Bjørn Mork <bjorn@mork.no>
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ cfparse.y | 10 +++++++++-
+ cftoken.l | 1 +
+ config.c | 19 ++++++++++++++-----
+ config.h | 2 +-
+ dhcp6c.conf.5 | 10 ++++++++++
+ 5 files changed, 35 insertions(+), 7 deletions(-)
+
+diff --git a/cfparse.y b/cfparse.y
+index c79d131..e83ecf7 100644
+--- a/cfparse.y
++++ b/cfparse.y
+@@ -104,7 +104,7 @@ static void cleanup_cflist __P((struct cf_list *));
+
+ %token INTERFACE IFNAME
+ %token PROFILE PROFILENAME
+-%token PREFIX_INTERFACE SLA_ID SLA_LEN DUID_ID
++%token PREFIX_INTERFACE SLA_ID SLA_LEN IFID DUID_ID
+ %token ID_ASSOC IA_PD IAID IA_NA
+ %token ADDRESS
+ %token REQUEST SEND ALLOW PREFERENCE
+@@ -1056,6 +1056,14 @@ ifparam:
+ l->num = $2;
+ $$ = l;
+ }
++ | IFID NUMBER EOS
++ {
++ struct cf_list *l;
++
++ MAKE_CFLIST(l, IFPARAM_IFID, NULL, NULL);
++ l->num = (u_int64_t)$2;
++ $$ = l;
++ }
+ ;
+
+ ianaconf_list:
+diff --git a/cftoken.l b/cftoken.l
+index 4c9ed10..6afda5f 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -240,6 +240,7 @@ ecl \}
+ <S_CNF>prefix-interface { DECHO; BEGIN S_IFACE; return (PREFIX_INTERFACE); }
+ <S_CNF>sla-id { DECHO; return (SLA_ID); }
+ <S_CNF>sla-len { DECHO; return (SLA_LEN); }
++<S_CNF>ifid { DECHO; return (IFID); }
+
+ /* duration */
+ <S_CNF>infinity { DECHO; return (INFINITY); }
+diff --git a/config.c b/config.c
+index 23598fc..e04d6a5 100644
+--- a/config.c
++++ b/config.c
+@@ -471,6 +471,7 @@ add_pd_pif(iapdc, cfl0)
+ {
+ struct cf_list *cfl;
+ struct prefix_ifconf *pif;
++ int i, use_default_ifid = 1;
+
+ /* duplication check */
+ for (pif = TAILQ_FIRST(&iapdc->iapd_pif_list); pif;
+@@ -504,11 +505,6 @@ add_pd_pif(iapdc, cfl0)
+
+ pif->ifid_len = IFID_LEN_DEFAULT;
+ pif->sla_len = SLA_LEN_DEFAULT;
+- if (get_default_ifid(pif)) {
+- debug_printf(LOG_NOTICE, FNAME,
+- "failed to get default IF ID for %s", pif->ifname);
+- goto bad;
+- }
+
+ for (cfl = cfl0->list; cfl; cfl = cfl->next) {
+ switch(cfl->type) {
+@@ -524,6 +520,11 @@ add_pd_pif(iapdc, cfl0)
+ goto bad;
+ }
+ break;
++ case IFPARAM_IFID:
++ for (i = sizeof(pif->ifid) -1; i >= 0; i--)
++ pif->ifid[i] = (cfl->num >> 8*(sizeof(pif->ifid) - 1 - i)) & 0xff;
++ use_default_ifid = 0;
++ break;
+ default:
+ debug_printf(LOG_ERR, FNAME, "%s:%d internal error: "
+ "invalid configuration",
+@@ -532,6 +533,14 @@ add_pd_pif(iapdc, cfl0)
+ }
+ }
+
++ if (use_default_ifid) {
++ if (get_default_ifid(pif)) {
++ debug_printf(LOG_NOTICE, FNAME,
++ "failed to get default IF ID for %s", pif->ifname);
++ goto bad;
++ }
++ }
++
+ TAILQ_INSERT_TAIL(&iapdc->iapd_pif_list, pif, link);
+ return (0);
+
+diff --git a/config.h b/config.h
+index ea8d17c..64ce9e8 100644
+--- a/config.h
++++ b/config.h
+@@ -266,7 +266,7 @@ enum { DECL_SEND, DECL_ALLOW, DECL_INFO_ONLY, DECL_REQUEST, DECL_DUID,
+ DECL_PREFIX, DECL_PREFERENCE, DECL_SCRIPT, DECL_DELAYEDKEY,
+ DECL_ADDRESS,
+ DECL_RANGE, DECL_ADDRESSPOOL,
+- IFPARAM_SLA_ID, IFPARAM_SLA_LEN,
++ IFPARAM_SLA_ID, IFPARAM_SLA_LEN, IFPARAM_IFID,
+ DHCPOPT_RAPID_COMMIT, DHCPOPT_AUTHINFO,
+ DHCPOPT_DNS, DHCPOPT_DNSNAME,
+ DHCPOPT_IA_PD, DHCPOPT_IA_NA, DHCPOPT_NTP,
+diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5
+index 3d5d25a..1c91d72 100644
+--- a/dhcp6c.conf.5
++++ b/dhcp6c.conf.5
+@@ -443,6 +443,16 @@ This statement specifies the length of the SLA ID in bits.
+ must be a decimal number between 0 and 128.
+ If the length is not specified by this statement,
+ the default value 16 will be used.
++.It Xo
++.Ic ifid Ar ID
++;
++.Xc
++This statement specifies the interface id.
++.Ar ID
++must be a decimal integer. It will be combined with the delegated
++prefix and the sla-id to form a complete interface address. The
++default is to use the EUI-64 address of the
++.Ar interface .
+ .El
+ .El
+ .\"
diff --git a/debian/patches/0008-Close-file-descriptors-on-exec.patch b/debian/patches/0008-Close-file-descriptors-on-exec.patch
new file mode 100644
index 0000000..8de2b05
--- /dev/null
+++ b/debian/patches/0008-Close-file-descriptors-on-exec.patch
@@ -0,0 +1,219 @@
+From: Jeremie Corbier <jeremie@famille-corbier.net>
+Date: Tue, 2 Dec 2014 10:52:42 +0100
+Subject: Close file descriptors on exec
+
+Avoid FD leakage to children
+Closes: #757848
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ cftoken.c | 8 ++++++++
+ cftoken.l | 8 ++++++++
+ common.c | 15 ++++++++++++++-
+ dhcp6_ctl.c | 3 +++
+ dhcp6_ctlclient.c | 3 +++
+ dhcp6c.c | 11 ++++++++++-
+ dhcp6relay.c | 6 ++++++
+ missing/getifaddrs.c | 9 +++++++--
+ 8 files changed, 59 insertions(+), 4 deletions(-)
+
+diff --git a/cftoken.c b/cftoken.c
+index 0f6c1bf..079f274 100644
+--- a/cftoken.c
++++ b/cftoken.c
+@@ -2539,7 +2539,11 @@ cfswitch_buffer(incl)
+ incstack[incstackp].state = YY_CURRENT_BUFFER;
+ incstack[incstackp].lineno = lineno;
+
++#ifdef __linux__
++ fp = fopen(path, "re");
++#else
+ fp = fopen(path, "r");
++#endif
+ if (fp == NULL) {
+ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ path, strerror(errno));
+@@ -2562,7 +2566,11 @@ cfparse(conf)
+ char *conf;
+ {
+ configfilename = conf;
++#ifdef __linux__
++ if ((yyin = fopen(configfilename, "re")) == NULL) {
++#else
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
++#endif
+ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ configfilename, strerror(errno));
+ if (errno == ENOENT)
+diff --git a/cftoken.l b/cftoken.l
+index 6afda5f..f480406 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -415,7 +415,11 @@ cfswitch_buffer(incl)
+ incstack[incstackp].state = YY_CURRENT_BUFFER;
+ incstack[incstackp].lineno = lineno;
+
++#ifdef __linux__
++ fp = fopen(path, "re");
++#else
+ fp = fopen(path, "r");
++#endif
+ if (fp == NULL) {
+ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ path, strerror(errno));
+@@ -438,7 +442,11 @@ cfparse(conf)
+ char *conf;
+ {
+ configfilename = conf;
++#ifdef __linux__
++ if ((yyin = fopen(configfilename, "re")) == NULL) {
++#else
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
++#endif
+ debug_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
+ configfilename, strerror(errno));
+ if (errno == ENOENT)
+diff --git a/common.c b/common.c
+index cc4abcc..b5c09c3 100644
+--- a/common.c
++++ b/common.c
+@@ -1115,7 +1115,11 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
+ (void) snprintf(fname, sizeof (fname), "/dev/%s", ifname);
+ getctl.maxlen = sizeof (getbuf);
+ getctl.buf = (char *)getbuf;
++#ifdef __linux__
++ if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1) {
++#else
+ if ((fd = open(fname, O_RDWR)) == -1) {
++#endif
+ dl_attach_req_t dlar;
+
+ cp = fname + strlen(fname) - 1;
+@@ -1131,7 +1135,11 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
+ cp++;
+ dlar.dl_ppa = atoi(cp);
+ *cp = '\0';
++#ifdef __linux__
++ if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1)
++#else
+ if ((fd = open(fname, O_RDWR)) == -1)
++#endif
+ return (-1);
+ dlar.dl_primitive = DL_ATTACH_REQ;
+ putctl.len = sizeof (dlar);
+@@ -3292,7 +3300,12 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ return (-1);
+ }
+
+- if ((s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
++#ifdef __linux__
++#define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
++#else
++#define SOCKTYPE SOCK_DGRAM
++#endif
++ if ((s = socket(PF_INET6, SOCKTYPE, IPPROTO_UDP)) < 0) {
+ debug_printf(LOG_ERR, FNAME, "can't open a temporary socket: %s",
+ strerror(errno));
+ return (-1);
+diff --git a/dhcp6_ctl.c b/dhcp6_ctl.c
+index a12f82a..f1bae0b 100644
+--- a/dhcp6_ctl.c
++++ b/dhcp6_ctl.c
+@@ -97,6 +97,9 @@ dhcp6_ctl_init(addr, port, max, sockp)
+ gai_strerror(error));
+ return (-1);
+ }
++#ifdef __linux__
++ res->ai_socktype |= SOCK_CLOEXEC;
++#endif
+ ctlsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (ctlsock < 0) {
+ debug_printf(LOG_ERR, FNAME, "socket(control sock): %s",
+diff --git a/dhcp6_ctlclient.c b/dhcp6_ctlclient.c
+index 5597c9e..2bec3e7 100644
+--- a/dhcp6_ctlclient.c
++++ b/dhcp6_ctlclient.c
+@@ -169,6 +169,9 @@ main(argc, argv)
+
+ s = -1;
+ for (res = res0; res != NULL; res = res->ai_next) {
++#ifdef __linux__
++ res->ai_socktype |= SOCK_CLOEXEC;
++#endif
+ s = socket(res->ai_family, res->ai_socktype,
+ res->ai_protocol);
+ if (s < 0) {
+diff --git a/dhcp6c.c b/dhcp6c.c
+index 1953f76..ccb601c 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -290,6 +290,10 @@ client6_init()
+ gai_strerror(error));
+ exit(1);
+ }
++#ifdef __linux__
++ /* Force socket to be closed on execve */
++ res->ai_socktype |= SOCK_CLOEXEC;
++#endif
+ sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (sock < 0) {
+ debug_printf(LOG_ERR, FNAME, "socket");
+@@ -346,7 +350,12 @@ client6_init()
+ freeaddrinfo(res);
+
+ /* open a routing socket to watch the routing table */
+- if ((rtsock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
++#ifdef __linux__
++#define SOCKTYPE (SOCK_RAW | SOCK_CLOEXEC)
++#else
++#define SOCKTYPE SOCK_RAW
++#endif
++ if ((rtsock = socket(PF_ROUTE, SOCKTYPE, 0)) < 0) {
+ debug_printf(LOG_ERR, FNAME, "open a routing socket: %s",
+ strerror(errno));
+ exit(1);
+diff --git a/dhcp6relay.c b/dhcp6relay.c
+index 99b1227..200d3cb 100644
+--- a/dhcp6relay.c
++++ b/dhcp6relay.c
+@@ -359,6 +359,9 @@ relay6_init(int ifnum, char *iflist[])
+ gai_strerror(error));
+ goto failexit;
+ }
++#ifdef __linux__
++ res->ai_socktype |= SOCK_CLOEXEC;
++#endif
+ csock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (csock < 0) {
+ debug_printf(LOG_ERR, FNAME, "socket(csock): %s", strerror(errno));
+@@ -465,6 +468,9 @@ relay6_init(int ifnum, char *iflist[])
+ goto failexit;
+ }
+ memcpy(&sa6_client, res->ai_addr, sizeof (sa6_client));
++#ifdef __linux__
++ res->ai_socktype |= SOCK_CLOEXEC;
++#endif
+ ssock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (ssock < 0) {
+ debug_printf(LOG_ERR, FNAME, "socket(outsock): %s",
+diff --git a/missing/getifaddrs.c b/missing/getifaddrs.c
+index 4320c43..23b3e43 100644
+--- a/missing/getifaddrs.c
++++ b/missing/getifaddrs.c
+@@ -167,9 +167,14 @@ getifaddrs(struct ifaddrs **ifap)
+ struct ifaddrs *ifa = NULL;
+ char *buf;
+
+- if ((fd4 = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
++#ifdef __linux__
++#define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
++#else
++#define SOCKTYPE SOCK_DGRAM
++#endif
++ if ((fd4 = socket(AF_INET, SOCKTYPE, 0)) == -1)
+ return (-1);
+- if ((fd6 = socket(AF_INET6, SOCK_DGRAM, 0)) == -1 &&
++ if ((fd6 = socket(AF_INET6, SOCKTYPE, 0)) == -1 &&
+ errno != EAFNOSUPPORT) {
+ (void) close(fd4);
+ return (-1);
diff --git a/debian/patches/0009-Fix-renewal-of-IA-NA.patch b/debian/patches/0009-Fix-renewal-of-IA-NA.patch
new file mode 100644
index 0000000..131c0b5
--- /dev/null
+++ b/debian/patches/0009-Fix-renewal-of-IA-NA.patch
@@ -0,0 +1,23 @@
+From: Jeremie Corbier <jeremie@famille-corbier.net>
+Date: Tue, 2 Dec 2014 11:04:59 +0100
+Subject: Fix renewal of IA NA
+
+Submitted-by: Vegard Engen <vegard@engen.priv.no>
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ addrconf.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/addrconf.c b/addrconf.c
+index 98d03e5..47f1738 100644
+--- a/addrconf.c
++++ b/addrconf.c
+@@ -173,7 +173,7 @@ update_address(ia, addr, dhcpifp, ctlp, callback)
+ sacreate ? "create" : "update",
+ in6addr2str(&addr->addr, 0), addr->pltime, addr->vltime);
+
+- if (sa->addr.vltime != 0)
++ if ((sa->addr.vltime != 0) && sacreate)
+ if (na_ifaddrconf(IFADDRCONF_ADD, sa) < 0)
+ return (-1);
+
diff --git a/debian/patches/0010-Call-client-script-after-interfaces-have-been-update.patch b/debian/patches/0010-Call-client-script-after-interfaces-have-been-update.patch
new file mode 100644
index 0000000..4d35478
--- /dev/null
+++ b/debian/patches/0010-Call-client-script-after-interfaces-have-been-update.patch
@@ -0,0 +1,47 @@
+From: Jeremie Corbier <jeremie@famille-corbier.net>
+Date: Tue, 2 Dec 2014 11:18:52 +0100
+Subject: Call client script after interfaces have been updated
+
+Closes: #734644
+
+Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
+---
+ dhcp6c.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/dhcp6c.c b/dhcp6c.c
+index ccb601c..1d10a78 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -1853,15 +1853,6 @@ client6_recvreply(ifp, dh6, len, optinfo)
+ }
+ }
+
+- /*
+- * Call the configuration script, if specified, to handle various
+- * configuration parameters.
+- */
+- if (ifp->scriptpath != NULL && strlen(ifp->scriptpath) != 0) {
+- debug_printf(LOG_DEBUG, FNAME, "executes %s", ifp->scriptpath);
+- client6_script(ifp->scriptpath, state, optinfo);
+- }
+-
+ /*
+ * Set refresh timer for configuration information specified in
+ * information-request. If the timer value is specified by the server
+@@ -1927,6 +1918,15 @@ client6_recvreply(ifp, dh6, len, optinfo)
+ check_exit();
+ }
+
++ /*
++ * Call the configuration script, if specified, to handle various
++ * configuration parameters.
++ */
++ if (ifp->scriptpath != NULL && strlen(ifp->scriptpath) != 0) {
++ debug_printf(LOG_DEBUG, FNAME, "executes %s", ifp->scriptpath);
++ client6_script(ifp->scriptpath, state, optinfo);
++ }
++
+ debug_printf(LOG_DEBUG, FNAME, "got an expected reply, sleeping.");
+
+ if (infreq_mode) {
diff --git a/debian/patches/0011-resolv-warnings-so-as-to-make-blhc-and-gcc-both-happ.patch b/debian/patches/0011-resolv-warnings-so-as-to-make-blhc-and-gcc-both-happ.patch
new file mode 100644
index 0000000..4a4e914
--- /dev/null
+++ b/debian/patches/0011-resolv-warnings-so-as-to-make-blhc-and-gcc-both-happ.patch
@@ -0,0 +1,137 @@
+From: Roger Shimizu <rogershimizu@gmail.com>
+Date: Wed, 2 Nov 2016 00:32:22 +0900
+Subject: resolv warnings so as to make "blhc" and "gcc" both happy
+
+- blhc complained: lacking of CFLAGS/CPPFLAGS for C files in Makefile
+- gcc complained implicit declaration of function 'time'
+- gcc complained ignoring return value of 'read'
+- adjust objects dependency and make parallel build working
+
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ Makefile.in | 19 ++++++++++---------
+ addrconf.c | 11 ++++++++++-
+ missing/arc4random.c | 3 ++-
+ prefixconf.c | 11 ++++++++++-
+ 4 files changed, 32 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index de25f48..2c8d6f3 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -36,7 +36,7 @@ localdbdir= @localdbdir@
+ user= @user@
+ group= @group@
+
+-CFLAGS= @CFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
++CFLAGS= @CFLAGS@ @CPPFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
+ -DLOCALDBDIR=\"${localdbdir}\"
+ LDFLAGS=@LDFLAGS@
+ LIBOBJS=@LIBOBJS@
+@@ -73,7 +73,8 @@ dhcp6relay: $(RELAYOBJS) $(LIBOBJS)
+ dhcp6ctl: $(CTLOBJS)
+ $(CC) $(LDFLAGS) -o $@ $(CTLOBJS) $(LIBOBJS) $(LIBS)
+
+-cfparse.c y.tab.h: cfparse.y
++cfparse.c: y.tab.h
++y.tab.h: cfparse.y
+ @YACC@ -d cfparse.y
+ mv y.tab.c cfparse.c
+
+@@ -82,21 +83,21 @@ cftoken.c: cftoken.l y.tab.h
+ mv lex.yy.c $@
+
+ getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ getnameinfo.o: $(srcdir)/missing/getnameinfo.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ strlcat.o: $(srcdir)/missing/strlcat.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ strlcpy.o: $(srcdir)/missing/strlcpy.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ arc4random.o: $(srcdir)/missing/arc4random.c
+ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ getifaddrs.o: $(srcdir)/missing/getifaddrs.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ daemon.o: $(srcdir)/missing/daemon.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+ warnx.o: $(srcdir)/missing/warnx.c
+- $(CC) -c $(srcdir)/missing/$*.c
++ $(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
+
+ $(srcdir)/ianaopts.h: gentab.pl bootp-dhcp-parameters
+ expand bootp-dhcp-parameters | perl gentab.pl > ianaopts.h
+diff --git a/addrconf.c b/addrconf.c
+index 47f1738..a8c52bc 100644
+--- a/addrconf.c
++++ b/addrconf.c
+@@ -29,11 +29,20 @@
+ * SUCH DAMAGE.
+ */
+ #include <sys/types.h>
+-#include <sys/time.h>
+ #include <sys/socket.h>
+ #include <sys/queue.h>
+ #include <sys/ioctl.h>
+
++#if TIME_WITH_SYS_TIME
++# include <sys/time.h>
++# include <time.h>
++#else
++# if HAVE_SYS_TIME_H
++# include <sys/time.h>
++# else
++# include <time.h>
++# endif
++#endif
+ #include <net/if.h>
+ #ifdef __FreeBSD__
+ #include <net/if_var.h>
+diff --git a/missing/arc4random.c b/missing/arc4random.c
+index 8d1e050..7fe143b 100644
+--- a/missing/arc4random.c
++++ b/missing/arc4random.c
+@@ -59,9 +59,10 @@ u_int32_t
+ arc4random()
+ {
+ u_int32_t v;
++ ssize_t n;
+
+ if (fd < 0)
+ arc4random_init();
+- read(fd, &v, sizeof(v));
++ n = read(fd, &v, sizeof(v));
+ return v;
+ }
+diff --git a/prefixconf.c b/prefixconf.c
+index 9450a3f..15b5417 100644
+--- a/prefixconf.c
++++ b/prefixconf.c
+@@ -29,11 +29,20 @@
+ * SUCH DAMAGE.
+ */
+ #include <sys/types.h>
+-#include <sys/time.h>
+ #include <sys/socket.h>
+ #include <sys/queue.h>
+ #include <sys/ioctl.h>
+
++#if TIME_WITH_SYS_TIME
++# include <sys/time.h>
++# include <time.h>
++#else
++# if HAVE_SYS_TIME_H
++# include <sys/time.h>
++# else
++# include <time.h>
++# endif
++#endif
+ #include <net/if.h>
+ #ifdef __FreeBSD__
+ #include <net/if_var.h>
diff --git a/debian/patches/0012-fix-a-redefined-YYDEBUG-warning-of-gcc-for-the-code-.patch b/debian/patches/0012-fix-a-redefined-YYDEBUG-warning-of-gcc-for-the-code-.patch
new file mode 100644
index 0000000..139cb91
--- /dev/null
+++ b/debian/patches/0012-fix-a-redefined-YYDEBUG-warning-of-gcc-for-the-code-.patch
@@ -0,0 +1,24 @@
+From: Roger Shimizu <rogershimizu@gmail.com>
+Date: Thu, 10 Sep 2015 22:19:10 +0900
+Subject: fix a redefined "YYDEBUG" warning of gcc for the code generated by
+ bison/flex
+
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ cftoken.l | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/cftoken.l b/cftoken.l
+index f480406..e307357 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -72,6 +72,9 @@ static int yy_first_time = 1;
+ static int yyerrorcount = 0;
+
+ #ifndef NOCONFIG_DEBUG
++#ifdef YYDEBUG
++#undef YYDEBUG
++#endif
+ #define YYDEBUG 1
+
+ int cfdebug = 1;
diff --git a/debian/patches/0013-added-several-comments-examples-by-Stefan-Sperling.patch b/debian/patches/0013-added-several-comments-examples-by-Stefan-Sperling.patch
new file mode 100644
index 0000000..bd83954
--- /dev/null
+++ b/debian/patches/0013-added-several-comments-examples-by-Stefan-Sperling.patch
@@ -0,0 +1,155 @@
+From: SUZUKI Shinsuke <suz@kame.net>
+Date: Wed, 30 Jul 2008 15:29:42 +0000
+Subject: added several comments/examples. (contributed by Stefan Sperling)
+
+---
+ CHANGES | 4 ++++
+ dhcp6c.conf.sample | 43 ++++++++++++++++++++++++++++++++++++++++---
+ dhcp6s.conf.sample | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
+ 3 files changed, 90 insertions(+), 11 deletions(-)
+
+diff --git a/CHANGES b/CHANGES
+index a1f62d8..8fa1f7b 100644
+--- a/CHANGES
++++ b/CHANGES
+@@ -1,3 +1,7 @@
++2008-07-30 SUZUKI, Shinsuke <suz@kame.net>
++ * dhcp6[cs].conf.sample: added several comments/examples.
++ (contributed by Stefan Sperling)
++
+ --- 20080615 tar ball released ---
+ 2008-05-01 SUZUKI, Shinsuke <suz@kame.net>
+ * common.c: fixed a memory leak (Bug-ID: 1847587)
+diff --git a/dhcp6c.conf.sample b/dhcp6c.conf.sample
+index 3aeede1..0b192b9 100644
+--- a/dhcp6c.conf.sample
++++ b/dhcp6c.conf.sample
+@@ -1,11 +1,31 @@
+-# The followings are a sample configuration for requiring the "stateless"
+-# DHCPv6 service.
++# The following is an example for use with IPv6 auto-configuration.
++# The "information-only" statement makes dhcp6c exchange informational
++# configuration parameters with servers. A list of DNS server addresses
++# is an example of such parameters. This statement is useful when the
++# client does not need stateful configuration parameters such as IPv6
++# addresses or prefixes.
++
+ interface ne0 {
+ information-only;
+ };
+
+
+-# The followings are a sample configuration to be delegated an IPv6 prefix
++# The following is a sample configuration for a client on a LAN
++# where IPv6 addresses are assigned via DHCPv6 ("stateful address
++# assignment"). Use this if you want the client to query the
++# DHCPv6 server for an IPv6 address and for DNS servers, as in
++# traditional IPv4 DHCP.
++
++interface em0 {
++ send ia-na 0;
++ send rapid-commit;
++ send domain-name-servers;
++};
++
++id-assoc na {
++};
++
++# The following is an example configuration for delegation of an IPv6 prefix
+ # from an upstream service provider. With this configuration dhcp6c will
+ # send solicit messages containing an IA_PD option, with an IAID 0, on to
+ # an upstream PPP link, ppp0. After receiving some prefixes from a server,
+@@ -22,3 +42,20 @@ id-assoc pd {
+ sla-id 1;
+ };
+ };
++
++# If a shared secret was to be configured in both the client and the server
++# for DHCPv6 authentication, it would be specified in this file as follows:
++
++keyinfo kame-key {
++ realm "kame.net";
++ keyid 1;
++ secret "5pvW2g48OHPvkYMJSw0vZA==";
++};
++
++# And the interface statement would be modified as follows:
++
++interface ppp0 {
++ send ia-pd 0;
++ send authentication kame;
++};
++
+diff --git a/dhcp6s.conf.sample b/dhcp6s.conf.sample
+index a3f5f27..cd903cc 100644
+--- a/dhcp6s.conf.sample
++++ b/dhcp6s.conf.sample
+@@ -1,5 +1,5 @@
+-# The followings are a sample configuration to provide a DNS server address
+-# for every client as well as to delegate a permanent IPv6 prefix
++# The following is an example configuration which provides a DNS server
++# address to every client, and also delegates a permanent IPv6 prefix
+ # 2001:db8:1111::/48 to a client whose DUID is 00:01:00:01:aa:bb.
+
+ option domain-name-servers 2001:db8::35;
+@@ -9,12 +9,30 @@ host kame {
+ prefix 2001:db8:1111::/48 infinity;
+ };
+
+-# The followings are a sample configuration to provide an IPv6 address
+-# from an address pool 2001:db8:1:2::1000-2000 for 3600[s].
+-# Note. You have to send an RA to fxp0; otherwise a client cannot be sure
+-# about the prefix-length and the default router. If you want to prevent
+-# stateless address configuration via RA, please set the autonomous-flag to
+-# OFF in your RA configuration.
++# If a shared secret was to be configured in both the server and the client
++# for DHCPv6 authentication, it would be specified in this file as follows:
++
++keyinfo kame {
++ realm "kame.net";
++ keyid 1;
++ secret "5pvW2g48OHPvkYMJSw0vZA==";
++};
++
++# And the host statement would be modified as follows:
++
++host kame {
++ duid 00:01:00:01:aa:bb;
++ prefix 2001:db8:1111::/48 infinity;
++ delayedkey kame;
++};
++
++# The following is an example configuration which provides an IPv6 address
++# from an address pool (2001:db8:1:2::1000-2000) with a lease time of 3600
++# seconds to any client attached to the fxp0 interface. Note that you have
++# to send router advertisements on fxp0, i.e. run rtadvd(8) on that interface.
++# Otherwise a client cannot know the prefix-length and the default router.
++# If you want to prevent stateless address configuration via RA, please
++# set the autonomous-flag to OFF in your RA configuration.
+
+ interface fxp0 {
+ address-pool pool1 3600;
+@@ -23,3 +41,23 @@ interface fxp0 {
+ pool pool1 {
+ range 2001:db8:1:2::1000 to 2001:db8:1:2::2000 ;
+ };
++
++# The following is an example configuration which provides fixed IPv6
++# addresses to two known clients. It also provides every client with a
++# DNS server. Note that you have to send router advertisements on fxp0,
++# i.e. run rtadvd(8) on the interface the clients are attached to.
++# Otherwise a client cannot know the prefix-length and the default router.
++# If you want to prevent stateless address configuration via RA, please
++# set the autonomous-flag to OFF in your RA configuration.
++
++option domain-name-servers 2001:db8::35;
++
++host puffy {
++ duid 00:01:00:01:0f:5b:29:7f:00:04:5a:35:1e:a1;
++ address 2001:db8:111::180 infinity;
++};
++
++host tux {
++ duid 00:01:00:01:0f:36:5f:31:00:0a:e4:3e:f2:4e;
++ address 2001:db8:111::181 infinity;
++};
diff --git a/debian/patches/0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch b/debian/patches/0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch
new file mode 100644
index 0000000..34df3d3
--- /dev/null
+++ b/debian/patches/0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch
@@ -0,0 +1,421 @@
+From: Roger Shimizu <rogershimizu@gmail.com>
+Date: Thu, 24 Dec 2015 01:16:58 +0900
+Subject: Support to build on kFreeBSD & GNU/Hurd platform
+
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ cftoken.c | 4 ++--
+ cftoken.l | 4 ++--
+ common.c | 38 +++++++++++++++++++-------------------
+ config.c | 8 ++++----
+ configure | 2 +-
+ configure.in | 2 +-
+ dhcp6_ctl.c | 2 +-
+ dhcp6_ctlclient.c | 2 +-
+ dhcp6c.c | 6 +++---
+ dhcp6relay.c | 6 +++---
+ dhcp6s.c | 4 ++--
+ if.c | 2 +-
+ missing/getifaddrs.c | 2 +-
+ 13 files changed, 41 insertions(+), 41 deletions(-)
+
+diff --git a/cftoken.c b/cftoken.c
+index 079f274..6d43200 100644
+--- a/cftoken.c
++++ b/cftoken.c
+@@ -2539,7 +2539,7 @@ cfswitch_buffer(incl)
+ incstack[incstackp].state = YY_CURRENT_BUFFER;
+ incstack[incstackp].lineno = lineno;
+
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ fp = fopen(path, "re");
+ #else
+ fp = fopen(path, "r");
+@@ -2566,7 +2566,7 @@ cfparse(conf)
+ char *conf;
+ {
+ configfilename = conf;
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ if ((yyin = fopen(configfilename, "re")) == NULL) {
+ #else
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
+diff --git a/cftoken.l b/cftoken.l
+index e307357..f35b59f 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -418,7 +418,7 @@ cfswitch_buffer(incl)
+ incstack[incstackp].state = YY_CURRENT_BUFFER;
+ incstack[incstackp].lineno = lineno;
+
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ fp = fopen(path, "re");
+ #else
+ fp = fopen(path, "r");
+@@ -445,7 +445,7 @@ cfparse(conf)
+ char *conf;
+ {
+ configfilename = conf;
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ if ((yyin = fopen(configfilename, "re")) == NULL) {
+ #else
+ if ((yyin = fopen(configfilename, "r")) == NULL) {
+diff --git a/common.c b/common.c
+index b5c09c3..10d905f 100644
+--- a/common.c
++++ b/common.c
+@@ -45,9 +45,9 @@
+ #endif
+ #include <net/if.h>
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <net/if_types.h>
+-#ifdef __FreeBSD__
++#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ #include <net/if_var.h>
+ #endif
+ #include <net/if_dl.h>
+@@ -64,7 +64,7 @@
+ #include <libdevinfo.h>
+ #endif
+
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <netinet6/in6_var.h>
+ #endif
+
+@@ -86,7 +86,7 @@
+ #include <common.h>
+ #include <timer.h>
+
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ /* from /usr/include/linux/ipv6.h */
+
+ struct in6_ifreq {
+@@ -716,7 +716,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
+ continue;
+
+ memcpy(&sin6, ifa->ifa_addr, sysdep_sa_len(ifa->ifa_addr));
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) {
+ sin6.sin6_addr.s6_addr[2] = 0;
+ sin6.sin6_addr.s6_addr[3] = 0;
+@@ -742,7 +742,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
+ continue;
+ }
+ memcpy(addr, &sin6.sin6_addr, sizeof(sin6.sin6_addr));
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ if (IN6_IS_ADDR_LINKLOCAL(addr))
+ addr->s6_addr[2] = addr->s6_addr[3] = 0;
+ #endif
+@@ -961,7 +961,7 @@ in6_matchflags(addr, ifnam, flags)
+ char *ifnam;
+ int flags;
+ {
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ int s;
+ struct in6_ifreq ifr6;
+
+@@ -1115,7 +1115,7 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
+ (void) snprintf(fname, sizeof (fname), "/dev/%s", ifname);
+ getctl.maxlen = sizeof (getbuf);
+ getctl.buf = (char *)getbuf;
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1) {
+ #else
+ if ((fd = open(fname, O_RDWR)) == -1) {
+@@ -1135,7 +1135,7 @@ getifhwaddr(const char *ifname, char *buf, u_int16_t *hwtypep, int ppa)
+ cp++;
+ dlar.dl_ppa = atoi(cp);
+ *cp = '\0';
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ if ((fd = open(fname, O_RDWR | O_CLOEXEC)) == -1)
+ #else
+ if ((fd = open(fname, O_RDWR)) == -1)
+@@ -1232,7 +1232,7 @@ gethwid(buf, len, ifname, hwtypep)
+ u_int16_t *hwtypep;
+ {
+ struct ifaddrs *ifa, *ifap;
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ struct sockaddr_dl *sdl;
+ #endif
+ #ifdef __linux__
+@@ -1270,7 +1270,7 @@ gethwid(buf, len, ifname, hwtypep)
+ continue;
+ if (ifa->ifa_addr == NULL)
+ continue;
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ if (ifa->ifa_addr->sa_family != AF_LINK)
+ continue;
+
+@@ -3257,10 +3257,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ int pltime;
+ int vltime;
+ {
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ struct in6_aliasreq req;
+ #endif
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ struct in6_ifreq req;
+ struct ifreq ifr;
+ #endif
+@@ -3274,10 +3274,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ switch(cmd) {
+ case IFADDRCONF_ADD:
+ cmdstr = "add";
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ ioctl_cmd = SIOCAIFADDR_IN6;
+ #endif
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ ioctl_cmd = SIOCSIFADDR;
+ #endif
+ #ifdef __sun__
+@@ -3286,10 +3286,10 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ break;
+ case IFADDRCONF_REMOVE:
+ cmdstr = "remove";
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ ioctl_cmd = SIOCDIFADDR_IN6;
+ #endif
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ ioctl_cmd = SIOCDIFADDR;
+ #endif
+ #ifdef __sun__
+@@ -3300,7 +3300,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ return (-1);
+ }
+
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ #define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
+ #else
+ #define SOCKTYPE SOCK_DGRAM
+@@ -3312,7 +3312,7 @@ ifaddrconf(cmd, ifname, addr, plen, pltime, vltime)
+ }
+
+ memset(&req, 0, sizeof(req));
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ req.ifra_addr = *addr;
+ memcpy(req.ifra_name, ifname, sizeof(req.ifra_name));
+ (void)sa6_plen2mask(&req.ifra_prefixmask, plen);
+diff --git a/config.c b/config.c
+index e04d6a5..2c5ad5d 100644
+--- a/config.c
++++ b/config.c
+@@ -35,7 +35,7 @@
+
+ #include <net/if.h>
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <net/if_dl.h>
+ #endif
+ #ifdef __linux__
+@@ -48,7 +48,7 @@
+ #include <string.h>
+ #include <ifaddrs.h>
+ #include <errno.h>
+-#ifdef __linux__
++#ifdef __GLIBC__
+ #define __USE_XOPEN
+ #include <time.h>
+ #endif
+@@ -1227,7 +1227,7 @@ get_default_ifid(pif)
+ struct prefix_ifconf *pif;
+ {
+ struct ifaddrs *ifa, *ifap;
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ struct sockaddr_dl *sdl;
+ #endif
+ #ifdef __linux__
+@@ -1254,7 +1254,7 @@ get_default_ifid(pif)
+ if (ifa->ifa_addr == NULL)
+ continue;
+
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ if (ifa->ifa_addr->sa_family != AF_LINK)
+ continue;
+
+diff --git a/configure b/configure
+index 4722b7b..8b67abe 100755
+--- a/configure
++++ b/configure
+@@ -2994,7 +2994,7 @@ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ yes
+ #endif
+ _ACEOF
+diff --git a/configure.in b/configure.in
+index 6da9af5..e320956 100644
+--- a/configure.in
++++ b/configure.in
+@@ -65,7 +65,7 @@ AC_TRY_COMPILE([#include <sys/queue.h>],
+
+ AC_EGREP_CPP(yes,
+ [#include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ yes
+ #endif], [result=kame], [result=regular])
+ AC_MSG_CHECKING(for getaddrinfo/getnameinfo library)
+diff --git a/dhcp6_ctl.c b/dhcp6_ctl.c
+index f1bae0b..dc6c323 100644
+--- a/dhcp6_ctl.c
++++ b/dhcp6_ctl.c
+@@ -97,7 +97,7 @@ dhcp6_ctl_init(addr, port, max, sockp)
+ gai_strerror(error));
+ return (-1);
+ }
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ res->ai_socktype |= SOCK_CLOEXEC;
+ #endif
+ ctlsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+diff --git a/dhcp6_ctlclient.c b/dhcp6_ctlclient.c
+index 2bec3e7..84ede58 100644
+--- a/dhcp6_ctlclient.c
++++ b/dhcp6_ctlclient.c
+@@ -169,7 +169,7 @@ main(argc, argv)
+
+ s = -1;
+ for (res = res0; res != NULL; res = res->ai_next) {
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ res->ai_socktype |= SOCK_CLOEXEC;
+ #endif
+ s = socket(res->ai_family, res->ai_socktype,
+diff --git a/dhcp6c.c b/dhcp6c.c
+index 1d10a78..4e1356b 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -50,7 +50,7 @@
+ #endif
+
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <net/if_dl.h>
+ #include <netinet6/in6_var.h>
+ #endif
+@@ -290,7 +290,7 @@ client6_init()
+ gai_strerror(error));
+ exit(1);
+ }
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ /* Force socket to be closed on execve */
+ res->ai_socktype |= SOCK_CLOEXEC;
+ #endif
+@@ -350,7 +350,7 @@ client6_init()
+ freeaddrinfo(res);
+
+ /* open a routing socket to watch the routing table */
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ #define SOCKTYPE (SOCK_RAW | SOCK_CLOEXEC)
+ #else
+ #define SOCKTYPE SOCK_RAW
+diff --git a/dhcp6relay.c b/dhcp6relay.c
+index 200d3cb..ed4aee7 100644
+--- a/dhcp6relay.c
++++ b/dhcp6relay.c
+@@ -41,7 +41,7 @@
+
+ #include <netinet/in.h>
+
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <netinet6/in6_var.h>
+ #endif
+
+@@ -359,7 +359,7 @@ relay6_init(int ifnum, char *iflist[])
+ gai_strerror(error));
+ goto failexit;
+ }
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ res->ai_socktype |= SOCK_CLOEXEC;
+ #endif
+ csock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+@@ -468,7 +468,7 @@ relay6_init(int ifnum, char *iflist[])
+ goto failexit;
+ }
+ memcpy(&sa6_client, res->ai_addr, sizeof (sa6_client));
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ res->ai_socktype |= SOCK_CLOEXEC;
+ #endif
+ ssock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+diff --git a/dhcp6s.c b/dhcp6s.c
+index ff8b17d..a230d75 100644
+--- a/dhcp6s.c
++++ b/dhcp6s.c
+@@ -51,7 +51,7 @@
+ #endif
+
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <netinet6/in6_var.h>
+ #endif
+
+@@ -532,7 +532,7 @@ server6_init()
+ strerror(errno));
+ exit(1);
+ }
+-#if !defined(__linux__) && !defined(__sun__)
++#if !defined(__linux__) && !defined(__sun__) && !defined(__GNU__)
+ /* make the socket write-only */
+ if (shutdown(outsock, 0)) {
+ debug_printf(LOG_ERR, FNAME, "shutdown(outbound, 0): %s",
+diff --git a/if.c b/if.c
+index c690671..d69e79a 100644
+--- a/if.c
++++ b/if.c
+@@ -34,7 +34,7 @@
+
+ #include <net/if.h>
+ #include <netinet/in.h>
+-#ifdef __KAME__
++#if defined (__KAME__) || defined (__FreeBSD_kernel__)
+ #include <net/if_dl.h>
+ #endif
+
+diff --git a/missing/getifaddrs.c b/missing/getifaddrs.c
+index 23b3e43..42dba27 100644
+--- a/missing/getifaddrs.c
++++ b/missing/getifaddrs.c
+@@ -167,7 +167,7 @@ getifaddrs(struct ifaddrs **ifap)
+ struct ifaddrs *ifa = NULL;
+ char *buf;
+
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ #define SOCKTYPE (SOCK_DGRAM | SOCK_CLOEXEC)
+ #else
+ #define SOCKTYPE SOCK_DGRAM
diff --git a/debian/patches/0015-a-bit-info-to-logger-when-get-OPTION_RECONF_ACCEPT.patch b/debian/patches/0015-a-bit-info-to-logger-when-get-OPTION_RECONF_ACCEPT.patch
new file mode 100644
index 0000000..a22af22
--- /dev/null
+++ b/debian/patches/0015-a-bit-info-to-logger-when-get-OPTION_RECONF_ACCEPT.patch
@@ -0,0 +1,57 @@
+From: Roger Shimizu <rogershimizu@gmail.com>
+Date: Thu, 24 Dec 2015 23:09:06 +0900
+Subject: Add a bit info to logger when get OPTION_RECONF_ACCEPT(20) dhcpv6
+ option
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Closes: #562079
+Reported-by: Bjørn Mork <bjorn@mork.no>
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ common.c | 10 ++++++++++
+ dhcp6.h | 2 +-
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/common.c b/common.c
+index 10d905f..cbb1c82 100644
+--- a/common.c
++++ b/common.c
+@@ -1723,6 +1723,14 @@ dhcp6_get_options(p, ep, optinfo)
+ memcpy(optinfo->ifidopt_id, cp, optlen);
+ optinfo->ifidopt_len = optlen;
+ break;
++ case DH6OPT_RECONF_ACCEPT:
++ /* Debian Bug: #562079 */
++ if (optlen != 0)
++ goto malformed;
++ debug_printf(LOG_INFO, FNAME,
++ "received option: \"%s\" (len %d), however reconfigure negotiation is not supported yet",
++ dhcp6optstr(opt), optlen);
++ break;
+ case DH6OPT_SIP_SERVER_D:
+ if (dhcp6_get_domain(optlen, cp, opt,
+ &optinfo->sipname_list) == -1)
+@@ -3024,6 +3032,8 @@ dhcp6optstr(type)
+ return ("interface ID");
+ case DH6OPT_RECONF_MSG:
+ return ("reconfigure message");
++ case DH6OPT_RECONF_ACCEPT:
++ return ("reconfigure accept");
+ case DH6OPT_SIP_SERVER_D:
+ return ("SIP domain name");
+ case DH6OPT_SIP_SERVER_A:
+diff --git a/dhcp6.h b/dhcp6.h
+index 9f3a62d..985decb 100644
+--- a/dhcp6.h
++++ b/dhcp6.h
+@@ -296,7 +296,7 @@ struct dhcp6_relay {
+ #define DH6OPT_VENDOR_OPTS 17
+ #define DH6OPT_INTERFACE_ID 18
+ #define DH6OPT_RECONF_MSG 19
+-
++#define DH6OPT_RECONF_ACCEPT 20
+ #define DH6OPT_SIP_SERVER_D 21
+ #define DH6OPT_SIP_SERVER_A 22
+ #define DH6OPT_DNS 23
diff --git a/debian/patches/0016-fix-typo-in-dhcp6c.8-manpage.patch b/debian/patches/0016-fix-typo-in-dhcp6c.8-manpage.patch
new file mode 100644
index 0000000..8cb99cf
--- /dev/null
+++ b/debian/patches/0016-fix-typo-in-dhcp6c.8-manpage.patch
@@ -0,0 +1,22 @@
+From: Roger Shimizu <rogershimizu@gmail.com>
+Date: Wed, 26 Oct 2016 23:50:06 +0900
+Subject: fix typo in dhcp6c.8 manpage
+
+Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
+---
+ dhcp6c.8 | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/dhcp6c.8 b/dhcp6c.8
+index acc8f46..fcaeb34 100644
+--- a/dhcp6c.8
++++ b/dhcp6c.8
+@@ -75,7 +75,7 @@ usually prints warning, debugging, or error messages to
+ it prints the messages to standard error if this option is
+ specified.
+ .It Fl i
+-Info-req mode. In this mode, stateless DHCPv6 is executed with the folllowing configuration, and the obtained info is written to stdout. After this output,
++Info-req mode. In this mode, stateless DHCPv6 is executed with the following configuration, and the obtained info is written to stdout. After this output,
+ .Nm
+ is terminated. (suits for a use in shell-script etc).
+ .Bd -literal -offset
diff --git a/debian/patches/0017-Remove-unused-linking-with-libfl.patch b/debian/patches/0017-Remove-unused-linking-with-libfl.patch
new file mode 100644
index 0000000..6f62b9b
--- /dev/null
+++ b/debian/patches/0017-Remove-unused-linking-with-libfl.patch
@@ -0,0 +1,43 @@
+From: Adrian Bunk <bunk@debian.org>
+Date: Thu, 15 Mar 2018 15:55:23 +0200
+Subject: Remove unused linking with libfl
+
+Due to the yylex requirement this caused FTBFS
+when a shared libfl is provided.
+
+Closes: #893008
+---
+ Makefile.in | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 2c8d6f3..2f7e528 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -40,7 +40,7 @@ CFLAGS= @CFLAGS@ @CPPFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
+ -DLOCALDBDIR=\"${localdbdir}\"
+ LDFLAGS=@LDFLAGS@
+ LIBOBJS=@LIBOBJS@
+-LIBS= @LIBS@ @LEXLIB@
++LIBS= @LIBS@
+ CC= @CC@
+ TARGET= dhcp6c dhcp6s dhcp6relay dhcp6ctl
+
+@@ -63,11 +63,15 @@ RELAYOBJS = dhcp6relay.o dhcp6relay_script.o common.o timer.o
+ CTLOBJS= dhcp6_ctlclient.o base64.o auth.o
+ CLEANFILES+= y.tab.h
+
++# Note: CLIENTLIBS gets overwritten with path to libfl.a for the udeb build
++CLIENTLIBS=@LEXLIB@
++SERVLIBS= @LEXLIB@
++
+ all: $(TARGET)
+ dhcp6c: $(CLIENTOBJS) $(LIBOBJS)
+- $(CC) $(LDFLAGS) -o dhcp6c $(CLIENTOBJS) $(LIBOBJS) $(LIBS)
++ $(CC) $(LDFLAGS) -o dhcp6c $(CLIENTOBJS) $(LIBOBJS) $(LIBS) $(CLIENTLIBS)
+ dhcp6s: $(SERVOBJS) $(LIBOBJS)
+- $(CC) $(LDFLAGS) -o dhcp6s $(SERVOBJS) $(LIBOBJS) $(LIBS)
++ $(CC) $(LDFLAGS) -o dhcp6s $(SERVOBJS) $(LIBOBJS) $(LIBS) $(SERVLIBS)
+ dhcp6relay: $(RELAYOBJS) $(LIBOBJS)
+ $(CC) $(LDFLAGS) -o $@ $(RELAYOBJS) $(LIBOBJS) $(LIBS)
+ dhcp6ctl: $(CTLOBJS)
diff --git a/debian/patches/0018-dhcpv6-ignore-advertise-messages-with-none-of-reques.patch b/debian/patches/0018-dhcpv6-ignore-advertise-messages-with-none-of-reques.patch
new file mode 100644
index 0000000..c0f6149
--- /dev/null
+++ b/debian/patches/0018-dhcpv6-ignore-advertise-messages-with-none-of-reques.patch
@@ -0,0 +1,137 @@
+From: Evgeniy Manachkin <sfstudio@mail.ru>
+Date: Mon, 30 Mar 2015 20:05:52 +0600
+Subject: dhcpv6: ignore advertise messages with none of requested data and
+ missed status codes.
+
+with RENEW fix. Thanks TheMiron.
+
+[ Roger Shimizu's comment ]
+The patch was originally from:
+- https://sourceforge.net/p/wide-dhcpv6/bugs/34/
+- https://gitorious.org/wive-ng-mt/wive-ng-mt/commit/844e8a1a0d9026ba6fef8b224583e97890ca522e
+- https://gitorious.org/wive-ng-mt/wive-ng-mt/commit/3f93dfec7a13c086f891b2ab9a974de2331d9b7d
+
+This resolved upstream issue #34:
+- https://sourceforge.net/p/wide-dhcpv6/bugs/34
+
+Closes: #765453
+---
+ dhcp6c.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------
+ 1 file changed, 55 insertions(+), 12 deletions(-)
+
+diff --git a/dhcp6c.c b/dhcp6c.c
+index 4e1356b..849835e 100644
+--- a/dhcp6c.c
++++ b/dhcp6c.c
+@@ -1484,10 +1484,10 @@ client6_recv()
+
+ switch(dh6->dh6_msgtype) {
+ case DH6_ADVERTISE:
+- (void)client6_recvadvert(ifp, dh6, len, &optinfo);
++ client6_recvadvert(ifp, dh6, len, &optinfo);
+ break;
+ case DH6_REPLY:
+- (void)client6_recvreply(ifp, dh6, len, &optinfo);
++ client6_recvreply(ifp, dh6, len, &optinfo);
+ break;
+ default:
+ debug_printf(LOG_INFO, FNAME, "received an unexpected message (%s) "
+@@ -1511,6 +1511,7 @@ client6_recvadvert(ifp, dh6, len, optinfo)
+ struct dhcp6_event *ev;
+ struct dhcp6_eventdata *evd;
+ struct authparam *authparam = NULL, authparam0;
++ int have_ia = -1;
+
+ /* find the corresponding event based on the received xid */
+ ev = find_event_withid(ifp, ntohl(dh6->dh6_xid) & DH6_XIDMASK);
+@@ -1549,38 +1550,80 @@ client6_recvadvert(ifp, dh6, len, optinfo)
+ * includes a Status Code option containing the value NoPrefixAvail
+ * [RFC3633 Section 11.1].
+ * Likewise, the client MUST ignore any Advertise message that includes
+- * a Status Code option containing the value NoAddrsAvail.
++ * a Status Code option containing the value NoAddrsAvail.
+ * [RFC3315 Section 17.1.3].
+ * We only apply this when we are going to request an address or
+ * a prefix.
+ */
+- for (evd = TAILQ_FIRST(&ev->data_list); evd;
+- evd = TAILQ_NEXT(evd, link)) {
++ for (evd = TAILQ_FIRST(&ev->data_list); evd; evd = TAILQ_NEXT(evd, link)) {
++ struct dhcp6_listval *lv, *slv;
+ u_int16_t stcode;
+ char *stcodestr;
+
+ switch (evd->type) {
+- case DHCP6_EVDATA_IAPD:
++ case DHCP6_EVDATA_IAPD:
+ stcode = DH6OPT_STCODE_NOPREFIXAVAIL;
+ stcodestr = "NoPrefixAvail";
+ break;
+- case DHCP6_EVDATA_IANA:
++ case DHCP6_EVDATA_IANA:
+ stcode = DH6OPT_STCODE_NOADDRSAVAIL;
+ stcodestr = "NoAddrsAvail";
+ break;
+- default:
++ default:
+ continue;
+ }
++
+ if (dhcp6_find_listval(&optinfo->stcode_list,
+ DHCP6_LISTVAL_STCODE, &stcode, 0)) {
+- debug_printf(LOG_INFO, FNAME,
+- "advertise contains %s status", stcodestr);
++ debug_printf(LOG_INFO, FNAME, "advertise contains %s status", stcodestr);
+ return (-1);
+ }
++
++ if (have_ia > 0 || TAILQ_EMPTY((struct dhcp6_list *)evd->data))
++ continue;
++
++ have_ia = 0;
++ /* parse list of IA_PD */
++ if (evd->type == DHCP6_EVDATA_IAPD) {
++ TAILQ_FOREACH(lv, (struct dhcp6_list *)evd->data, link) {
++ slv = dhcp6_find_listval(&optinfo->iapd_list, DHCP6_LISTVAL_IAPD, &lv->val_ia, 0);
++ if (slv == NULL)
++ continue;
++ TAILQ_FOREACH(slv, &slv->sublist, link) {
++ if (slv->type == DHCP6_LISTVAL_PREFIX6) {
++ have_ia = 1;
++ break;
++ }
++ }
++ }
++ }
++ /* parse list of IA_NA */
++ if (evd->type == DHCP6_EVDATA_IANA) {
++ TAILQ_FOREACH(lv, (struct dhcp6_list *)evd->data, link) {
++ slv = dhcp6_find_listval(&optinfo->iana_list, DHCP6_LISTVAL_IANA, &lv->val_ia, 0);
++ if (slv == NULL)
++ continue;
++ TAILQ_FOREACH(slv, &slv->sublist, link) {
++ if (slv->type == DHCP6_LISTVAL_STATEFULADDR6) {
++ have_ia = 1;
++ break;
++ }
++ }
++ }
++ }
++ }
++
++ /*
++ * Ignore message with none of requested addresses and/or
++ * a prefixes as if NoAddrsAvail/NoPrefixAvail Status Code
++ * was included.
++ */
++ if (have_ia == 0) {
++ debug_printf(LOG_INFO, FNAME, "advertise contains no address/prefix");
++ return (-1);
+ }
+
+- if (ev->state != DHCP6S_SOLICIT ||
+- (ifp->send_flags & DHCIFF_RAPID_COMMIT) || infreq_mode) {
++ if (ev->state != DHCP6S_SOLICIT || (ifp->send_flags & DHCIFF_RAPID_COMMIT) || infreq_mode) {
+ /*
+ * We expected a reply message, but do actually receive an
+ * Advertise message. The server should be configured not to
diff --git a/debian/patches/0019-Server-should-not-bind-control-port-if-there-is-no-s.patch b/debian/patches/0019-Server-should-not-bind-control-port-if-there-is-no-s.patch
new file mode 100644
index 0000000..e0f1944
--- /dev/null
+++ b/debian/patches/0019-Server-should-not-bind-control-port-if-there-is-no-s.patch
@@ -0,0 +1,66 @@
+From: Robert Wolf <r.wolf.debian@atlas.cz>
+Date: Mon, 11 Jan 2016 14:21:40 +0100
+Subject: Server should not bind control port if there is no shared secret
+
+And add two additional check of shared secret
+- checks validity of the read shared secret and set ctlkey structure
+ pointer not NULL only if there is really any shared secret.
+- check if ctlkey is NULL or if shared secret is NULL or empty
+ (pointer is not NULL, but there are no data - length is 0).
+
+This resolved upstream issue #36:
+- https://sourceforge.net/p/wide-dhcpv6/bugs/36
+
+Closes: #799080
+---
+ dhcp6_ctl.c | 16 +++++++++++++---
+ dhcp6s.c | 2 +-
+ 2 files changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/dhcp6_ctl.c b/dhcp6_ctl.c
+index dc6c323..056b550 100644
+--- a/dhcp6_ctl.c
++++ b/dhcp6_ctl.c
+@@ -166,9 +166,14 @@ dhcp6_ctl_authinit(keyfile, keyinfop, digestlenp)
+ strerror(errno));
+ return (-1);
+ }
+- if (fgets(line, sizeof(line), fp) == NULL && ferror(fp)) {
+- debug_printf(LOG_ERR, FNAME, "failed to read key file: %s",
+- strerror(errno));
++ if (fgets(line, sizeof(line), fp) == NULL) {
++ if (ferror(fp)) {
++ debug_printf(LOG_ERR, FNAME, "failed to read key file: %s",
++ strerror(errno));
++ } else {
++ debug_printf(LOG_INFO, FNAME, "no shared key. shared key file "
++ "is empty. dhcp6s will not listen on a control port.");
++ }
+ goto fail;
+ }
+ if ((secretlen = base64_decodestring(line, secret, sizeof(secret)))
+@@ -176,6 +181,11 @@ dhcp6_ctl_authinit(keyfile, keyinfop, digestlenp)
+ debug_printf(LOG_ERR, FNAME, "failed to decode base64 string");
+ goto fail;
+ }
++ if (secretlen == 0) {
++ debug_printf(LOG_INFO, FNAME, "no shared key found. dhcp6s will "
++ "not listen on a control port.");
++ goto fail;
++ }
+ if ((ctlkey = malloc(sizeof(*ctlkey))) == NULL) {
+ debug_printf(LOG_WARNING, FNAME, "failed to allocate control key");
+ goto fail;
+diff --git a/dhcp6s.c b/dhcp6s.c
+index a230d75..1942d8d 100644
+--- a/dhcp6s.c
++++ b/dhcp6s.c
+@@ -573,7 +573,7 @@ server6_init()
+ freeaddrinfo(res);
+
+ /* set up control socket */
+- if (ctlkey == NULL)
++ if (ctlkey == NULL || ctlkey->secret == NULL || ctlkey->secretlen == 0)
+ debug_printf(LOG_NOTICE, FNAME, "skip opening control port");
+ else if (dhcp6_ctl_init(ctladdr, ctlport,
+ DHCP6CTL_DEF_COMMANDQUEUELEN, &ctlsock)) {
diff --git a/debian/patches/0020-Adding-option-to-randomize-interface-id.patch b/debian/patches/0020-Adding-option-to-randomize-interface-id.patch
new file mode 100644
index 0000000..23c3a43
--- /dev/null
+++ b/debian/patches/0020-Adding-option-to-randomize-interface-id.patch
@@ -0,0 +1,120 @@
+From: Christopher Martin <chrsmrtn@gmail.com>
+Date: Tue, 16 Oct 2018 19:16:53 -0400
+Subject: Adding option to randomize interface id
+
+Please find attached a patch that adds a new feature to
+wide-dhcpv6-client, namely an option ("ifid-random") in the
+prefix-interface section of dhcp6c.conf to generate a random interface
+id on startup. This is useful if you wish to have the final 64 bits of
+your IPv6 address change from time to time - a sort of very rough
+equivalent of IPv6 Privacy Extensions. If you do not add "ifid-random"
+to the config file, then nothing about the client's current behaviour
+changes.
+
+Note that if your prefix-interface section has both the current "ifid
+X" option (where X is whatever number you want to manually assign as
+your interface id) and the new "ifid-random" option, then the
+interface id is randomized and "ifid X" is ignored.
+
+Thanks,
+Christopher Martin
+---
+ cfparse.y | 9 ++++++++-
+ cftoken.l | 1 +
+ config.c | 9 +++++++++
+ config.h | 2 +-
+ dhcp6c.conf.5 | 9 +++++++++
+ 5 files changed, 28 insertions(+), 2 deletions(-)
+
+diff --git a/cfparse.y b/cfparse.y
+index e83ecf7..9e685f4 100644
+--- a/cfparse.y
++++ b/cfparse.y
+@@ -104,7 +104,7 @@ static void cleanup_cflist __P((struct cf_list *));
+
+ %token INTERFACE IFNAME
+ %token PROFILE PROFILENAME
+-%token PREFIX_INTERFACE SLA_ID SLA_LEN IFID DUID_ID
++%token PREFIX_INTERFACE SLA_ID SLA_LEN IFID IFID_RAND DUID_ID
+ %token ID_ASSOC IA_PD IAID IA_NA
+ %token ADDRESS
+ %token REQUEST SEND ALLOW PREFERENCE
+@@ -1064,6 +1064,13 @@ ifparam:
+ l->num = (u_int64_t)$2;
+ $$ = l;
+ }
++ | IFID_RAND EOS
++ {
++ struct cf_list *l;
++
++ MAKE_CFLIST(l, IFPARAM_IFID_RAND, NULL, NULL);
++ $$ = l;
++ }
+ ;
+
+ ianaconf_list:
+diff --git a/cftoken.l b/cftoken.l
+index f35b59f..e266ac2 100644
+--- a/cftoken.l
++++ b/cftoken.l
+@@ -244,6 +244,7 @@ ecl \}
+ <S_CNF>sla-id { DECHO; return (SLA_ID); }
+ <S_CNF>sla-len { DECHO; return (SLA_LEN); }
+ <S_CNF>ifid { DECHO; return (IFID); }
++<S_CNF>ifid-random { DECHO; return (IFID_RAND); }
+
+ /* duration */
+ <S_CNF>infinity { DECHO; return (INFINITY); }
+diff --git a/config.c b/config.c
+index 2c5ad5d..5829d92 100644
+--- a/config.c
++++ b/config.c
+@@ -521,6 +521,15 @@ add_pd_pif(iapdc, cfl0)
+ }
+ break;
+ case IFPARAM_IFID:
++ if (use_default_ifid) {
++ for (i = sizeof(pif->ifid) - 1; i >= 0; i--)
++ pif->ifid[i] = (cfl->num >> 8*(sizeof(pif->ifid) - 1 - i)) & 0xff;
++ use_default_ifid = 0;
++ }
++ break;
++ case IFPARAM_IFID_RAND:
++ for (i = 0; i < pif->ifid_len ; i++)
++ cfl->num = cfl->num*2 + rand()%2;
+ for (i = sizeof(pif->ifid) -1; i >= 0; i--)
+ pif->ifid[i] = (cfl->num >> 8*(sizeof(pif->ifid) - 1 - i)) & 0xff;
+ use_default_ifid = 0;
+diff --git a/config.h b/config.h
+index 64ce9e8..36a5aa3 100644
+--- a/config.h
++++ b/config.h
+@@ -266,7 +266,7 @@ enum { DECL_SEND, DECL_ALLOW, DECL_INFO_ONLY, DECL_REQUEST, DECL_DUID,
+ DECL_PREFIX, DECL_PREFERENCE, DECL_SCRIPT, DECL_DELAYEDKEY,
+ DECL_ADDRESS,
+ DECL_RANGE, DECL_ADDRESSPOOL,
+- IFPARAM_SLA_ID, IFPARAM_SLA_LEN, IFPARAM_IFID,
++ IFPARAM_SLA_ID, IFPARAM_SLA_LEN, IFPARAM_IFID, IFPARAM_IFID_RAND,
+ DHCPOPT_RAPID_COMMIT, DHCPOPT_AUTHINFO,
+ DHCPOPT_DNS, DHCPOPT_DNSNAME,
+ DHCPOPT_IA_PD, DHCPOPT_IA_NA, DHCPOPT_NTP,
+diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5
+index 1c91d72..5693fb8 100644
+--- a/dhcp6c.conf.5
++++ b/dhcp6c.conf.5
+@@ -453,6 +453,15 @@ must be a decimal integer. It will be combined with the delegated
+ prefix and the sla-id to form a complete interface address. The
+ default is to use the EUI-64 address of the
+ .Ar interface .
++.It Xo
++.Ic ifid-random ;
++.Xc
++This statement instructs the client to generate a completely random
++interface id. This will override the
++.Ic ifid
++statement, if present. The resulting random interface id will be combined
++with the delegated prefix and the sla-id to form a complete interface
++address.
+ .El
+ .El
+ .\"
diff --git a/debian/patches/0021-Make-sla-len-config-optional.patch b/debian/patches/0021-Make-sla-len-config-optional.patch
new file mode 100644
index 0000000..a263ef9
--- /dev/null
+++ b/debian/patches/0021-Make-sla-len-config-optional.patch
@@ -0,0 +1,32 @@
+From: Roger Shimizu <rosh@debian.org>
+Date: Sun, 6 Sep 2020 14:34:36 +0900
+Subject: Make sla-len config optional
+
+Cherry-pick from Fedora:
+https://src.fedoraproject.org/rpms/wide-dhcpv6/blob/master/f/wide-dhcpv6-0008-Make-sla-len-config-optional.patch
+---
+ prefixconf.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/prefixconf.c b/prefixconf.c
+index 15b5417..98d9b77 100644
+--- a/prefixconf.c
++++ b/prefixconf.c
+@@ -460,6 +460,17 @@ add_ifprefix(siteprefix, prefix, pconf)
+ ifpfx->paddr.sin6_len = sizeof(struct sockaddr_in6);
+ #endif
+ ifpfx->paddr.sin6_addr = prefix->addr;
++
++ /*
++ * dave (bevhost) thinks this should fix it rather than
++ * generare the error below "invalid prefix length"
++ * this way the sla-len can be left out of the config file
++ * and calculated when the prefix is received
++ */
++ if (prefix->plen + pconf->ifid_len + pconf->sla_len > 128) {
++ pconf->sla_len = 128 - pconf->ifid_len - prefix->plen;
++ }
++
+ ifpfx->plen = prefix->plen + pconf->sla_len;
+ /*
+ * XXX: our current implementation assumes ifid len is a multiple of 8
diff --git a/debian/patches/0022-Make-sla-id-config-optional.patch b/debian/patches/0022-Make-sla-id-config-optional.patch
new file mode 100644
index 0000000..551a9d8
--- /dev/null
+++ b/debian/patches/0022-Make-sla-id-config-optional.patch
@@ -0,0 +1,72 @@
+From: Roger Shimizu <rosh@debian.org>
+Date: Sun, 6 Sep 2020 14:36:10 +0900
+Subject: Make sla-id config optional
+
+Cherry-pick from Fedora:
+https://src.fedoraproject.org/rpms/wide-dhcpv6/blob/master/f/wide-dhcpv6-0009-Make-sla-id-config-optional.patch
+---
+ config.c | 13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/config.c b/config.c
+index 5829d92..70f6287 100644
+--- a/config.c
++++ b/config.c
+@@ -126,7 +126,7 @@ extern long long cf_refreshtime;
+ extern char *configfilename;
+
+ static struct keyinfo *find_keybyname __P((struct keyinfo *, char *));
+-static int add_pd_pif __P((struct iapd_conf *, struct cf_list *));
++static int add_pd_pif __P((struct iapd_conf *, struct cf_list *, u_int32_t));
+ static int add_options __P((int, struct dhcp6_ifconf *, struct cf_list *));
+ static int add_prefix __P((struct dhcp6_list *, char *, int,
+ struct dhcp6_prefix *));
+@@ -358,6 +358,8 @@ configure_ia(ialist, iatype)
+ size_t confsize;
+ static int init = 1;
+
++ u_int32_t if_count;
++
+ if (init) {
+ TAILQ_INIT(&ia_conflist0);
+ init = 0;
+@@ -403,6 +405,8 @@ configure_ia(ialist, iatype)
+ break;
+ }
+
++ if_count = 0;
++
+ /* set up parameters for the IA */
+ for (cfl = iap->params; cfl; cfl = cfl->next) {
+ struct iapd_conf *pdp = (struct iapd_conf *) iac;
+@@ -412,8 +416,9 @@ configure_ia(ialist, iatype)
+ case IATYPE_PD:
+ switch(cfl->type) {
+ case IACONF_PIF:
+- if (add_pd_pif(pdp, cfl))
++ if (add_pd_pif(pdp, cfl, if_count))
+ goto bad;
++ if_count++;
+ break;
+ case IACONF_PREFIX:
+ if (add_prefix(&pdp->iapd_prefix_list,
+@@ -465,9 +470,10 @@ configure_ia(ialist, iatype)
+ }
+
+ static int
+-add_pd_pif(iapdc, cfl0)
++add_pd_pif(iapdc, cfl0, if_count)
+ struct iapd_conf *iapdc;
+ struct cf_list *cfl0;
++ u_int32_t if_count;
+ {
+ struct cf_list *cfl;
+ struct prefix_ifconf *pif;
+@@ -503,6 +509,7 @@ add_pd_pif(iapdc, cfl0)
+ goto bad;
+ }
+
++ pif->sla_id = if_count;
+ pif->ifid_len = IFID_LEN_DEFAULT;
+ pif->sla_len = SLA_LEN_DEFAULT;
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..06b270c
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,22 @@
+0001-Fix-manpages.patch
+0002-Don-t-strip-binaries.patch
+0003-Close-inherited-file-descriptors.patch
+0004-GNU-libc6-fixes.patch
+0005-Update-ifid-on-interface-restart.patch
+0006-Add-new-feature-dhcp6c-profiles.patch
+0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch
+0008-Close-file-descriptors-on-exec.patch
+0009-Fix-renewal-of-IA-NA.patch
+0010-Call-client-script-after-interfaces-have-been-update.patch
+0011-resolv-warnings-so-as-to-make-blhc-and-gcc-both-happ.patch
+0012-fix-a-redefined-YYDEBUG-warning-of-gcc-for-the-code-.patch
+0013-added-several-comments-examples-by-Stefan-Sperling.patch
+0014-Support-to-build-on-kFreeBSD-n-GNU-Hurd-platform.patch
+0015-a-bit-info-to-logger-when-get-OPTION_RECONF_ACCEPT.patch
+0016-fix-typo-in-dhcp6c.8-manpage.patch
+0017-Remove-unused-linking-with-libfl.patch
+0018-dhcpv6-ignore-advertise-messages-with-none-of-reques.patch
+0019-Server-should-not-bind-control-port-if-there-is-no-s.patch
+0020-Adding-option-to-randomize-interface-id.patch
+0021-Make-sla-len-config-optional.patch
+0022-Make-sla-id-config-optional.patch