#include "idl_types.h"

/*
   IDL structures for DNSP structures

   See [MS-DNSP].pdf in MCPP for details
*/

import "misc.idl";

/*
  note that this is not a real RPC interface. We are just using PIDL
  to save us a lot of tedious hand parsing of the dnsRecord
  attribute. The uuid is randomly generated.
 */
[
  uuid("bdd66e9e-d45f-4202-85c0-6132edc4f30a"),
  version(0.0),
  pointer_default(unique),
  helper("../librpc/ndr/ndr_dnsp.h"),
  helpstring("DNSP interfaces")
]

interface dnsp
{
	typedef [enum16bit] enum {
		DNS_TYPE_TOMBSTONE  = 0x0,
		DNS_TYPE_A     = 0x1,
		DNS_TYPE_NS    = 0x2,
		DNS_TYPE_MD    = 0x3,
		DNS_TYPE_MF    = 0x4,
		DNS_TYPE_CNAME = 0x5,
		DNS_TYPE_SOA   = 0x6,
		DNS_TYPE_MB    = 0x7,
		DNS_TYPE_MG    = 0x8,
		DNS_TYPE_MR    = 0x9,
		DNS_TYPE_NULL  = 0xA,
		DNS_TYPE_WKS   = 0xB,
		DNS_TYPE_PTR   = 0xC,
		DNS_TYPE_HINFO = 0xD,
		DNS_TYPE_MINFO = 0xE,
		DNS_TYPE_MX    = 0xF,
		DNS_TYPE_TXT   = 0x10,
		DNS_TYPE_RP    = 0x11,
		DNS_TYPE_AFSDB = 0x12,
		DNS_TYPE_X25   = 0x13,
		DNS_TYPE_ISDN  = 0x14,
		DNS_TYPE_RT    = 0x15,
		DNS_TYPE_SIG   = 0x18,
		DNS_TYPE_KEY   = 0x19,
		DNS_TYPE_AAAA  = 0x1C,
		DNS_TYPE_LOC   = 0x1D,
		DNS_TYPE_NXT   = 0x1E,
		DNS_TYPE_SRV   = 0x21,
		DNS_TYPE_ATMA  = 0x22,
		DNS_TYPE_NAPTR = 0x23,
		DNS_TYPE_DNAME = 0x27,
		DNS_TYPE_DS    = 0x2B,
		DNS_TYPE_RRSIG = 0x2E,
		DNS_TYPE_NSEC  = 0x2F,
		DNS_TYPE_DNSKEY= 0x30,
		DNS_TYPE_DHCID = 0x31,
		DNS_TYPE_ALL   = 0xFF,
		DNS_TYPE_WINS  = 0xFF01,
		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;
		uint32		retry;
		uint32		expire;
		uint32		minimum;
		dnsp_name       mname;
		dnsp_name       rname;
	} dnsp_soa;

	typedef [public] struct {
		uint16	        wPriority;
		dnsp_name       nameTarget;
	} dnsp_mx;

	typedef [public] struct {
		dnsp_string     cpu;
		dnsp_string     os;
	} dnsp_hinfo;

	typedef [public] struct {
		uint16          wPriority;
		uint16          wWeight;
		uint16          wPort;
		dnsp_name       nameTarget;
	} dnsp_srv;

	typedef [nodiscriminant,gensize] union {
		[case(DNS_TYPE_TOMBSTONE)] 		    NTTIME timestamp;
		[case(DNS_TYPE_A)] [flag(NDR_BIG_ENDIAN)]   ipv4address ipv4;
		[case(DNS_TYPE_NS)]                         dnsp_name ns;
		[case(DNS_TYPE_CNAME)]                      dnsp_name cname;
		[case(DNS_TYPE_SOA)] [flag(NDR_BIG_ENDIAN)] dnsp_soa soa;
		[case(DNS_TYPE_MX)] [flag(NDR_BIG_ENDIAN)]  dnsp_mx mx;
		[case(DNS_TYPE_TXT)]                        dnsp_string txt;
		[case(DNS_TYPE_PTR)]                        dnsp_name ptr;
		[case(DNS_TYPE_HINFO)]                      dnsp_hinfo hinfo;
		[case(DNS_TYPE_AAAA)]                       ipv6address ipv6;
		[case(DNS_TYPE_SRV)] [flag(NDR_BIG_ENDIAN)] dnsp_srv srv;
		[default] [flag(NDR_REMAINING)] DATA_BLOB data;
	} dnsRecordData;

	/* this is the format for the dnsRecord attribute in the DNS
	   partitions in AD */
	typedef [public] struct {
		[value(ndr_size_dnsRecordData(&data,wType,ndr->flags))] uint16 wDataLength;
		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;


	/*
	  this is a convenience hook for ndrdump
	 */
	void decode_DnssrvRpcRecord(
		[in] dnsp_DnssrvRpcRecord blob
		);
}