dns: fixed dns record format
authorAndrew Tridgell <tridge@samba.org>
Wed, 22 Dec 2010 01:13:44 +0000 (12:13 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 22 Dec 2010 03:45:46 +0000 (04:45 +0100)
based on new WSPP docs from Bryan Burgin

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Wed Dec 22 04:45:46 CET 2010 on sn-devel-104

librpc/idl/dnsp.idl
source4/dns_server/dlz_bind9.c

index eed0c478fb87e945344b7d117b7d72580a75f988..495a3e2af201dfa357a938258a0480c4740a544e 100644 (file)
@@ -23,7 +23,7 @@ import "misc.idl";
 
 interface dnsp
 {
-       typedef enum {
+       typedef [enum16bit] enum {
                DNS_TYPE_ZERO  = 0x0,
                DNS_TYPE_A     = 0x1,
                DNS_TYPE_NS    = 0x2,
@@ -65,6 +65,22 @@ interface dnsp
                DNS_TYPE_WINSR = 0xFF02
        } dns_record_type;
 
+       typedef [enum8bit] enum {
+               DNS_RANK_NONE                   = 0x00,
+               DNS_RANK_CACHE_BIT              = 0x01,
+               DNS_RANK_ROOT_HINT              = 0x08,
+               DNS_RANK_OUTSIDE_GLUE           = 0x20,
+               DNS_RANK_CACHE_NA_ADDITIONAL    = 0x31,
+               DNS_RANK_CACHE_NA_AUTHORITY     = 0x41,
+               DNS_RANK_CACHE_A_ADDITIONAL     = 0x51,
+               DNS_RANK_CACHE_NA_ANSWER        = 0x61,
+               DNS_RANK_CACHE_A_AUTHORITY      = 0x71,
+               DNS_RANK_GLUE                   = 0x80,
+               DNS_RANK_NS_GLUE                = 0x82,
+               DNS_RANK_CACHE_A_ANSWER         = 0xc1,
+               DNS_RANK_ZONE                   = 0xf0
+       } dns_record_rank;
+
        typedef [public] struct {
                uint32          serial;
                uint32          refresh;
@@ -110,12 +126,14 @@ interface dnsp
           partitions in AD */
        typedef [public] struct {
                [value(ndr_size_dnsRecordData(&data,wType,ndr->flags))] uint16 wDataLength;
-               dns_record_type wType;
-               uint32          dwFlags;
-               uint32          dwSerial;
-               [flag(NDR_BIG_ENDIAN)] uint32   dwTtlSeconds;
-               uint32          dwTimeStamp;
-               uint32          dwReserved;
+               dns_record_type         wType;
+               [value(5)] uint8        version;
+               dns_record_rank         rank;
+               uint16                  flags;
+               uint32                  dwSerial;
+               [flag(NDR_BIG_ENDIAN)]  uint32   dwTtlSeconds;
+               uint32                  dwReserved;
+               uint32                  dwTimeStamp;
                [switch_is(wType)] dnsRecordData data;
        } dnsp_DnssrvRpcRecord;
 
index 83790c8da0359d24160833c25e659ecde278e133..7f5125dbf6e6b1478f5b04782a6978c8bc2c1984 100644 (file)
@@ -150,7 +150,7 @@ static bool b9_format(struct dlz_bind9_data *state,
                *type = "soa";
 
                /* we need to fake the authoritative nameserver to
-                * point at ourselves. This is now AD DNS servers
+                * point at ourselves. This is how AD DNS servers
                 * force clients to send updates to the right local DC
                 */
                mname = talloc_asprintf(mem_ctx, "%s.%s",
@@ -1179,6 +1179,7 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo
        int ret, i;
        struct ldb_message_element *el;
        enum ndr_err_code ndr_err;
+       NTTIME t;
 
        if (state->transaction_token != (void*)version) {
                state->log(ISC_LOG_INFO, "samba_dlz: bad transaction version");
@@ -1190,9 +1191,13 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo
                return ISC_R_NOMEMORY;
        }
 
-       /* we're waiting on docs for this field */
-       rec->dwFlags = 0x0000f005;
-       rec->dwSerial = state->soa_serial;
+       unix_to_nt_time(&t, time(NULL));
+       t /= 10*1000*1000; /* convert to seconds (NT time is in 100ns units) */
+       t /= 3600;         /* convert to hours */
+
+       rec->rank        = DNS_RANK_ZONE;
+       rec->dwSerial    = state->soa_serial;
+       rec->dwTimeStamp = (uint32_t)t;
 
        if (!b9_parse(state, rdatastr, rec)) {
                state->log(ISC_LOG_INFO, "samba_dlz: failed to parse rdataset '%s'", rdatastr);