include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / dnsapi / tests / record.c
blobd340c0645549bbc38a6f80396ce03d3e1be13a68
1 /*
2 * Tests for record handling functions
4 * Copyright 2006 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "windns.h"
29 #include "wine/test.h"
31 static WCHAR name1[] = L"localhost";
32 static WCHAR name2[] = L"LOCALHOST";
34 static DNS_RECORDW r1 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
35 static DNS_RECORDW r2 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
36 static DNS_RECORDW r3 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
38 static void test_DnsRecordCompare( void )
40 ok( DnsRecordCompare( &r1, &r1 ) == TRUE, "failed unexpectedly\n" );
42 r2.pName = name2;
43 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
45 r2.Flags.S.CharSet = DnsCharSetUnicode;
46 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
48 r2.Flags.S.CharSet = DnsCharSetAnsi;
49 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
51 r1.Flags.S.CharSet = DnsCharSetAnsi;
52 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
54 r1.dwTtl = 0;
55 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
57 r2.Data.A.IpAddress = 0;
58 ok( DnsRecordCompare( &r1, &r2 ) == FALSE, "succeeded unexpectedly\n" );
61 static void test_DnsRecordSetCompare( void )
63 DNS_RECORDW *diff1;
64 DNS_RECORDW *diff2;
65 DNS_RRSET rr1, rr2;
67 r1.Flags.DW = 0x2019;
68 r2.Flags.DW = 0x2019;
69 r2.Data.A.IpAddress = 0xffffffff;
71 DNS_RRSET_INIT( rr1 );
72 DNS_RRSET_INIT( rr2 );
74 DNS_RRSET_ADD( rr1, &r1 );
75 DNS_RRSET_ADD( rr2, &r2 );
77 DNS_RRSET_TERMINATE( rr1 );
78 DNS_RRSET_TERMINATE( rr2 );
80 ok( DnsRecordSetCompare( NULL, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
81 ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
82 ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
84 diff1 = NULL;
85 diff2 = NULL;
87 ok( DnsRecordSetCompare( NULL, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
88 ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
90 ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
91 ok( diff1 != NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
92 DnsRecordListFree( diff1, DnsFreeRecordList );
94 ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
95 ok( diff1 == NULL && diff2 != NULL, "unexpected result: %p, %p\n", diff1, diff2 );
96 DnsRecordListFree( diff2, DnsFreeRecordList );
98 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == TRUE, "failed unexpectedly\n" );
99 ok( diff2 == NULL, "unexpected result: %p\n", diff2 );
101 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == TRUE, "failed unexpectedly\n" );
102 ok( diff1 == NULL, "unexpected result: %p\n", diff1 );
104 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == TRUE, "failed unexpectedly\n" );
105 ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
107 r2.Data.A.IpAddress = 0;
109 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
110 DnsRecordListFree( diff2, DnsFreeRecordList );
112 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == FALSE, "succeeded unexpectedly\n" );
113 DnsRecordListFree( diff1, DnsFreeRecordList );
115 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
116 DnsRecordListFree( diff1, DnsFreeRecordList );
117 DnsRecordListFree( diff2, DnsFreeRecordList );
120 static void test_DnsRecordSetDetach( void )
122 DNS_RRSET rr;
123 DNS_RECORDW *r, *s;
125 DNS_RRSET_INIT( rr );
126 DNS_RRSET_ADD( rr, &r1 );
127 DNS_RRSET_ADD( rr, &r2 );
128 DNS_RRSET_ADD( rr, &r3 );
129 DNS_RRSET_TERMINATE( rr );
131 ok( !DnsRecordSetDetach( NULL ), "succeeded unexpectedly\n" );
133 r = rr.pFirstRR;
134 s = DnsRecordSetDetach( r );
136 ok( s == &r3, "failed unexpectedly: got %p, expected %p\n", s, &r3 );
137 ok( r == &r1, "failed unexpectedly: got %p, expected %p\n", r, &r1 );
138 ok( !r2.pNext, "failed unexpectedly\n" );
141 static BYTE msg_empty[] = /* empty message */
143 0x12, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
144 0x00
146 static BYTE msg_empty_answer[] = /* marked as answer but contains only question */
148 0x12, 0x34, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 0x00, 0x00, 0x01, 0x00, 0x01
151 static BYTE msg_question[] = /* question only */
153 0x12, 0x34, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x01, 0x00, 0x01
156 static BYTE msg_winehq[] = /* valid answer for winehq.org */
158 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x06, 'w', 'i', 'n', 'e', 'h', 'q', 0x03, 'o', 'r', 'g', 0x00, 0x00, 0x01, 0x00, 0x01,
160 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x04, 0x04, 0x04, 0x51, 0x7c
162 static BYTE msg_invchars[] = /* invalid characters in name */
164 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x02, 'a', '$', 0x02, 'b', '\\', 0x02, 'c', '.', 0x02, 0x09, 'd', 0x00, 0x00, 0x01, 0x00, 0x01,
166 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04, 0x51, 0x7c
168 static BYTE msg_root[] = /* root name */
170 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x01, 0x00, 0x01,
172 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04, 0x51, 0x7c
174 static BYTE msg_label[] = /* name with binary label, not supported on Windows */
176 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x03, 'a', 'b', 'c', 0x41, 0x01, 0x34, 0x00, 0x00, 0x01, 0x00, 0x01,
178 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04, 0x51, 0x7c
180 static BYTE msg_loop[] = /* name with loop */
182 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01,
184 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04, 0x51, 0x7c
186 static BYTE msg_types[] = /* various record types */
188 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
189 0x06, 'w', 'i', 'n', 'e', 'h', 'q', 0x03, 'o', 'r', 'g', 0x00, 0x00, 0x01, 0x00, 0x01,
190 /* CNAME */ 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x05, 0x01, 'a', 0x01, 'b', 0x00,
191 /* MX */ 0xc0, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x07, 0x03, 0x04, 0x01, 'c', 0x01, 'd', 0x00,
192 /* AAAA */ 0xc0, 0x0c, 0x00, 0x1c, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00,
193 /* KEY */ 0xc0, 0x0c, 0x00, 0x19, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x06, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
194 /* TXT */ 0x01, 't', 0x01, 'x', 0x00, 0x00, 0x10, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x09, 0x02, 'z', 'y', 0x00, 0x04, 'X', 'Y', 0xc3, 0xa9
196 static BYTE msg_question_srv[] = /* SRV question only */
198 0x12, 0x34, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,0x00,0x00,0x21,0x00
201 static BYTE msg_answer_srv[] = /* SRV answer only */
203 0x12, 0x34, 0x81, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
204 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,
205 0x00,0x21,0x00,0x01,0x04,0x05,0x06,0x07,
206 0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x85,
207 2,'d','c',6,'w','i','n','e','h','q',3,'o','r','g',0x00
209 static BYTE msg_full_srv[] = /* SRV question + answer */
211 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
212 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,
213 0x00,0x21,0x00,0x01,
214 0xc0,0x0c,0x00,0x21,0x00,0x01,0x04,0x05,0x06,0x07,
215 0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x85,
216 2,'d','c',6,'w','i','n','e','h','q',3,'o','r','g',0x00
219 static void test_DnsExtractRecordsFromMessage(void)
221 DNS_STATUS ret;
222 DNS_RECORDA *rec, *r;
223 DNS_RECORDW *recW, *rW;
225 rec = NULL;
226 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_full_srv, sizeof(msg_full_srv), &rec );
227 ok( !ret, "failed %ld\n", ret );
228 ok( rec != NULL, "record not set\n" );
229 ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
230 ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
231 ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
232 ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
233 ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
234 ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
235 ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
236 ok( !rec->pNext, "next record %p\n", rec->pNext );
237 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
239 rec = (void *)0xdeadbeef;
240 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_question_srv, sizeof(msg_question_srv), &rec );
241 ok( !ret, "failed %ld\n", ret );
242 ok( !rec, "record %p\n", rec );
244 rec = NULL;
245 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_answer_srv, sizeof(msg_answer_srv), &rec );
246 ok( !ret, "failed %ld\n", ret );
247 ok( rec != NULL, "record not set\n" );
248 ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
249 ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
250 ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
251 ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
252 ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
253 ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
254 ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
255 ok( !rec->pNext, "next record %p\n", rec->pNext );
256 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
258 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_empty, sizeof(msg_empty) - 1, &rec );
259 ok( ret == ERROR_INVALID_PARAMETER || broken(ret == DNS_ERROR_BAD_PACKET) /* win7 */,
260 "failed %ld\n", ret );
262 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_empty, sizeof(msg_empty), &rec );
263 ok( ret == DNS_ERROR_BAD_PACKET, "failed %ld\n", ret );
265 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_empty_answer, sizeof(msg_empty_answer), &rec );
266 ok( ret == DNS_ERROR_BAD_PACKET, "failed %ld\n", ret );
268 rec = (void *)0xdeadbeef;
269 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_question, sizeof(msg_question), &rec );
270 ok( !ret, "failed %ld\n", ret );
271 ok( !rec, "record %p\n", rec );
273 rec = (void *)0xdeadbeef;
274 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_winehq, sizeof(msg_winehq), &rec );
275 ok( !ret, "failed %ld\n", ret );
276 ok( rec != NULL, "record not set\n" );
277 ok( !strcmp( rec->pName, "winehq.org" ), "wrong name %s\n", rec->pName );
278 ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
279 ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
280 ok( rec->wType == DNS_TYPE_A, "wrong type %u\n", rec->wType );
281 ok( rec->wDataLength == sizeof(DNS_A_DATA), "wrong len %u\n", rec->wDataLength );
282 ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
283 ok( rec->Data.A.IpAddress == 0x7c510404, "wrong addr %#lx\n", rec->Data.A.IpAddress );
284 ok( !rec->pNext, "next record %p\n", rec->pNext );
285 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
287 recW = (void *)0xdeadbeef;
288 ret = DnsExtractRecordsFromMessage_W( (DNS_MESSAGE_BUFFER *)msg_winehq, sizeof(msg_winehq), &recW );
289 ok( !ret, "failed %ld\n", ret );
290 ok( recW != NULL, "record not set\n" );
291 ok( !wcscmp( recW->pName, L"winehq.org" ), "wrong name %s\n", debugstr_w(recW->pName) );
292 DnsRecordListFree( (DNS_RECORD *)recW, DnsFreeRecordList );
294 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_invchars, sizeof(msg_invchars), &rec );
295 ok( !ret, "failed %ld\n", ret );
296 ok( !strcmp( rec->pName, "a$.b\\.c..\td" ), "wrong name %s\n", rec->pName );
297 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
299 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_root, sizeof(msg_root), &rec );
300 ok( !ret, "failed %ld\n", ret );
301 ok( !strcmp( rec->pName, "." ), "wrong name %s\n", rec->pName );
302 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
304 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_label, sizeof(msg_label), &rec );
305 ok( ret == DNS_ERROR_BAD_PACKET, "failed %ld\n", ret );
307 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_loop, sizeof(msg_loop), &rec );
308 ok( ret == DNS_ERROR_BAD_PACKET, "failed %ld\n", ret );
310 ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_types, sizeof(msg_types), &rec );
311 ok( !ret, "failed %ld\n", ret );
312 r = rec;
313 ok( r != NULL, "record not set\n" );
314 ok( !strcmp( r->pName, "winehq.org" ), "wrong name %s\n", r->pName );
315 ok( r->wType == DNS_TYPE_CNAME, "wrong type %u\n", r->wType );
316 ok( !strcmp( r->Data.CNAME.pNameHost, "a.b" ), "wrong cname %s\n", r->Data.CNAME.pNameHost );
317 ok( r->wDataLength == sizeof(DNS_PTR_DATAA) + 4, "wrong len %x\n", r->wDataLength );
318 r = r->pNext;
319 ok( r != NULL, "record not set\n" );
320 ok( !strcmp( r->pName, "winehq.org" ), "wrong name %s\n", r->pName );
321 ok( r->wType == DNS_TYPE_MX, "wrong type %u\n", r->wType );
322 ok( r->Data.MX.wPreference == 0x0304, "wrong pref %x\n", r->Data.MX.wPreference );
323 ok( !strcmp( r->Data.MX.pNameExchange, "c.d" ), "wrong mx %s\n", r->Data.MX.pNameExchange );
324 ok( r->wDataLength == sizeof(DNS_MX_DATAA) + 4, "wrong len %x\n", r->wDataLength );
325 r = r->pNext;
326 ok( r != NULL, "record not set\n" );
327 ok( !strcmp( r->pName, "winehq.org" ), "wrong name %s\n", r->pName );
328 ok( r->wType == DNS_TYPE_AAAA, "wrong type %u\n", r->wType );
329 ok( r->Data.AAAA.Ip6Address.IP6Dword[0] == 0x04030201, "wrong addr %#lx\n",
330 r->Data.AAAA.Ip6Address.IP6Dword[0] );
331 ok( r->Data.AAAA.Ip6Address.IP6Dword[1] == 0x08070605, "wrong addr %#lx\n",
332 r->Data.AAAA.Ip6Address.IP6Dword[1] );
333 ok( r->Data.AAAA.Ip6Address.IP6Dword[2] == 0x0c0b0a09, "wrong addr %#lx\n",
334 r->Data.AAAA.Ip6Address.IP6Dword[2] );
335 ok( r->Data.AAAA.Ip6Address.IP6Dword[3] == 0x000f0e0d, "wrong addr %#lx\n",
336 r->Data.AAAA.Ip6Address.IP6Dword[3] );
337 ok( r->wDataLength == sizeof(DNS_AAAA_DATA), "wrong len %u\n", r->wDataLength );
338 r = r->pNext;
339 ok( r != NULL, "record not set\n" );
340 ok( !strcmp( r->pName, "winehq.org" ), "wrong name %s\n", r->pName );
341 ok( r->wType == DNS_TYPE_KEY, "wrong type %u\n", r->wType );
342 ok( r->Data.KEY.wFlags == 0x1122, "wrong flags %x\n", r->Data.KEY.wFlags );
343 ok( r->Data.KEY.chProtocol == 0x33, "wrong protocol %x\n", r->Data.KEY.chProtocol );
344 ok( r->Data.KEY.chAlgorithm == 0x44, "wrong algorithm %x\n", r->Data.KEY.chAlgorithm );
345 ok( r->Data.KEY.wKeyLength == 0x02, "wrong len %x\n", r->Data.KEY.wKeyLength );
346 ok( r->Data.KEY.Key[0] == 0x55, "wrong key %x\n", r->Data.KEY.Key[0] );
347 ok( r->Data.KEY.Key[1] == 0x66, "wrong key %x\n", r->Data.KEY.Key[1] );
348 ok( r->wDataLength == offsetof( DNS_KEY_DATA, Key[r->Data.KEY.wKeyLength] ),
349 "wrong len %x\n", r->wDataLength );
350 r = r->pNext;
351 ok( r != NULL, "record not set\n" );
352 ok( !strcmp( r->pName, "t.x" ), "wrong name %s\n", r->pName );
353 ok( r->wType == DNS_TYPE_TEXT, "wrong type %u\n", r->wType );
354 ok( r->Data.TXT.dwStringCount == 3, "wrong count %lu\n", r->Data.TXT.dwStringCount );
355 ok( !strcmp( r->Data.TXT.pStringArray[0], "zy" ), "wrong string %s\n", r->Data.TXT.pStringArray[0] );
356 ok( !strcmp( r->Data.TXT.pStringArray[1], "" ), "wrong string %s\n", r->Data.TXT.pStringArray[1] );
357 ok( !strcmp( r->Data.TXT.pStringArray[2], "XY\xc3\xa9" ), "wrong string %s\n", r->Data.TXT.pStringArray[2] );
358 ok( r->wDataLength == offsetof( DNS_TXT_DATAA, pStringArray[r->Data.TXT.dwStringCount] ),
359 "wrong len %x\n", r->wDataLength );
360 ok( !r->pNext, "next record %p\n", r->pNext );
361 DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
363 ret = DnsExtractRecordsFromMessage_W( (DNS_MESSAGE_BUFFER *)msg_types, sizeof(msg_types), &recW );
364 ok( !ret, "failed %ld\n", ret );
365 rW = recW;
366 ok( rW != NULL, "record not set\n" );
367 ok( !wcscmp( rW->pName, L"winehq.org" ), "wrong name %s\n", debugstr_w(rW->pName) );
368 ok( rW->wType == DNS_TYPE_CNAME, "wrong type %u\n", rW->wType );
369 ok( !wcscmp( rW->Data.CNAME.pNameHost, L"a.b" ), "wrong cname %s\n", debugstr_w(rW->Data.CNAME.pNameHost) );
370 rW = rW->pNext;
371 ok( rW != NULL, "record not set\n" );
372 ok( !wcscmp( rW->pName, L"winehq.org" ), "wrong name %s\n", debugstr_w(rW->pName) );
373 ok( rW->wType == DNS_TYPE_MX, "wrong type %u\n", rW->wType );
374 ok( !wcscmp( rW->Data.MX.pNameExchange, L"c.d" ), "wrong mx %s\n", debugstr_w(rW->Data.MX.pNameExchange) );
375 rW = rW->pNext;
376 ok( r != NULL, "record not set\n" );
377 ok( !wcscmp( rW->pName, L"winehq.org" ), "wrong name %s\n", debugstr_w(rW->pName) );
378 ok( rW->wType == DNS_TYPE_AAAA, "wrong type %u\n", rW->wType );
379 rW = rW->pNext;
380 ok( r != NULL, "record not set\n" );
381 ok( !wcscmp( rW->pName, L"winehq.org" ), "wrong name %s\n", debugstr_w(rW->pName) );
382 rW = rW->pNext;
383 ok( r != NULL, "record not set\n" );
384 ok( !wcscmp( rW->pName, L"t.x" ), "wrong name %s\n", debugstr_w(rW->pName) );
385 ok( rW->wType == DNS_TYPE_TEXT, "wrong type %u\n", rW->wType );
386 ok( rW->Data.TXT.dwStringCount == 3, "wrong count %lu\n", rW->Data.TXT.dwStringCount );
387 ok( !wcscmp( rW->Data.TXT.pStringArray[0], L"zy" ), "wrong string %s\n", debugstr_w(rW->Data.TXT.pStringArray[0]) );
388 ok( !wcscmp( rW->Data.TXT.pStringArray[1], L"" ), "wrong string %s\n", debugstr_w(rW->Data.TXT.pStringArray[1]) );
389 ok( !wcscmp( rW->Data.TXT.pStringArray[2], L"XY\x00e9" ), "wrong string %s\n", debugstr_w(rW->Data.TXT.pStringArray[2]) );
390 ok( !rW->pNext, "next record %p\n", rW->pNext );
391 DnsRecordListFree( (DNS_RECORD *)recW, DnsFreeRecordList );
394 START_TEST(record)
396 test_DnsRecordCompare();
397 test_DnsRecordSetCompare();
398 test_DnsRecordSetDetach();
399 test_DnsExtractRecordsFromMessage();