d247e0e67d59f9fbc7069b801cebb673eaaa2e34
[samba.git] / librpc / idl / dns.idl
1 #include "idl_types.h"
2
3 /*
4    IDL structures for DNS operations
5
6    DNS is not traditionally encoded using IDL/NDR. This is a bit of an
7    experiment, and I may well switch us back to a more traditional
8    encoding if it doesn't work out
9 */
10
11 import "misc.idl";
12 [
13         helper("librpc/ndr/ndr_dns.h"),
14         helpstring("DNS records"),
15         version(0.0),
16         uuid("a047c001-5f22-40b0-9d52-7042c43f711a")
17 ]
18 interface dns
19 {
20         const int DNS_SERVICE_PORT       = 53;
21
22         typedef [public,bitmap16bit] bitmap {
23                 DNS_RCODE                   = 0x000F,
24                 DNS_FLAG_BROADCAST          = 0x0010,
25                 DNS_FLAG_RECURSION_AVAIL    = 0x0080,
26                 DNS_FLAG_RECURSION_DESIRED  = 0x0100,
27                 DNS_FLAG_TRUNCATION         = 0x0200,
28                 DNS_FLAG_AUTHORITATIVE      = 0x0400,
29                 DNS_OPCODE                  = 0x7800,
30                 DNS_FLAG_REPLY              = 0x8000
31         } dns_operation;
32
33         /* the opcodes are in the operation field, masked with
34            DNS_OPCODE */
35         typedef [public] enum {
36                 DNS_OPCODE_QUERY          =  (0x0<<11),
37                 DNS_OPCODE_IQUERY         =  (0x1<<11),
38                 DNS_OPCODE_STATUS         =  (0x2<<11),
39                 DNS_OPCODE_UPDATE         =  (0x5<<11),
40                 DNS_OPCODE_RELEASE        =  (0x6<<11),
41                 DNS_OPCODE_WACK           =  (0x7<<11),
42                 DNS_OPCODE_REFRESH        =  (0x8<<11),
43                 DNS_OPCODE_REFRESH2       =  (0x9<<11),
44                 DNS_OPCODE_MULTI_HOME_REG =  (0xf<<11)
45         } dns_opcode;
46
47         /* rcode values */
48         typedef [public] enum {
49                 DNS_RCODE_OK       = 0x00,
50                 DNS_RCODE_FORMERR  = 0x01,
51                 DNS_RCODE_SERVFAIL = 0x02,
52                 DNS_RCODE_NXDOMAIN = 0x03,
53                 DNS_RCODE_NOTIMP   = 0x04,
54                 DNS_RCODE_REFUSED  = 0x05,
55                 DNS_RCODE_YXDOMAIN = 0x06,
56                 DNS_RCODE_YXRRSET  = 0x07,
57                 DNS_RCODE_NXRRSET  = 0x08,
58                 DNS_RCODE_NOTAUTH  = 0x09,
59                 DNS_RCODE_NOTZONE  = 0x0A,
60                 DNS_RCODE_BADSIG   = 0x10,
61                 DNS_RCODE_BADKEY   = 0x11,
62                 DNS_RCODE_BADTIME  = 0x12,
63                 DNS_RCODE_BADMODE  = 0x13,
64                 DNS_RCODE_BADNAME  = 0x14,
65                 DNS_RCODE_BADALG   = 0x15
66         } dns_rcode;
67
68         typedef [public,enum16bit] enum {
69                 DNS_QCLASS_IN   = 0x0001,
70                 DNS_QCLASS_NONE = 0x00FE,
71                 DNS_QCLASS_ANY  = 0x00FF
72         } dns_qclass;
73
74         /* These vese values could have been merged with NBT_QTYPE values, but
75            DNS_QTYPE_SRV and NBT_QTYPE_STATUS have the same numeric value. */
76         typedef [public,enum16bit] enum {
77                 DNS_QTYPE_ZERO   = 0x0000,
78                 DNS_QTYPE_A      = 0x0001,
79                 DNS_QTYPE_NS     = 0x0002,
80                 DNS_QTYPE_MD     = 0x0003,
81                 DNS_QTYPE_MF     = 0x0004,
82                 DNS_QTYPE_CNAME  = 0x0005,
83                 DNS_QTYPE_SOA    = 0x0006,
84                 DNS_QTYPE_MB     = 0x0007,
85                 DNS_QTYPE_MG     = 0x0008,
86                 DNS_QTYPE_MR     = 0x0009,
87                 DNS_QTYPE_NULL   = 0x000A,
88                 DNS_QTYPE_WKS    = 0x000B,
89                 DNS_QTYPE_PTR    = 0x000C,
90                 DNS_QTYPE_HINFO  = 0x000D,
91                 DNS_QTYPE_MINFO  = 0x000E,
92                 DNS_QTYPE_MX     = 0x000F,
93                 DNS_QTYPE_TXT    = 0x0010,
94                 DNS_QTYPE_RP     = 0x0011,
95                 DNS_QTYPE_AFSDB  = 0x0012,
96                 DNS_QTYPE_X25    = 0x0013,
97                 DNS_QTYPE_ISDN   = 0x0014,
98                 DNS_QTYPE_RT     = 0x0015,
99                 DNS_QTYPE_SIG    = 0x0018,
100                 DNS_QTYPE_KEY    = 0x0019,
101                 DNS_QTYPE_AAAA   = 0x001C,
102                 DNS_QTYPE_LOC    = 0x001D,
103                 DNS_QTYPE_NXT    = 0x001E,
104                 DNS_QTYPE_NETBIOS= 0x0020,
105                 DNS_QTYPE_SRV    = 0x0021,
106                 DNS_QTYPE_ATMA   = 0x0022,
107                 DNS_QTYPE_NAPTR  = 0x0023,
108                 DNS_QTYPE_DNAME  = 0x0027,
109                 DNS_QTYPE_OPT    = 0x0029,
110                 DNS_QTYPE_DS     = 0x002B,
111                 DNS_QTYPE_RRSIG  = 0x002E,
112                 DNS_QTYPE_NSEC   = 0x002F,
113                 DNS_QTYPE_DNSKEY = 0x0030,
114                 DNS_QTYPE_DHCID  = 0x0031,
115                 DNS_QTYPE_TKEY   = 0x00F9,
116                 DNS_QTYPE_TSIG   = 0x00FA,
117                 DNS_QTYPE_AXFR   = 0x00FC,
118                 DNS_QTYPE_MAILB  = 0x00FD,
119                 DNS_QTYPE_MAILA  = 0x00FE,
120                 DNS_QTYPE_ALL    = 0x00FF
121         } dns_qtype;
122
123         typedef [public,enum16bit] enum {
124                 DNS_TKEY_MODE_NULL   = 0x0000,
125                 DNS_TKEY_MODE_SERVER = 0x0001,
126                 DNS_TKEY_MODE_DH     = 0x0002,
127                 DNS_TKEY_MODE_GSSAPI = 0x0003,
128                 DNS_TKEY_MODE_CLIENT = 0x0004,
129                 DNS_TKEY_MODE_DELETE = 0x0005,
130                 DNS_TKEY_MODE_LAST   = 0xFFFF
131         } dns_tkey_mode;
132
133         typedef [public] struct {
134                 dns_string name;
135                 dns_qtype  question_type;
136                 dns_qclass question_class;
137         } dns_name_question;
138
139         typedef [public] struct {
140                 uint16 length;
141                 uint8  data[length];
142         } dns_rdata_data;
143
144         typedef struct {
145                 dns_string mname;
146                 dns_string rname;
147                 uint32     serial;
148                 uint32     refresh;
149                 uint32     retry;
150                 uint32     expire;
151                 uint32     minimum;
152         } dns_soa_record;
153
154         typedef [public] struct {
155                 [value(strlen(cpu))] uint8 cpu_length;
156                 [charset(DOS)] uint8 cpu[cpu_length];
157                 [value(strlen(os))] uint8 os_length;
158                 [charset(DOS)] uint8 os[os_length];
159         } dns_hinfo_record;
160
161         typedef [public] struct {
162                 uint16     preference;
163                 dns_string exchange;
164         } dns_mx_record;
165
166         typedef [public] struct {
167                 [value(strlen(txt))] uint8 length;
168                 [charset(DOS)] uint8 txt[length];
169         } dns_txt_record;
170
171         typedef [public] struct {
172                 dns_string mbox;
173                 dns_string txt;
174
175         } dns_rp_record;
176
177         typedef [public] struct {
178                 uint16     priority;
179                 uint16     weight;
180                 uint16     port;
181                 dns_string target;
182         } dns_srv_record;
183
184         typedef [public] struct {
185                 uint16     option_code;
186                 uint16     option_length;
187                 uint8      option_data[option_length];
188         } dns_opt_record;
189
190         typedef [public] struct {
191                 dns_string     algorithm;
192                 uint32         inception;
193                 uint32         expiration;
194                 dns_tkey_mode  mode;
195                 uint16         error;
196                 uint16         key_size;
197                 uint8          key_data[key_size];
198                 uint16         other_size;
199                 uint8          other_data[other_size];
200         } dns_tkey_record;
201
202         typedef [public] struct {
203                 dns_string algorithm_name;
204                 uint16     time_prefix; /* 0 until February 2106*/
205                 uint32     time;
206                 uint16     fudge;
207                 uint16     mac_size;
208                 uint8      mac[mac_size];
209                 uint16     original_id;
210                 uint16     error;
211                 uint16     other_size;
212                 uint8      other_data[other_size];
213         } dns_tsig_record;
214
215         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
216                 dns_string      name;
217                 dns_qclass      rr_class;
218                 uint32          ttl;
219                 dns_string      algorithm_name;
220                 uint16          time_prefix; /* 0 until February 2106*/
221                 uint32          time;
222                 uint16          fudge;
223                 uint16          original_id;
224                 uint16          error;
225                 uint16          other_size;
226                 uint8           other_data[other_size];
227         } dns_fake_tsig_rec;
228
229         typedef [nodiscriminant,public,flag(NDR_NOALIGN)] union {
230                 [case(DNS_QTYPE_A)]     ipv4address      ipv4_record;
231                 [case(DNS_QTYPE_NS)]    dns_string       ns_record;
232                 [case(DNS_QTYPE_CNAME)] dns_string       cname_record;
233                 [case(DNS_QTYPE_SOA)]   dns_soa_record   soa_record;
234                 [case(DNS_QTYPE_PTR)]   dns_string       ptr_record;
235                 [case(DNS_QTYPE_HINFO)] dns_hinfo_record  hinfo_record;
236                 [case(DNS_QTYPE_MX)]    dns_mx_record    mx_record;
237                 [case(DNS_QTYPE_TXT)]   dns_txt_record   txt_record;
238                 [case(DNS_QTYPE_RP)]    dns_rp_record    rp_record;
239                 [case(DNS_QTYPE_AAAA)]  ipv6address      ipv6_record;
240                 [case(DNS_QTYPE_SRV)]   dns_srv_record   srv_record;
241                 [case(DNS_QTYPE_OPT)]   dns_opt_record   opt_record;
242                 [case(DNS_QTYPE_TSIG)]  dns_tsig_record  tsig_record;
243                 [case(DNS_QTYPE_TKEY)]  dns_tkey_record  tkey_record;
244                 [default];
245         } dns_rdata;
246
247         typedef [flag(LIBNDR_PRINT_ARRAY_HEX|NDR_NOALIGN),nopush,nopull] struct {
248                 dns_string name;
249                 dns_qtype  rr_type;
250                 dns_qclass rr_class;
251                 uint32     ttl;
252                 uint16     length; /* Should be set to either UINT16_MAX or 0 */
253                 [switch_is(rr_type)] dns_rdata rdata;
254                 DATA_BLOB  unexpected;
255         } dns_res_rec;
256
257         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
258                 uint16            id;
259                 dns_operation     operation;
260                 uint16            qdcount;
261                 uint16            ancount;
262                 uint16            nscount;
263                 uint16            arcount;
264                 dns_name_question questions[qdcount];
265                 dns_res_rec       answers[ancount];
266                 dns_res_rec       nsrecs[nscount];
267                 dns_res_rec       additional[arcount];
268         } dns_name_packet;
269
270         /*
271            this is a convenience hook for ndrdump
272         */
273         void decode_dns_name_packet(
274                                     [in] dns_name_packet packet
275                                    );
276 }