summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2011-09-24 18:17:11 -0700
committerKai Blin <kai@samba.org>2011-09-24 21:46:06 -0700
commit7466612392272e70c60114fc035b62b16f6194aa (patch)
treeaa593799183c6690d5b0cc994e5ee55870c1074c
parent8eb80a9d832e08bb356507a870522b0b7180a10a (diff)
downloadsamba-7466612392272e70c60114fc035b62b16f6194aa.tar.gz
samba-7466612392272e70c60114fc035b62b16f6194aa.tar.bz2
samba-7466612392272e70c60114fc035b62b16f6194aa.zip
addns: Allow creating AAAA records during updates
-rw-r--r--lib/addns/dns.h4
-rw-r--r--lib/addns/dnsrecord.c60
2 files changed, 60 insertions, 4 deletions
diff --git a/lib/addns/dns.h b/lib/addns/dns.h
index 6ccdbb60f1..d98a27ea2d 100644
--- a/lib/addns/dns.h
+++ b/lib/addns/dns.h
@@ -205,6 +205,7 @@
#define QTYPE_MD 3
#define QTYPE_CNAME 5
#define QTYPE_SOA 6
+#define QTYPE_AAAA 28
#define QTYPE_ANY 255
#define QTYPE_TKEY 249
#define QTYPE_TSIG 250
@@ -408,6 +409,9 @@ DNS_ERROR dns_create_name_not_in_use_record(TALLOC_CTX *mem_ctx,
DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
uint32 ttl, const struct sockaddr_storage *pss,
struct dns_rrec **prec);
+DNS_ERROR dns_create_aaaa_record(TALLOC_CTX *mem_ctx, const char *host,
+ uint32 ttl, const struct sockaddr_storage *pss,
+ struct dns_rrec **prec);
DNS_ERROR dns_unmarshall_tkey_record(TALLOC_CTX *mem_ctx, struct dns_rrec *rec,
struct dns_tkey_record **ptkey);
DNS_ERROR dns_create_tsig_record(TALLOC_CTX *mem_ctx, const char *keyname,
diff --git a/lib/addns/dnsrecord.c b/lib/addns/dnsrecord.c
index 2240d08fb9..045fd465da 100644
--- a/lib/addns/dnsrecord.c
+++ b/lib/addns/dnsrecord.c
@@ -127,8 +127,7 @@ DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
struct in_addr ip;
if (pss->ss_family != AF_INET) {
- /* Silently ignore this. */
- return ERROR_DNS_SUCCESS;
+ return ERROR_DNS_INVALID_PARAMETER;
}
ip = ((const struct sockaddr_in *)pss)->sin_addr;
@@ -147,13 +146,54 @@ DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
return err;
}
+DNS_ERROR dns_create_aaaa_record(TALLOC_CTX *mem_ctx, const char *host,
+ uint32 ttl, const struct sockaddr_storage *pss,
+ struct dns_rrec **prec)
+{
+#ifdef HAVE_IPV6
+ uint8 *data;
+ DNS_ERROR err;
+ struct in6_addr ip6;
+
+ if (pss->ss_family != AF_INET6) {
+ return ERROR_DNS_INVALID_PARAMETER;
+ }
+
+ ip6 = ((const struct sockaddr_in6 *)pss)->sin6_addr;
+ if (!(data = (uint8 *)talloc_memdup(mem_ctx, (const void *)&ip6.s6_addr,
+ sizeof(ip6.s6_addr)))) {
+ return ERROR_DNS_NO_MEMORY;
+ }
+
+ err = dns_create_rrec(mem_ctx, host, QTYPE_AAAA, DNS_CLASS_IN, ttl,
+ sizeof(ip6.s6_addr), data, prec);
+
+ if (!ERR_DNS_IS_OK(err)) {
+ TALLOC_FREE(data);
+ }
+
+ return err;
+#else
+ return ERROR_DNS_INVALID_PARAMETER;
+#endif
+}
+
DNS_ERROR dns_create_name_in_use_record(TALLOC_CTX *mem_ctx,
const char *name,
const struct sockaddr_storage *ss,
struct dns_rrec **prec)
{
if (ss != NULL) {
- return dns_create_a_record(mem_ctx, name, 0, ss, prec);
+ switch (ss->ss_family) {
+ case AF_INET:
+ return dns_create_a_record(mem_ctx, name, 0, ss, prec);
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ return dns_create_aaaa_record(mem_ctx, name, 0, ss, prec);
+#endif
+ default:
+ return ERROR_DNS_INVALID_PARAMETER;
+ }
}
return dns_create_rrec(mem_ctx, name, QTYPE_ANY, DNS_CLASS_IN, 0, 0,
@@ -404,7 +444,19 @@ DNS_ERROR dns_create_update_request(TALLOC_CTX *mem_ctx,
*/
for ( i=0; i<num_addrs; i++ ) {
- err = dns_create_a_record(req, hostname, 3600, &ss_addrs[i], &rec);
+
+ switch(ss_addrs[i].ss_family) {
+ case AF_INET:
+ err = dns_create_a_record(req, hostname, 3600, &ss_addrs[i], &rec);
+ break;
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ err = dns_create_aaaa_record(req, hostname, 3600, &ss_addrs[i], &rec);
+ break;
+#endif
+ default:
+ continue;
+ }
if (!ERR_DNS_IS_OK(err))
goto error;