aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile.in7
-rw-r--r--common/conflex.c6
-rw-r--r--common/dns.c149
-rw-r--r--common/parse.c57
-rw-r--r--common/tests/Makefile.in7
5 files changed, 168 insertions, 58 deletions
diff --git a/common/Makefile.in b/common/Makefile.in
index 487f629..3c39008 100644
--- a/common/Makefile.in
+++ b/common/Makefile.in
@@ -110,6 +110,7 @@ LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
@@ -186,7 +187,7 @@ all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .o .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -211,9 +212,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: $(am__configure_deps)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLIBRARIES:
diff --git a/common/conflex.c b/common/conflex.c
index 1ec2328..9c9ed66 100644
--- a/common/conflex.c
+++ b/common/conflex.c
@@ -1228,6 +1228,8 @@ intern(char *atom, enum dhcp_token dfv) {
return PEER;
if (!strcasecmp (atom + 1, "rimary"))
return PRIMARY;
+ if (!strcasecmp (atom + 1, "rimary6"))
+ return PRIMARY6;
if (!strncasecmp (atom + 1, "artner", 6)) {
if (!atom [7])
return PARTNER;
@@ -1317,7 +1319,9 @@ intern(char *atom, enum dhcp_token dfv) {
tolower((unsigned char)atom[2]) == 'c') {
if (!strncasecmp(atom + 3, "ond", 3)) {
if (!strcasecmp(atom + 6, "ary"))
- return SECONDARY;
+ return SECONDARY;
+ if (!strcasecmp(atom + 6, "ary6"))
+ return SECONDARY6;
if (!strcasecmp(atom + 6, "s"))
return SECONDS;
break;
diff --git a/common/dns.c b/common/dns.c
index 5ecae67..3992b6c 100644
--- a/common/dns.c
+++ b/common/dns.c
@@ -64,6 +64,11 @@
* support update forwarding, AFAIK). If no TSIG key is listed, the update
* is attempted without TSIG.
*
+ * You can also include IPv6 addresses via the primary6 and secondary6
+ * options. The search order for the addresses is primary, primary6,
+ * secondary and lastly secondary6, with a limit on the number of
+ * addresses used. Currently this limit is 3.
+ *
* The DHCP server tries to find an existing zone for any given name by
* trying to look up a local zone structure for each domain containing
* that name, all the way up to '.'. If it finds one cached, it tries
@@ -602,44 +607,48 @@ int dns_zone_dereference (ptr, file, line)
{
struct dns_zone *dns_zone;
- if (!ptr || !*ptr) {
- log_error ("%s(%d): null pointer", file, line);
+ if ((ptr == NULL) || (*ptr == NULL)) {
+ log_error("%s(%d): null pointer", file, line);
#if defined (POINTER_DEBUG)
- abort ();
+ abort();
#else
- return 0;
+ return (0);
#endif
}
dns_zone = *ptr;
- *ptr = (struct dns_zone *)0;
- --dns_zone -> refcnt;
- rc_register (file, line, ptr, dns_zone, dns_zone -> refcnt, 1, RC_MISC);
- if (dns_zone -> refcnt > 0)
- return 1;
-
- if (dns_zone -> refcnt < 0) {
- log_error ("%s(%d): negative refcnt!", file, line);
+ *ptr = NULL;
+ --dns_zone->refcnt;
+ rc_register(file, line, ptr, dns_zone, dns_zone->refcnt, 1, RC_MISC);
+ if (dns_zone->refcnt > 0)
+ return (1);
+
+ if (dns_zone->refcnt < 0) {
+ log_error("%s(%d): negative refcnt!", file, line);
#if defined (DEBUG_RC_HISTORY)
- dump_rc_history (dns_zone);
+ dump_rc_history(dns_zone);
#endif
#if defined (POINTER_DEBUG)
- abort ();
+ abort();
#else
- return 0;
+ return (0);
#endif
}
- if (dns_zone -> name)
- dfree (dns_zone -> name, file, line);
- if (dns_zone -> key)
- omapi_auth_key_dereference (&dns_zone -> key, file, line);
- if (dns_zone -> primary)
- option_cache_dereference (&dns_zone -> primary, file, line);
- if (dns_zone -> secondary)
- option_cache_dereference (&dns_zone -> secondary, file, line);
- dfree (dns_zone, file, line);
- return 1;
+ if (dns_zone->name)
+ dfree(dns_zone->name, file, line);
+ if (dns_zone->key)
+ omapi_auth_key_dereference(&dns_zone->key, file, line);
+ if (dns_zone->primary)
+ option_cache_dereference(&dns_zone->primary, file, line);
+ if (dns_zone->secondary)
+ option_cache_dereference(&dns_zone->secondary, file, line);
+ if (dns_zone->primary6)
+ option_cache_dereference(&dns_zone->primary6, file, line);
+ if (dns_zone->secondary6)
+ option_cache_dereference(&dns_zone->secondary6, file, line);
+ dfree(dns_zone, file, line);
+ return (1);
}
#if defined (NSUPDATE)
@@ -648,9 +657,10 @@ find_cached_zone(dhcp_ddns_cb_t *ddns_cb, int direction)
{
isc_result_t status = ISC_R_NOTFOUND;
const char *np;
- struct dns_zone *zone = (struct dns_zone *)0;
+ struct dns_zone *zone = NULL;
struct data_string nsaddrs;
struct in_addr zone_addr;
+ struct in6_addr zone_addr6;
int ix;
if (direction == FIND_FORWARD) {
@@ -661,14 +671,14 @@ find_cached_zone(dhcp_ddns_cb_t *ddns_cb, int direction)
/* We can't look up a null zone. */
if ((np == NULL) || (*np == '\0')) {
- return DHCP_R_INVALIDARG;
+ return (DHCP_R_INVALIDARG);
}
/*
* For each subzone, try to find a cached zone.
*/
for (;;) {
- status = dns_zone_lookup (&zone, np);
+ status = dns_zone_lookup(&zone, np);
if (status == ISC_R_SUCCESS)
break;
@@ -679,32 +689,28 @@ find_cached_zone(dhcp_ddns_cb_t *ddns_cb, int direction)
}
if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
/* Make sure the zone is valid. */
- if (zone -> timeout && zone -> timeout < cur_time) {
- dns_zone_dereference (&zone, MDL);
- return ISC_R_CANCELED;
+ if (zone->timeout && zone->timeout < cur_time) {
+ dns_zone_dereference(&zone, MDL);
+ return (ISC_R_CANCELED);
}
/* Make sure the zone name will fit. */
if (strlen(zone->name) > sizeof(ddns_cb->zone_name)) {
- dns_zone_dereference (&zone, MDL);
- return ISC_R_NOSPACE;
+ dns_zone_dereference(&zone, MDL);
+ return (ISC_R_NOSPACE);
}
strcpy((char *)&ddns_cb->zone_name[0], zone->name);
memset (&nsaddrs, 0, sizeof nsaddrs);
ix = 0;
- if (zone -> primary) {
- if (evaluate_option_cache (&nsaddrs, (struct packet *)0,
- (struct lease *)0,
- (struct client_state *)0,
- (struct option_state *)0,
- (struct option_state *)0,
- &global_scope,
- zone -> primary, MDL)) {
+ if (zone->primary) {
+ if (evaluate_option_cache(&nsaddrs, NULL, NULL, NULL,
+ NULL, NULL, &global_scope,
+ zone->primary, MDL)) {
int ip = 0;
while (ix < DHCP_MAXNS) {
if (ip + 4 > nsaddrs.len)
@@ -719,17 +725,36 @@ find_cached_zone(dhcp_ddns_cb_t *ddns_cb, int direction)
ip += 4;
ix++;
}
- data_string_forget (&nsaddrs, MDL);
+ data_string_forget(&nsaddrs, MDL);
+ }
+ }
+
+ if (zone->primary6) {
+ if (evaluate_option_cache(&nsaddrs, NULL, NULL, NULL,
+ NULL, NULL, &global_scope,
+ zone->primary6, MDL)) {
+ int ip = 0;
+ while (ix < DHCP_MAXNS) {
+ if (ip + 16 > nsaddrs.len)
+ break;
+ memcpy(&zone_addr6, &nsaddrs.data[ip], 16);
+ isc_sockaddr_fromin6(&ddns_cb->zone_addrs[ix],
+ &zone_addr6,
+ NS_DEFAULTPORT);
+ ISC_LIST_APPEND(ddns_cb->zone_server_list,
+ &ddns_cb->zone_addrs[ix],
+ link);
+ ip += 16;
+ ix++;
+ }
+ data_string_forget(&nsaddrs, MDL);
}
}
- if (zone -> secondary) {
- if (evaluate_option_cache (&nsaddrs, (struct packet *)0,
- (struct lease *)0,
- (struct client_state *)0,
- (struct option_state *)0,
- (struct option_state *)0,
- &global_scope,
- zone -> secondary, MDL)) {
+
+ if (zone->secondary) {
+ if (evaluate_option_cache(&nsaddrs, NULL, NULL, NULL,
+ NULL, NULL, &global_scope,
+ zone->secondary, MDL)) {
int ip = 0;
while (ix < DHCP_MAXNS) {
if (ip + 4 > nsaddrs.len)
@@ -748,6 +773,28 @@ find_cached_zone(dhcp_ddns_cb_t *ddns_cb, int direction)
}
}
+ if (zone->secondary6) {
+ if (evaluate_option_cache(&nsaddrs, NULL, NULL, NULL,
+ NULL, NULL, &global_scope,
+ zone->secondary6, MDL)) {
+ int ip = 0;
+ while (ix < DHCP_MAXNS) {
+ if (ip + 16 > nsaddrs.len)
+ break;
+ memcpy(&zone_addr6, &nsaddrs.data[ip], 16);
+ isc_sockaddr_fromin6(&ddns_cb->zone_addrs[ix],
+ &zone_addr6,
+ NS_DEFAULTPORT);
+ ISC_LIST_APPEND(ddns_cb->zone_server_list,
+ &ddns_cb->zone_addrs[ix],
+ link);
+ ip += 16;
+ ix++;
+ }
+ data_string_forget (&nsaddrs, MDL);
+ }
+ }
+
dns_zone_reference(&ddns_cb->zone, zone, MDL);
dns_zone_dereference (&zone, MDL);
return ISC_R_SUCCESS;
diff --git a/common/parse.c b/common/parse.c
index 049ce7b..61488c1 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -2698,6 +2698,8 @@ int parse_executable_statement (result, cfile, lose, case_context)
zone-statement :==
PRIMARY ip-addresses SEMI |
SECONDARY ip-addresses SEMI |
+ PRIMARY6 ip-address6 SEMI |
+ SECONDARY6 ip-address6 SEMI |
key-reference SEMI
ip-addresses :== ip-addr-or-hostname |
ip-addr-or-hostname COMMA ip-addresses
@@ -2779,6 +2781,61 @@ int parse_zone (struct dns_zone *zone, struct parse *cfile)
}
break;
+ case PRIMARY6:
+ if (zone->primary6) {
+ parse_warn(cfile, "more than one primary6.");
+ skip_to_semi(cfile);
+ return (0);
+ }
+ if (!option_cache_allocate (&zone->primary6, MDL))
+ log_fatal("can't allocate primary6 option cache.");
+ oc = zone->primary6;
+ goto consemup6;
+
+ case SECONDARY6:
+ if (zone->secondary6) {
+ parse_warn(cfile, "more than one secondary6.");
+ skip_to_semi(cfile);
+ return (0);
+ }
+ if (!option_cache_allocate (&zone->secondary6, MDL))
+ log_fatal("can't allocate secondary6 "
+ "option cache.");
+ oc = zone->secondary6;
+ consemup6:
+ token = next_token(&val, NULL, cfile);
+ do {
+ struct expression *expr = NULL;
+ if (parse_ip6_addr_expr(&expr, cfile) == 0) {
+ parse_warn(cfile, "expecting IPv6 addr.");
+ skip_to_semi(cfile);
+ return (0);
+ }
+ if (oc->expression) {
+ struct expression *old = NULL;
+ expression_reference(&old, oc->expression,
+ MDL);
+ expression_dereference(&oc->expression,
+ MDL);
+ if (!make_concat(&oc->expression,
+ old, expr))
+ log_fatal("no memory for concat.");
+ expression_dereference(&expr, MDL);
+ expression_dereference(&old, MDL);
+ } else {
+ expression_reference(&oc->expression,
+ expr, MDL);
+ expression_dereference(&expr, MDL);
+ }
+ token = next_token(&val, NULL, cfile);
+ } while (token == COMMA);
+ if (token != SEMI) {
+ parse_warn(cfile, "expecting semicolon.");
+ skip_to_semi(cfile);
+ return (0);
+ }
+ break;
+
case KEY:
token = next_token (&val, (unsigned *)0, cfile);
token = peek_token (&val, (unsigned *)0, cfile);
diff --git a/common/tests/Makefile.in b/common/tests/Makefile.in
index 80a0024..43a477e 100644
--- a/common/tests/Makefile.in
+++ b/common/tests/Makefile.in
@@ -87,6 +87,7 @@ LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
@@ -157,7 +158,7 @@ all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -182,9 +183,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: $(am__configure_deps)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-checkPROGRAMS: