Skip to content

Commit

Permalink
- Add a no release option '-n'. This prevents a release signal from
Browse files Browse the repository at this point in the history
  being sent to the ISP causing a new PD or address to be allocated.
- Added some extra light INFO logging which is useful to see the
  communications between dhcp6c and the ISP
- s/dprintf/d_printf/.

Submitted by:	marjohn56 <martin@queens-park.com>
  • Loading branch information
hrs-allbsd committed Dec 19, 2016
1 parent 98ae83f commit 4a0cb26
Show file tree
Hide file tree
Showing 15 changed files with 720 additions and 681 deletions.
16 changes: 8 additions & 8 deletions addrconf.c
Expand Up @@ -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: "
d_printf(LOG_INFO, FNAME, "invalid address %s: "
"pltime (%lu) is larger than vltime (%lu)",
in6addr2str(&addr->addr, 0),
addr->pltime, addr->vltime);
Expand All @@ -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");
d_printf(LOG_NOTICE, FNAME, "memory allocation failed");
return (-1);
}
memset(iac_na, 0, sizeof(*iac_na));
Expand All @@ -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");
d_printf(LOG_NOTICE, FNAME, "memory allocation failed");
return (-1);
}
memset(sa, 0, sizeof(*sa));
Expand All @@ -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",
d_printf(LOG_DEBUG, FNAME, "%s an address %s pltime=%lu, vltime=%lu",
sacreate ? "create" : "update",
in6addr2str(&addr->addr, 0), addr->pltime, addr->vltime);

Expand All @@ -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,
d_printf(LOG_NOTICE, FNAME,
"failed to add stateful addr timer");
remove_addr(sa); /* XXX */
return (-1);
Expand Down Expand Up @@ -233,7 +233,7 @@ remove_addr(sa)
{
int ret;

dprintf(LOG_DEBUG, FNAME, "remove an address %s",
d_printf(LOG_DEBUG, FNAME, "remove an address %s",
in6addr2str(&sa->addr.addr, 0));

if (sa->timer)
Expand Down Expand Up @@ -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");
d_printf(LOG_ERR, FNAME, "assumption failure");
exit(1);
}

Expand All @@ -362,7 +362,7 @@ addr_timo(arg)
struct ia *ia;
void (*callback)__P((struct ia *));

dprintf(LOG_DEBUG, FNAME, "address timeout for %s",
d_printf(LOG_DEBUG, FNAME, "address timeout for %s",
in6addr2str(&sa->addr.addr, 0));

ia = sa->ctl->iacna_ia;
Expand Down
12 changes: 6 additions & 6 deletions cftoken.l
Expand Up @@ -340,10 +340,10 @@ cfdebug_print(w, t, l)
int l;
{
if (w) {
dprintf(LOG_DEBUG, FNAME,
d_printf(LOG_DEBUG, FNAME,
"<%d>%s [%s] (%d)", yy_start, w, t, l);
} else {
dprintf(LOG_DEBUG, FNAME,
d_printf(LOG_DEBUG, FNAME,
"<%d>[%s] (%d)", yy_start, t, l);
}
}
Expand All @@ -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);
d_printf(level, FNAME, ebuf);
}
void
Expand Down Expand Up @@ -397,7 +397,7 @@ cfswitch_buffer(incl)
FILE *fp;
if (incstackp >= MAX_INCLUDE_DEPTH) {
dprintf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
d_printf(LOG_ERR, FNAME, "cfparse: includes nested too deeply");
return (-1);
}
incstack[incstackp].path = configfilename;
Expand All @@ -406,7 +406,7 @@ cfswitch_buffer(incl)
fp = fopen(path, "r");
if (fp == NULL) {
dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
d_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
path, strerror(errno));
if (errno == ENOENT)
return (0);
Expand All @@ -428,7 +428,7 @@ cfparse(conf)
{
configfilename = conf;
if ((yyin = fopen(configfilename, "r")) == NULL) {
dprintf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
d_printf(LOG_ERR, FNAME, "cfparse: fopen(%s): %s",
configfilename, strerror(errno));
if (errno == ENOENT)
return (0);
Expand Down
1 change: 1 addition & 0 deletions common.h
Expand Up @@ -120,6 +120,7 @@ sysdep_sa_len (const struct sockaddr *sa)
extern int foreground;
extern int debug_thresh;
extern char *device;
extern int opt_norelease;

/* search option for dhcp6_find_listval() */
#define MATCHLIST_PREFIXLEN 0x1
Expand Down

0 comments on commit 4a0cb26

Please sign in to comment.