diff options
author | Ted Lemon <source@isc.org> | 2000-10-12 08:58:11 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 2000-10-12 08:58:11 +0000 |
commit | b2b468ef848f3e51e1f32166a9b5ad5d04ed55e3 (patch) | |
tree | da9410975afbb19c7e14cff7dffd2a2cebbdd250 /common/dns.c | |
parent | f07d12c62209234b7104008ace8ad66f8d6c13bb (diff) | |
download | isc-dhcp-b2b468ef848f3e51e1f32166a9b5ad5d04ed55e3.tar.gz |
Add cache_found_zone() function.
Diffstat (limited to 'common/dns.c')
-rw-r--r-- | common/dns.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/common/dns.c b/common/dns.c index a7d808ab..ef423cef 100644 --- a/common/dns.c +++ b/common/dns.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dns.c,v 1.28 2000/09/14 11:29:43 mellon Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dns.c,v 1.29 2000/10/12 08:58:11 mellon Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -396,6 +396,70 @@ void repudiate_zone (struct dns_zone **zone) (*zone) -> timeout = cur_time - 1; dns_zone_dereference (zone, MDL); } + +void cache_found_zone (ns_class class, + char *zname, struct in_addr *addrs, int naddrs) +{ + isc_result_t status = ISC_R_NOTFOUND; + const char *np; + struct dns_zone *zone = (struct dns_zone *)0; + struct data_string nsaddrs; + int ix = strlen (zname); + + if (zname [ix - 1] == '.') + ix = 0; + + /* See if there's already such a zone. */ + if (dns_zone_lookup (&zone, np) == ISC_R_SUCCESS) { + /* If it's not a dynamic zone, leave it alone. */ + if (!zone -> timeout) + return; + /* Address may have changed, so just blow it away. */ + if (zone -> primary) + option_cache_dereference (&zone -> primary, MDL); + if (zone -> secondary) + option_cache_dereference (&zone -> secondary, MDL); + } + + if (!dns_zone_allocate (&zone, MDL)) + return; + + if (!zone -> name) { + zone -> name = + dmalloc (strlen (zname) + 1 + (ix != 0), MDL); + if (!zone -> name) { + dns_zone_dereference (&zone, MDL); + return; + } + strcpy (zone -> name, zname); + /* Add a trailing '.' if it was missing. */ + if (ix) { + zone -> name [ix] = '.'; + zone -> name [ix + 1] = 0; + } + } + + /* XXX Need to get the lower-level code to push the actual zone + XXX TTL up to us. */ + zone -> timeout = cur_time + 1800; + + if (!option_cache_allocate (&zone -> primary, MDL)) { + dns_zone_dereference (&zone, MDL); + return; + } + if (!buffer_allocate (&zone -> primary -> data.buffer, + naddrs * sizeof (struct in_addr), MDL)) { + dns_zone_dereference (&zone, MDL); + return; + } + memcpy (zone -> primary -> data.buffer -> data, + addrs, naddrs * sizeof *addrs); + zone -> primary -> data.data = + &zone -> primary -> data.buffer -> data [0]; + zone -> primary -> data.len = naddrs * sizeof *addrs; + + enter_dns_zone (zone); +} #endif /* NSUPDATE */ HASH_FUNCTIONS (dns_zone, const char *, struct dns_zone) |