r11967: Fix more 64-bit warnings.
[samba.git] / source / torture / nbt / winsreplication.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    WINS replication testing
5
6    Copyright (C) Andrew Tridgell        2005
7    Copyright (C) Stefan Metzmacher      2005
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #include "includes.h"
25 #include "libcli/nbt/libnbt.h"
26 #include "libcli/wrepl/winsrepl.h"
27 #include "lib/events/events.h"
28 #include "lib/socket/socket.h"
29 #include "system/time.h"
30
31 #define CHECK_STATUS(status, correct) do { \
32         if (!NT_STATUS_EQUAL(status, correct)) { \
33                 printf("(%s) Incorrect status %s - should be %s\n", \
34                        __location__, nt_errstr(status), nt_errstr(correct)); \
35                 ret = False; \
36                 goto done; \
37         }} while (0)
38
39 #define CHECK_VALUE(v, correct) do { \
40         if ((v) != (correct)) { \
41                 printf("(%s) Incorrect value %s=%d - should be %d\n", \
42                        __location__, #v, v, correct); \
43                 ret = False; \
44                 goto done; \
45         }} while (0)
46
47 #define CHECK_VALUE_UINT64(v, correct) do { \
48         if ((v) != (correct)) { \
49                 printf("(%s) Incorrect value %s=%llu - should be %llu\n", \
50                        __location__, #v, (long long)v, (long long)correct); \
51                 ret = False; \
52                 goto done; \
53         }} while (0)
54
55 #define CHECK_VALUE_STRING(v, correct) do { \
56         if ( ((!v) && (correct)) || \
57              ((v) && (!correct)) || \
58              ((v) && (correct) && strcmp(v,correct) != 0)) { \
59                 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
60                        __location__, #v, v, correct); \
61                 ret = False; \
62                 goto done; \
63         }} while (0)
64
65 #define _NBT_NAME(n,t,s) {\
66         .name   = n,\
67         .type   = t,\
68         .scope  = s\
69 }
70
71 static const char *wrepl_name_type_string(enum wrepl_name_type type)
72 {
73         switch (type) {
74         case WREPL_TYPE_UNIQUE: return "UNIQUE";
75         case WREPL_TYPE_GROUP: return "GROUP";
76         case WREPL_TYPE_SGROUP: return "SGROUP";
77         case WREPL_TYPE_MHOMED: return "MHOMED";
78         }
79         return "UNKNOWN_TYPE";
80 }
81
82 static const char *wrepl_name_state_string(enum wrepl_name_state state)
83 {
84         switch (state) {
85         case WREPL_STATE_ACTIVE: return "ACTIVE";
86         case WREPL_STATE_RELEASED: return "RELEASED";
87         case WREPL_STATE_TOMBSTONE: return "TOMBSTONE";
88         case WREPL_STATE_RESERVED: return "RESERVED";
89         }
90         return "UNKNOWN_STATE";
91 }
92
93 /*
94   test how assoc_ctx's are only usable on the connection
95   they are created on.
96 */
97 static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address)
98 {
99         BOOL ret = True;
100         struct wrepl_request *req;
101         struct wrepl_socket *wrepl_socket1;
102         struct wrepl_associate associate1;
103         struct wrepl_socket *wrepl_socket2;
104         struct wrepl_associate associate2;
105         struct wrepl_pull_table pull_table;
106         struct wrepl_packet *rep_packet;
107         struct wrepl_associate_stop assoc_stop;
108         NTSTATUS status;
109
110         if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
111                 printf("winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use\n");
112                 return True;
113         }
114
115         printf("Test if assoc_ctx is only valid on the conection it was created on\n");
116
117         wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL);
118         wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL);
119
120         printf("Setup 2 wrepl connections\n");
121         status = wrepl_connect(wrepl_socket1, NULL, address);
122         CHECK_STATUS(status, NT_STATUS_OK);
123
124         status = wrepl_connect(wrepl_socket2, NULL, address);
125         CHECK_STATUS(status, NT_STATUS_OK);
126
127         printf("Send a start association request (conn1)\n");
128         status = wrepl_associate(wrepl_socket1, &associate1);
129         CHECK_STATUS(status, NT_STATUS_OK);
130
131         printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx);
132
133         printf("Send a start association request (conn2)\n");
134         status = wrepl_associate(wrepl_socket2, &associate2);
135         CHECK_STATUS(status, NT_STATUS_OK);
136
137         printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx);
138
139         printf("Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n");
140         pull_table.in.assoc_ctx = associate1.out.assoc_ctx;
141         req = wrepl_pull_table_send(wrepl_socket2, &pull_table);
142         req->send_only = True;
143         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
144         CHECK_STATUS(status, NT_STATUS_OK);
145
146         printf("Send a association request (conn2), to make sure the last request was ignored\n");
147         status = wrepl_associate(wrepl_socket2, &associate2);
148         CHECK_STATUS(status, NT_STATUS_OK);
149
150         printf("Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n");
151         pull_table.in.assoc_ctx = 0;
152         req = wrepl_pull_table_send(wrepl_socket1, &pull_table);
153         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
154         CHECK_STATUS(status, NT_STATUS_OK);
155
156         printf("Send a association request (conn1), to make sure the last request was handled correct\n");
157         status = wrepl_associate(wrepl_socket1, &associate2);
158         CHECK_STATUS(status, NT_STATUS_OK);
159
160         assoc_stop.in.assoc_ctx = associate1.out.assoc_ctx;
161         assoc_stop.in.reason    = 4;
162         printf("Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason);
163         status = wrepl_associate_stop(wrepl_socket1, &assoc_stop);
164         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
165
166         assoc_stop.in.assoc_ctx = associate2.out.assoc_ctx;
167         assoc_stop.in.reason    = 0;
168         printf("Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason);
169         status = wrepl_associate_stop(wrepl_socket2, &assoc_stop);
170         CHECK_STATUS(status, NT_STATUS_OK);
171
172 done:
173         printf("Close 2 wrepl connections\n");
174         talloc_free(wrepl_socket1);
175         talloc_free(wrepl_socket2);
176         return ret;
177 }
178
179 /*
180   test if we always get back the same assoc_ctx
181 */
182 static BOOL test_assoc_ctx2(TALLOC_CTX *mem_ctx, const char *address)
183 {
184         BOOL ret = True;
185         struct wrepl_socket *wrepl_socket;
186         struct wrepl_associate associate;
187         uint32_t assoc_ctx1;
188         NTSTATUS status;
189
190         printf("Test if we always get back the same assoc_ctx\n");
191
192         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
193         
194         printf("Setup wrepl connections\n");
195         status = wrepl_connect(wrepl_socket, NULL, address);
196         CHECK_STATUS(status, NT_STATUS_OK);
197
198
199         printf("Send 1st start association request\n");
200         status = wrepl_associate(wrepl_socket, &associate);
201         CHECK_STATUS(status, NT_STATUS_OK);
202         assoc_ctx1 = associate.out.assoc_ctx;
203         printf("1st association context: 0x%x\n", associate.out.assoc_ctx);
204
205         printf("Send 2nd start association request\n");
206         status = wrepl_associate(wrepl_socket, &associate);
207         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
208         CHECK_STATUS(status, NT_STATUS_OK);
209         printf("2nd association context: 0x%x\n", associate.out.assoc_ctx);
210
211         printf("Send 3rd start association request\n");
212         status = wrepl_associate(wrepl_socket, &associate);
213         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
214         CHECK_STATUS(status, NT_STATUS_OK);
215         printf("3rd association context: 0x%x\n", associate.out.assoc_ctx);
216
217 done:
218         printf("Close wrepl connections\n");
219         talloc_free(wrepl_socket);
220         return ret;
221 }
222
223
224 /*
225   display a replication entry
226 */
227 static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name)
228 {
229         int i;
230
231         printf("%s\n", nbt_name_string(mem_ctx, &name->name));
232         printf("\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n",
233                 name->type, name->state, name->node, name->is_static, (long long)name->version_id);
234         printf("\tRAW_FLAGS: 0x%08X OWNER: %-15s\n",
235                 name->raw_flags, name->owner);
236         for (i=0;i<name->num_addresses;i++) {
237                 printf("\tADDR: %-15s OWNER: %-15s\n", 
238                         name->addresses[i].address, name->addresses[i].owner);
239         }
240 }
241
242 /*
243   test a full replication dump from a WINS server
244 */
245 static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address)
246 {
247         BOOL ret = True;
248         struct wrepl_socket *wrepl_socket;
249         NTSTATUS status;
250         int i, j;
251         struct wrepl_associate associate;
252         struct wrepl_pull_table pull_table;
253         struct wrepl_pull_names pull_names;
254
255         printf("Test one pull replication cycle\n");
256
257         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
258         
259         printf("Setup wrepl connections\n");
260         status = wrepl_connect(wrepl_socket, NULL, address);
261         CHECK_STATUS(status, NT_STATUS_OK);
262
263         printf("Send a start association request\n");
264
265         status = wrepl_associate(wrepl_socket, &associate);
266         CHECK_STATUS(status, NT_STATUS_OK);
267
268         printf("association context: 0x%x\n", associate.out.assoc_ctx);
269
270         printf("Send a replication table query\n");
271         pull_table.in.assoc_ctx = associate.out.assoc_ctx;
272
273         status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table);
274         if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) {
275                 struct wrepl_packet packet;
276                 struct wrepl_request *req;
277
278                 ZERO_STRUCT(packet);
279                 packet.opcode                      = WREPL_OPCODE_BITS;
280                 packet.assoc_ctx                   = associate.out.assoc_ctx;
281                 packet.mess_type                   = WREPL_STOP_ASSOCIATION;
282                 packet.message.stop.reason         = 0;
283
284                 req = wrepl_request_send(wrepl_socket, &packet);
285                 talloc_free(req);
286
287                 printf("failed - We are not a valid pull partner for the server\n");
288                 ret = False;
289                 goto done;
290         }
291         CHECK_STATUS(status, NT_STATUS_OK);
292
293         printf("Found %d replication partners\n", pull_table.out.num_partners);
294
295         for (i=0;i<pull_table.out.num_partners;i++) {
296                 struct wrepl_wins_owner *partner = &pull_table.out.partners[i];
297                 printf("%s   max_version=%6llu   min_version=%6llu type=%d\n",
298                        partner->address, 
299                        (long long)partner->max_version, 
300                        (long long)partner->min_version, 
301                        partner->type);
302
303                 pull_names.in.assoc_ctx = associate.out.assoc_ctx;
304                 pull_names.in.partner = *partner;
305                 
306                 status = wrepl_pull_names(wrepl_socket, mem_ctx, &pull_names);
307                 CHECK_STATUS(status, NT_STATUS_OK);
308
309                 printf("Received %d names\n", pull_names.out.num_names);
310
311                 for (j=0;j<pull_names.out.num_names;j++) {
312                         display_entry(mem_ctx, &pull_names.out.names[j]);
313                 }
314         }
315
316 done:
317         printf("Close wrepl connections\n");
318         talloc_free(wrepl_socket);
319         return ret;
320 }
321
322 struct test_wrepl_conflict_conn {
323         const char *address;
324         struct wrepl_socket *pull;
325         uint32_t pull_assoc;
326
327 #define TEST_OWNER_A_ADDRESS "127.65.65.1"
328 #define TEST_ADDRESS_A_PREFIX "127.0.65"
329 #define TEST_OWNER_B_ADDRESS "127.66.66.1"
330 #define TEST_ADDRESS_B_PREFIX "127.0.66"
331 #define TEST_OWNER_X_ADDRESS "127.88.88.1"
332 #define TEST_ADDRESS_X_PREFIX "127.0.88"
333
334         struct wrepl_wins_owner a, b, c, x;
335
336         const char *myaddr;
337         const char *myaddr2;
338         struct nbt_name_socket *nbtsock;
339         struct nbt_name_socket *nbtsock2;
340
341         struct nbt_name_socket *nbtsock_srv;
342         struct nbt_name_socket *nbtsock_srv2;
343
344         uint32_t addresses_best_num;
345         struct wrepl_ip *addresses_best;
346
347         uint32_t addresses_best2_num;
348         struct wrepl_ip *addresses_best2;
349
350         uint32_t addresses_all_num;
351         struct wrepl_ip *addresses_all;
352
353         uint32_t addresses_mhomed_num;
354         struct wrepl_ip *addresses_mhomed;
355 };
356
357 static const struct wrepl_ip addresses_A_1[] = {
358         {
359         .owner  = TEST_OWNER_A_ADDRESS,
360         .ip     = TEST_ADDRESS_A_PREFIX".1"
361         }
362 };
363 static const struct wrepl_ip addresses_A_2[] = {
364         {
365         .owner  = TEST_OWNER_A_ADDRESS,
366         .ip     = TEST_ADDRESS_A_PREFIX".2"
367         }
368 };
369 static const struct wrepl_ip addresses_A_3_4[] = {
370         {
371         .owner  = TEST_OWNER_A_ADDRESS,
372         .ip     = TEST_ADDRESS_A_PREFIX".3"
373         },
374         {
375         .owner  = TEST_OWNER_A_ADDRESS,
376         .ip     = TEST_ADDRESS_A_PREFIX".4"
377         }
378 };
379 static const struct wrepl_ip addresses_A_3_4_X_3_4[] = {
380         {
381         .owner  = TEST_OWNER_A_ADDRESS,
382         .ip     = TEST_ADDRESS_A_PREFIX".3"
383         },
384         {
385         .owner  = TEST_OWNER_A_ADDRESS,
386         .ip     = TEST_ADDRESS_A_PREFIX".4"
387         },
388         {
389         .owner  = TEST_OWNER_X_ADDRESS,
390         .ip     = TEST_ADDRESS_X_PREFIX".3"
391         },
392         {
393         .owner  = TEST_OWNER_X_ADDRESS,
394         .ip     = TEST_ADDRESS_X_PREFIX".4"
395         }
396 };
397 static const struct wrepl_ip addresses_A_3_4_B_3_4[] = {
398         {
399         .owner  = TEST_OWNER_A_ADDRESS,
400         .ip     = TEST_ADDRESS_A_PREFIX".3"
401         },
402         {
403         .owner  = TEST_OWNER_A_ADDRESS,
404         .ip     = TEST_ADDRESS_A_PREFIX".4"
405         },
406         {
407         .owner  = TEST_OWNER_B_ADDRESS,
408         .ip     = TEST_ADDRESS_B_PREFIX".3"
409         },
410         {
411         .owner  = TEST_OWNER_B_ADDRESS,
412         .ip     = TEST_ADDRESS_B_PREFIX".4"
413         }
414 };
415 static const struct wrepl_ip addresses_A_3_4_OWNER_B[] = {
416         {
417         .owner  = TEST_OWNER_B_ADDRESS,
418         .ip     = TEST_ADDRESS_A_PREFIX".3"
419         },
420         {
421         .owner  = TEST_OWNER_B_ADDRESS,
422         .ip     = TEST_ADDRESS_A_PREFIX".4"
423         }
424 };
425 static const struct wrepl_ip addresses_A_3_4_X_3_4_OWNER_B[] = {
426         {
427         .owner  = TEST_OWNER_B_ADDRESS,
428         .ip     = TEST_ADDRESS_A_PREFIX".3"
429         },
430         {
431         .owner  = TEST_OWNER_B_ADDRESS,
432         .ip     = TEST_ADDRESS_A_PREFIX".4"
433         },
434         {
435         .owner  = TEST_OWNER_B_ADDRESS,
436         .ip     = TEST_ADDRESS_X_PREFIX".3"
437         },
438         {
439         .owner  = TEST_OWNER_B_ADDRESS,
440         .ip     = TEST_ADDRESS_X_PREFIX".4"
441         }
442 };
443
444 static const struct wrepl_ip addresses_A_3_4_X_1_2[] = {
445         {
446         .owner  = TEST_OWNER_A_ADDRESS,
447         .ip     = TEST_ADDRESS_A_PREFIX".3"
448         },
449         {
450         .owner  = TEST_OWNER_A_ADDRESS,
451         .ip     = TEST_ADDRESS_A_PREFIX".4"
452         },
453         {
454         .owner  = TEST_OWNER_X_ADDRESS,
455         .ip     = TEST_ADDRESS_X_PREFIX".1"
456         },
457         {
458         .owner  = TEST_OWNER_X_ADDRESS,
459         .ip     = TEST_ADDRESS_X_PREFIX".2"
460         }
461 };
462
463 static const struct wrepl_ip addresses_B_1[] = {
464         {
465         .owner  = TEST_OWNER_B_ADDRESS,
466         .ip     = TEST_ADDRESS_B_PREFIX".1"
467         }
468 };
469 static const struct wrepl_ip addresses_B_2[] = {
470         {
471         .owner  = TEST_OWNER_B_ADDRESS,
472         .ip     = TEST_ADDRESS_B_PREFIX".2"
473         }
474 };
475 static const struct wrepl_ip addresses_B_3_4[] = {
476         {
477         .owner  = TEST_OWNER_B_ADDRESS,
478         .ip     = TEST_ADDRESS_B_PREFIX".3"
479         },
480         {
481         .owner  = TEST_OWNER_B_ADDRESS,
482         .ip     = TEST_ADDRESS_B_PREFIX".4"
483         }
484 };
485 static const struct wrepl_ip addresses_B_3_4_X_3_4[] = {
486         {
487         .owner  = TEST_OWNER_B_ADDRESS,
488         .ip     = TEST_ADDRESS_B_PREFIX".3"
489         },
490         {
491         .owner  = TEST_OWNER_B_ADDRESS,
492         .ip     = TEST_ADDRESS_B_PREFIX".4"
493         },
494         {
495         .owner  = TEST_OWNER_X_ADDRESS,
496         .ip     = TEST_ADDRESS_X_PREFIX".3"
497         },
498         {
499         .owner  = TEST_OWNER_X_ADDRESS,
500         .ip     = TEST_ADDRESS_X_PREFIX".4"
501         }
502 };
503 static const struct wrepl_ip addresses_B_3_4_X_1_2[] = {
504         {
505         .owner  = TEST_OWNER_B_ADDRESS,
506         .ip     = TEST_ADDRESS_B_PREFIX".3"
507         },
508         {
509         .owner  = TEST_OWNER_B_ADDRESS,
510         .ip     = TEST_ADDRESS_B_PREFIX".4"
511         },
512         {
513         .owner  = TEST_OWNER_X_ADDRESS,
514         .ip     = TEST_ADDRESS_X_PREFIX".1"
515         },
516         {
517         .owner  = TEST_OWNER_X_ADDRESS,
518         .ip     = TEST_ADDRESS_X_PREFIX".2"
519         }
520 };
521
522 static const struct wrepl_ip addresses_X_1_2[] = {
523         {
524         .owner  = TEST_OWNER_X_ADDRESS,
525         .ip     = TEST_ADDRESS_X_PREFIX".1"
526         },
527         {
528         .owner  = TEST_OWNER_X_ADDRESS,
529         .ip     = TEST_ADDRESS_X_PREFIX".2"
530         }
531 };
532 static const struct wrepl_ip addresses_X_3_4[] = {
533         {
534         .owner  = TEST_OWNER_X_ADDRESS,
535         .ip     = TEST_ADDRESS_X_PREFIX".3"
536         },
537         {
538         .owner  = TEST_OWNER_X_ADDRESS,
539         .ip     = TEST_ADDRESS_X_PREFIX".4"
540         }
541 };
542
543 static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem_ctx,
544                                                                  const char *address)
545 {
546         struct test_wrepl_conflict_conn *ctx;
547         struct wrepl_associate associate;
548         struct wrepl_pull_table pull_table;
549         NTSTATUS status;
550         uint32_t i;
551
552         ctx = talloc_zero(mem_ctx, struct test_wrepl_conflict_conn);
553         if (!ctx) return NULL;
554
555         ctx->address    = address;
556         ctx->pull       = wrepl_socket_init(ctx, NULL);
557         if (!ctx->pull) return NULL;
558
559         printf("Setup wrepl conflict pull connection\n");
560         status = wrepl_connect(ctx->pull, NULL, ctx->address);
561         if (!NT_STATUS_IS_OK(status)) return NULL;
562
563         status = wrepl_associate(ctx->pull, &associate);
564         if (!NT_STATUS_IS_OK(status)) return NULL;
565
566         ctx->pull_assoc = associate.out.assoc_ctx;
567
568         ctx->a.address          = TEST_OWNER_A_ADDRESS;
569         ctx->a.max_version      = 0;
570         ctx->a.min_version      = 0;
571         ctx->a.type             = 1;
572
573         ctx->b.address          = TEST_OWNER_B_ADDRESS;
574         ctx->b.max_version      = 0;
575         ctx->b.min_version      = 0;
576         ctx->b.type             = 1;
577
578         ctx->x.address          = TEST_OWNER_X_ADDRESS;
579         ctx->x.max_version      = 0;
580         ctx->x.min_version      = 0;
581         ctx->x.type             = 1;
582
583         ctx->c.address          = address;
584         ctx->c.max_version      = 0;
585         ctx->c.min_version      = 0;
586         ctx->c.type             = 1;
587
588         pull_table.in.assoc_ctx = ctx->pull_assoc;
589         status = wrepl_pull_table(ctx->pull, ctx->pull, &pull_table);
590         if (!NT_STATUS_IS_OK(status)) return NULL;
591
592         for (i=0; i < pull_table.out.num_partners; i++) {
593                 if (strcmp(TEST_OWNER_A_ADDRESS,pull_table.out.partners[i].address)==0) {
594                         ctx->a.max_version      = pull_table.out.partners[i].max_version;
595                         ctx->a.min_version      = pull_table.out.partners[i].min_version;
596                 }
597                 if (strcmp(TEST_OWNER_B_ADDRESS,pull_table.out.partners[i].address)==0) {
598                         ctx->b.max_version      = pull_table.out.partners[i].max_version;
599                         ctx->b.min_version      = pull_table.out.partners[i].min_version;
600                 }
601                 if (strcmp(TEST_OWNER_X_ADDRESS,pull_table.out.partners[i].address)==0) {
602                         ctx->x.max_version      = pull_table.out.partners[i].max_version;
603                         ctx->x.min_version      = pull_table.out.partners[i].min_version;
604                 }
605                 if (strcmp(address,pull_table.out.partners[i].address)==0) {
606                         ctx->c.max_version      = pull_table.out.partners[i].max_version;
607                         ctx->c.min_version      = pull_table.out.partners[i].min_version;
608                 }
609         }
610
611         talloc_free(pull_table.out.partners);
612
613         ctx->myaddr = talloc_strdup(mem_ctx, iface_best_ip(address));
614         if (!ctx->myaddr) return NULL;
615
616         for (i = 0; i < iface_count(); i++) {
617                 if (strcmp(ctx->myaddr, iface_n_ip(i)) == 0) continue;
618                 ctx->myaddr2 = talloc_strdup(mem_ctx, iface_n_ip(i));
619                 if (!ctx->myaddr2) return NULL;
620                 break;
621         }
622
623         ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
624         if (!ctx->nbtsock) return NULL;
625
626         status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0, 0);
627         if (!NT_STATUS_IS_OK(status)) return NULL;
628
629         ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL);
630         if (!ctx->nbtsock_srv) return NULL;
631
632         status = socket_listen(ctx->nbtsock_srv->sock, ctx->myaddr, lp_nbt_port(), 0, 0);
633         if (!NT_STATUS_IS_OK(status)) {
634                 talloc_free(ctx->nbtsock_srv);
635                 ctx->nbtsock_srv = NULL;
636         }
637
638         if (ctx->myaddr2 && ctx->nbtsock_srv) {
639                 ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL);
640                 if (!ctx->nbtsock2) return NULL;
641
642                 status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0, 0);
643                 if (!NT_STATUS_IS_OK(status)) return NULL;
644
645                 ctx->nbtsock_srv2 = nbt_name_socket_init(ctx, ctx->nbtsock_srv->event_ctx);
646                 if (!ctx->nbtsock_srv2) return NULL;
647
648                 status = socket_listen(ctx->nbtsock_srv2->sock, ctx->myaddr2, lp_nbt_port(), 0, 0);
649                 if (!NT_STATUS_IS_OK(status)) {
650                         talloc_free(ctx->nbtsock_srv2);
651                         ctx->nbtsock_srv2 = NULL;
652                 }
653         }
654
655         ctx->addresses_best_num = 1;
656         ctx->addresses_best = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best_num);
657         if (!ctx->addresses_best) return NULL;
658         ctx->addresses_best[0].owner    = ctx->b.address;
659         ctx->addresses_best[0].ip       = ctx->myaddr;
660
661         ctx->addresses_all_num = iface_count();
662         ctx->addresses_all = talloc_array(ctx, struct wrepl_ip, ctx->addresses_all_num);
663         if (!ctx->addresses_all) return NULL;
664         for (i=0; i < ctx->addresses_all_num; i++) {
665                 ctx->addresses_all[i].owner     = ctx->b.address;
666                 ctx->addresses_all[i].ip        = talloc_strdup(ctx->addresses_all, iface_n_ip(i));
667                 if (!ctx->addresses_all[i].ip) return NULL;
668         }
669
670         if (ctx->nbtsock_srv2) {
671                 ctx->addresses_best2_num = 1;
672                 ctx->addresses_best2 = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best2_num);
673                 if (!ctx->addresses_best2) return NULL;
674                 ctx->addresses_best2[0].owner   = ctx->b.address;
675                 ctx->addresses_best2[0].ip      = ctx->myaddr2;
676
677                 ctx->addresses_mhomed_num = 2;
678                 ctx->addresses_mhomed = talloc_array(ctx, struct wrepl_ip, ctx->addresses_mhomed_num);
679                 if (!ctx->addresses_mhomed) return NULL;
680                 ctx->addresses_mhomed[0].owner  = ctx->b.address;
681                 ctx->addresses_mhomed[0].ip     = ctx->myaddr;
682                 ctx->addresses_mhomed[1].owner  = ctx->b.address;
683                 ctx->addresses_mhomed[1].ip     = ctx->myaddr2;
684         }
685
686         return ctx;
687 }
688
689 static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx,
690                                   const struct wrepl_wins_owner *owner,
691                                   const struct wrepl_wins_name *name)
692 {
693         BOOL ret = True;
694         struct wrepl_socket *wrepl_socket;
695         struct wrepl_associate associate;
696         struct wrepl_packet update_packet, repl_send;
697         struct wrepl_table *update;
698         struct wrepl_wins_owner wrepl_wins_owners[1];
699         struct wrepl_packet *repl_recv;
700         struct wrepl_wins_owner *send_request;
701         struct wrepl_send_reply *send_reply;
702         struct wrepl_wins_name wrepl_wins_names[1];
703         uint32_t assoc_ctx;
704         NTSTATUS status;
705
706         wrepl_socket = wrepl_socket_init(ctx, NULL);
707
708         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
709         CHECK_STATUS(status, NT_STATUS_OK);
710
711         status = wrepl_associate(wrepl_socket, &associate);
712         CHECK_STATUS(status, NT_STATUS_OK);
713         assoc_ctx = associate.out.assoc_ctx;
714
715         /* now send a WREPL_REPL_UPDATE message */
716         ZERO_STRUCT(update_packet);
717         update_packet.opcode                    = WREPL_OPCODE_BITS;
718         update_packet.assoc_ctx                 = assoc_ctx;
719         update_packet.mess_type                 = WREPL_REPLICATION;
720         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
721         update  = &update_packet.message.replication.info.table;
722
723         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
724         update->partners        = wrepl_wins_owners;
725         update->initiator       = "0.0.0.0";
726
727         wrepl_wins_owners[0]    = *owner;
728
729         status = wrepl_request(wrepl_socket, wrepl_socket,
730                                &update_packet, &repl_recv);
731         CHECK_STATUS(status, NT_STATUS_OK);
732         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
733         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
734         send_request = &repl_recv->message.replication.info.owner;
735
736         ZERO_STRUCT(repl_send);
737         repl_send.opcode                        = WREPL_OPCODE_BITS;
738         repl_send.assoc_ctx                     = assoc_ctx;
739         repl_send.mess_type                     = WREPL_REPLICATION;
740         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
741         send_reply = &repl_send.message.replication.info.reply;
742
743         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
744         send_reply->names       = wrepl_wins_names;
745
746         wrepl_wins_names[0]     = *name;
747
748         status = wrepl_request(wrepl_socket, wrepl_socket,
749                                &repl_send, &repl_recv);
750         CHECK_STATUS(status, NT_STATUS_OK);
751         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
752         CHECK_VALUE(repl_recv->message.stop.reason, 0);
753
754 done:
755         talloc_free(wrepl_socket);
756         return ret;
757 }
758
759 static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx,
760                                   const struct wrepl_wins_owner *owner,
761                                   const struct wrepl_wins_name *name,
762                                   BOOL expected)
763 {
764         BOOL ret = True;
765         NTSTATUS status;
766         struct wrepl_pull_names pull_names;
767         struct wrepl_name *names;
768
769         pull_names.in.assoc_ctx = ctx->pull_assoc;
770         pull_names.in.partner   = *owner;
771         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
772                 
773         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
774         CHECK_STATUS(status, NT_STATUS_OK);
775         CHECK_VALUE(pull_names.out.num_names, (expected?1:0));
776
777         names = pull_names.out.names;
778
779         if (expected) {
780                 uint32_t flags = WREPL_NAME_FLAGS(names[0].type,
781                                                   names[0].state,
782                                                   names[0].node,
783                                                   names[0].is_static);
784                 CHECK_VALUE(names[0].name.type, name->name->type);
785                 CHECK_VALUE_STRING(names[0].name.name, name->name->name);
786                 CHECK_VALUE_STRING(names[0].name.scope, name->name->scope);
787                 CHECK_VALUE(flags, name->flags);
788                 CHECK_VALUE_UINT64(names[0].version_id, name->id);
789
790                 if (flags & 2) {
791                         CHECK_VALUE(names[0].num_addresses,
792                                     name->addresses.addresses.num_ips);
793                 } else {
794                         CHECK_VALUE(names[0].num_addresses, 1);
795                         CHECK_VALUE_STRING(names[0].addresses[0].address,
796                                            name->addresses.ip);
797                 }
798         }
799 done:
800         talloc_free(pull_names.out.names);
801         return ret;
802 }
803
804 static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx,
805                                      const struct wrepl_wins_owner *owner1,
806                                      uint32_t num_ips1, const struct wrepl_ip *ips1,
807                                      const struct wrepl_wins_owner *owner2,
808                                      uint32_t num_ips2, const struct wrepl_ip *ips2,
809                                      const struct wrepl_wins_name *name2)
810 {
811         BOOL ret = True;
812         NTSTATUS status;
813         struct wrepl_pull_names pull_names;
814         struct wrepl_name *names;
815         uint32_t flags;
816         uint32_t i, j;
817         uint32_t num_ips = num_ips1 + num_ips2;
818
819         for (i = 0; i < num_ips2; i++) {
820                 for (j = 0; j < num_ips1; j++) {
821                         if (strcmp(ips2[i].ip,ips1[j].ip) == 0) {
822                                 num_ips--;
823                                 break;
824                         }
825                 } 
826         }
827
828         pull_names.in.assoc_ctx = ctx->pull_assoc;
829         pull_names.in.partner   = *owner2;
830         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
831
832         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
833         CHECK_STATUS(status, NT_STATUS_OK);
834         CHECK_VALUE(pull_names.out.num_names, 1);
835
836         names = pull_names.out.names;
837
838         flags = WREPL_NAME_FLAGS(names[0].type,
839                                  names[0].state,
840                                  names[0].node,
841                                  names[0].is_static);
842         CHECK_VALUE(names[0].name.type, name2->name->type);
843         CHECK_VALUE_STRING(names[0].name.name, name2->name->name);
844         CHECK_VALUE_STRING(names[0].name.scope, name2->name->scope);
845         CHECK_VALUE(flags, name2->flags | WREPL_TYPE_MHOMED);
846         CHECK_VALUE_UINT64(names[0].version_id, name2->id);
847
848         CHECK_VALUE(names[0].num_addresses, num_ips);
849
850         for (i = 0; i < names[0].num_addresses; i++) {
851                 const char *addr = names[0].addresses[i].address; 
852                 const char *owner = names[0].addresses[i].owner;
853                 BOOL found = False;
854
855                 for (j = 0; j < num_ips2; j++) {
856                         if (strcmp(addr, ips2[j].ip) == 0) {
857                                 found = True;
858                                 CHECK_VALUE_STRING(owner, owner2->address);
859                                 break;
860                         }
861                 }
862
863                 if (found) continue;
864
865                 for (j = 0; j < num_ips1; j++) {
866                         if (strcmp(addr, ips1[j].ip) == 0) {
867                                 found = True;
868                                 CHECK_VALUE_STRING(owner, owner1->address);
869                                 break;
870                         }
871                 }
872
873                 if (found) continue;
874
875                 CHECK_VALUE_STRING(addr, "not found in address list");
876         }
877 done:
878         talloc_free(pull_names.out.names);
879         return ret;
880 }
881
882 static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx,
883                                      struct wrepl_wins_owner *merge_owner,
884                                      struct wrepl_wins_owner *owner1,
885                                      uint32_t num_ips1, const struct wrepl_ip *ips1,
886                                      struct wrepl_wins_owner *owner2,
887                                      uint32_t num_ips2, const struct wrepl_ip *ips2,
888                                      const struct wrepl_wins_name *name2)
889 {
890         BOOL ret = True;
891         NTSTATUS status;
892         struct wrepl_pull_names pull_names;
893         struct wrepl_name *names;
894         struct wrepl_name *name = NULL;
895         uint32_t flags;
896         uint32_t i, j;
897         uint32_t num_ips = num_ips1 + num_ips2;
898
899         if (!merge_owner) {
900                 merge_owner = &ctx->c;
901         }
902
903         for (i = 0; i < num_ips1; i++) {
904                 if (owner1 != &ctx->c && strcmp(ips1[i].owner,owner2->address) == 0) {
905                         num_ips--;
906                         continue;
907                 }
908                 for (j = 0; j < num_ips2; j++) {
909                         if (strcmp(ips1[i].ip,ips2[j].ip) == 0) {
910                                 num_ips--;
911                                 break;
912                         }
913                 }
914         }
915
916
917         pull_names.in.assoc_ctx = ctx->pull_assoc;
918         pull_names.in.partner   = *merge_owner;
919         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
920         pull_names.in.partner.max_version = 0;
921
922         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
923         CHECK_STATUS(status, NT_STATUS_OK);
924
925         names = pull_names.out.names;
926         
927         for (i = 0; i < pull_names.out.num_names; i++) {
928                 if (names[i].name.type != name2->name->type)    continue;
929                 if (!names[i].name.name) continue;
930                 if (strcmp(names[i].name.name, name2->name->name) != 0) continue;
931                 if (names[i].name.scope) continue;
932
933                 name = &names[i];
934         }
935
936         if (pull_names.out.num_names > 0) {
937                 merge_owner->max_version        = names[pull_names.out.num_names-1].version_id;
938         }
939
940         if (!name) {
941                 printf("%s: Name '%s' not found\n", __location__, nbt_name_string(ctx, name2->name));
942                 return False;
943         }
944
945         flags = WREPL_NAME_FLAGS(name->type,
946                                  name->state,
947                                  name->node,
948                                  name->is_static);
949         CHECK_VALUE(name->name.type, name2->name->type);
950         CHECK_VALUE_STRING(name->name.name, name2->name->name);
951         CHECK_VALUE_STRING(name->name.scope, name2->name->scope);
952         CHECK_VALUE(flags, name2->flags);
953
954         CHECK_VALUE(name->num_addresses, num_ips);
955
956         for (i = 0; i < name->num_addresses; i++) {
957                 const char *addr = name->addresses[i].address; 
958                 const char *owner = name->addresses[i].owner;
959                 BOOL found = False;
960
961                 for (j = 0; j < num_ips2; j++) {
962                         if (strcmp(addr, ips2[j].ip) == 0) {
963                                 found = True;
964                                 CHECK_VALUE_STRING(owner, ips2[j].owner);
965                                 break;
966                         }
967                 }
968
969                 if (found) continue;
970
971                 for (j = 0; j < num_ips1; j++) {
972                         if (strcmp(addr, ips1[j].ip) == 0) {
973                                 found = True;
974                                 if (owner1 == &ctx->c) {
975                                         CHECK_VALUE_STRING(owner, owner1->address);
976                                 } else {
977                                         CHECK_VALUE_STRING(owner, ips1[j].owner);
978                                 }
979                                 break;
980                         }
981                 }
982
983                 if (found) continue;
984
985                 CHECK_VALUE_STRING(addr, "not found in address list");
986         }
987 done:
988         talloc_free(pull_names.out.names);
989         return ret;
990 }
991
992 static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx)
993 {
994         BOOL ret = True;
995         struct nbt_name name;
996         struct wrepl_wins_name wins_name1;
997         struct wrepl_wins_name wins_name2;
998         struct wrepl_wins_name *wins_name_tmp;
999         struct wrepl_wins_name *wins_name_last;
1000         struct wrepl_wins_name *wins_name_cur;
1001         uint32_t i,j;
1002         uint8_t types[] = { 0x00, 0x1C };
1003         struct {
1004                 enum wrepl_name_type type;
1005                 enum wrepl_name_state state;
1006                 enum wrepl_name_node node;
1007                 BOOL is_static;
1008                 uint32_t num_ips;
1009                 const struct wrepl_ip *ips;
1010         } records[] = {
1011                 {
1012                 .type           = WREPL_TYPE_GROUP,
1013                 .state          = WREPL_STATE_ACTIVE,
1014                 .node           = WREPL_NODE_B,
1015                 .is_static      = False,
1016                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1017                 .ips            = addresses_A_1,
1018                 },{
1019                 .type           = WREPL_TYPE_UNIQUE,
1020                 .state          = WREPL_STATE_ACTIVE,
1021                 .node           = WREPL_NODE_B,
1022                 .is_static      = False,
1023                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1024                 .ips            = addresses_A_1,
1025                 },{
1026                 .type           = WREPL_TYPE_UNIQUE,
1027                 .state          = WREPL_STATE_ACTIVE,
1028                 .node           = WREPL_NODE_B,
1029                 .is_static      = False,
1030                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1031                 .ips            = addresses_A_2,
1032                 },{
1033                 .type           = WREPL_TYPE_UNIQUE,
1034                 .state          = WREPL_STATE_ACTIVE,
1035                 .node           = WREPL_NODE_B,
1036                 .is_static      = True,
1037                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1038                 .ips            = addresses_A_1,
1039                 },{
1040                 .type           = WREPL_TYPE_UNIQUE,
1041                 .state          = WREPL_STATE_ACTIVE,
1042                 .node           = WREPL_NODE_B,
1043                 .is_static      = False,
1044                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1045                 .ips            = addresses_A_2,
1046                 },{
1047                 .type           = WREPL_TYPE_SGROUP,
1048                 .state          = WREPL_STATE_TOMBSTONE,
1049                 .node           = WREPL_NODE_B,
1050                 .is_static      = False,
1051                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1052                 .ips            = addresses_A_2,
1053                 },{
1054                 .type           = WREPL_TYPE_MHOMED,
1055                 .state          = WREPL_STATE_TOMBSTONE,
1056                 .node           = WREPL_NODE_B,
1057                 .is_static      = False,
1058                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1059                 .ips            = addresses_A_1,
1060                 },{
1061                 .type           = WREPL_TYPE_MHOMED,
1062                 .state          = WREPL_STATE_RELEASED,
1063                 .node           = WREPL_NODE_B,
1064                 .is_static      = False,
1065                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1066                 .ips            = addresses_A_2,
1067                 },{
1068                 .type           = WREPL_TYPE_SGROUP,
1069                 .state          = WREPL_STATE_ACTIVE,
1070                 .node           = WREPL_NODE_B,
1071                 .is_static      = False,
1072                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1073                 .ips            = addresses_A_1,
1074                 },{
1075                 .type           = WREPL_TYPE_SGROUP,
1076                 .state          = WREPL_STATE_ACTIVE,
1077                 .node           = WREPL_NODE_B,
1078                 .is_static      = False,
1079                 .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1080                 .ips            = addresses_A_3_4,
1081                 },{
1082                 .type           = WREPL_TYPE_SGROUP,
1083                 .state          = WREPL_STATE_TOMBSTONE,
1084                 .node           = WREPL_NODE_B,
1085                 .is_static      = False,
1086                 .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1087                 .ips            = addresses_B_3_4,
1088                 },{
1089                 /* the last one should always be a unique,tomstone record! */
1090                 .type           = WREPL_TYPE_UNIQUE,
1091                 .state          = WREPL_STATE_TOMBSTONE,
1092                 .node           = WREPL_NODE_B,
1093                 .is_static      = False,
1094                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1095                 .ips            = addresses_A_1,
1096                 }
1097         };
1098
1099         if (!ctx) return False;
1100
1101         name.name       = "_SAME_OWNER_A";
1102         name.type       = 0;
1103         name.scope      = NULL;
1104
1105         wins_name_tmp   = NULL;
1106         wins_name_last  = &wins_name2;
1107         wins_name_cur   = &wins_name1;
1108
1109         for (j=0; ret && j < ARRAY_SIZE(types); j++) {
1110                 name.type = types[j];
1111                 printf("Test Replica Conflicts with same owner[%s] for %s\n",
1112                         nbt_name_string(ctx, &name), ctx->a.address);
1113
1114                 for(i=0; ret && i < ARRAY_SIZE(records); i++) {
1115                         wins_name_tmp   = wins_name_last;
1116                         wins_name_last  = wins_name_cur;
1117                         wins_name_cur   = wins_name_tmp;
1118
1119                         if (i > 0) {
1120                                 printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
1121                                         wrepl_name_type_string(records[i-1].type),
1122                                         wrepl_name_state_string(records[i-1].state),
1123                                         (records[i-1].is_static?",static":""),
1124                                         wrepl_name_type_string(records[i].type),
1125                                         wrepl_name_state_string(records[i].state),
1126                                         (records[i].is_static?",static":""),
1127                                         (records[i-1].ips==records[i].ips?"same":"different"),
1128                                         "REPLACE");
1129                         }
1130
1131                         wins_name_cur->name     = &name;
1132                         wins_name_cur->flags    = WREPL_NAME_FLAGS(records[i].type,
1133                                                                    records[i].state,
1134                                                                    records[i].node,
1135                                                                    records[i].is_static);
1136                         wins_name_cur->id       = ++ctx->a.max_version;
1137                         if (wins_name_cur->flags & 2) {
1138                                 wins_name_cur->addresses.addresses.num_ips = records[i].num_ips;
1139                                 wins_name_cur->addresses.addresses.ips     = discard_const(records[i].ips);
1140                         } else {
1141                                 wins_name_cur->addresses.ip = records[i].ips[0].ip;
1142                         }
1143                         wins_name_cur->unknown  = "255.255.255.255";
1144
1145                         ret &= test_wrepl_update_one(ctx, &ctx->a,wins_name_cur);
1146                         if (records[i].state == WREPL_STATE_RELEASED) {
1147                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_last, False);
1148                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, False);
1149                         } else {
1150                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, True);
1151                         }
1152
1153                         /* the first one is a cleanup run */
1154                         if (!ret && i == 0) ret = True;
1155
1156                         if (!ret) {
1157                                 printf("conflict handled wrong or record[%u]: %s\n", i, __location__);
1158                                 return ret;
1159                         }
1160                 }
1161         }
1162         return ret;
1163 }
1164
1165 static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx)
1166 {
1167         BOOL ret = True;
1168         struct wrepl_wins_name wins_name1;
1169         struct wrepl_wins_name wins_name2;
1170         struct wrepl_wins_name *wins_name_r1;
1171         struct wrepl_wins_name *wins_name_r2;
1172         uint32_t i;
1173         struct {
1174                 const char *line; /* just better debugging */
1175                 struct nbt_name name;
1176                 const char *comment;
1177                 BOOL extra; /* not the worst case, this is an extra test */
1178                 BOOL cleanup;
1179                 struct {
1180                         struct wrepl_wins_owner *owner;
1181                         enum wrepl_name_type type;
1182                         enum wrepl_name_state state;
1183                         enum wrepl_name_node node;
1184                         BOOL is_static;
1185                         uint32_t num_ips;
1186                         const struct wrepl_ip *ips;
1187                         BOOL apply_expected;
1188                         BOOL sgroup_merge;
1189                         struct wrepl_wins_owner *merge_owner;
1190                         BOOL sgroup_cleanup;
1191                 } r1, r2, result;
1192         } records[] = {
1193         /* 
1194          * NOTE: the first record and the last applied one
1195          *       needs to be from the same owner,
1196          *       to not conflict in the next smbtorture run!!!
1197          */
1198         {
1199                 .line   = __location__,
1200                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1201                 .cleanup= True,
1202                 .r1     = {
1203                         .owner          = &ctx->b,
1204                         .type           = WREPL_TYPE_UNIQUE,
1205                         .state          = WREPL_STATE_TOMBSTONE,
1206                         .node           = WREPL_NODE_B,
1207                         .is_static      = False,
1208                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1209                         .ips            = addresses_B_1,
1210                         .apply_expected = True /* ignored */
1211                 },
1212                 .r2     = {
1213                         .owner          = &ctx->a,
1214                         .type           = WREPL_TYPE_UNIQUE,
1215                         .state          = WREPL_STATE_TOMBSTONE,
1216                         .node           = WREPL_NODE_B,
1217                         .is_static      = False,
1218                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1219                         .ips            = addresses_A_1,
1220                         .apply_expected = True /* ignored */
1221                 }
1222         },
1223
1224 /*
1225  * unique vs unique section
1226  */
1227         /* 
1228          * unique,active vs. unique,active
1229          * => should be replaced
1230          */
1231         {
1232                 .line   = __location__,
1233                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1234                 .r1     = {
1235                         .owner          = &ctx->a,
1236                         .type           = WREPL_TYPE_UNIQUE,
1237                         .state          = WREPL_STATE_ACTIVE,
1238                         .node           = WREPL_NODE_B,
1239                         .is_static      = False,
1240                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1241                         .ips            = addresses_A_1,
1242                         .apply_expected = True
1243                 },
1244                 .r2     = {
1245                         .owner          = &ctx->b,
1246                         .type           = WREPL_TYPE_UNIQUE,
1247                         .state          = WREPL_STATE_ACTIVE,
1248                         .node           = WREPL_NODE_B,
1249                         .is_static      = False,
1250                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1251                         .ips            = addresses_B_1,
1252                         .apply_expected = True
1253                 }
1254         },
1255
1256         /* 
1257          * unique,active vs. unique,tombstone
1258          * => should NOT be replaced
1259          */
1260         {
1261                 .line   = __location__,
1262                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1263                 .r1     = {
1264                         .owner          = &ctx->b,
1265                         .type           = WREPL_TYPE_UNIQUE,
1266                         .state          = WREPL_STATE_ACTIVE,
1267                         .node           = WREPL_NODE_B,
1268                         .is_static      = False,
1269                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1270                         .ips            = addresses_B_1,
1271                         .apply_expected = True
1272                 },
1273                 .r2     = {
1274                         .owner          = &ctx->a,
1275                         .type           = WREPL_TYPE_UNIQUE,
1276                         .state          = WREPL_STATE_TOMBSTONE,
1277                         .node           = WREPL_NODE_B,
1278                         .is_static      = False,
1279                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1280                         .ips            = addresses_B_1,
1281                         .apply_expected = False
1282                 }
1283         },
1284
1285         /* 
1286          * unique,released vs. unique,active
1287          * => should be replaced
1288          */
1289         {
1290                 .line   = __location__,
1291                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1292                 .r1     = {
1293                         .owner          = &ctx->b,
1294                         .type           = WREPL_TYPE_UNIQUE,
1295                         .state          = WREPL_STATE_RELEASED,
1296                         .node           = WREPL_NODE_B,
1297                         .is_static      = False,
1298                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1299                         .ips            = addresses_B_1,
1300                         .apply_expected = False
1301                 },
1302                 .r2     = {
1303                         .owner          = &ctx->a,
1304                         .type           = WREPL_TYPE_UNIQUE,
1305                         .state          = WREPL_STATE_ACTIVE,
1306                         .node           = WREPL_NODE_B,
1307                         .is_static      = False,
1308                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1309                         .ips            = addresses_A_1,
1310                         .apply_expected = True
1311                 }
1312         },
1313
1314         /* 
1315          * unique,released vs. unique,tombstone
1316          * => should be replaced
1317          */
1318         {
1319                 .line   = __location__,
1320                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1321                 .r1     = {
1322                         .owner          = &ctx->a,
1323                         .type           = WREPL_TYPE_UNIQUE,
1324                         .state          = WREPL_STATE_RELEASED,
1325                         .node           = WREPL_NODE_B,
1326                         .is_static      = False,
1327                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1328                         .ips            = addresses_A_1,
1329                         .apply_expected = False
1330                 },
1331                 .r2     = {
1332                         .owner          = &ctx->b,
1333                         .type           = WREPL_TYPE_UNIQUE,
1334                         .state          = WREPL_STATE_TOMBSTONE,
1335                         .node           = WREPL_NODE_B,
1336                         .is_static      = False,
1337                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1338                         .ips            = addresses_B_1,
1339                         .apply_expected = True
1340                 }
1341         },
1342
1343         /* 
1344          * unique,tombstone vs. unique,active
1345          * => should be replaced
1346          */
1347         {
1348                 .line   = __location__,
1349                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1350                 .r1     = {
1351                         .owner          = &ctx->b,
1352                         .type           = WREPL_TYPE_UNIQUE,
1353                         .state          = WREPL_STATE_TOMBSTONE,
1354                         .node           = WREPL_NODE_B,
1355                         .is_static      = False,
1356                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1357                         .ips            = addresses_B_1,
1358                         .apply_expected = True
1359                 },
1360                 .r2     = {
1361                         .owner          = &ctx->a,
1362                         .type           = WREPL_TYPE_UNIQUE,
1363                         .state          = WREPL_STATE_ACTIVE,
1364                         .node           = WREPL_NODE_B,
1365                         .is_static      = False,
1366                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1367                         .ips            = addresses_A_1,
1368                         .apply_expected = True
1369                 }
1370         },
1371
1372         /* 
1373          * unique,tombstone vs. unique,tombstone
1374          * => should be replaced
1375          */
1376         {
1377                 .line   = __location__,
1378                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1379                 .r1     = {
1380                         .owner          = &ctx->a,
1381                         .type           = WREPL_TYPE_UNIQUE,
1382                         .state          = WREPL_STATE_TOMBSTONE,
1383                         .node           = WREPL_NODE_B,
1384                         .is_static      = False,
1385                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1386                         .ips            = addresses_A_1,
1387                         .apply_expected = True
1388                 },
1389                 .r2     = {
1390                         .owner          = &ctx->b,
1391                         .type           = WREPL_TYPE_UNIQUE,
1392                         .state          = WREPL_STATE_TOMBSTONE,
1393                         .node           = WREPL_NODE_B,
1394                         .is_static      = False,
1395                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1396                         .ips            = addresses_B_1,
1397                         .apply_expected = True
1398                 }
1399         },
1400
1401
1402 /*
1403  * unique vs normal groups section,
1404  */
1405         /* 
1406          * unique,active vs. group,active
1407          * => should be replaced
1408          */
1409         {
1410                 .line   = __location__,
1411                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1412                 .r1     = {
1413                         .owner          = &ctx->b,
1414                         .type           = WREPL_TYPE_UNIQUE,
1415                         .state          = WREPL_STATE_ACTIVE,
1416                         .node           = WREPL_NODE_B,
1417                         .is_static      = False,
1418                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1419                         .ips            = addresses_B_1,
1420                         .apply_expected = True
1421                 },
1422                 .r2     = {
1423                         .owner          = &ctx->a,
1424                         .type           = WREPL_TYPE_GROUP,
1425                         .state          = WREPL_STATE_ACTIVE,
1426                         .node           = WREPL_NODE_B,
1427                         .is_static      = False,
1428                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1429                         .ips            = addresses_A_1,
1430                         .apply_expected = True
1431                 }
1432         },
1433
1434         /* 
1435          * unique,active vs. group,tombstone
1436          * => should NOT be replaced
1437          */
1438         {
1439                 .line   = __location__,
1440                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1441                 .r1     = {
1442                         .owner          = &ctx->a,
1443                         .type           = WREPL_TYPE_UNIQUE,
1444                         .state          = WREPL_STATE_ACTIVE,
1445                         .node           = WREPL_NODE_B,
1446                         .is_static      = False,
1447                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1448                         .ips            = addresses_A_1,
1449                         .apply_expected = True
1450                 },
1451                 .r2     = {
1452                         .owner          = &ctx->b,
1453                         .type           = WREPL_TYPE_GROUP,
1454                         .state          = WREPL_STATE_TOMBSTONE,
1455                         .node           = WREPL_NODE_B,
1456                         .is_static      = False,
1457                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1458                         .ips            = addresses_A_1,
1459                         .apply_expected = False
1460                 }
1461         },
1462
1463         /* 
1464          * unique,released vs. group,active
1465          * => should be replaced
1466          */
1467         {
1468                 .line   = __location__,
1469                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1470                 .r1     = {
1471                         .owner          = &ctx->a,
1472                         .type           = WREPL_TYPE_UNIQUE,
1473                         .state          = WREPL_STATE_RELEASED,
1474                         .node           = WREPL_NODE_B,
1475                         .is_static      = False,
1476                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1477                         .ips            = addresses_A_1,
1478                         .apply_expected = False
1479                 },
1480                 .r2     = {
1481                         .owner          = &ctx->b,
1482                         .type           = WREPL_TYPE_GROUP,
1483                         .state          = WREPL_STATE_ACTIVE,
1484                         .node           = WREPL_NODE_B,
1485                         .is_static      = False,
1486                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1487                         .ips            = addresses_B_1,
1488                         .apply_expected = True
1489                 }
1490         },
1491
1492         /* 
1493          * unique,released vs. group,tombstone
1494          * => should be replaced
1495          */
1496         {
1497                 .line   = __location__,
1498                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1499                 .r1     = {
1500                         .owner          = &ctx->b,
1501                         .type           = WREPL_TYPE_UNIQUE,
1502                         .state          = WREPL_STATE_RELEASED,
1503                         .node           = WREPL_NODE_B,
1504                         .is_static      = False,
1505                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1506                         .ips            = addresses_B_1,
1507                         .apply_expected = False
1508                 },
1509                 .r2     = {
1510                         .owner          = &ctx->a,
1511                         .type           = WREPL_TYPE_GROUP,
1512                         .state          = WREPL_STATE_TOMBSTONE,
1513                         .node           = WREPL_NODE_B,
1514                         .is_static      = False,
1515                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1516                         .ips            = addresses_A_1,
1517                         .apply_expected = True
1518                 }
1519         },
1520
1521         /* 
1522          * unique,tombstone vs. group,active
1523          * => should be replaced
1524          */
1525         {
1526                 .line   = __location__,
1527                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1528                 .r1     = {
1529                         .owner          = &ctx->a,
1530                         .type           = WREPL_TYPE_UNIQUE,
1531                         .state          = WREPL_STATE_TOMBSTONE,
1532                         .node           = WREPL_NODE_B,
1533                         .is_static      = False,
1534                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1535                         .ips            = addresses_A_1,
1536                         .apply_expected = True
1537                 },
1538                 .r2     = {
1539                         .owner          = &ctx->b,
1540                         .type           = WREPL_TYPE_GROUP,
1541                         .state          = WREPL_STATE_ACTIVE,
1542                         .node           = WREPL_NODE_B,
1543                         .is_static      = False,
1544                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1545                         .ips            = addresses_B_1,
1546                         .apply_expected = True
1547                 }
1548         },
1549
1550         /* 
1551          * unique,tombstone vs. group,tombstone
1552          * => should be replaced
1553          */
1554         {
1555                 .line   = __location__,
1556                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1557                 .r1     = {
1558                         .owner          = &ctx->b,
1559                         .type           = WREPL_TYPE_UNIQUE,
1560                         .state          = WREPL_STATE_TOMBSTONE,
1561                         .node           = WREPL_NODE_B,
1562                         .is_static      = False,
1563                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1564                         .ips            = addresses_B_1,
1565                         .apply_expected = True
1566                 },
1567                 .r2     = {
1568                         .owner          = &ctx->a,
1569                         .type           = WREPL_TYPE_GROUP,
1570                         .state          = WREPL_STATE_TOMBSTONE,
1571                         .node           = WREPL_NODE_B,
1572                         .is_static      = False,
1573                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1574                         .ips            = addresses_A_1,
1575                         .apply_expected = True
1576                 }
1577         },
1578
1579 /*
1580  * unique vs special groups section,
1581  */
1582         /* 
1583          * unique,active vs. sgroup,active
1584          * => should NOT be replaced
1585          */
1586         {
1587                 .line   = __location__,
1588                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1589                 .r1     = {
1590                         .owner          = &ctx->a,
1591                         .type           = WREPL_TYPE_UNIQUE,
1592                         .state          = WREPL_STATE_ACTIVE,
1593                         .node           = WREPL_NODE_B,
1594                         .is_static      = False,
1595                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1596                         .ips            = addresses_A_1,
1597                         .apply_expected = True
1598                 },
1599                 .r2     = {
1600                         .owner          = &ctx->b,
1601                         .type           = WREPL_TYPE_SGROUP,
1602                         .state          = WREPL_STATE_ACTIVE,
1603                         .node           = WREPL_NODE_B,
1604                         .is_static      = False,
1605                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1606                         .ips            = addresses_A_1,
1607                         .apply_expected = False
1608                 }
1609         },
1610
1611         /* 
1612          * unique,active vs. sgroup,tombstone
1613          * => should NOT be replaced
1614          */
1615         {
1616                 .line   = __location__,
1617                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1618                 .r1     = {
1619                         .owner          = &ctx->a,
1620                         .type           = WREPL_TYPE_UNIQUE,
1621                         .state          = WREPL_STATE_ACTIVE,
1622                         .node           = WREPL_NODE_B,
1623                         .is_static      = False,
1624                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1625                         .ips            = addresses_A_1,
1626                         .apply_expected = True
1627                 },
1628                 .r2     = {
1629                         .owner          = &ctx->b,
1630                         .type           = WREPL_TYPE_SGROUP,
1631                         .state          = WREPL_STATE_TOMBSTONE,
1632                         .node           = WREPL_NODE_B,
1633                         .is_static      = False,
1634                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1635                         .ips            = addresses_A_1,
1636                         .apply_expected = False
1637                 }
1638         },
1639
1640         /* 
1641          * unique,released vs. sgroup,active
1642          * => should be replaced
1643          */
1644         {
1645                 .line   = __location__,
1646                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1647                 .r1     = {
1648                         .owner          = &ctx->a,
1649                         .type           = WREPL_TYPE_UNIQUE,
1650                         .state          = WREPL_STATE_RELEASED,
1651                         .node           = WREPL_NODE_B,
1652                         .is_static      = False,
1653                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1654                         .ips            = addresses_A_1,
1655                         .apply_expected = False
1656                 },
1657                 .r2     = {
1658                         .owner          = &ctx->b,
1659                         .type           = WREPL_TYPE_SGROUP,
1660                         .state          = WREPL_STATE_ACTIVE,
1661                         .node           = WREPL_NODE_B,
1662                         .is_static      = False,
1663                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1664                         .ips            = addresses_B_3_4,
1665                         .apply_expected = True
1666                 }
1667         },
1668
1669         /* 
1670          * unique,released vs. sgroup,tombstone
1671          * => should be replaced
1672          */
1673         {
1674                 .line   = __location__,
1675                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1676                 .r1     = {
1677                         .owner          = &ctx->b,
1678                         .type           = WREPL_TYPE_UNIQUE,
1679                         .state          = WREPL_STATE_RELEASED,
1680                         .node           = WREPL_NODE_B,
1681                         .is_static      = False,
1682                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1683                         .ips            = addresses_B_1,
1684                         .apply_expected = False
1685                 },
1686                 .r2     = {
1687                         .owner          = &ctx->a,
1688                         .type           = WREPL_TYPE_SGROUP,
1689                         .state          = WREPL_STATE_TOMBSTONE,
1690                         .node           = WREPL_NODE_B,
1691                         .is_static      = False,
1692                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1693                         .ips            = addresses_A_3_4,
1694                         .apply_expected = True
1695                 }
1696         },
1697
1698         /* 
1699          * unique,tombstone vs. sgroup,active
1700          * => should be replaced
1701          */
1702         {
1703                 .line   = __location__,
1704                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1705                 .r1     = {
1706                         .owner          = &ctx->a,
1707                         .type           = WREPL_TYPE_UNIQUE,
1708                         .state          = WREPL_STATE_TOMBSTONE,
1709                         .node           = WREPL_NODE_B,
1710                         .is_static      = False,
1711                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1712                         .ips            = addresses_A_1,
1713                         .apply_expected = True
1714                 },
1715                 .r2     = {
1716                         .owner          = &ctx->b,
1717                         .type           = WREPL_TYPE_SGROUP,
1718                         .state          = WREPL_STATE_ACTIVE,
1719                         .node           = WREPL_NODE_B,
1720                         .is_static      = False,
1721                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1722                         .ips            = addresses_B_3_4,
1723                         .apply_expected = True
1724                 }
1725         },
1726
1727         /* 
1728          * unique,tombstone vs. sgroup,tombstone
1729          * => should be replaced
1730          */
1731         {
1732                 .line   = __location__,
1733                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1734                 .r1     = {
1735                         .owner          = &ctx->b,
1736                         .type           = WREPL_TYPE_UNIQUE,
1737                         .state          = WREPL_STATE_TOMBSTONE,
1738                         .node           = WREPL_NODE_B,
1739                         .is_static      = False,
1740                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1741                         .ips            = addresses_B_1,
1742                         .apply_expected = True
1743                 },
1744                 .r2     = {
1745                         .owner          = &ctx->a,
1746                         .type           = WREPL_TYPE_SGROUP,
1747                         .state          = WREPL_STATE_TOMBSTONE,
1748                         .node           = WREPL_NODE_B,
1749                         .is_static      = False,
1750                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1751                         .ips            = addresses_A_3_4,
1752                         .apply_expected = True
1753                 }
1754         },
1755
1756 /*
1757  * unique vs multi homed section,
1758  */
1759         /* 
1760          * unique,active vs. mhomed,active
1761          * => should be replaced
1762          */
1763         {
1764                 .line   = __location__,
1765                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1766                 .r1     = {
1767                         .owner          = &ctx->a,
1768                         .type           = WREPL_TYPE_UNIQUE,
1769                         .state          = WREPL_STATE_ACTIVE,
1770                         .node           = WREPL_NODE_B,
1771                         .is_static      = False,
1772                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1773                         .ips            = addresses_A_1,
1774                         .apply_expected = True
1775                 },
1776                 .r2     = {
1777                         .owner          = &ctx->b,
1778                         .type           = WREPL_TYPE_MHOMED,
1779                         .state          = WREPL_STATE_ACTIVE,
1780                         .node           = WREPL_NODE_B,
1781                         .is_static      = False,
1782                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1783                         .ips            = addresses_B_3_4,
1784                         .apply_expected = True
1785                 }
1786         },
1787
1788         /* 
1789          * unique,active vs. mhomed,tombstone
1790          * => should NOT be replaced
1791          */
1792         {
1793                 .line   = __location__,
1794                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1795                 .r1     = {
1796                         .owner          = &ctx->b,
1797                         .type           = WREPL_TYPE_UNIQUE,
1798                         .state          = WREPL_STATE_ACTIVE,
1799                         .node           = WREPL_NODE_B,
1800                         .is_static      = False,
1801                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1802                         .ips            = addresses_B_3_4,
1803                         .apply_expected = True
1804                 },
1805                 .r2     = {
1806                         .owner          = &ctx->a,
1807                         .type           = WREPL_TYPE_MHOMED,
1808                         .state          = WREPL_STATE_TOMBSTONE,
1809                         .node           = WREPL_NODE_B,
1810                         .is_static      = False,
1811                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1812                         .ips            = addresses_B_3_4,
1813                         .apply_expected = False
1814                 }
1815         },
1816
1817         /* 
1818          * unique,released vs. mhomed,active
1819          * => should be replaced
1820          */
1821         {
1822                 .line   = __location__,
1823                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1824                 .r1     = {
1825                         .owner          = &ctx->b,
1826                         .type           = WREPL_TYPE_UNIQUE,
1827                         .state          = WREPL_STATE_RELEASED,
1828                         .node           = WREPL_NODE_B,
1829                         .is_static      = False,
1830                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1831                         .ips            = addresses_B_1,
1832                         .apply_expected = False
1833                 },
1834                 .r2     = {
1835                         .owner          = &ctx->a,
1836                         .type           = WREPL_TYPE_MHOMED,
1837                         .state          = WREPL_STATE_ACTIVE,
1838                         .node           = WREPL_NODE_B,
1839                         .is_static      = False,
1840                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1841                         .ips            = addresses_A_3_4,
1842                         .apply_expected = True
1843                 }
1844         },
1845
1846         /* 
1847          * unique,released vs. mhomed,tombstone
1848          * => should be replaced
1849          */
1850         {
1851                 .line   = __location__,
1852                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1853                 .r1     = {
1854                         .owner          = &ctx->a,
1855                         .type           = WREPL_TYPE_UNIQUE,
1856                         .state          = WREPL_STATE_RELEASED,
1857                         .node           = WREPL_NODE_B,
1858                         .is_static      = False,
1859                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1860                         .ips            = addresses_A_1,
1861                         .apply_expected = False
1862                 },
1863                 .r2     = {
1864                         .owner          = &ctx->b,
1865                         .type           = WREPL_TYPE_MHOMED,
1866                         .state          = WREPL_STATE_TOMBSTONE,
1867                         .node           = WREPL_NODE_B,
1868                         .is_static      = False,
1869                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1870                         .ips            = addresses_B_3_4,
1871                         .apply_expected = True
1872                 }
1873         },
1874
1875         /* 
1876          * unique,tombstone vs. mhomed,active
1877          * => should be replaced
1878          */
1879         {
1880                 .line   = __location__,
1881                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1882                 .r1     = {
1883                         .owner          = &ctx->b,
1884                         .type           = WREPL_TYPE_UNIQUE,
1885                         .state          = WREPL_STATE_TOMBSTONE,
1886                         .node           = WREPL_NODE_B,
1887                         .is_static      = False,
1888                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1889                         .ips            = addresses_B_1,
1890                         .apply_expected = True
1891                 },
1892                 .r2     = {
1893                         .owner          = &ctx->a,
1894                         .type           = WREPL_TYPE_MHOMED,
1895                         .state          = WREPL_STATE_ACTIVE,
1896                         .node           = WREPL_NODE_B,
1897                         .is_static      = False,
1898                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1899                         .ips            = addresses_A_3_4,
1900                         .apply_expected = True
1901                 }
1902         },
1903
1904         /* 
1905          * unique,tombstone vs. mhomed,tombstone
1906          * => should be replaced
1907          */
1908         {
1909                 .line   = __location__,
1910                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1911                 .r1     = {
1912                         .owner          = &ctx->a,
1913                         .type           = WREPL_TYPE_UNIQUE,
1914                         .state          = WREPL_STATE_TOMBSTONE,
1915                         .node           = WREPL_NODE_B,
1916                         .is_static      = False,
1917                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1918                         .ips            = addresses_A_1,
1919                         .apply_expected = True
1920                 },
1921                 .r2     = {
1922                         .owner          = &ctx->b,
1923                         .type           = WREPL_TYPE_MHOMED,
1924                         .state          = WREPL_STATE_TOMBSTONE,
1925                         .node           = WREPL_NODE_B,
1926                         .is_static      = False,
1927                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1928                         .ips            = addresses_B_3_4,
1929                         .apply_expected = True
1930                 }
1931         },
1932
1933 /*
1934  * normal groups vs unique section,
1935  */
1936         /* 
1937          * group,active vs. unique,active
1938          * => should NOT be replaced
1939          */
1940         {
1941                 .line   = __location__,
1942                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1943                 .r1     = {
1944                         .owner          = &ctx->a,
1945                         .type           = WREPL_TYPE_GROUP,
1946                         .state          = WREPL_STATE_ACTIVE,
1947                         .node           = WREPL_NODE_B,
1948                         .is_static      = False,
1949                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1950                         .ips            = addresses_A_1,
1951                         .apply_expected = True
1952                 },
1953                 .r2     = {
1954                         .owner          = &ctx->b,
1955                         .type           = WREPL_TYPE_UNIQUE,
1956                         .state          = WREPL_STATE_ACTIVE,
1957                         .node           = WREPL_NODE_B,
1958                         .is_static      = False,
1959                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1960                         .ips            = addresses_A_1,
1961                         .apply_expected = False
1962                 }
1963         },
1964
1965         /* 
1966          * group,active vs. unique,tombstone
1967          * => should NOT be replaced
1968          */
1969         {
1970                 .line   = __location__,
1971                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1972                 .r1     = {
1973                         .owner          = &ctx->a,
1974                         .type           = WREPL_TYPE_GROUP,
1975                         .state          = WREPL_STATE_ACTIVE,
1976                         .node           = WREPL_NODE_B,
1977                         .is_static      = False,
1978                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1979                         .ips            = addresses_A_1,
1980                         .apply_expected = True
1981                 },
1982                 .r2     = {
1983                         .owner          = &ctx->b,
1984                         .type           = WREPL_TYPE_UNIQUE,
1985                         .state          = WREPL_STATE_TOMBSTONE,
1986                         .node           = WREPL_NODE_B,
1987                         .is_static      = False,
1988                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1989                         .ips            = addresses_A_1,
1990                         .apply_expected = False
1991                 }
1992         },
1993
1994         /* 
1995          * group,released vs. unique,active
1996          * => should NOT be replaced
1997          */
1998         {
1999                 .line   = __location__,
2000                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2001                 .r1     = {
2002                         .owner          = &ctx->a,
2003                         .type           = WREPL_TYPE_GROUP,
2004                         .state          = WREPL_STATE_RELEASED,
2005                         .node           = WREPL_NODE_B,
2006                         .is_static      = False,
2007                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2008                         .ips            = addresses_A_1,
2009                         .apply_expected = False
2010                 },
2011                 .r2     = {
2012                         .owner          = &ctx->b,
2013                         .type           = WREPL_TYPE_UNIQUE,
2014                         .state          = WREPL_STATE_ACTIVE,
2015                         .node           = WREPL_NODE_B,
2016                         .is_static      = False,
2017                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2018                         .ips            = addresses_A_1,
2019                         .apply_expected = False
2020                 }
2021         },
2022
2023         /* 
2024          * group,released vs. unique,tombstone
2025          * => should NOT be replaced
2026          */
2027         {
2028                 .line   = __location__,
2029                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2030                 .r1     = {
2031                         .owner          = &ctx->a,
2032                         .type           = WREPL_TYPE_GROUP,
2033                         .state          = WREPL_STATE_RELEASED,
2034                         .node           = WREPL_NODE_B,
2035                         .is_static      = False,
2036                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2037                         .ips            = addresses_A_1,
2038                         .apply_expected = False
2039                 },
2040                 .r2     = {
2041                         .owner          = &ctx->b,
2042                         .type           = WREPL_TYPE_UNIQUE,
2043                         .state          = WREPL_STATE_TOMBSTONE,
2044                         .node           = WREPL_NODE_B,
2045                         .is_static      = False,
2046                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2047                         .ips            = addresses_A_1,
2048                         .apply_expected = False
2049                 }
2050         },
2051
2052         /* 
2053          * group,tombstone vs. unique,active
2054          * => should NOT be replaced
2055          */
2056         {
2057                 .line   = __location__,
2058                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2059                 .r1     = {
2060                         .owner          = &ctx->a,
2061                         .type           = WREPL_TYPE_GROUP,
2062                         .state          = WREPL_STATE_TOMBSTONE,
2063                         .node           = WREPL_NODE_B,
2064                         .is_static      = False,
2065                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2066                         .ips            = addresses_A_1,
2067                         .apply_expected = True
2068                 },
2069                 .r2     = {
2070                         .owner          = &ctx->b,
2071                         .type           = WREPL_TYPE_UNIQUE,
2072                         .state          = WREPL_STATE_ACTIVE,
2073                         .node           = WREPL_NODE_B,
2074                         .is_static      = False,
2075                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2076                         .ips            = addresses_A_1,
2077                         .apply_expected = False
2078                 }
2079         },
2080
2081         /* 
2082          * group,tombstone vs. unique,tombstone
2083          * => should NOT be replaced
2084          */
2085         {
2086                 .line   = __location__,
2087                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2088                 .r1     = {
2089                         .owner          = &ctx->a,
2090                         .type           = WREPL_TYPE_GROUP,
2091                         .state          = WREPL_STATE_TOMBSTONE,
2092                         .node           = WREPL_NODE_B,
2093                         .is_static      = False,
2094                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2095                         .ips            = addresses_A_1,
2096                         .apply_expected = True
2097                 },
2098                 .r2     = {
2099                         .owner          = &ctx->b,
2100                         .type           = WREPL_TYPE_UNIQUE,
2101                         .state          = WREPL_STATE_TOMBSTONE,
2102                         .node           = WREPL_NODE_B,
2103                         .is_static      = False,
2104                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2105                         .ips            = addresses_A_1,
2106                         .apply_expected = False
2107                 }
2108         },
2109
2110 /*
2111  * normal groups vs normal groups section,
2112  */
2113         /* 
2114          * group,active vs. group,active
2115          * => should NOT be replaced
2116          */
2117         {
2118                 .line   = __location__,
2119                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2120                 .r1     = {
2121                         .owner          = &ctx->a,
2122                         .type           = WREPL_TYPE_GROUP,
2123                         .state          = WREPL_STATE_ACTIVE,
2124                         .node           = WREPL_NODE_B,
2125                         .is_static      = False,
2126                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2127                         .ips            = addresses_A_1,
2128                         .apply_expected = True
2129                 },
2130                 .r2     = {
2131                         .owner          = &ctx->b,
2132                         .type           = WREPL_TYPE_GROUP,
2133                         .state          = WREPL_STATE_ACTIVE,
2134                         .node           = WREPL_NODE_B,
2135                         .is_static      = False,
2136                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2137                         .ips            = addresses_A_1,
2138                         .apply_expected = False
2139                 }
2140         },
2141
2142         /* 
2143          * group,active vs. group,tombstone
2144          * => should NOT be replaced
2145          */
2146         {
2147                 .line   = __location__,
2148                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2149                 .r1     = {
2150                         .owner          = &ctx->a,
2151                         .type           = WREPL_TYPE_GROUP,
2152                         .state          = WREPL_STATE_ACTIVE,
2153                         .node           = WREPL_NODE_B,
2154                         .is_static      = False,
2155                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2156                         .ips            = addresses_A_1,
2157                         .apply_expected = True
2158                 },
2159                 .r2     = {
2160                         .owner          = &ctx->b,
2161                         .type           = WREPL_TYPE_GROUP,
2162                         .state          = WREPL_STATE_TOMBSTONE,
2163                         .node           = WREPL_NODE_B,
2164                         .is_static      = False,
2165                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2166                         .ips            = addresses_A_1,
2167                         .apply_expected = False
2168                 }
2169         },
2170
2171         /* 
2172          * group,released vs. group,active
2173          * => should be replaced
2174          */
2175         {
2176                 .line   = __location__,
2177                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2178                 .r1     = {
2179                         .owner          = &ctx->a,
2180                         .type           = WREPL_TYPE_GROUP,
2181                         .state          = WREPL_STATE_RELEASED,
2182                         .node           = WREPL_NODE_B,
2183                         .is_static      = False,
2184                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2185                         .ips            = addresses_A_1,
2186                         .apply_expected = False
2187                 },
2188                 .r2     = {
2189                         .owner          = &ctx->b,
2190                         .type           = WREPL_TYPE_GROUP,
2191                         .state          = WREPL_STATE_ACTIVE,
2192                         .node           = WREPL_NODE_B,
2193                         .is_static      = False,
2194                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2195                         .ips            = addresses_B_1,
2196                         .apply_expected = True
2197                 }
2198         },
2199
2200         /* 
2201          * group,released vs. group,tombstone
2202          * => should be replaced
2203          */
2204         {
2205                 .line   = __location__,
2206                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2207                 .r1     = {
2208                         .owner          = &ctx->a,
2209                         .type           = WREPL_TYPE_GROUP,
2210                         .state          = WREPL_STATE_RELEASED,
2211                         .node           = WREPL_NODE_B,
2212                         .is_static      = False,
2213                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2214                         .ips            = addresses_A_1,
2215                         .apply_expected = False
2216                 },
2217                 .r2     = {
2218                         .owner          = &ctx->b,
2219                         .type           = WREPL_TYPE_GROUP,
2220                         .state          = WREPL_STATE_TOMBSTONE,
2221                         .node           = WREPL_NODE_B,
2222                         .is_static      = False,
2223                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2224                         .ips            = addresses_B_1,
2225                         .apply_expected = True
2226                 }
2227         },
2228
2229         /* 
2230          * group,tombstone vs. group,active
2231          * => should be replaced
2232          */
2233         {
2234                 .line   = __location__,
2235                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2236                 .r1     = {
2237                         .owner          = &ctx->b,
2238                         .type           = WREPL_TYPE_GROUP,
2239                         .state          = WREPL_STATE_TOMBSTONE,
2240                         .node           = WREPL_NODE_B,
2241                         .is_static      = False,
2242                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2243                         .ips            = addresses_B_1,
2244                         .apply_expected = True
2245                 },
2246                 .r2     = {
2247                         .owner          = &ctx->a,
2248                         .type           = WREPL_TYPE_GROUP,
2249                         .state          = WREPL_STATE_ACTIVE,
2250                         .node           = WREPL_NODE_B,
2251                         .is_static      = False,
2252                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2253                         .ips            = addresses_A_1,
2254                         .apply_expected = True
2255                 }
2256         },
2257
2258         /* 
2259          * group,tombstone vs. group,tombstone
2260          * => should be replaced
2261          */
2262         {
2263                 .line   = __location__,
2264                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2265                 .r1     = {
2266                         .owner          = &ctx->a,
2267                         .type           = WREPL_TYPE_GROUP,
2268                         .state          = WREPL_STATE_TOMBSTONE,
2269                         .node           = WREPL_NODE_B,
2270                         .is_static      = False,
2271                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2272                         .ips            = addresses_A_1,
2273                         .apply_expected = True
2274                 },
2275                 .r2     = {
2276                         .owner          = &ctx->b,
2277                         .type           = WREPL_TYPE_GROUP,
2278                         .state          = WREPL_STATE_TOMBSTONE,
2279                         .node           = WREPL_NODE_B,
2280                         .is_static      = False,
2281                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2282                         .ips            = addresses_B_1,
2283                         .apply_expected = True
2284                 }
2285         },
2286
2287 /*
2288  * normal groups vs special groups section,
2289  */
2290         /* 
2291          * group,active vs. sgroup,active
2292          * => should NOT be replaced
2293          */
2294         {
2295                 .line   = __location__,
2296                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2297                 .r1     = {
2298                         .owner          = &ctx->b,
2299                         .type           = WREPL_TYPE_GROUP,
2300                         .state          = WREPL_STATE_ACTIVE,
2301                         .node           = WREPL_NODE_B,
2302                         .is_static      = False,
2303                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2304                         .ips            = addresses_B_1,
2305                         .apply_expected = True
2306                 },
2307                 .r2     = {
2308                         .owner          = &ctx->a,
2309                         .type           = WREPL_TYPE_SGROUP,
2310                         .state          = WREPL_STATE_ACTIVE,
2311                         .node           = WREPL_NODE_B,
2312                         .is_static      = False,
2313                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2314                         .ips            = addresses_B_1,
2315                         .apply_expected = False
2316                 }
2317         },
2318
2319         /* 
2320          * group,active vs. sgroup,tombstone
2321          * => should NOT be replaced
2322          */
2323         {
2324                 .line   = __location__,
2325                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2326                 .r1     = {
2327                         .owner          = &ctx->b,
2328                         .type           = WREPL_TYPE_GROUP,
2329                         .state          = WREPL_STATE_ACTIVE,
2330                         .node           = WREPL_NODE_B,
2331                         .is_static      = False,
2332                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2333                         .ips            = addresses_B_1,
2334                         .apply_expected = True
2335                 },
2336                 .r2     = {
2337                         .owner          = &ctx->a,
2338                         .type           = WREPL_TYPE_SGROUP,
2339                         .state          = WREPL_STATE_TOMBSTONE,
2340                         .node           = WREPL_NODE_B,
2341                         .is_static      = False,
2342                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2343                         .ips            = addresses_B_1,
2344                         .apply_expected = False
2345                 }
2346         },
2347
2348         /* 
2349          * group,released vs. sgroup,active
2350          * => should be replaced
2351          */
2352         {
2353                 .line   = __location__,
2354                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2355                 .r1     = {
2356                         .owner          = &ctx->a,
2357                         .type           = WREPL_TYPE_GROUP,
2358                         .state          = WREPL_STATE_RELEASED,
2359                         .node           = WREPL_NODE_B,
2360                         .is_static      = False,
2361                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2362                         .ips            = addresses_A_1,
2363                         .apply_expected = False
2364                 },
2365                 .r2     = {
2366                         .owner          = &ctx->b,
2367                         .type           = WREPL_TYPE_SGROUP,
2368                         .state          = WREPL_STATE_ACTIVE,
2369                         .node           = WREPL_NODE_B,
2370                         .is_static      = False,
2371                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2372                         .ips            = addresses_B_1,
2373                         .apply_expected = True
2374                 }
2375         },
2376
2377         /* 
2378          * group,released vs. sgroup,tombstone
2379          * => should NOT be replaced
2380          */
2381         {
2382                 .line   = __location__,
2383                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2384                 .r1     = {
2385                         .owner          = &ctx->b,
2386                         .type           = WREPL_TYPE_GROUP,
2387                         .state          = WREPL_STATE_RELEASED,
2388                         .node           = WREPL_NODE_B,
2389                         .is_static      = False,
2390                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2391                         .ips            = addresses_B_1,
2392                         .apply_expected = False
2393                 },
2394                 .r2     = {
2395                         .owner          = &ctx->a,
2396                         .type           = WREPL_TYPE_SGROUP,
2397                         .state          = WREPL_STATE_TOMBSTONE,
2398                         .node           = WREPL_NODE_B,
2399                         .is_static      = False,
2400                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2401                         .ips            = addresses_B_1,
2402                         .apply_expected = False
2403                 }
2404         },
2405
2406         /* 
2407          * group,tombstone vs. sgroup,active
2408          * => should be replaced
2409          */
2410         {
2411                 .line   = __location__,
2412                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2413                 .r1     = {
2414                         .owner          = &ctx->b,
2415                         .type           = WREPL_TYPE_GROUP,
2416                         .state          = WREPL_STATE_TOMBSTONE,
2417                         .node           = WREPL_NODE_B,
2418                         .is_static      = False,
2419                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2420                         .ips            = addresses_B_1,
2421                         .apply_expected = True
2422                 },
2423                 .r2     = {
2424                         .owner          = &ctx->a,
2425                         .type           = WREPL_TYPE_SGROUP,
2426                         .state          = WREPL_STATE_ACTIVE,
2427                         .node           = WREPL_NODE_B,
2428                         .is_static      = False,
2429                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2430                         .ips            = addresses_A_1,
2431                         .apply_expected = True
2432                 }
2433         },
2434
2435         /* 
2436          * group,tombstone vs. sgroup,tombstone
2437          * => should be replaced
2438          */
2439         {
2440                 .line   = __location__,
2441                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2442                 .r1     = {
2443                         .owner          = &ctx->a,
2444                         .type           = WREPL_TYPE_GROUP,
2445                         .state          = WREPL_STATE_TOMBSTONE,
2446                         .node           = WREPL_NODE_B,
2447                         .is_static      = False,
2448                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2449                         .ips            = addresses_A_1,
2450                         .apply_expected = True
2451                 },
2452                 .r2     = {
2453                         .owner          = &ctx->b,
2454                         .type           = WREPL_TYPE_SGROUP,
2455                         .state          = WREPL_STATE_TOMBSTONE,
2456                         .node           = WREPL_NODE_B,
2457                         .is_static      = False,
2458                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2459                         .ips            = addresses_B_1,
2460                         .apply_expected = True
2461                 }
2462         },
2463
2464 /*
2465  * normal groups vs multi homed section,
2466  */
2467         /* 
2468          * group,active vs. mhomed,active
2469          * => should NOT be replaced
2470          */
2471         {
2472                 .line   = __location__,
2473                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2474                 .r1     = {
2475                         .owner          = &ctx->b,
2476                         .type           = WREPL_TYPE_GROUP,
2477                         .state          = WREPL_STATE_ACTIVE,
2478                         .node           = WREPL_NODE_B,
2479                         .is_static      = False,
2480                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2481                         .ips            = addresses_B_1,
2482                         .apply_expected = True
2483                 },
2484                 .r2     = {
2485                         .owner          = &ctx->a,
2486                         .type           = WREPL_TYPE_MHOMED,
2487                         .state          = WREPL_STATE_ACTIVE,
2488                         .node           = WREPL_NODE_B,
2489                         .is_static      = False,
2490                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2491                         .ips            = addresses_B_1,
2492                         .apply_expected = False
2493                 }
2494         },
2495
2496         /* 
2497          * group,active vs. mhomed,tombstone
2498          * => should NOT be replaced
2499          */
2500         {
2501                 .line   = __location__,
2502                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2503                 .r1     = {
2504                         .owner          = &ctx->b,
2505                         .type           = WREPL_TYPE_GROUP,
2506                         .state          = WREPL_STATE_ACTIVE,
2507                         .node           = WREPL_NODE_B,
2508                         .is_static      = False,
2509                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2510                         .ips            = addresses_B_1,
2511                         .apply_expected = True
2512                 },
2513                 .r2     = {
2514                         .owner          = &ctx->a,
2515                         .type           = WREPL_TYPE_MHOMED,
2516                         .state          = WREPL_STATE_TOMBSTONE,
2517                         .node           = WREPL_NODE_B,
2518                         .is_static      = False,
2519                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2520                         .ips            = addresses_B_1,
2521                         .apply_expected = False
2522                 }
2523         },
2524
2525         /* 
2526          * group,released vs. mhomed,active
2527          * => should NOT be replaced
2528          */
2529         {
2530                 .line   = __location__,
2531                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2532                 .r1     = {
2533                         .owner          = &ctx->b,
2534                         .type           = WREPL_TYPE_GROUP,
2535                         .state          = WREPL_STATE_RELEASED,
2536                         .node           = WREPL_NODE_B,
2537                         .is_static      = False,
2538                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2539                         .ips            = addresses_B_1,
2540                         .apply_expected = False
2541                 },
2542                 .r2     = {
2543                         .owner          = &ctx->a,
2544                         .type           = WREPL_TYPE_MHOMED,
2545                         .state          = WREPL_STATE_ACTIVE,
2546                         .node           = WREPL_NODE_B,
2547                         .is_static      = False,
2548                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2549                         .ips            = addresses_B_1,
2550                         .apply_expected = False
2551                 }
2552         },
2553
2554         /* 
2555          * group,released vs. mhomed,tombstone
2556          * => should NOT be replaced
2557          */
2558         {
2559                 .line   = __location__,
2560                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2561                 .r1     = {
2562                         .owner          = &ctx->b,
2563                         .type           = WREPL_TYPE_GROUP,
2564                         .state          = WREPL_STATE_RELEASED,
2565                         .node           = WREPL_NODE_B,
2566                         .is_static      = False,
2567                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2568                         .ips            = addresses_B_1,
2569                         .apply_expected = False
2570                 },
2571                 .r2     = {
2572                         .owner          = &ctx->a,
2573                         .type           = WREPL_TYPE_MHOMED,
2574                         .state          = WREPL_STATE_TOMBSTONE,
2575                         .node           = WREPL_NODE_B,
2576                         .is_static      = False,
2577                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2578                         .ips            = addresses_B_1,
2579                         .apply_expected = False
2580                 }
2581         },
2582
2583         /* 
2584          * group,tombstone vs. mhomed,active
2585          * => should be replaced
2586          */
2587         {
2588                 .line   = __location__,
2589                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2590                 .r1     = {
2591                         .owner          = &ctx->b,
2592                         .type           = WREPL_TYPE_GROUP,
2593                         .state          = WREPL_STATE_TOMBSTONE,
2594                         .node           = WREPL_NODE_B,
2595                         .is_static      = False,
2596                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2597                         .ips            = addresses_B_1,
2598                         .apply_expected = True
2599                 },
2600                 .r2     = {
2601                         .owner          = &ctx->a,
2602                         .type           = WREPL_TYPE_MHOMED,
2603                         .state          = WREPL_STATE_ACTIVE,
2604                         .node           = WREPL_NODE_B,
2605                         .is_static      = False,
2606                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2607                         .ips            = addresses_A_1,
2608                         .apply_expected = True
2609                 }
2610         },
2611
2612         /* 
2613          * group,tombstone vs. mhomed,tombstone
2614          * => should be replaced
2615          */
2616         {
2617                 .line   = __location__,
2618                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2619                 .r1     = {
2620                         .owner          = &ctx->a,
2621                         .type           = WREPL_TYPE_GROUP,
2622                         .state          = WREPL_STATE_TOMBSTONE,
2623                         .node           = WREPL_NODE_B,
2624                         .is_static      = False,
2625                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2626                         .ips            = addresses_A_1,
2627                         .apply_expected = True
2628                 },
2629                 .r2     = {
2630                         .owner          = &ctx->b,
2631                         .type           = WREPL_TYPE_MHOMED,
2632                         .state          = WREPL_STATE_TOMBSTONE,
2633                         .node           = WREPL_NODE_B,
2634                         .is_static      = False,
2635                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2636                         .ips            = addresses_B_1,
2637                         .apply_expected = True
2638                 }
2639         },
2640
2641 /*
2642  * special groups vs unique section,
2643  */
2644         /* 
2645          * sgroup,active vs. unique,active
2646          * => should NOT be replaced
2647          */
2648         {
2649                 .line   = __location__,
2650                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2651                 .r1     = {
2652                         .owner          = &ctx->b,
2653                         .type           = WREPL_TYPE_SGROUP,
2654                         .state          = WREPL_STATE_ACTIVE,
2655                         .node           = WREPL_NODE_B,
2656                         .is_static      = False,
2657                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2658                         .ips            = addresses_B_1,
2659                         .apply_expected = True
2660                 },
2661                 .r2     = {
2662                         .owner          = &ctx->a,
2663                         .type           = WREPL_TYPE_UNIQUE,
2664                         .state          = WREPL_STATE_ACTIVE,
2665                         .node           = WREPL_NODE_B,
2666                         .is_static      = False,
2667                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2668                         .ips            = addresses_B_1,
2669                         .apply_expected = False
2670                 }
2671         },
2672
2673         /* 
2674          * sgroup,active vs. unique,tombstone
2675          * => should NOT be replaced
2676          */
2677         {
2678                 .line   = __location__,
2679                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2680                 .r1     = {
2681                         .owner          = &ctx->b,
2682                         .type           = WREPL_TYPE_SGROUP,
2683                         .state          = WREPL_STATE_ACTIVE,
2684                         .node           = WREPL_NODE_B,
2685                         .is_static      = False,
2686                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2687                         .ips            = addresses_B_1,
2688                         .apply_expected = True
2689                 },
2690                 .r2     = {
2691                         .owner          = &ctx->a,
2692                         .type           = WREPL_TYPE_UNIQUE,
2693                         .state          = WREPL_STATE_TOMBSTONE,
2694                         .node           = WREPL_NODE_B,
2695                         .is_static      = False,
2696                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2697                         .ips            = addresses_B_1,
2698                         .apply_expected = False
2699                 }
2700         },
2701
2702         /* 
2703          * sgroup,released vs. unique,active
2704          * => should be replaced
2705          */
2706         {
2707                 .line   = __location__,
2708                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2709                 .r1     = {
2710                         .owner          = &ctx->b,
2711                         .type           = WREPL_TYPE_SGROUP,
2712                         .state          = WREPL_STATE_RELEASED,
2713                         .node           = WREPL_NODE_B,
2714                         .is_static      = False,
2715                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2716                         .ips            = addresses_B_1,
2717                         .apply_expected = False
2718                 },
2719                 .r2     = {
2720                         .owner          = &ctx->a,
2721                         .type           = WREPL_TYPE_UNIQUE,
2722                         .state          = WREPL_STATE_ACTIVE,
2723                         .node           = WREPL_NODE_B,
2724                         .is_static      = False,
2725                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2726                         .ips            = addresses_A_1,
2727                         .apply_expected = True
2728                 }
2729         },
2730
2731         /* 
2732          * sgroup,released vs. unique,tombstone
2733          * => should be replaced
2734          */
2735         {
2736                 .line   = __location__,
2737                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2738                 .r1     = {
2739                         .owner          = &ctx->a,
2740                         .type           = WREPL_TYPE_SGROUP,
2741                         .state          = WREPL_STATE_RELEASED,
2742                         .node           = WREPL_NODE_B,
2743                         .is_static      = False,
2744                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2745                         .ips            = addresses_A_1,
2746                         .apply_expected = False
2747                 },
2748                 .r2     = {
2749                         .owner          = &ctx->b,
2750                         .type           = WREPL_TYPE_UNIQUE,
2751                         .state          = WREPL_STATE_TOMBSTONE,
2752                         .node           = WREPL_NODE_B,
2753                         .is_static      = False,
2754                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2755                         .ips            = addresses_B_1,
2756                         .apply_expected = True
2757                 }
2758         },
2759
2760         /* 
2761          * sgroup,tombstone vs. unique,active
2762          * => should be replaced
2763          */
2764         {
2765                 .line   = __location__,
2766                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2767                 .r1     = {
2768                         .owner          = &ctx->a,
2769                         .type           = WREPL_TYPE_SGROUP,
2770                         .state          = WREPL_STATE_TOMBSTONE,
2771                         .node           = WREPL_NODE_B,
2772                         .is_static      = False,
2773                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2774                         .ips            = addresses_A_1,
2775                         .apply_expected = True
2776                 },
2777                 .r2     = {
2778                         .owner          = &ctx->b,
2779                         .type           = WREPL_TYPE_UNIQUE,
2780                         .state          = WREPL_STATE_ACTIVE,
2781                         .node           = WREPL_NODE_B,
2782                         .is_static      = False,
2783                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2784                         .ips            = addresses_B_1,
2785                         .apply_expected = True
2786                 }
2787         },
2788
2789         /* 
2790          * sgroup,tombstone vs. unique,tombstone
2791          * => should be replaced
2792          */
2793         {
2794                 .line   = __location__,
2795                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2796                 .r1     = {
2797                         .owner          = &ctx->b,
2798                         .type           = WREPL_TYPE_SGROUP,
2799                         .state          = WREPL_STATE_TOMBSTONE,
2800                         .node           = WREPL_NODE_B,
2801                         .is_static      = False,
2802                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2803                         .ips            = addresses_B_1,
2804                         .apply_expected = True
2805                 },
2806                 .r2     = {
2807                         .owner          = &ctx->a,
2808                         .type           = WREPL_TYPE_UNIQUE,
2809                         .state          = WREPL_STATE_TOMBSTONE,
2810                         .node           = WREPL_NODE_B,
2811                         .is_static      = False,
2812                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2813                         .ips            = addresses_A_1,
2814                         .apply_expected = True
2815                 }
2816         },
2817
2818 /*
2819  * special groups vs normal group section,
2820  */
2821         /* 
2822          * sgroup,active vs. group,active
2823          * => should NOT be replaced
2824          */
2825         {
2826                 .line   = __location__,
2827                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2828                 .r1     = {
2829                         .owner          = &ctx->a,
2830                         .type           = WREPL_TYPE_SGROUP,
2831                         .state          = WREPL_STATE_ACTIVE,
2832                         .node           = WREPL_NODE_B,
2833                         .is_static      = False,
2834                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2835                         .ips            = addresses_A_1,
2836                         .apply_expected = True
2837                 },
2838                 .r2     = {
2839                         .owner          = &ctx->b,
2840                         .type           = WREPL_TYPE_GROUP,
2841                         .state          = WREPL_STATE_ACTIVE,
2842                         .node           = WREPL_NODE_B,
2843                         .is_static      = False,
2844                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2845                         .ips            = addresses_A_1,
2846                         .apply_expected = False
2847                 }
2848         },
2849
2850         /* 
2851          * sgroup,active vs. group,tombstone
2852          * => should NOT be replaced
2853          */
2854         {
2855                 .line   = __location__,
2856                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2857                 .r1     = {
2858                         .owner          = &ctx->a,
2859                         .type           = WREPL_TYPE_SGROUP,
2860                         .state          = WREPL_STATE_ACTIVE,
2861                         .node           = WREPL_NODE_B,
2862                         .is_static      = False,
2863                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2864                         .ips            = addresses_A_1,
2865                         .apply_expected = True
2866                 },
2867                 .r2     = {
2868                         .owner          = &ctx->b,
2869                         .type           = WREPL_TYPE_GROUP,
2870                         .state          = WREPL_STATE_TOMBSTONE,
2871                         .node           = WREPL_NODE_B,
2872                         .is_static      = False,
2873                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2874                         .ips            = addresses_A_1,
2875                         .apply_expected = False
2876                 }
2877         },
2878
2879         /* 
2880          * sgroup,released vs. group,active
2881          * => should be replaced
2882          */
2883         {
2884                 .line   = __location__,
2885                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2886                 .r1     = {
2887                         .owner          = &ctx->a,
2888                         .type           = WREPL_TYPE_SGROUP,
2889                         .state          = WREPL_STATE_RELEASED,
2890                         .node           = WREPL_NODE_B,
2891                         .is_static      = False,
2892                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2893                         .ips            = addresses_A_1,
2894                         .apply_expected = False
2895                 },
2896                 .r2     = {
2897                         .owner          = &ctx->b,
2898                         .type           = WREPL_TYPE_GROUP,
2899                         .state          = WREPL_STATE_ACTIVE,
2900                         .node           = WREPL_NODE_B,
2901                         .is_static      = False,
2902                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2903                         .ips            = addresses_B_1,
2904                         .apply_expected = True
2905                 }
2906         },
2907
2908         /* 
2909          * sgroup,released vs. group,tombstone
2910          * => should be replaced
2911          */
2912         {
2913                 .line   = __location__,
2914                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2915                 .r1     = {
2916                         .owner          = &ctx->b,
2917                         .type           = WREPL_TYPE_SGROUP,
2918                         .state          = WREPL_STATE_RELEASED,
2919                         .node           = WREPL_NODE_B,
2920                         .is_static      = False,
2921                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2922                         .ips            = addresses_B_1,
2923                         .apply_expected = False
2924                 },
2925                 .r2     = {
2926                         .owner          = &ctx->a,
2927                         .type           = WREPL_TYPE_GROUP,
2928                         .state          = WREPL_STATE_TOMBSTONE,
2929                         .node           = WREPL_NODE_B,
2930                         .is_static      = False,
2931                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2932                         .ips            = addresses_A_1,
2933                         .apply_expected = True
2934                 }
2935         },
2936
2937         /* 
2938          * sgroup,tombstone vs. group,active
2939          * => should NOT be replaced
2940          */
2941         {
2942                 .line   = __location__,
2943                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2944                 .r1     = {
2945                         .owner          = &ctx->a,
2946                         .type           = WREPL_TYPE_SGROUP,
2947                         .state          = WREPL_STATE_TOMBSTONE,
2948                         .node           = WREPL_NODE_B,
2949                         .is_static      = False,
2950                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2951                         .ips            = addresses_A_1,
2952                         .apply_expected = True
2953                 },
2954                 .r2     = {
2955                         .owner          = &ctx->b,
2956                         .type           = WREPL_TYPE_GROUP,
2957                         .state          = WREPL_STATE_ACTIVE,
2958                         .node           = WREPL_NODE_B,
2959                         .is_static      = False,
2960                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2961                         .ips            = addresses_B_1,
2962                         .apply_expected = True
2963                 }
2964         },
2965
2966         /* 
2967          * sgroup,tombstone vs. group,tombstone
2968          * => should NOT be replaced
2969          */
2970         {
2971                 .line   = __location__,
2972                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2973                 .r1     = {
2974                         .owner          = &ctx->b,
2975                         .type           = WREPL_TYPE_SGROUP,
2976                         .state          = WREPL_STATE_TOMBSTONE,
2977                         .node           = WREPL_NODE_B,
2978                         .is_static      = False,
2979                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2980                         .ips            = addresses_B_1,
2981                         .apply_expected = True
2982                 },
2983                 .r2     = {
2984                         .owner          = &ctx->a,
2985                         .type           = WREPL_TYPE_GROUP,
2986                         .state          = WREPL_STATE_TOMBSTONE,
2987                         .node           = WREPL_NODE_B,
2988                         .is_static      = False,
2989                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2990                         .ips            = addresses_A_1,
2991                         .apply_expected = True
2992                 }
2993         },
2994
2995 /*
2996  * special groups (not active) vs special group section,
2997  */
2998         /* 
2999          * sgroup,released vs. sgroup,active
3000          * => should be replaced
3001          */
3002         {
3003                 .line   = __location__,
3004                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3005                 .r1     = {
3006                         .owner          = &ctx->a,
3007                         .type           = WREPL_TYPE_SGROUP,
3008                         .state          = WREPL_STATE_RELEASED,
3009                         .node           = WREPL_NODE_B,
3010                         .is_static      = False,
3011                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3012                         .ips            = addresses_A_1,
3013                         .apply_expected = False
3014                 },
3015                 .r2     = {
3016                         .owner          = &ctx->b,
3017                         .type           = WREPL_TYPE_SGROUP,
3018                         .state          = WREPL_STATE_ACTIVE,
3019                         .node           = WREPL_NODE_B,
3020                         .is_static      = False,
3021                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3022                         .ips            = addresses_B_1,
3023                         .apply_expected = True
3024                 }
3025         },
3026
3027         /* 
3028          * sgroup,released vs. sgroup,tombstone
3029          * => should be replaced
3030          */
3031         {
3032                 .line   = __location__,
3033                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3034                 .r1     = {
3035                         .owner          = &ctx->b,
3036                         .type           = WREPL_TYPE_SGROUP,
3037                         .state          = WREPL_STATE_RELEASED,
3038                         .node           = WREPL_NODE_B,
3039                         .is_static      = False,
3040                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3041                         .ips            = addresses_B_1,
3042                         .apply_expected = False
3043                 },
3044                 .r2     = {
3045                         .owner          = &ctx->a,
3046                         .type           = WREPL_TYPE_SGROUP,
3047                         .state          = WREPL_STATE_TOMBSTONE,
3048                         .node           = WREPL_NODE_B,
3049                         .is_static      = False,
3050                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3051                         .ips            = addresses_A_1,
3052                         .apply_expected = True
3053                 }
3054         },
3055
3056         /* 
3057          * sgroup,tombstone vs. sgroup,active
3058          * => should NOT be replaced
3059          */
3060         {
3061                 .line   = __location__,
3062                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3063                 .r1     = {
3064                         .owner          = &ctx->a,
3065                         .type           = WREPL_TYPE_SGROUP,
3066                         .state          = WREPL_STATE_TOMBSTONE,
3067                         .node           = WREPL_NODE_B,
3068                         .is_static      = False,
3069                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3070                         .ips            = addresses_A_1,
3071                         .apply_expected = True
3072                 },
3073                 .r2     = {
3074                         .owner          = &ctx->b,
3075                         .type           = WREPL_TYPE_SGROUP,
3076                         .state          = WREPL_STATE_ACTIVE,
3077                         .node           = WREPL_NODE_B,
3078                         .is_static      = False,
3079                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3080                         .ips            = addresses_B_1,
3081                         .apply_expected = True
3082                 }
3083         },
3084
3085         /* 
3086          * sgroup,tombstone vs. sgroup,tombstone
3087          * => should NOT be replaced
3088          */
3089         {
3090                 .line   = __location__,
3091                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3092                 .r1     = {
3093                         .owner          = &ctx->b,
3094                         .type           = WREPL_TYPE_SGROUP,
3095                         .state          = WREPL_STATE_TOMBSTONE,
3096                         .node           = WREPL_NODE_B,
3097                         .is_static      = False,
3098                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3099                         .ips            = addresses_B_1,
3100                         .apply_expected = True
3101                 },
3102                 .r2     = {
3103                         .owner          = &ctx->a,
3104                         .type           = WREPL_TYPE_SGROUP,
3105                         .state          = WREPL_STATE_TOMBSTONE,
3106                         .node           = WREPL_NODE_B,
3107                         .is_static      = False,
3108                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3109                         .ips            = addresses_A_1,
3110                         .apply_expected = True
3111                 }
3112         },
3113
3114 /*
3115  * special groups vs multi homed section,
3116  */
3117         /* 
3118          * sgroup,active vs. mhomed,active
3119          * => should NOT be replaced
3120          */
3121         {
3122                 .line   = __location__,
3123                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3124                 .r1     = {
3125                         .owner          = &ctx->a,
3126                         .type           = WREPL_TYPE_SGROUP,
3127                         .state          = WREPL_STATE_ACTIVE,
3128                         .node           = WREPL_NODE_B,
3129                         .is_static      = False,
3130                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3131                         .ips            = addresses_A_1,
3132                         .apply_expected = True
3133                 },
3134                 .r2     = {
3135                         .owner          = &ctx->b,
3136                         .type           = WREPL_TYPE_MHOMED,
3137                         .state          = WREPL_STATE_ACTIVE,
3138                         .node           = WREPL_NODE_B,
3139                         .is_static      = False,
3140                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3141                         .ips            = addresses_A_1,
3142                         .apply_expected = False
3143                 }
3144         },
3145
3146         /* 
3147          * sgroup,active vs. mhomed,tombstone
3148          * => should NOT be replaced
3149          */
3150         {
3151                 .line   = __location__,
3152                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3153                 .r1     = {
3154                         .owner          = &ctx->a,
3155                         .type           = WREPL_TYPE_SGROUP,
3156                         .state          = WREPL_STATE_ACTIVE,
3157                         .node           = WREPL_NODE_B,
3158                         .is_static      = False,
3159                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3160                         .ips            = addresses_A_1,
3161                         .apply_expected = True
3162                 },
3163                 .r2     = {
3164                         .owner          = &ctx->b,
3165                         .type           = WREPL_TYPE_MHOMED,
3166                         .state          = WREPL_STATE_TOMBSTONE,
3167                         .node           = WREPL_NODE_B,
3168                         .is_static      = False,
3169                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3170                         .ips            = addresses_A_1,
3171                         .apply_expected = False
3172                 }
3173         },
3174
3175         /* 
3176          * sgroup,released vs. mhomed,active
3177          * => should be replaced
3178          */
3179         {
3180                 .line   = __location__,
3181                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3182                 .r1     = {
3183                         .owner          = &ctx->a,
3184                         .type           = WREPL_TYPE_SGROUP,
3185                         .state          = WREPL_STATE_RELEASED,
3186                         .node           = WREPL_NODE_B,
3187                         .is_static      = False,
3188                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3189                         .ips            = addresses_A_1,
3190                         .apply_expected = False
3191                 },
3192                 .r2     = {
3193                         .owner          = &ctx->b,
3194                         .type           = WREPL_TYPE_MHOMED,
3195                         .state          = WREPL_STATE_ACTIVE,
3196                         .node           = WREPL_NODE_B,
3197                         .is_static      = False,
3198                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3199                         .ips            = addresses_B_1,
3200                         .apply_expected = True
3201                 }
3202         },
3203
3204         /* 
3205          * sgroup,released vs. mhomed,tombstone
3206          * => should be replaced
3207          */
3208         {
3209                 .line   = __location__,
3210                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3211                 .r1     = {
3212                         .owner          = &ctx->b,
3213                         .type           = WREPL_TYPE_SGROUP,
3214                         .state          = WREPL_STATE_RELEASED,
3215                         .node           = WREPL_NODE_B,
3216                         .is_static      = False,
3217                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3218                         .ips            = addresses_B_1,
3219                         .apply_expected = False
3220                 },
3221                 .r2     = {
3222                         .owner          = &ctx->a,
3223                         .type           = WREPL_TYPE_MHOMED,
3224                         .state          = WREPL_STATE_TOMBSTONE,
3225                         .node           = WREPL_NODE_B,
3226                         .is_static      = False,
3227                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3228                         .ips            = addresses_A_1,
3229                         .apply_expected = True
3230                 }
3231         },
3232
3233         /* 
3234          * sgroup,tombstone vs. mhomed,active
3235          * => should be replaced
3236          */
3237         {
3238                 .line   = __location__,
3239                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3240                 .r1     = {
3241                         .owner          = &ctx->a,
3242                         .type           = WREPL_TYPE_SGROUP,
3243                         .state          = WREPL_STATE_TOMBSTONE,
3244                         .node           = WREPL_NODE_B,
3245                         .is_static      = False,
3246                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3247                         .ips            = addresses_A_1,
3248                         .apply_expected = True
3249                 },
3250                 .r2     = {
3251                         .owner          = &ctx->b,
3252                         .type           = WREPL_TYPE_MHOMED,
3253                         .state          = WREPL_STATE_ACTIVE,
3254                         .node           = WREPL_NODE_B,
3255                         .is_static      = False,
3256                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3257                         .ips            = addresses_B_1,
3258                         .apply_expected = True
3259                 }
3260         },
3261
3262         /* 
3263          * sgroup,tombstone vs. mhomed,tombstone
3264          * => should be replaced
3265          */
3266         {
3267                 .line   = __location__,
3268                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3269                 .r1     = {
3270                         .owner          = &ctx->b,
3271                         .type           = WREPL_TYPE_SGROUP,
3272                         .state          = WREPL_STATE_TOMBSTONE,
3273                         .node           = WREPL_NODE_B,
3274                         .is_static      = False,
3275                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3276                         .ips            = addresses_B_1,
3277                         .apply_expected = True
3278                 },
3279                 .r2     = {
3280                         .owner          = &ctx->a,
3281                         .type           = WREPL_TYPE_MHOMED,
3282                         .state          = WREPL_STATE_TOMBSTONE,
3283                         .node           = WREPL_NODE_B,
3284                         .is_static      = False,
3285                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3286                         .ips            = addresses_A_1,
3287                         .apply_expected = True
3288                 }
3289         },
3290
3291 /*
3292  * multi homed vs. unique section,
3293  */
3294         /* 
3295          * mhomed,active vs. unique,active
3296          * => should be replaced
3297          */
3298         {
3299                 .line   = __location__,
3300                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3301                 .r1     = {
3302                         .owner          = &ctx->a,
3303                         .type           = WREPL_TYPE_MHOMED,
3304                         .state          = WREPL_STATE_ACTIVE,
3305                         .node           = WREPL_NODE_B,
3306                         .is_static      = False,
3307                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3308                         .ips            = addresses_A_3_4,
3309                         .apply_expected = True
3310                 },
3311                 .r2     = {
3312                         .owner          = &ctx->b,
3313                         .type           = WREPL_TYPE_UNIQUE,
3314                         .state          = WREPL_STATE_ACTIVE,
3315                         .node           = WREPL_NODE_B,
3316                         .is_static      = False,
3317                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3318                         .ips            = addresses_B_1,
3319                         .apply_expected = True
3320                 }
3321         },
3322
3323         /* 
3324          * mhomed,active vs. unique,tombstone
3325          * => should NOT be replaced
3326          */
3327         {
3328                 .line   = __location__,
3329                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3330                 .r1     = {
3331                         .owner          = &ctx->b,
3332                         .type           = WREPL_TYPE_MHOMED,
3333                         .state          = WREPL_STATE_ACTIVE,
3334                         .node           = WREPL_NODE_B,
3335                         .is_static      = False,
3336                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3337                         .ips            = addresses_B_1,
3338                         .apply_expected = True
3339                 },
3340                 .r2     = {
3341                         .owner          = &ctx->a,
3342                         .type           = WREPL_TYPE_UNIQUE,
3343                         .state          = WREPL_STATE_TOMBSTONE,
3344                         .node           = WREPL_NODE_B,
3345                         .is_static      = False,
3346                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3347                         .ips            = addresses_B_1,
3348                         .apply_expected = False
3349                 }
3350         },
3351
3352         /* 
3353          * mhomed,released vs. unique,active
3354          * => should be replaced
3355          */
3356         {
3357                 .line   = __location__,
3358                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3359                 .r1     = {
3360                         .owner          = &ctx->a,
3361                         .type           = WREPL_TYPE_MHOMED,
3362                         .state          = WREPL_STATE_RELEASED,
3363                         .node           = WREPL_NODE_B,
3364                         .is_static      = False,
3365                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3366                         .ips            = addresses_A_1,
3367                         .apply_expected = False
3368                 },
3369                 .r2     = {
3370                         .owner          = &ctx->b,
3371                         .type           = WREPL_TYPE_UNIQUE,
3372                         .state          = WREPL_STATE_ACTIVE,
3373                         .node           = WREPL_NODE_B,
3374                         .is_static      = False,
3375                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3376                         .ips            = addresses_B_1,
3377                         .apply_expected = True
3378                 }
3379         },
3380
3381         /* 
3382          * mhomed,released vs. uinique,tombstone
3383          * => should be replaced
3384          */
3385         {
3386                 .line   = __location__,
3387                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3388                 .r1     = {
3389                         .owner          = &ctx->b,
3390                         .type           = WREPL_TYPE_MHOMED,
3391                         .state          = WREPL_STATE_RELEASED,
3392                         .node           = WREPL_NODE_B,
3393                         .is_static      = False,
3394                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3395                         .ips            = addresses_B_1,
3396                         .apply_expected = False
3397                 },
3398                 .r2     = {
3399                         .owner          = &ctx->a,
3400                         .type           = WREPL_TYPE_UNIQUE,
3401                         .state          = WREPL_STATE_TOMBSTONE,
3402                         .node           = WREPL_NODE_B,
3403                         .is_static      = False,
3404                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3405                         .ips            = addresses_A_1,
3406                         .apply_expected = True
3407                 }
3408         },
3409
3410         /* 
3411          * mhomed,tombstone vs. unique,active
3412          * => should be replaced
3413          */
3414         {
3415                 .line   = __location__,
3416                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3417                 .r1     = {
3418                         .owner          = &ctx->a,
3419                         .type           = WREPL_TYPE_MHOMED,
3420                         .state          = WREPL_STATE_TOMBSTONE,
3421                         .node           = WREPL_NODE_B,
3422                         .is_static      = False,
3423                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3424                         .ips            = addresses_A_1,
3425                         .apply_expected = True
3426                 },
3427                 .r2     = {
3428                         .owner          = &ctx->b,
3429                         .type           = WREPL_TYPE_UNIQUE,
3430                         .state          = WREPL_STATE_ACTIVE,
3431                         .node           = WREPL_NODE_B,
3432                         .is_static      = False,
3433                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3434                         .ips            = addresses_B_1,
3435                         .apply_expected = True
3436                 }
3437         },
3438
3439         /* 
3440          * mhomed,tombstone vs. uinique,tombstone
3441          * => should be replaced
3442          */
3443         {
3444                 .line   = __location__,
3445                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3446                 .r1     = {
3447                         .owner          = &ctx->b,
3448                         .type           = WREPL_TYPE_MHOMED,
3449                         .state          = WREPL_STATE_TOMBSTONE,
3450                         .node           = WREPL_NODE_B,
3451                         .is_static      = False,
3452                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3453                         .ips            = addresses_B_1,
3454                         .apply_expected = True
3455                 },
3456                 .r2     = {
3457                         .owner          = &ctx->a,
3458                         .type           = WREPL_TYPE_UNIQUE,
3459                         .state          = WREPL_STATE_TOMBSTONE,
3460                         .node           = WREPL_NODE_B,
3461                         .is_static      = False,
3462                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3463                         .ips            = addresses_A_1,
3464                         .apply_expected = True
3465                 }
3466         },
3467
3468 /*
3469  * multi homed vs. normal group section,
3470  */
3471         /* 
3472          * mhomed,active vs. group,active
3473          * => should be replaced
3474          */
3475         {
3476                 .line   = __location__,
3477                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3478                 .r1     = {
3479                         .owner          = &ctx->a,
3480                         .type           = WREPL_TYPE_MHOMED,
3481                         .state          = WREPL_STATE_ACTIVE,
3482                         .node           = WREPL_NODE_B,
3483                         .is_static      = False,
3484                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3485                         .ips            = addresses_A_1,
3486                         .apply_expected = True
3487                 },
3488                 .r2     = {
3489                         .owner          = &ctx->b,
3490                         .type           = WREPL_TYPE_GROUP,
3491                         .state          = WREPL_STATE_ACTIVE,
3492                         .node           = WREPL_NODE_B,
3493                         .is_static      = False,
3494                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3495                         .ips            = addresses_B_1,
3496                         .apply_expected = True
3497                 }
3498         },
3499
3500         /* 
3501          * mhomed,active vs. group,tombstone
3502          * => should NOT be replaced
3503          */
3504         {
3505                 .line   = __location__,
3506                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3507                 .r1     = {
3508                         .owner          = &ctx->b,
3509                         .type           = WREPL_TYPE_MHOMED,
3510                         .state          = WREPL_STATE_ACTIVE,
3511                         .node           = WREPL_NODE_B,
3512                         .is_static      = False,
3513                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3514                         .ips            = addresses_B_1,
3515                         .apply_expected = True
3516                 },
3517                 .r2     = {
3518                         .owner          = &ctx->a,
3519                         .type           = WREPL_TYPE_GROUP,
3520                         .state          = WREPL_STATE_TOMBSTONE,
3521                         .node           = WREPL_NODE_B,
3522                         .is_static      = False,
3523                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3524                         .ips            = addresses_B_1,
3525                         .apply_expected = False
3526                 }
3527         },
3528
3529         /* 
3530          * mhomed,released vs. group,active
3531          * => should be replaced
3532          */
3533         {
3534                 .line   = __location__,
3535                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3536                 .r1     = {
3537                         .owner          = &ctx->b,
3538                         .type           = WREPL_TYPE_MHOMED,
3539                         .state          = WREPL_STATE_RELEASED,
3540                         .node           = WREPL_NODE_B,
3541                         .is_static      = False,
3542                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3543                         .ips            = addresses_B_1,
3544                         .apply_expected = False
3545                 },
3546                 .r2     = {
3547                         .owner          = &ctx->a,
3548                         .type           = WREPL_TYPE_GROUP,
3549                         .state          = WREPL_STATE_ACTIVE,
3550                         .node           = WREPL_NODE_B,
3551                         .is_static      = False,
3552                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3553                         .ips            = addresses_A_1,
3554                         .apply_expected = True
3555                 }
3556         },
3557
3558         /* 
3559          * mhomed,released vs. group,tombstone
3560          * => should be replaced
3561          */
3562         {
3563                 .line   = __location__,
3564                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3565                 .r1     = {
3566                         .owner          = &ctx->a,
3567                         .type           = WREPL_TYPE_MHOMED,
3568                         .state          = WREPL_STATE_RELEASED,
3569                         .node           = WREPL_NODE_B,
3570                         .is_static      = False,
3571                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3572                         .ips            = addresses_A_1,
3573                         .apply_expected = False
3574                 },
3575                 .r2     = {
3576                         .owner          = &ctx->b,
3577                         .type           = WREPL_TYPE_GROUP,
3578                         .state          = WREPL_STATE_TOMBSTONE,
3579                         .node           = WREPL_NODE_B,
3580                         .is_static      = False,
3581                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3582                         .ips            = addresses_B_1,
3583                         .apply_expected = True
3584                 }
3585         },
3586
3587         /* 
3588          * mhomed,tombstone vs. group,active
3589          * => should be replaced
3590          */
3591         {
3592                 .line   = __location__,
3593                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3594                 .r1     = {
3595                         .owner          = &ctx->b,
3596                         .type           = WREPL_TYPE_MHOMED,
3597                         .state          = WREPL_STATE_TOMBSTONE,
3598                         .node           = WREPL_NODE_B,
3599                         .is_static      = False,
3600                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3601                         .ips            = addresses_B_1,
3602                         .apply_expected = True
3603                 },
3604                 .r2     = {
3605                         .owner          = &ctx->a,
3606                         .type           = WREPL_TYPE_GROUP,
3607                         .state          = WREPL_STATE_ACTIVE,
3608                         .node           = WREPL_NODE_B,
3609                         .is_static      = False,
3610                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3611                         .ips            = addresses_A_1,
3612                         .apply_expected = True
3613                 }
3614         },
3615
3616         /* 
3617          * mhomed,tombstone vs. group,tombstone
3618          * => should be replaced
3619          */
3620         {
3621                 .line   = __location__,
3622                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3623                 .r1     = {
3624                         .owner          = &ctx->a,
3625                         .type           = WREPL_TYPE_MHOMED,
3626                         .state          = WREPL_STATE_TOMBSTONE,
3627                         .node           = WREPL_NODE_B,
3628                         .is_static      = False,
3629                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3630                         .ips            = addresses_A_1,
3631                         .apply_expected = True
3632                 },
3633                 .r2     = {
3634                         .owner          = &ctx->b,
3635                         .type           = WREPL_TYPE_GROUP,
3636                         .state          = WREPL_STATE_TOMBSTONE,
3637                         .node           = WREPL_NODE_B,
3638                         .is_static      = False,
3639                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3640                         .ips            = addresses_B_1,
3641                         .apply_expected = True
3642                 }
3643         },
3644
3645 /*
3646  * multi homed vs. special group section,
3647  */
3648         /* 
3649          * mhomed,active vs. sgroup,active
3650          * => should NOT be replaced
3651          */
3652         {
3653                 .line   = __location__,
3654                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3655                 .r1     = {
3656                         .owner          = &ctx->a,
3657                         .type           = WREPL_TYPE_MHOMED,
3658                         .state          = WREPL_STATE_ACTIVE,
3659                         .node           = WREPL_NODE_B,
3660                         .is_static      = False,
3661                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3662                         .ips            = addresses_A_1,
3663                         .apply_expected = True
3664                 },
3665                 .r2     = {
3666                         .owner          = &ctx->b,
3667                         .type           = WREPL_TYPE_SGROUP,
3668                         .state          = WREPL_STATE_ACTIVE,
3669                         .node           = WREPL_NODE_B,
3670                         .is_static      = False,
3671                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3672                         .ips            = addresses_A_1,
3673                         .apply_expected = False
3674                 }
3675         },
3676
3677         /* 
3678          * mhomed,active vs. sgroup,tombstone
3679          * => should NOT be replaced
3680          */
3681         {
3682                 .line   = __location__,
3683                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3684                 .r1     = {
3685                         .owner          = &ctx->a,
3686                         .type           = WREPL_TYPE_MHOMED,
3687                         .state          = WREPL_STATE_ACTIVE,
3688                         .node           = WREPL_NODE_B,
3689                         .is_static      = False,
3690                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3691                         .ips            = addresses_A_1,
3692                         .apply_expected = True
3693                 },
3694                 .r2     = {
3695                         .owner          = &ctx->b,
3696                         .type           = WREPL_TYPE_SGROUP,
3697                         .state          = WREPL_STATE_TOMBSTONE,
3698                         .node           = WREPL_NODE_B,
3699                         .is_static      = False,
3700                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3701                         .ips            = addresses_A_1,
3702                         .apply_expected = False
3703                 }
3704         },
3705
3706         /* 
3707          * mhomed,released vs. sgroup,active
3708          * => should be replaced
3709          */
3710         {
3711                 .line   = __location__,
3712                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3713                 .r1     = {
3714                         .owner          = &ctx->a,
3715                         .type           = WREPL_TYPE_MHOMED,
3716                         .state          = WREPL_STATE_RELEASED,
3717                         .node           = WREPL_NODE_B,
3718                         .is_static      = False,
3719                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3720                         .ips            = addresses_A_1,
3721                         .apply_expected = False
3722                 },
3723                 .r2     = {
3724                         .owner          = &ctx->b,
3725                         .type           = WREPL_TYPE_SGROUP,
3726                         .state          = WREPL_STATE_ACTIVE,
3727                         .node           = WREPL_NODE_B,
3728                         .is_static      = False,
3729                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3730                         .ips            = addresses_B_1,
3731                         .apply_expected = True
3732                 }
3733         },
3734
3735         /* 
3736          * mhomed,released vs. sgroup,tombstone
3737          * => should be replaced
3738          */
3739         {
3740                 .line   = __location__,
3741                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3742                 .r1     = {
3743                         .owner          = &ctx->b,
3744                         .type           = WREPL_TYPE_MHOMED,
3745                         .state          = WREPL_STATE_RELEASED,
3746                         .node           = WREPL_NODE_B,
3747                         .is_static      = False,
3748                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3749                         .ips            = addresses_B_1,
3750                         .apply_expected = False
3751                 },
3752                 .r2     = {
3753                         .owner          = &ctx->a,
3754                         .type           = WREPL_TYPE_SGROUP,
3755                         .state          = WREPL_STATE_TOMBSTONE,
3756                         .node           = WREPL_NODE_B,
3757                         .is_static      = False,
3758                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3759                         .ips            = addresses_A_1,
3760                         .apply_expected = True
3761                 }
3762         },
3763
3764         /* 
3765          * mhomed,tombstone vs. sgroup,active
3766          * => should be replaced
3767          */
3768         {
3769                 .line   = __location__,
3770                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3771                 .r1     = {
3772                         .owner          = &ctx->a,
3773                         .type           = WREPL_TYPE_MHOMED,
3774                         .state          = WREPL_STATE_TOMBSTONE,
3775                         .node           = WREPL_NODE_B,
3776                         .is_static      = False,
3777                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3778                         .ips            = addresses_A_1,
3779                         .apply_expected = True
3780                 },
3781                 .r2     = {
3782                         .owner          = &ctx->b,
3783                         .type           = WREPL_TYPE_SGROUP,
3784                         .state          = WREPL_STATE_ACTIVE,
3785                         .node           = WREPL_NODE_B,
3786                         .is_static      = False,
3787                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3788                         .ips            = addresses_B_1,
3789                         .apply_expected = True
3790                 }
3791         },
3792
3793         /* 
3794          * mhomed,tombstone vs. sgroup,tombstone
3795          * => should be replaced
3796          */
3797         {
3798                 .line   = __location__,
3799                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3800                 .r1     = {
3801                         .owner          = &ctx->b,
3802                         .type           = WREPL_TYPE_MHOMED,
3803                         .state          = WREPL_STATE_TOMBSTONE,
3804                         .node           = WREPL_NODE_B,
3805                         .is_static      = False,
3806                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3807                         .ips            = addresses_B_1,
3808                         .apply_expected = True
3809                 },
3810                 .r2     = {
3811                         .owner          = &ctx->a,
3812                         .type           = WREPL_TYPE_SGROUP,
3813                         .state          = WREPL_STATE_TOMBSTONE,
3814                         .node           = WREPL_NODE_B,
3815                         .is_static      = False,
3816                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3817                         .ips            = addresses_A_1,
3818                         .apply_expected = True
3819                 }
3820         },
3821
3822 /*
3823  * multi homed vs. mlti homed section,
3824  */
3825         /* 
3826          * mhomed,active vs. mhomed,active
3827          * => should be replaced
3828          */
3829         {
3830                 .line   = __location__,
3831                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3832                 .r1     = {
3833                         .owner          = &ctx->a,
3834                         .type           = WREPL_TYPE_MHOMED,
3835                         .state          = WREPL_STATE_ACTIVE,
3836                         .node           = WREPL_NODE_B,
3837                         .is_static      = False,
3838                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3839                         .ips            = addresses_A_3_4,
3840                         .apply_expected = True
3841                 },
3842                 .r2     = {
3843                         .owner          = &ctx->b,
3844                         .type           = WREPL_TYPE_MHOMED,
3845                         .state          = WREPL_STATE_ACTIVE,
3846                         .node           = WREPL_NODE_B,
3847                         .is_static      = False,
3848                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3849                         .ips            = addresses_B_3_4,
3850                         .apply_expected = True
3851                 }
3852         },
3853
3854         /* 
3855          * mhomed,active vs. mhomed,tombstone
3856          * => should NOT be replaced
3857          */
3858         {
3859                 .line   = __location__,
3860                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3861                 .r1     = {
3862                         .owner          = &ctx->b,
3863                         .type           = WREPL_TYPE_MHOMED,
3864                         .state          = WREPL_STATE_ACTIVE,
3865                         .node           = WREPL_NODE_B,
3866                         .is_static      = False,
3867                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3868                         .ips            = addresses_B_3_4,
3869                         .apply_expected = True
3870                 },
3871                 .r2     = {
3872                         .owner          = &ctx->a,
3873                         .type           = WREPL_TYPE_MHOMED,
3874                         .state          = WREPL_STATE_TOMBSTONE,
3875                         .node           = WREPL_NODE_B,
3876                         .is_static      = False,
3877                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3878                         .ips            = addresses_B_3_4,
3879                         .apply_expected = False
3880                 }
3881         },
3882
3883         /* 
3884          * mhomed,released vs. mhomed,active
3885          * => should be replaced
3886          */
3887         {
3888                 .line   = __location__,
3889                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3890                 .r1     = {
3891                         .owner          = &ctx->b,
3892                         .type           = WREPL_TYPE_MHOMED,
3893                         .state          = WREPL_STATE_RELEASED,
3894                         .node           = WREPL_NODE_B,
3895                         .is_static      = False,
3896                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3897                         .ips            = addresses_B_3_4,
3898                         .apply_expected = False
3899                 },
3900                 .r2     = {
3901                         .owner          = &ctx->a,
3902                         .type           = WREPL_TYPE_MHOMED,
3903                         .state          = WREPL_STATE_ACTIVE,
3904                         .node           = WREPL_NODE_B,
3905                         .is_static      = False,
3906                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3907                         .ips            = addresses_A_3_4,
3908                         .apply_expected = True
3909                 }
3910         },
3911
3912         /* 
3913          * mhomed,released vs. mhomed,tombstone
3914          * => should be replaced
3915          */
3916         {
3917                 .line   = __location__,
3918                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3919                 .r1     = {
3920                         .owner          = &ctx->a,
3921                         .type           = WREPL_TYPE_MHOMED,
3922                         .state          = WREPL_STATE_RELEASED,
3923                         .node           = WREPL_NODE_B,
3924                         .is_static      = False,
3925                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3926                         .ips            = addresses_A_3_4,
3927                         .apply_expected = False
3928                 },
3929                 .r2     = {
3930                         .owner          = &ctx->b,
3931                         .type           = WREPL_TYPE_MHOMED,
3932                         .state          = WREPL_STATE_TOMBSTONE,
3933                         .node           = WREPL_NODE_B,
3934                         .is_static      = False,
3935                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3936                         .ips            = addresses_B_3_4,
3937                         .apply_expected = True
3938                 }
3939         },
3940
3941         /* 
3942          * mhomed,tombstone vs. mhomed,active
3943          * => should be replaced
3944          */
3945         {
3946                 .line   = __location__,
3947                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3948                 .r1     = {
3949                         .owner          = &ctx->b,
3950                         .type           = WREPL_TYPE_MHOMED,
3951                         .state          = WREPL_STATE_TOMBSTONE,
3952                         .node           = WREPL_NODE_B,
3953                         .is_static      = False,
3954                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3955                         .ips            = addresses_B_3_4,
3956                         .apply_expected = True
3957                 },
3958                 .r2     = {
3959                         .owner          = &ctx->a,
3960                         .type           = WREPL_TYPE_MHOMED,
3961                         .state          = WREPL_STATE_ACTIVE,
3962                         .node           = WREPL_NODE_B,
3963                         .is_static      = False,
3964                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3965                         .ips            = addresses_A_3_4,
3966                         .apply_expected = True
3967                 }
3968         },
3969
3970         /* 
3971          * mhomed,tombstone vs. mhomed,tombstone
3972          * => should be replaced
3973          */
3974         {
3975                 .line   = __location__,
3976                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3977                 .r1     = {
3978                         .owner          = &ctx->a,
3979                         .type           = WREPL_TYPE_MHOMED,
3980                         .state          = WREPL_STATE_TOMBSTONE,
3981                         .node           = WREPL_NODE_B,
3982                         .is_static      = False,
3983                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3984                         .ips            = addresses_A_3_4,
3985                         .apply_expected = True
3986                 },
3987                 .r2     = {
3988                         .owner          = &ctx->b,
3989                         .type           = WREPL_TYPE_MHOMED,
3990                         .state          = WREPL_STATE_TOMBSTONE,
3991                         .node           = WREPL_NODE_B,
3992                         .is_static      = False,
3993                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3994                         .ips            = addresses_B_3_4,
3995                         .apply_expected = True
3996                 }
3997         },
3998         {
3999                 .line   = __location__,
4000                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4001                 .cleanup= True,
4002                 .r1     = {
4003                         .owner          = &ctx->b,
4004                         .type           = WREPL_TYPE_UNIQUE,
4005                         .state          = WREPL_STATE_TOMBSTONE,
4006                         .node           = WREPL_NODE_B,
4007                         .is_static      = False,
4008                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4009                         .ips            = addresses_B_1,
4010                         .apply_expected = True,
4011                 },
4012                 .r2     = {
4013                         .owner          = &ctx->a,
4014                         .type           = WREPL_TYPE_UNIQUE,
4015                         .state          = WREPL_STATE_TOMBSTONE,
4016                         .node           = WREPL_NODE_B,
4017                         .is_static      = False,
4018                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4019                         .ips            = addresses_A_1,
4020                         .apply_expected = True,
4021                 }
4022         },
4023 /*
4024  * special group vs special group section,
4025  */
4026         /* 
4027          * sgroup,active vs. sgroup,active same addresses
4028          * => should be NOT replaced
4029          */
4030         {
4031                 .line   = __location__,
4032                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4033                 .comment= "A:A_3_4 vs. B:A_3_4",
4034                 .extra  = True,
4035                 .r1     = {
4036                         .owner          = &ctx->a,
4037                         .type           = WREPL_TYPE_SGROUP,
4038                         .state          = WREPL_STATE_ACTIVE,
4039                         .node           = WREPL_NODE_B,
4040                         .is_static      = False,
4041                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4042                         .ips            = addresses_A_3_4,
4043                         .apply_expected = True
4044                 },
4045                 .r2     = {
4046                         .owner          = &ctx->b,
4047                         .type           = WREPL_TYPE_SGROUP,
4048                         .state          = WREPL_STATE_ACTIVE,
4049                         .node           = WREPL_NODE_B,
4050                         .is_static      = False,
4051                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4052                         .ips            = addresses_A_3_4,
4053                         .apply_expected = False,
4054                         .sgroup_cleanup = True
4055                 }
4056         },
4057         /* 
4058          * sgroup,active vs. sgroup,active same addresses
4059          * => should be NOT replaced
4060          */
4061         {
4062                 .line   = __location__,
4063                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4064                 .comment= "A:A_3_4 vs. B:NULL",
4065                 .extra  = True,
4066                 .r1     = {
4067                         .owner          = &ctx->a,
4068                         .type           = WREPL_TYPE_SGROUP,
4069                         .state          = WREPL_STATE_ACTIVE,
4070                         .node           = WREPL_NODE_B,
4071                         .is_static      = False,
4072                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4073                         .ips            = addresses_A_3_4,
4074                         .apply_expected = True
4075                 },
4076                 .r2     = {
4077                         .owner          = &ctx->b,
4078                         .type           = WREPL_TYPE_SGROUP,
4079                         .state          = WREPL_STATE_ACTIVE,
4080                         .node           = WREPL_NODE_B,
4081                         .is_static      = False,
4082                         .num_ips        = 0,
4083                         .ips            = NULL,
4084                         .apply_expected = False,
4085                         .sgroup_cleanup = True
4086                 }
4087         },
4088         /* 
4089          * sgroup,active vs. sgroup,active subset addresses, special case...
4090          * => should NOT be replaced
4091          */
4092         {
4093                 .line   = __location__,
4094                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4095                 .comment= "A:A_3_4_X_3_4 vs. B:A_3_4",
4096                 .extra  = True,
4097                 .r1     = {
4098                         .owner          = &ctx->a,
4099                         .type           = WREPL_TYPE_SGROUP,
4100                         .state          = WREPL_STATE_ACTIVE,
4101                         .node           = WREPL_NODE_B,
4102                         .is_static      = False,
4103                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4),
4104                         .ips            = addresses_A_3_4_X_3_4,
4105                         .apply_expected = True,
4106                 },
4107                 .r2     = {
4108                         .owner          = &ctx->b,
4109                         .type           = WREPL_TYPE_SGROUP,
4110                         .state          = WREPL_STATE_ACTIVE,
4111                         .node           = WREPL_NODE_B,
4112                         .is_static      = False,
4113                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4114                         .ips            = addresses_A_3_4,
4115                         .apply_expected = False,
4116                 }
4117         },
4118         {
4119                 .line   = __location__,
4120                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4121                 .cleanup= True,
4122                 .r1     = {
4123                         .owner          = &ctx->a,
4124                         .type           = WREPL_TYPE_SGROUP,
4125                         .state          = WREPL_STATE_ACTIVE,
4126                         .node           = WREPL_NODE_B,
4127                         .is_static      = False,
4128                         .num_ips        = 0,
4129                         .ips            = NULL,
4130                         .apply_expected = False,
4131                 },
4132                 .r2     = {
4133                         .owner          = &ctx->x,
4134                         .type           = WREPL_TYPE_SGROUP,
4135                         .state          = WREPL_STATE_ACTIVE,
4136                         .node           = WREPL_NODE_B,
4137                         .is_static      = False,
4138                         .num_ips        = 0,
4139                         .ips            = NULL,
4140                         .apply_expected = False,
4141                 }
4142         },
4143         /* 
4144          * sgroup,active vs. sgroup,active different addresses, but owner changed
4145          * => should be replaced
4146          */
4147         {
4148                 .line   = __location__,
4149                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4150                 .comment= "A:B_3_4 vs. B:A_3_4",
4151                 .extra  = True,
4152                 .r1     = {
4153                         .owner          = &ctx->a,
4154                         .type           = WREPL_TYPE_SGROUP,
4155                         .state          = WREPL_STATE_ACTIVE,
4156                         .node           = WREPL_NODE_B,
4157                         .is_static      = False,
4158                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4159                         .ips            = addresses_B_3_4,
4160                         .apply_expected = True,
4161                 },
4162                 .r2     = {
4163                         .owner          = &ctx->b,
4164                         .type           = WREPL_TYPE_SGROUP,
4165                         .state          = WREPL_STATE_ACTIVE,
4166                         .node           = WREPL_NODE_B,
4167                         .is_static      = False,
4168                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4169                         .ips            = addresses_A_3_4,
4170                         .apply_expected = True,
4171                         .sgroup_cleanup = True
4172                 }
4173         },
4174         /* 
4175          * sgroup,active vs. sgroup,active different addresses, but owner changed
4176          * => should be replaced
4177          */
4178         {
4179                 .line   = __location__,
4180                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4181                 .comment= "A:A_3_4 vs. B:A_3_4_OWNER_B",
4182                 .extra  = True,
4183                 .r1     = {
4184                         .owner          = &ctx->a,
4185                         .type           = WREPL_TYPE_SGROUP,
4186                         .state          = WREPL_STATE_ACTIVE,
4187                         .node           = WREPL_NODE_B,
4188                         .is_static      = False,
4189                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4190                         .ips            = addresses_A_3_4,
4191                         .apply_expected = True,
4192                 },
4193                 .r2     = {
4194                         .owner          = &ctx->b,
4195                         .type           = WREPL_TYPE_SGROUP,
4196                         .state          = WREPL_STATE_ACTIVE,
4197                         .node           = WREPL_NODE_B,
4198                         .is_static      = False,
4199                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4200                         .ips            = addresses_A_3_4_OWNER_B,
4201                         .apply_expected = True,
4202                         .sgroup_cleanup = True
4203                 }
4204         },
4205         /* 
4206          * sgroup,active vs. sgroup,active different addresses, but owner changed
4207          * => should be replaced
4208          */
4209         {
4210                 .line   = __location__,
4211                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4212                 .comment= "A:A_3_4_OWNER_B vs. B:A_3_4",
4213                 .extra  = True,
4214                 .r1     = {
4215                         .owner          = &ctx->a,
4216                         .type           = WREPL_TYPE_SGROUP,
4217                         .state          = WREPL_STATE_ACTIVE,
4218                         .node           = WREPL_NODE_B,
4219                         .is_static      = False,
4220                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4221                         .ips            = addresses_A_3_4_OWNER_B,
4222                         .apply_expected = True,
4223                 },
4224                 .r2     = {
4225                         .owner          = &ctx->b,
4226                         .type           = WREPL_TYPE_SGROUP,
4227                         .state          = WREPL_STATE_ACTIVE,
4228                         .node           = WREPL_NODE_B,
4229                         .is_static      = False,
4230                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4231                         .ips            = addresses_A_3_4,
4232                         .apply_expected = True,
4233                         .sgroup_cleanup = True
4234                 }
4235         },
4236         /* 
4237          * sgroup,active vs. sgroup,active different addresses
4238          * => should be merged
4239          */
4240         {
4241                 .line   = __location__,
4242                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4243                 .comment= "A:A_3_4 vs. B:B_3_4 => C:A_3_4_B_3_4",
4244                 .extra  = True,
4245                 .r1     = {
4246                         .owner          = &ctx->a,
4247                         .type           = WREPL_TYPE_SGROUP,
4248                         .state          = WREPL_STATE_ACTIVE,
4249                         .node           = WREPL_NODE_B,
4250                         .is_static      = False,
4251                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4252                         .ips            = addresses_A_3_4,
4253                         .apply_expected = True,
4254                 },
4255                 .r2     = {
4256                         .owner          = &ctx->b,
4257                         .type           = WREPL_TYPE_SGROUP,
4258                         .state          = WREPL_STATE_ACTIVE,
4259                         .node           = WREPL_NODE_B,
4260                         .is_static      = False,
4261                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4262                         .ips            = addresses_B_3_4,
4263                         .sgroup_merge   = True,
4264                         .sgroup_cleanup = True,
4265                 }
4266         },
4267         /* 
4268          * sgroup,active vs. sgroup,active different addresses, special case...
4269          * => should be merged
4270          */
4271         {
4272                 .line   = __location__,
4273                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4274                 .comment= "A:B_3_4_X_3_4 vs. B:A_3_4 => B:A_3_4_X_3_4",
4275                 .extra  = True,
4276                 .r1     = {
4277                         .owner          = &ctx->a,
4278                         .type           = WREPL_TYPE_SGROUP,
4279                         .state          = WREPL_STATE_ACTIVE,
4280                         .node           = WREPL_NODE_B,
4281                         .is_static      = False,
4282                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4283                         .ips            = addresses_B_3_4_X_3_4,
4284                         .apply_expected = True,
4285                 },
4286                 .r2     = {
4287                         .owner          = &ctx->b,
4288                         .type           = WREPL_TYPE_SGROUP,
4289                         .state          = WREPL_STATE_ACTIVE,
4290                         .node           = WREPL_NODE_B,
4291                         .is_static      = False,
4292                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4293                         .ips            = addresses_A_3_4,
4294                         .sgroup_merge   = True,
4295                         .merge_owner    = &ctx->b,
4296                         .sgroup_cleanup = False
4297                 }
4298         },
4299         {
4300                 .line   = __location__,
4301                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4302                 .cleanup= True,
4303                 .r1     = {
4304                         .owner          = &ctx->b,
4305                         .type           = WREPL_TYPE_SGROUP,
4306                         .state          = WREPL_STATE_ACTIVE,
4307                         .node           = WREPL_NODE_B,
4308                         .is_static      = False,
4309                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4_OWNER_B),
4310                         .ips            = addresses_A_3_4_X_3_4_OWNER_B,
4311                         .apply_expected = True,
4312                 },
4313                 .r2     = {
4314                         .owner          = &ctx->b,
4315                         .type           = WREPL_TYPE_SGROUP,
4316                         .state          = WREPL_STATE_ACTIVE,
4317                         .node           = WREPL_NODE_B,
4318                         .is_static      = False,
4319                         .num_ips        = 0,
4320                         .ips            = NULL,
4321                         .apply_expected = False,
4322                 }
4323         },
4324         /* 
4325          * sgroup,active vs. sgroup,active different addresses, special case...
4326          * => should be merged
4327          */
4328         {
4329                 .line   = __location__,
4330                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4331                 .comment= "A:X_3_4 vs. B:A_3_4 => C:A_3_4_X_3_4",
4332                 .extra  = True,
4333                 .r1     = {
4334                         .owner          = &ctx->a,
4335                         .type           = WREPL_TYPE_SGROUP,
4336                         .state          = WREPL_STATE_ACTIVE,
4337                         .node           = WREPL_NODE_B,
4338                         .is_static      = False,
4339                         .num_ips        = ARRAY_SIZE(addresses_X_3_4),
4340                         .ips            = addresses_X_3_4,
4341                         .apply_expected = True,
4342                 },
4343                 .r2     = {
4344                         .owner          = &ctx->b,
4345                         .type           = WREPL_TYPE_SGROUP,
4346                         .state          = WREPL_STATE_ACTIVE,
4347                         .node           = WREPL_NODE_B,
4348                         .is_static      = False,
4349                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4350                         .ips            = addresses_A_3_4,
4351                         .sgroup_merge   = True,
4352                         .sgroup_cleanup = False
4353                 }
4354         },
4355         {
4356                 .line   = __location__,
4357                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4358                 .cleanup= True,
4359                 .r1     = {
4360                         .owner          = &ctx->a,
4361                         .type           = WREPL_TYPE_SGROUP,
4362                         .state          = WREPL_STATE_ACTIVE,
4363                         .node           = WREPL_NODE_B,
4364                         .is_static      = False,
4365                         .num_ips        = 0,
4366                         .ips            = NULL,
4367                         .apply_expected = False,
4368                 },
4369                 .r2     = {
4370                         .owner          = &ctx->x,
4371                         .type           = WREPL_TYPE_SGROUP,
4372                         .state          = WREPL_STATE_ACTIVE,
4373                         .node           = WREPL_NODE_B,
4374                         .is_static      = False,
4375                         .num_ips        = 0,
4376                         .ips            = NULL,
4377                         .apply_expected = False,
4378                 }
4379         },
4380         /* 
4381          * sgroup,active vs. sgroup,active different addresses, special case...
4382          * => should be merged
4383          */
4384         {
4385                 .line   = __location__,
4386                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4387                 .comment= "A:A_3_4_X_3_4 vs. B:A_3_4_OWNER_B => B:A_3_4_OWNER_B_X_3_4",
4388                 .extra  = True,
4389                 .r1     = {
4390                         .owner          = &ctx->a,
4391                         .type           = WREPL_TYPE_SGROUP,
4392                         .state          = WREPL_STATE_ACTIVE,
4393                         .node           = WREPL_NODE_B,
4394                         .is_static      = False,
4395                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4),
4396                         .ips            = addresses_A_3_4_X_3_4,
4397                         .apply_expected = True,
4398                 },
4399                 .r2     = {
4400                         .owner          = &ctx->b,
4401                         .type           = WREPL_TYPE_SGROUP,
4402                         .state          = WREPL_STATE_ACTIVE,
4403                         .node           = WREPL_NODE_B,
4404                         .is_static      = False,
4405                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4406                         .ips            = addresses_A_3_4_OWNER_B,
4407                         .sgroup_merge   = True,
4408                         .merge_owner    = &ctx->b,
4409                 }
4410         },
4411         {
4412                 .line   = __location__,
4413                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4414                 .cleanup= True,
4415                 .r1     = {
4416                         .owner          = &ctx->b,
4417                         .type           = WREPL_TYPE_SGROUP,
4418                         .state          = WREPL_STATE_ACTIVE,
4419                         .node           = WREPL_NODE_B,
4420                         .is_static      = False,
4421                         .num_ips        = 0,
4422                         .ips            = NULL,
4423                         .apply_expected = False,
4424                 },
4425                 .r2     = {
4426                         .owner          = &ctx->x,
4427                         .type           = WREPL_TYPE_SGROUP,
4428                         .state          = WREPL_STATE_ACTIVE,
4429                         .node           = WREPL_NODE_B,
4430                         .is_static      = False,
4431                         .num_ips        = 0,
4432                         .ips            = NULL,
4433                         .apply_expected = False,
4434                 }
4435         },
4436         /* 
4437          * sgroup,active vs. sgroup,active partly different addresses, special case...
4438          * => should be merged
4439          */
4440         {
4441                 .line   = __location__,
4442                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4443                 .comment= "A:B_3_4_X_3_4 vs. B:B_3_4_X_1_2 => C:B_3_4_X_1_2_3_4",
4444                 .extra  = True,
4445                 .r1     = {
4446                         .owner          = &ctx->a,
4447                         .type           = WREPL_TYPE_SGROUP,
4448                         .state          = WREPL_STATE_ACTIVE,
4449                         .node           = WREPL_NODE_B,
4450                         .is_static      = False,
4451                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4452                         .ips            = addresses_B_3_4_X_3_4,
4453                         .apply_expected = True,
4454                 },
4455                 .r2     = {
4456                         .owner          = &ctx->b,
4457                         .type           = WREPL_TYPE_SGROUP,
4458                         .state          = WREPL_STATE_ACTIVE,
4459                         .node           = WREPL_NODE_B,
4460                         .is_static      = False,
4461                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_1_2),
4462                         .ips            = addresses_B_3_4_X_1_2,
4463                         .sgroup_merge   = True,
4464                         .sgroup_cleanup = False
4465                 }
4466         },
4467         {
4468                 .line   = __location__,
4469                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4470                 .cleanup= True,
4471                 .r1     = {
4472                         .owner          = &ctx->b,
4473                         .type           = WREPL_TYPE_SGROUP,
4474                         .state          = WREPL_STATE_ACTIVE,
4475                         .node           = WREPL_NODE_B,
4476                         .is_static      = False,
4477                         .num_ips        = 0,
4478                         .ips            = NULL,
4479                         .apply_expected = False,
4480                 },
4481                 .r2     = {
4482                         .owner          = &ctx->x,
4483                         .type           = WREPL_TYPE_SGROUP,
4484                         .state          = WREPL_STATE_ACTIVE,
4485                         .node           = WREPL_NODE_B,
4486                         .is_static      = False,
4487                         .num_ips        = 0,
4488                         .ips            = NULL,
4489                         .apply_expected = False,
4490                 }
4491         },
4492         /* 
4493          * sgroup,active vs. sgroup,active different addresses, special case...
4494          * => should be merged
4495          */
4496         {
4497                 .line   = __location__,
4498                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4499                 .comment= "A:A_3_4_B_3_4 vs. B:NULL => B:A_3_4",
4500                 .extra  = True,
4501                 .r1     = {
4502                         .owner          = &ctx->a,
4503                         .type           = WREPL_TYPE_SGROUP,
4504                         .state          = WREPL_STATE_ACTIVE,
4505                         .node           = WREPL_NODE_B,
4506                         .is_static      = False,
4507                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_B_3_4),
4508                         .ips            = addresses_A_3_4_B_3_4,
4509                         .apply_expected = True,
4510                 },
4511                 .r2     = {
4512                         .owner          = &ctx->b,
4513                         .type           = WREPL_TYPE_SGROUP,
4514                         .state          = WREPL_STATE_ACTIVE,
4515                         .node           = WREPL_NODE_B,
4516                         .is_static      = False,
4517                         .num_ips        = 0,
4518                         .ips            = NULL,
4519                         .sgroup_merge   = True,
4520                         .merge_owner    = &ctx->b,
4521                         .sgroup_cleanup = True
4522                 }
4523         },
4524         {
4525                 .line   = __location__,
4526                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4527                 .cleanup= True,
4528                 .r1     = {
4529                         .owner          = &ctx->a,
4530                         .type           = WREPL_TYPE_SGROUP,
4531                         .state          = WREPL_STATE_ACTIVE,
4532                         .node           = WREPL_NODE_B,
4533                         .is_static      = False,
4534                         .num_ips        = 0,
4535                         .ips            = NULL,
4536                         .apply_expected = False,
4537                 },
4538                 .r2     = {
4539                         .owner          = &ctx->a,
4540                         .type           = WREPL_TYPE_UNIQUE,
4541                         .state          = WREPL_STATE_TOMBSTONE,
4542                         .node           = WREPL_NODE_B,
4543                         .is_static      = False,
4544                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4545                         .ips            = addresses_A_1,
4546                         .apply_expected = True,
4547                 }
4548         },
4549         /* 
4550          * sgroup,active vs. sgroup,active different addresses, special case...
4551          * => should be merged
4552          */
4553         {
4554                 .line   = __location__,
4555                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4556                 .comment= "A:B_3_4_X_3_4 vs. B:NULL => B:X_3_4",
4557                 .extra  = True,
4558                 .r1     = {
4559                         .owner          = &ctx->a,
4560                         .type           = WREPL_TYPE_SGROUP,
4561                         .state          = WREPL_STATE_ACTIVE,
4562                         .node           = WREPL_NODE_B,
4563                         .is_static      = False,
4564                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4565                         .ips            = addresses_B_3_4_X_3_4,
4566                         .apply_expected = True,
4567                 },
4568                 .r2     = {
4569                         .owner          = &ctx->b,
4570                         .type           = WREPL_TYPE_SGROUP,
4571                         .state          = WREPL_STATE_ACTIVE,
4572                         .node           = WREPL_NODE_B,
4573                         .is_static      = False,
4574                         .num_ips        = 0,
4575                         .ips            = NULL,
4576                         .sgroup_merge   = True,
4577                         .merge_owner    = &ctx->b,
4578                         .sgroup_cleanup = True
4579                 }
4580         },
4581         {
4582                 .line   = __location__,
4583                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4584                 .cleanup= True,
4585                 .r1     = {
4586                         .owner          = &ctx->x,
4587                         .type           = WREPL_TYPE_SGROUP,
4588                         .state          = WREPL_STATE_ACTIVE,
4589                         .node           = WREPL_NODE_B,
4590                         .is_static      = False,
4591                         .num_ips        = 0,
4592                         .ips            = NULL,
4593                         .apply_expected = False,
4594                 },
4595                 .r2     = {
4596                         .owner          = &ctx->x,
4597                         .type           = WREPL_TYPE_UNIQUE,
4598                         .state          = WREPL_STATE_TOMBSTONE,
4599                         .node           = WREPL_NODE_B,
4600                         .is_static      = False,
4601                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4602                         .ips            = addresses_A_1,
4603                         .apply_expected = True,
4604                 }
4605         },
4606         /* 
4607          * This should be the last record in this array,
4608          * we need to make sure the we leave a tombstoned unique entry
4609          * owned by OWNER_A
4610          */
4611         {
4612                 .line   = __location__,
4613                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4614                 .cleanup= True,
4615                 .r1     = {
4616                         .owner          = &ctx->a,
4617                         .type           = WREPL_TYPE_UNIQUE,
4618                         .state          = WREPL_STATE_TOMBSTONE,
4619                         .node           = WREPL_NODE_B,
4620                         .is_static      = False,
4621                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4622                         .ips            = addresses_A_1,
4623                         .apply_expected = True
4624                 },
4625                 .r2     = {
4626                         .owner          = &ctx->a,
4627                         .type           = WREPL_TYPE_UNIQUE,
4628                         .state          = WREPL_STATE_TOMBSTONE,
4629                         .node           = WREPL_NODE_B,
4630                         .is_static      = False,
4631                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4632                         .ips            = addresses_A_1,
4633                         .apply_expected = True
4634                 }
4635         }}; /* do not add entries here, this should be the last record! */
4636
4637         if (!ctx) return False;
4638
4639         wins_name_r1    = &wins_name1;
4640         wins_name_r2    = &wins_name2;
4641
4642         printf("Test Replica Conflicts with different owners\n");
4643
4644         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
4645
4646                 if (!records[i].extra && !records[i].cleanup) {
4647                         /* we should test the worst cases */
4648                         if (records[i].r2.apply_expected && records[i].r1.ips==records[i].r2.ips) {
4649                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
4650                                         __location__, i, records[i].line);
4651                                 return False;
4652                         } else if (!records[i].r2.apply_expected && records[i].r1.ips!=records[i].r2.ips) {
4653                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
4654                                         __location__, i, records[i].line);
4655                                 return False;
4656                         }
4657                 }
4658
4659                 if (!records[i].cleanup) {
4660                         const char *expected;
4661                         const char *ips;
4662
4663                         if (records[i].r2.sgroup_merge) {
4664                                 expected = "SGROUP_MERGE";
4665                         } else if (records[i].r2.apply_expected) {
4666                                 expected = "REPLACE";
4667                         } else {
4668                                 expected = "NOT REPLACE";
4669                         }
4670
4671                         if (!records[i].r1.ips && !records[i].r2.ips) {
4672                                 ips = "with no ip(s)";
4673                         } else if (records[i].r1.ips==records[i].r2.ips) {
4674                                 ips = "with same ip(s)";
4675                         } else {
4676                                 ips = "with different ip(s)";
4677                         }
4678
4679                         printf("%s,%s%s vs. %s,%s%s %s => %s\n",
4680                                 wrepl_name_type_string(records[i].r1.type),
4681                                 wrepl_name_state_string(records[i].r1.state),
4682                                 (records[i].r1.is_static?",static":""),
4683                                 wrepl_name_type_string(records[i].r2.type),
4684                                 wrepl_name_state_string(records[i].r2.state),
4685                                 (records[i].r2.is_static?",static":""),
4686                                 (records[i].comment?records[i].comment:ips),
4687                                 expected);
4688                 }
4689
4690                 /*
4691                  * Setup R1
4692                  */
4693                 wins_name_r1->name      = &records[i].name;
4694                 wins_name_r1->flags     = WREPL_NAME_FLAGS(records[i].r1.type,
4695                                                            records[i].r1.state,
4696                                                            records[i].r1.node,
4697                                                            records[i].r1.is_static);
4698                 wins_name_r1->id        = ++records[i].r1.owner->max_version;
4699                 if (wins_name_r1->flags & 2) {
4700                         wins_name_r1->addresses.addresses.num_ips = records[i].r1.num_ips;
4701                         wins_name_r1->addresses.addresses.ips     = discard_const(records[i].r1.ips);
4702                 } else {
4703                         wins_name_r1->addresses.ip = records[i].r1.ips[0].ip;
4704                 }
4705                 wins_name_r1->unknown   = "255.255.255.255";
4706
4707                 /* now apply R1 */
4708                 ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
4709                 ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4710                                              wins_name_r1, records[i].r1.apply_expected);
4711
4712                 /*
4713                  * Setup R2
4714                  */
4715                 wins_name_r2->name      = &records[i].name;
4716                 wins_name_r2->flags     = WREPL_NAME_FLAGS(records[i].r2.type,
4717                                                            records[i].r2.state,
4718                                                            records[i].r2.node,
4719                                                            records[i].r2.is_static);
4720                 wins_name_r2->id        = ++records[i].r2.owner->max_version;
4721                 if (wins_name_r2->flags & 2) {
4722                         wins_name_r2->addresses.addresses.num_ips = records[i].r2.num_ips;
4723                         wins_name_r2->addresses.addresses.ips     = discard_const(records[i].r2.ips);
4724                 } else {
4725                         wins_name_r2->addresses.ip = records[i].r2.ips[0].ip;
4726                 }
4727                 wins_name_r2->unknown   = "255.255.255.255";
4728
4729                 /* now apply R2 */
4730                 ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4731                 if (records[i].r1.state == WREPL_STATE_RELEASED) {
4732                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4733                                                      wins_name_r1, False);
4734                 } else if (records[i].r2.sgroup_merge) {
4735                         ret &= test_wrepl_sgroup_merged(ctx, records[i].r2.merge_owner,
4736                                                         records[i].r1.owner,
4737                                                         records[i].r1.num_ips, records[i].r1.ips,
4738                                                         records[i].r2.owner,
4739                                                         records[i].r2.num_ips, records[i].r2.ips,
4740                                                         wins_name_r2);
4741                 } else if (records[i].r1.owner != records[i].r2.owner) {
4742                         BOOL _expected;
4743                         _expected = (records[i].r1.apply_expected && !records[i].r2.apply_expected);
4744                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4745                                                      wins_name_r1, _expected);
4746                 }
4747                 if (records[i].r2.state == WREPL_STATE_RELEASED) {
4748                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
4749                                                      wins_name_r2, False);
4750                 } else if (!records[i].r2.sgroup_merge) {
4751                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
4752                                                      wins_name_r2, records[i].r2.apply_expected);
4753                 }
4754
4755                 if (records[i].r2.sgroup_cleanup) {
4756                         if (!ret) {
4757                                 printf("failed before sgroup_cleanup record[%u]: %s\n", i, records[i].line);
4758                                 return ret;
4759                         }
4760
4761                         /* clean up the SGROUP record */
4762                         wins_name_r1->name      = &records[i].name;
4763                         wins_name_r1->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4764                                                                    WREPL_STATE_ACTIVE,
4765                                                                    WREPL_NODE_B, False);
4766                         wins_name_r1->id        = ++records[i].r1.owner->max_version;
4767                         wins_name_r1->addresses.addresses.num_ips = 0;
4768                         wins_name_r1->addresses.addresses.ips     = NULL;
4769                         wins_name_r1->unknown   = "255.255.255.255";
4770                         ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
4771
4772                         /* here we test how names from an owner are deleted */
4773                         if (records[i].r2.sgroup_merge && records[i].r2.num_ips) {
4774                                 ret &= test_wrepl_sgroup_merged(ctx, NULL,
4775                                                                 records[i].r2.owner,
4776                                                                 records[i].r2.num_ips, records[i].r2.ips,
4777                                                                 records[i].r1.owner,
4778                                                                 0, NULL,
4779                                                                 wins_name_r2);
4780                         }
4781
4782                         /* clean up the SGROUP record */
4783                         wins_name_r2->name      = &records[i].name;
4784                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4785                                                                    WREPL_STATE_ACTIVE,
4786                                                                    WREPL_NODE_B, False);
4787                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4788                         wins_name_r2->addresses.addresses.num_ips = 0;
4789                         wins_name_r2->addresses.addresses.ips     = NULL;
4790                         wins_name_r2->unknown   = "255.255.255.255";
4791                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4792
4793                         /* take ownership of the SGROUP record */
4794                         wins_name_r2->name      = &records[i].name;
4795                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4796                                                                    WREPL_STATE_ACTIVE,
4797                                                                    WREPL_NODE_B, False);
4798                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4799                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4800                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4801                         wins_name_r2->unknown   = "255.255.255.255";
4802                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4803                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4804
4805                         /* overwrite the SGROUP record with unique,tombstone */
4806                         wins_name_r2->name      = &records[i].name;
4807                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4808                                                                    WREPL_STATE_TOMBSTONE,
4809                                                                    WREPL_NODE_B, False);
4810                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4811                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4812                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4813                         wins_name_r2->unknown   = "255.255.255.255";
4814                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4815                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4816
4817                         if (!ret) {
4818                                 printf("failed in sgroup_cleanup record[%u]: %s\n", i, records[i].line);
4819                                 return ret;
4820                         }
4821                 }
4822
4823                 /* the first one is a cleanup run */
4824                 if (!ret && i == 0) ret = True;
4825
4826                 if (!ret) {
4827                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
4828                         return ret;
4829                 }
4830         }
4831
4832         return ret;
4833 }
4834
4835 static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx)
4836 {
4837         BOOL ret = True;
4838         NTSTATUS status;
4839         struct wrepl_wins_name wins_name_;
4840         struct wrepl_wins_name *wins_name = &wins_name_;
4841         struct nbt_name_register name_register_;
4842         struct nbt_name_register *name_register = &name_register_;
4843         struct nbt_name_release release_;
4844         struct nbt_name_release *release = &release_;
4845         uint32_t i;
4846         struct {
4847                 const char *line; /* just better debugging */
4848                 struct nbt_name name;
4849                 struct {
4850                         uint32_t nb_flags;
4851                         BOOL mhomed;
4852                         uint32_t num_ips;
4853                         const struct wrepl_ip *ips;
4854                         BOOL apply_expected;
4855                 } wins;
4856                 struct {
4857                         enum wrepl_name_type type;
4858                         enum wrepl_name_state state;
4859                         enum wrepl_name_node node;
4860                         BOOL is_static;
4861                         uint32_t num_ips;
4862                         const struct wrepl_ip *ips;
4863                         BOOL apply_expected;
4864                 } replica;
4865         } records[] = {
4866 /* 
4867  * unique vs. unique section
4868  */
4869         /*
4870          * unique,released vs. unique,active with same ip(s)
4871          */
4872         {
4873                 .line   = __location__,
4874                 .name   = _NBT_NAME("_UR_UA_SI", 0x00, NULL),
4875                 .wins   = {
4876                         .nb_flags       = 0,
4877                         .mhomed         = False,
4878                         .num_ips        = ctx->addresses_best_num,
4879                         .ips            = ctx->addresses_best,
4880                         .apply_expected = True
4881                 },
4882                 .replica= {
4883                         .type           = WREPL_TYPE_UNIQUE,
4884                         .state          = WREPL_STATE_ACTIVE,
4885                         .node           = WREPL_NODE_B,
4886                         .is_static      = False,
4887                         .num_ips        = ctx->addresses_best_num,
4888                         .ips            = ctx->addresses_best,
4889                         .apply_expected = True
4890                 },
4891         },
4892         /*
4893          * unique,released vs. unique,active with different ip(s)
4894          */
4895         {
4896                 .line   = __location__,
4897                 .name   = _NBT_NAME("_UR_UA_DI", 0x00, NULL),
4898                 .wins   = {
4899                         .nb_flags       = 0,
4900                         .mhomed         = False,
4901                         .num_ips        = ctx->addresses_best_num,
4902                         .ips            = ctx->addresses_best,
4903                         .apply_expected = True
4904                 },
4905                 .replica= {
4906                         .type           = WREPL_TYPE_UNIQUE,
4907                         .state          = WREPL_STATE_ACTIVE,
4908                         .node           = WREPL_NODE_B,
4909                         .is_static      = False,
4910                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4911                         .ips            = addresses_B_1,
4912                         .apply_expected = True
4913                 },
4914         },
4915         /*
4916          * unique,released vs. unique,tombstone with same ip(s)
4917          */
4918         {
4919                 .line   = __location__,
4920                 .name   = _NBT_NAME("_UR_UT_SI", 0x00, NULL),
4921                 .wins   = {
4922                         .nb_flags       = 0,
4923                         .mhomed         = False,
4924                         .num_ips        = ctx->addresses_best_num,
4925                         .ips            = ctx->addresses_best,
4926                         .apply_expected = True
4927                 },
4928                 .replica= {
4929                         .type           = WREPL_TYPE_UNIQUE,
4930                         .state          = WREPL_STATE_TOMBSTONE,
4931                         .node           = WREPL_NODE_B,
4932                         .is_static      = False,
4933                         .num_ips        = ctx->addresses_best_num,
4934                         .ips            = ctx->addresses_best,
4935                         .apply_expected = True
4936                 },
4937         },
4938         /*
4939          * unique,released vs. unique,tombstone with different ip(s)
4940          */
4941         {
4942                 .line   = __location__,
4943                 .name   = _NBT_NAME("_UR_UT_DI", 0x00, NULL),
4944                 .wins   = {
4945                         .nb_flags       = 0,
4946                         .mhomed         = False,
4947                         .num_ips        = ctx->addresses_best_num,
4948                         .ips            = ctx->addresses_best,
4949                         .apply_expected = True
4950                 },
4951                 .replica= {
4952                         .type           = WREPL_TYPE_UNIQUE,
4953                         .state          = WREPL_STATE_TOMBSTONE,
4954                         .node           = WREPL_NODE_B,
4955                         .is_static      = False,
4956                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4957                         .ips            = addresses_B_1,
4958                         .apply_expected = True
4959                 },
4960         },
4961 /* 
4962  * unique vs. group section
4963  */
4964         /*
4965          * unique,released vs. group,active with same ip(s)
4966          */
4967         {
4968                 .line   = __location__,
4969                 .name   = _NBT_NAME("_UR_GA_SI", 0x00, NULL),
4970                 .wins   = {
4971                         .nb_flags       = 0,
4972                         .mhomed         = False,
4973                         .num_ips        = ctx->addresses_best_num,
4974                         .ips            = ctx->addresses_best,
4975                         .apply_expected = True
4976                 },
4977                 .replica= {
4978                         .type           = WREPL_TYPE_GROUP,
4979                         .state          = WREPL_STATE_ACTIVE,
4980                         .node           = WREPL_NODE_B,
4981                         .is_static      = False,
4982                         .num_ips        = ctx->addresses_best_num,
4983                         .ips            = ctx->addresses_best,
4984                         .apply_expected = True
4985                 },
4986         },
4987         /*
4988          * unique,released vs. group,active with different ip(s)
4989          */
4990         {
4991                 .line   = __location__,
4992                 .name   = _NBT_NAME("_UR_GA_DI", 0x00, NULL),
4993                 .wins   = {
4994                         .nb_flags       = 0,
4995                         .mhomed         = False,
4996                         .num_ips        = ctx->addresses_best_num,
4997                         .ips            = ctx->addresses_best,
4998                         .apply_expected = True
4999                 },
5000                 .replica= {
5001                         .type           = WREPL_TYPE_GROUP,
5002                         .state          = WREPL_STATE_ACTIVE,
5003                         .node           = WREPL_NODE_B,
5004                         .is_static      = False,
5005                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5006                         .ips            = addresses_B_1,
5007                         .apply_expected = True
5008                 },
5009         },
5010         /*
5011          * unique,released vs. group,tombstone with same ip(s)
5012          */
5013         {
5014                 .line   = __location__,
5015                 .name   = _NBT_NAME("_UR_GT_SI", 0x00, NULL),
5016                 .wins   = {
5017                         .nb_flags       = 0,
5018                         .mhomed         = False,
5019                         .num_ips        = ctx->addresses_best_num,
5020                         .ips            = ctx->addresses_best,
5021                         .apply_expected = True
5022                 },
5023                 .replica= {
5024                         .type           = WREPL_TYPE_GROUP,
5025                         .state          = WREPL_STATE_TOMBSTONE,
5026                         .node           = WREPL_NODE_B,
5027                         .is_static      = False,
5028                         .num_ips        = ctx->addresses_best_num,
5029                         .ips            = ctx->addresses_best,
5030                         .apply_expected = True
5031                 },
5032         },
5033         /*
5034          * unique,released vs. group,tombstone with different ip(s)
5035          */
5036         {
5037                 .line   = __location__,
5038                 .name   = _NBT_NAME("_UR_GT_DI", 0x00, NULL),
5039                 .wins   = {
5040                         .nb_flags       = 0,
5041                         .mhomed         = False,
5042                         .num_ips        = ctx->addresses_best_num,
5043                         .ips            = ctx->addresses_best,
5044                         .apply_expected = True
5045                 },
5046                 .replica= {
5047                         .type           = WREPL_TYPE_GROUP,
5048                         .state          = WREPL_STATE_TOMBSTONE,
5049                         .node           = WREPL_NODE_B,
5050                         .is_static      = False,
5051                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5052                         .ips            = addresses_B_1,
5053                         .apply_expected = True
5054                 },
5055         },
5056 /* 
5057  * unique vs. special group section
5058  */
5059         /*
5060          * unique,released vs. sgroup,active with same ip(s)
5061          */
5062         {
5063                 .line   = __location__,
5064                 .name   = _NBT_NAME("_UR_SA_SI", 0x00, NULL),
5065                 .wins   = {
5066                         .nb_flags       = 0,
5067                         .mhomed         = False,
5068                         .num_ips        = ctx->addresses_best_num,
5069                         .ips            = ctx->addresses_best,
5070                         .apply_expected = True
5071                 },
5072                 .replica= {
5073                         .type           = WREPL_TYPE_SGROUP,
5074                         .state          = WREPL_STATE_ACTIVE,
5075                         .node           = WREPL_NODE_B,
5076                         .is_static      = False,
5077                         .num_ips        = ctx->addresses_best_num,
5078                         .ips            = ctx->addresses_best,
5079                         .apply_expected = True
5080                 },
5081         },
5082         /*
5083          * unique,released vs. sgroup,active with different ip(s)
5084          */
5085         {
5086                 .line   = __location__,
5087                 .name   = _NBT_NAME("_UR_SA_DI", 0x00, NULL),
5088                 .wins   = {
5089                         .nb_flags       = 0,
5090                         .mhomed         = False,
5091                         .num_ips        = ctx->addresses_best_num,
5092                         .ips            = ctx->addresses_best,
5093                         .apply_expected = True
5094                 },
5095                 .replica= {
5096                         .type           = WREPL_TYPE_SGROUP,
5097                         .state          = WREPL_STATE_ACTIVE,
5098                         .node           = WREPL_NODE_B,
5099                         .is_static      = False,
5100                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5101                         .ips            = addresses_B_1,
5102                         .apply_expected = True
5103                 },
5104         },
5105         /*
5106          * unique,released vs. sgroup,tombstone with same ip(s)
5107          */
5108         {
5109                 .line   = __location__,
5110                 .name   = _NBT_NAME("_UR_ST_SI", 0x00, NULL),
5111                 .wins   = {
5112                         .nb_flags       = 0,
5113                         .mhomed         = False,
5114                         .num_ips        = ctx->addresses_best_num,
5115                         .ips            = ctx->addresses_best,
5116                         .apply_expected = True
5117                 },
5118                 .replica= {
5119                         .type           = WREPL_TYPE_SGROUP,
5120                         .state          = WREPL_STATE_TOMBSTONE,
5121                         .node           = WREPL_NODE_B,
5122                         .is_static      = False,
5123                         .num_ips        = ctx->addresses_best_num,
5124                         .ips            = ctx->addresses_best,
5125                         .apply_expected = True
5126                 },
5127         },
5128         /*
5129          * unique,released vs. sgroup,tombstone with different ip(s)
5130          */
5131         {
5132                 .line   = __location__,
5133                 .name   = _NBT_NAME("_UR_ST_DI", 0x00, NULL),
5134                 .wins   = {
5135                         .nb_flags       = 0,
5136                         .mhomed         = False,
5137                         .num_ips        = ctx->addresses_best_num,
5138                         .ips            = ctx->addresses_best,
5139                         .apply_expected = True
5140                 },
5141                 .replica= {
5142                         .type           = WREPL_TYPE_SGROUP,
5143                         .state          = WREPL_STATE_TOMBSTONE,
5144                         .node           = WREPL_NODE_B,
5145                         .is_static      = False,
5146                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5147                         .ips            = addresses_B_1,
5148                         .apply_expected = True
5149                 },
5150         },
5151 /* 
5152  * unique vs. multi homed section
5153  */
5154         /*
5155          * unique,released vs. mhomed,active with same ip(s)
5156          */
5157         {
5158                 .line   = __location__,
5159                 .name   = _NBT_NAME("_UR_MA_SI", 0x00, NULL),
5160                 .wins   = {
5161                         .nb_flags       = 0,
5162                         .mhomed         = False,
5163                         .num_ips        = ctx->addresses_best_num,
5164                         .ips            = ctx->addresses_best,
5165                         .apply_expected = True
5166                 },
5167                 .replica= {
5168                         .type           = WREPL_TYPE_MHOMED,
5169                         .state          = WREPL_STATE_ACTIVE,
5170                         .node           = WREPL_NODE_B,
5171                         .is_static      = False,
5172                         .num_ips        = ctx->addresses_best_num,
5173                         .ips            = ctx->addresses_best,
5174                         .apply_expected = True
5175                 },
5176         },
5177         /*
5178          * unique,released vs. mhomed,active with different ip(s)
5179          */
5180         {
5181                 .line   = __location__,
5182                 .name   = _NBT_NAME("_UR_MA_DI", 0x00, NULL),
5183                 .wins   = {
5184                         .nb_flags       = 0,
5185                         .mhomed         = False,
5186                         .num_ips        = ctx->addresses_best_num,
5187                         .ips            = ctx->addresses_best,
5188                         .apply_expected = True
5189                 },
5190                 .replica= {
5191                         .type           = WREPL_TYPE_MHOMED,
5192                         .state          = WREPL_STATE_ACTIVE,
5193                         .node           = WREPL_NODE_B,
5194                         .is_static      = False,
5195                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5196                         .ips            = addresses_B_1,
5197                         .apply_expected = True
5198                 },
5199         },
5200         /*
5201          * unique,released vs. mhomed,tombstone with same ip(s)
5202          */
5203         {
5204                 .line   = __location__,
5205                 .name   = _NBT_NAME("_UR_MT_SI", 0x00, NULL),
5206                 .wins   = {
5207                         .nb_flags       = 0,
5208                         .mhomed         = False,
5209                         .num_ips        = ctx->addresses_best_num,
5210                         .ips            = ctx->addresses_best,
5211                         .apply_expected = True
5212                 },
5213                 .replica= {
5214                         .type           = WREPL_TYPE_MHOMED,
5215                         .state          = WREPL_STATE_TOMBSTONE,
5216                         .node           = WREPL_NODE_B,
5217                         .is_static      = False,
5218                         .num_ips        = ctx->addresses_best_num,
5219                         .ips            = ctx->addresses_best,
5220                         .apply_expected = True
5221                 },
5222         },
5223         /*
5224          * unique,released vs. mhomed,tombstone with different ip(s)
5225          */
5226         {
5227                 .line   = __location__,
5228                 .name   = _NBT_NAME("_UR_MT_DI", 0x00, NULL),
5229                 .wins   = {
5230                         .nb_flags       = 0,
5231                         .mhomed         = False,
5232                         .num_ips        = ctx->addresses_best_num,
5233                         .ips            = ctx->addresses_best,
5234                         .apply_expected = True
5235                 },
5236                 .replica= {
5237                         .type           = WREPL_TYPE_MHOMED,
5238                         .state          = WREPL_STATE_TOMBSTONE,
5239                         .node           = WREPL_NODE_B,
5240                         .is_static      = False,
5241                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5242                         .ips            = addresses_B_1,
5243                         .apply_expected = True
5244                 },
5245         },
5246 /* 
5247  * group vs. unique section
5248  */
5249         /*
5250          * group,released vs. unique,active with same ip(s)
5251          */
5252         {
5253                 .line   = __location__,
5254                 .name   = _NBT_NAME("_GR_UA_SI", 0x00, NULL),
5255                 .wins   = {
5256                         .nb_flags       = NBT_NM_GROUP,
5257                         .mhomed         = False,
5258                         .num_ips        = ctx->addresses_best_num,
5259                         .ips            = ctx->addresses_best,
5260                         .apply_expected = True
5261                 },
5262                 .replica= {
5263                         .type           = WREPL_TYPE_UNIQUE,
5264                         .state          = WREPL_STATE_ACTIVE,
5265                         .node           = WREPL_NODE_B,
5266                         .is_static      = False,
5267                         .num_ips        = ctx->addresses_best_num,
5268                         .ips            = ctx->addresses_best,
5269                         .apply_expected = False
5270                 },
5271         },
5272         /*
5273          * group,released vs. unique,active with different ip(s)
5274          */
5275         {
5276                 .line   = __location__,
5277                 .name   = _NBT_NAME("_GR_UA_DI", 0x00, NULL),
5278                 .wins   = {
5279                         .nb_flags       = NBT_NM_GROUP,
5280                         .mhomed         = False,
5281                         .num_ips        = ctx->addresses_best_num,
5282                         .ips            = ctx->addresses_best,
5283                         .apply_expected = True
5284                 },
5285                 .replica= {
5286                         .type           = WREPL_TYPE_UNIQUE,
5287                         .state          = WREPL_STATE_ACTIVE,
5288                         .node           = WREPL_NODE_B,
5289                         .is_static      = False,
5290                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5291                         .ips            = addresses_B_1,
5292                         .apply_expected = False
5293                 },
5294         },
5295         /*
5296          * group,released vs. unique,tombstone with same ip(s)
5297          */
5298         {
5299                 .line   = __location__,
5300                 .name   = _NBT_NAME("_GR_UT_SI", 0x00, NULL),
5301                 .wins   = {
5302                         .nb_flags       = NBT_NM_GROUP,
5303                         .mhomed         = False,
5304                         .num_ips        = ctx->addresses_best_num,
5305                         .ips            = ctx->addresses_best,
5306                         .apply_expected = True
5307                 },
5308                 .replica= {
5309                         .type           = WREPL_TYPE_UNIQUE,
5310                         .state          = WREPL_STATE_TOMBSTONE,
5311                         .node           = WREPL_NODE_B,
5312                         .is_static      = False,
5313                         .num_ips        = ctx->addresses_best_num,
5314                         .ips            = ctx->addresses_best,
5315                         .apply_expected = False
5316                 },
5317         },
5318         /*
5319          * group,released vs. unique,tombstone with different ip(s)
5320          */
5321         {
5322                 .line   = __location__,
5323                 .name   = _NBT_NAME("_GR_UT_DI", 0x00, NULL),
5324                 .wins   = {
5325                         .nb_flags       = NBT_NM_GROUP,
5326                         .mhomed         = False,
5327                         .num_ips        = ctx->addresses_best_num,
5328                         .ips            = ctx->addresses_best,
5329                         .apply_expected = True
5330                 },
5331                 .replica= {
5332                         .type           = WREPL_TYPE_UNIQUE,
5333                         .state          = WREPL_STATE_TOMBSTONE,
5334                         .node           = WREPL_NODE_B,
5335                         .is_static      = False,
5336                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5337                         .ips            = addresses_B_1,
5338                         .apply_expected = False
5339                 },
5340         },
5341 /* 
5342  * group vs. group section
5343  */
5344         /*
5345          * group,released vs. group,active with same ip(s)
5346          */
5347         {
5348                 .line   = __location__,
5349                 .name   = _NBT_NAME("_GR_GA_SI", 0x00, NULL),
5350                 .wins   = {
5351                         .nb_flags       = NBT_NM_GROUP,
5352                         .mhomed         = False,
5353                         .num_ips        = ctx->addresses_best_num,
5354                         .ips            = ctx->addresses_best,
5355                         .apply_expected = True
5356                 },
5357                 .replica= {
5358                         .type           = WREPL_TYPE_GROUP,
5359                         .state          = WREPL_STATE_ACTIVE,
5360                         .node           = WREPL_NODE_B,
5361                         .is_static      = False,
5362                         .num_ips        = ctx->addresses_best_num,
5363                         .ips            = ctx->addresses_best,
5364                         .apply_expected = True
5365                 },
5366         },
5367         /*
5368          * group,released vs. group,active with different ip(s)
5369          */
5370         {
5371                 .line   = __location__,
5372                 .name   = _NBT_NAME("_GR_GA_DI", 0x00, NULL),
5373                 .wins   = {
5374                         .nb_flags       = NBT_NM_GROUP,
5375                         .mhomed         = False,
5376                         .num_ips        = ctx->addresses_best_num,
5377                         .ips            = ctx->addresses_best,
5378                         .apply_expected = True
5379                 },
5380                 .replica= {
5381                         .type           = WREPL_TYPE_GROUP,
5382                         .state          = WREPL_STATE_ACTIVE,
5383                         .node           = WREPL_NODE_B,
5384                         .is_static      = False,
5385                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5386                         .ips            = addresses_B_1,
5387                         .apply_expected = True
5388                 },
5389         },
5390         /*
5391          * group,released vs. group,tombstone with same ip(s)
5392          */
5393         {
5394                 .line   = __location__,
5395                 .name   = _NBT_NAME("_GR_GT_SI", 0x00, NULL),
5396                 .wins   = {
5397                         .nb_flags       = NBT_NM_GROUP,
5398                         .mhomed         = False,
5399                         .num_ips        = ctx->addresses_best_num,
5400                         .ips            = ctx->addresses_best,
5401                         .apply_expected = True
5402                 },
5403                 .replica= {
5404                         .type           = WREPL_TYPE_GROUP,
5405                         .state          = WREPL_STATE_TOMBSTONE,
5406                         .node           = WREPL_NODE_B,
5407                         .is_static      = False,
5408                         .num_ips        = ctx->addresses_best_num,
5409                         .ips            = ctx->addresses_best,
5410                         .apply_expected = True
5411                 },
5412         },
5413         /*
5414          * group,released vs. group,tombstone with different ip(s)
5415          */
5416         {
5417                 .line   = __location__,
5418                 .name   = _NBT_NAME("_GR_GT_DI", 0x00, NULL),
5419                 .wins   = {
5420                         .nb_flags       = NBT_NM_GROUP,
5421                         .mhomed         = False,
5422                         .num_ips        = ctx->addresses_best_num,
5423                         .ips            = ctx->addresses_best,
5424                         .apply_expected = True
5425                 },
5426                 .replica= {
5427                         .type           = WREPL_TYPE_GROUP,
5428                         .state          = WREPL_STATE_TOMBSTONE,
5429                         .node           = WREPL_NODE_B,
5430                         .is_static      = False,
5431                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5432                         .ips            = addresses_B_1,
5433                         .apply_expected = True
5434                 },
5435         },
5436 /* 
5437  * group vs. special group section
5438  */
5439         /*
5440          * group,released vs. sgroup,active with same ip(s)
5441          */
5442         {
5443                 .line   = __location__,
5444                 .name   = _NBT_NAME("_GR_SA_SI", 0x00, NULL),
5445                 .wins   = {
5446                         .nb_flags       = NBT_NM_GROUP,
5447                         .mhomed         = False,
5448                         .num_ips        = ctx->addresses_best_num,
5449                         .ips            = ctx->addresses_best,
5450                         .apply_expected = True
5451                 },
5452                 .replica= {
5453                         .type           = WREPL_TYPE_SGROUP,
5454                         .state          = WREPL_STATE_ACTIVE,
5455                         .node           = WREPL_NODE_B,
5456                         .is_static      = False,
5457                         .num_ips        = ctx->addresses_best_num,
5458                         .ips            = ctx->addresses_best,
5459                         .apply_expected = False
5460                 },
5461         },
5462         /*
5463          * group,released vs. sgroup,active with different ip(s)
5464          */
5465         {
5466                 .line   = __location__,
5467                 .name   = _NBT_NAME("_GR_SA_DI", 0x00, NULL),
5468                 .wins   = {
5469                         .nb_flags       = NBT_NM_GROUP,
5470                         .mhomed         = False,
5471                         .num_ips        = ctx->addresses_best_num,
5472                         .ips            = ctx->addresses_best,
5473                         .apply_expected = True
5474                 },
5475                 .replica= {
5476                         .type           = WREPL_TYPE_SGROUP,
5477                         .state          = WREPL_STATE_ACTIVE,
5478                         .node           = WREPL_NODE_B,
5479                         .is_static      = False,
5480                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5481                         .ips            = addresses_B_1,
5482                         .apply_expected = False
5483                 },
5484         },
5485         /*
5486          * group,released vs. sgroup,tombstone with same ip(s)
5487          */
5488         {
5489                 .line   = __location__,
5490                 .name   = _NBT_NAME("_GR_ST_SI", 0x00, NULL),
5491                 .wins   = {
5492                         .nb_flags       = NBT_NM_GROUP,
5493                         .mhomed         = False,
5494                         .num_ips        = ctx->addresses_best_num,
5495                         .ips            = ctx->addresses_best,
5496                         .apply_expected = True
5497                 },
5498                 .replica= {
5499                         .type           = WREPL_TYPE_SGROUP,
5500                         .state          = WREPL_STATE_TOMBSTONE,
5501                         .node           = WREPL_NODE_B,
5502                         .is_static      = False,
5503                         .num_ips        = ctx->addresses_best_num,
5504                         .ips            = ctx->addresses_best,
5505                         .apply_expected = False
5506                 },
5507         },
5508         /*
5509          * group,released vs. sgroup,tombstone with different ip(s)
5510          */
5511         {
5512                 .line   = __location__,
5513                 .name   = _NBT_NAME("_GR_ST_DI", 0x00, NULL),
5514                 .wins   = {
5515                         .nb_flags       = NBT_NM_GROUP,
5516                         .mhomed         = False,
5517                         .num_ips        = ctx->addresses_best_num,
5518                         .ips            = ctx->addresses_best,
5519                         .apply_expected = True
5520                 },
5521                 .replica= {
5522                         .type           = WREPL_TYPE_SGROUP,
5523                         .state          = WREPL_STATE_TOMBSTONE,
5524                         .node           = WREPL_NODE_B,
5525                         .is_static      = False,
5526                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5527                         .ips            = addresses_B_1,
5528                         .apply_expected = False
5529                 },
5530         },
5531 /* 
5532  * group vs. multi homed section
5533  */
5534         /*
5535          * group,released vs. mhomed,active with same ip(s)
5536          */
5537         {
5538                 .line   = __location__,
5539                 .name   = _NBT_NAME("_GR_MA_SI", 0x00, NULL),
5540                 .wins   = {
5541                         .nb_flags       = NBT_NM_GROUP,
5542                         .mhomed         = False,
5543                         .num_ips        = ctx->addresses_best_num,
5544                         .ips            = ctx->addresses_best,
5545                         .apply_expected = True
5546                 },
5547                 .replica= {
5548                         .type           = WREPL_TYPE_MHOMED,
5549                         .state          = WREPL_STATE_ACTIVE,
5550                         .node           = WREPL_NODE_B,
5551                         .is_static      = False,
5552                         .num_ips        = ctx->addresses_best_num,
5553                         .ips            = ctx->addresses_best,
5554                         .apply_expected = False
5555                 },
5556         },
5557         /*
5558          * group,released vs. mhomed,active with different ip(s)
5559          */
5560         {
5561                 .line   = __location__,
5562                 .name   = _NBT_NAME("_GR_MA_DI", 0x00, NULL),
5563                 .wins   = {
5564                         .nb_flags       = NBT_NM_GROUP,
5565                         .mhomed         = False,
5566                         .num_ips        = ctx->addresses_best_num,
5567                         .ips            = ctx->addresses_best,
5568                         .apply_expected = True
5569                 },
5570                 .replica= {
5571                         .type           = WREPL_TYPE_MHOMED,
5572                         .state          = WREPL_STATE_ACTIVE,
5573                         .node           = WREPL_NODE_B,
5574                         .is_static      = False,
5575                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5576                         .ips            = addresses_B_1,
5577                         .apply_expected = False
5578                 },
5579         },
5580         /*
5581          * group,released vs. mhomed,tombstone with same ip(s)
5582          */
5583         {
5584                 .line   = __location__,
5585                 .name   = _NBT_NAME("_GR_MT_SI", 0x00, NULL),
5586                 .wins   = {
5587                         .nb_flags       = NBT_NM_GROUP,
5588                         .mhomed         = False,
5589                         .num_ips        = ctx->addresses_best_num,
5590                         .ips            = ctx->addresses_best,
5591                         .apply_expected = True
5592                 },
5593                 .replica= {
5594                         .type           = WREPL_TYPE_MHOMED,
5595                         .state          = WREPL_STATE_TOMBSTONE,
5596                         .node           = WREPL_NODE_B,
5597                         .is_static      = False,
5598                         .num_ips        = ctx->addresses_best_num,
5599                         .ips            = ctx->addresses_best,
5600                         .apply_expected = False
5601                 },
5602         },
5603         /*
5604          * group,released vs. mhomed,tombstone with different ip(s)
5605          */
5606         {
5607                 .line   = __location__,
5608                 .name   = _NBT_NAME("_GR_MT_DI", 0x00, NULL),
5609                 .wins   = {
5610                         .nb_flags       = NBT_NM_GROUP,
5611                         .mhomed         = False,
5612                         .num_ips        = ctx->addresses_best_num,
5613                         .ips            = ctx->addresses_best,
5614                         .apply_expected = True
5615                 },
5616                 .replica= {
5617                         .type           = WREPL_TYPE_MHOMED,
5618                         .state          = WREPL_STATE_TOMBSTONE,
5619                         .node           = WREPL_NODE_B,
5620                         .is_static      = False,
5621                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5622                         .ips            = addresses_B_1,
5623                         .apply_expected = False
5624                 },
5625         },
5626 /* 
5627  * special group vs. unique section
5628  */
5629         /*
5630          * sgroup,released vs. unique,active with same ip(s)
5631          */
5632         {
5633                 .line   = __location__,
5634                 .name   = _NBT_NAME("_SR_UA_SI", 0x1C, NULL),
5635                 .wins   = {
5636                         .nb_flags       = NBT_NM_GROUP,
5637                         .mhomed         = False,
5638                         .num_ips        = ctx->addresses_best_num,
5639                         .ips            = ctx->addresses_best,
5640                         .apply_expected = True
5641                 },
5642                 .replica= {
5643                         .type           = WREPL_TYPE_UNIQUE,
5644                         .state          = WREPL_STATE_ACTIVE,
5645                         .node           = WREPL_NODE_B,
5646                         .is_static      = False,
5647                         .num_ips        = ctx->addresses_best_num,
5648                         .ips            = ctx->addresses_best,
5649                         .apply_expected = True
5650                 },
5651         },
5652         /*
5653          * sgroup,released vs. unique,active with different ip(s)
5654          */
5655         {
5656                 .line   = __location__,
5657                 .name   = _NBT_NAME("_SR_UA_DI", 0x1C, NULL),
5658                 .wins   = {
5659                         .nb_flags       = NBT_NM_GROUP,
5660                         .mhomed         = False,
5661                         .num_ips        = ctx->addresses_best_num,
5662                         .ips            = ctx->addresses_best,
5663                         .apply_expected = True
5664                 },
5665                 .replica= {
5666                         .type           = WREPL_TYPE_UNIQUE,
5667                         .state          = WREPL_STATE_ACTIVE,
5668                         .node           = WREPL_NODE_B,
5669                         .is_static      = False,
5670                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5671                         .ips            = addresses_B_1,
5672                         .apply_expected = True
5673                 },
5674         },
5675         /*
5676          * sgroup,released vs. unique,tombstone with same ip(s)
5677          */
5678         {
5679                 .line   = __location__,
5680                 .name   = _NBT_NAME("_SR_UT_SI", 0x1C, NULL),
5681                 .wins   = {
5682                         .nb_flags       = NBT_NM_GROUP,
5683                         .mhomed         = False,
5684                         .num_ips        = ctx->addresses_best_num,
5685                         .ips            = ctx->addresses_best,
5686                         .apply_expected = True
5687                 },
5688                 .replica= {
5689                         .type           = WREPL_TYPE_UNIQUE,
5690                         .state          = WREPL_STATE_TOMBSTONE,
5691                         .node           = WREPL_NODE_B,
5692                         .is_static      = False,
5693                         .num_ips        = ctx->addresses_best_num,
5694                         .ips            = ctx->addresses_best,
5695                         .apply_expected = True
5696                 },
5697         },
5698         /*
5699          * sgroup,released vs. unique,tombstone with different ip(s)
5700          */
5701         {
5702                 .line   = __location__,
5703                 .name   = _NBT_NAME("_SR_UT_DI", 0x1C, NULL),
5704                 .wins   = {
5705                         .nb_flags       = NBT_NM_GROUP,
5706                         .mhomed         = False,
5707                         .num_ips        = ctx->addresses_best_num,
5708                         .ips            = ctx->addresses_best,
5709                         .apply_expected = True
5710                 },
5711                 .replica= {
5712                         .type           = WREPL_TYPE_UNIQUE,
5713                         .state          = WREPL_STATE_TOMBSTONE,
5714                         .node           = WREPL_NODE_B,
5715                         .is_static      = False,
5716                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5717                         .ips            = addresses_B_1,
5718                         .apply_expected = True
5719                 },
5720         },
5721 /* 
5722  * special group vs. group section
5723  */
5724         /*
5725          * sgroup,released vs. group,active with same ip(s)
5726          */
5727         {
5728                 .line   = __location__,
5729                 .name   = _NBT_NAME("_SR_GA_SI", 0x1C, NULL),
5730                 .wins   = {
5731                         .nb_flags       = NBT_NM_GROUP,
5732                         .mhomed         = False,
5733                         .num_ips        = ctx->addresses_best_num,
5734                         .ips            = ctx->addresses_best,
5735                         .apply_expected = True
5736                 },
5737                 .replica= {
5738                         .type           = WREPL_TYPE_GROUP,
5739                         .state          = WREPL_STATE_ACTIVE,
5740                         .node           = WREPL_NODE_B,
5741                         .is_static      = False,
5742                         .num_ips        = ctx->addresses_best_num,
5743                         .ips            = ctx->addresses_best,
5744                         .apply_expected = True
5745                 },
5746         },
5747         /*
5748          * sgroup,released vs. group,active with different ip(s)
5749          */
5750         {
5751                 .line   = __location__,
5752                 .name   = _NBT_NAME("_SR_GA_DI", 0x1C, NULL),
5753                 .wins   = {
5754                         .nb_flags       = NBT_NM_GROUP,
5755                         .mhomed         = False,
5756                         .num_ips        = ctx->addresses_best_num,
5757                         .ips            = ctx->addresses_best,
5758                         .apply_expected = True
5759                 },
5760                 .replica= {
5761                         .type           = WREPL_TYPE_GROUP,
5762                         .state          = WREPL_STATE_ACTIVE,
5763                         .node           = WREPL_NODE_B,
5764                         .is_static      = False,
5765                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5766                         .ips            = addresses_B_1,
5767                         .apply_expected = True
5768                 },
5769         },
5770         /*
5771          * sgroup,released vs. group,tombstone with same ip(s)
5772          */
5773         {
5774                 .line   = __location__,
5775                 .name   = _NBT_NAME("_SR_GT_SI", 0x1C, NULL),
5776                 .wins   = {
5777                         .nb_flags       = NBT_NM_GROUP,
5778                         .mhomed         = False,
5779                         .num_ips        = ctx->addresses_best_num,
5780                         .ips            = ctx->addresses_best,
5781                         .apply_expected = True
5782                 },
5783                 .replica= {
5784                         .type           = WREPL_TYPE_GROUP,
5785                         .state          = WREPL_STATE_TOMBSTONE,
5786                         .node           = WREPL_NODE_B,
5787                         .is_static      = False,
5788                         .num_ips        = ctx->addresses_best_num,
5789                         .ips            = ctx->addresses_best,
5790                         .apply_expected = True
5791                 },
5792         },
5793         /*
5794          * sgroup,released vs. group,tombstone with different ip(s)
5795          */
5796         {
5797                 .line   = __location__,
5798                 .name   = _NBT_NAME("_SR_GT_DI", 0x1C, NULL),
5799                 .wins   = {
5800                         .nb_flags       = NBT_NM_GROUP,
5801                         .mhomed         = False,
5802                         .num_ips        = ctx->addresses_best_num,
5803                         .ips            = ctx->addresses_best,
5804                         .apply_expected = True
5805                 },
5806                 .replica= {
5807                         .type           = WREPL_TYPE_GROUP,
5808                         .state          = WREPL_STATE_TOMBSTONE,
5809                         .node           = WREPL_NODE_B,
5810                         .is_static      = False,
5811                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5812                         .ips            = addresses_B_1,
5813                         .apply_expected = True
5814                 },
5815         },
5816 /* 
5817  * special group vs. special group section
5818  */
5819         /*
5820          * sgroup,released vs. sgroup,active with same ip(s)
5821          */
5822         {
5823                 .line   = __location__,
5824                 .name   = _NBT_NAME("_SR_SA_SI", 0x1C, NULL),
5825                 .wins   = {
5826                         .nb_flags       = NBT_NM_GROUP,
5827                         .mhomed         = False,
5828                         .num_ips        = ctx->addresses_best_num,
5829                         .ips            = ctx->addresses_best,
5830                         .apply_expected = True
5831                 },
5832                 .replica= {
5833                         .type           = WREPL_TYPE_SGROUP,
5834                         .state          = WREPL_STATE_ACTIVE,
5835                         .node           = WREPL_NODE_B,
5836                         .is_static      = False,
5837                         .num_ips        = ctx->addresses_best_num,
5838                         .ips            = ctx->addresses_best,
5839                         .apply_expected = True
5840                 },
5841         },
5842         /*
5843          * sgroup,released vs. sgroup,active with different ip(s)
5844          */
5845         {
5846                 .line   = __location__,
5847                 .name   = _NBT_NAME("_SR_SA_DI", 0x1C, NULL),
5848                 .wins   = {
5849                         .nb_flags       = NBT_NM_GROUP,
5850                         .mhomed         = False,
5851                         .num_ips        = ctx->addresses_best_num,
5852                         .ips            = ctx->addresses_best,
5853                         .apply_expected = True
5854                 },
5855                 .replica= {
5856                         .type           = WREPL_TYPE_SGROUP,
5857                         .state          = WREPL_STATE_ACTIVE,
5858                         .node           = WREPL_NODE_B,
5859                         .is_static      = False,
5860                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5861                         .ips            = addresses_B_1,
5862                         .apply_expected = True
5863                 },
5864         },
5865         /*
5866          * sgroup,released vs. sgroup,tombstone with same ip(s)
5867          */
5868         {
5869                 .line   = __location__,
5870                 .name   = _NBT_NAME("_SR_ST_SI", 0x1C, NULL),
5871                 .wins   = {
5872                         .nb_flags       = NBT_NM_GROUP,
5873                         .mhomed         = False,
5874                         .num_ips        = ctx->addresses_best_num,
5875                         .ips            = ctx->addresses_best,
5876                         .apply_expected = True
5877                 },
5878                 .replica= {
5879                         .type           = WREPL_TYPE_SGROUP,
5880                         .state          = WREPL_STATE_TOMBSTONE,
5881                         .node           = WREPL_NODE_B,
5882                         .is_static      = False,
5883                         .num_ips        = ctx->addresses_best_num,
5884                         .ips            = ctx->addresses_best,
5885                         .apply_expected = True
5886                 },
5887         },
5888         /*
5889          * sgroup,released vs. sgroup,tombstone with different ip(s)
5890          */
5891         {
5892                 .line   = __location__,
5893                 .name   = _NBT_NAME("_SR_ST_DI", 0x1C, NULL),
5894                 .wins   = {
5895                         .nb_flags       = NBT_NM_GROUP,
5896                         .mhomed         = False,
5897                         .num_ips        = ctx->addresses_best_num,
5898                         .ips            = ctx->addresses_best,
5899                         .apply_expected = True
5900                 },
5901                 .replica= {
5902                         .type           = WREPL_TYPE_SGROUP,
5903                         .state          = WREPL_STATE_TOMBSTONE,
5904                         .node           = WREPL_NODE_B,
5905                         .is_static      = False,
5906                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5907                         .ips            = addresses_B_1,
5908                         .apply_expected = True
5909                 },
5910         },
5911 /* 
5912  * special group vs. multi homed section
5913  */
5914         /*
5915          * sgroup,released vs. mhomed,active with same ip(s)
5916          */
5917         {
5918                 .line   = __location__,
5919                 .name   = _NBT_NAME("_SR_MA_SI", 0x1C, NULL),
5920                 .wins   = {
5921                         .nb_flags       = NBT_NM_GROUP,
5922                         .mhomed         = False,
5923                         .num_ips        = ctx->addresses_best_num,
5924                         .ips            = ctx->addresses_best,
5925                         .apply_expected = True
5926                 },
5927                 .replica= {
5928                         .type           = WREPL_TYPE_MHOMED,
5929                         .state          = WREPL_STATE_ACTIVE,
5930                         .node           = WREPL_NODE_B,
5931                         .is_static      = False,
5932                         .num_ips        = ctx->addresses_best_num,
5933                         .ips            = ctx->addresses_best,
5934                         .apply_expected = True
5935                 },
5936         },
5937         /*
5938          * sgroup,released vs. mhomed,active with different ip(s)
5939          */
5940         {
5941                 .line   = __location__,
5942                 .name   = _NBT_NAME("_SR_MA_DI", 0x1C, NULL),
5943                 .wins   = {
5944                         .nb_flags       = NBT_NM_GROUP,
5945                         .mhomed         = False,
5946                         .num_ips        = ctx->addresses_best_num,
5947                         .ips            = ctx->addresses_best,
5948                         .apply_expected = True
5949                 },
5950                 .replica= {
5951                         .type           = WREPL_TYPE_MHOMED,
5952                         .state          = WREPL_STATE_ACTIVE,
5953                         .node           = WREPL_NODE_B,
5954                         .is_static      = False,
5955                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5956                         .ips            = addresses_B_1,
5957                         .apply_expected = True
5958                 },
5959         },
5960         /*
5961          * sgroup,released vs. mhomed,tombstone with same ip(s)
5962          */
5963         {
5964                 .line   = __location__,
5965                 .name   = _NBT_NAME("_SR_MT_SI", 0x1C, NULL),
5966                 .wins   = {
5967                         .nb_flags       = NBT_NM_GROUP,
5968                         .mhomed         = False,
5969                         .num_ips        = ctx->addresses_best_num,
5970                         .ips            = ctx->addresses_best,
5971                         .apply_expected = True
5972                 },
5973                 .replica= {
5974                         .type           = WREPL_TYPE_MHOMED,
5975                         .state          = WREPL_STATE_TOMBSTONE,
5976                         .node           = WREPL_NODE_B,
5977                         .is_static      = False,
5978                         .num_ips        = ctx->addresses_best_num,
5979                         .ips            = ctx->addresses_best,
5980                         .apply_expected = True
5981                 },
5982         },
5983         /*
5984          * sgroup,released vs. mhomed,tombstone with different ip(s)
5985          */
5986         {
5987                 .line   = __location__,
5988                 .name   = _NBT_NAME("_SR_MT_DI", 0x1C, NULL),
5989                 .wins   = {
5990                         .nb_flags       = NBT_NM_GROUP,
5991                         .mhomed         = False,
5992                         .num_ips        = ctx->addresses_best_num,
5993                         .ips            = ctx->addresses_best,
5994                         .apply_expected = True
5995                 },
5996                 .replica= {
5997                         .type           = WREPL_TYPE_MHOMED,
5998                         .state          = WREPL_STATE_TOMBSTONE,
5999                         .node           = WREPL_NODE_B,
6000                         .is_static      = False,
6001                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6002                         .ips            = addresses_B_1,
6003                         .apply_expected = True
6004                 },
6005         },
6006 /* 
6007  * multi homed vs. unique section
6008  */
6009         /*
6010          * mhomed,released vs. unique,active with same ip(s)
6011          */
6012         {
6013                 .line   = __location__,
6014                 .name   = _NBT_NAME("_MR_UA_SI", 0x00, NULL),
6015                 .wins   = {
6016                         .nb_flags       = 0,
6017                         .mhomed         = True,
6018                         .num_ips        = ctx->addresses_best_num,
6019                         .ips            = ctx->addresses_best,
6020                         .apply_expected = True
6021                 },
6022                 .replica= {
6023                         .type           = WREPL_TYPE_UNIQUE,
6024                         .state          = WREPL_STATE_ACTIVE,
6025                         .node           = WREPL_NODE_B,
6026                         .is_static      = False,
6027                         .num_ips        = ctx->addresses_best_num,
6028                         .ips            = ctx->addresses_best,
6029                         .apply_expected = True
6030                 },
6031         },
6032         /*
6033          * mhomed,released vs. unique,active with different ip(s)
6034          */
6035         {
6036                 .line   = __location__,
6037                 .name   = _NBT_NAME("_MR_UA_DI", 0x00, NULL),
6038                 .wins   = {
6039                         .nb_flags       = 0,
6040                         .mhomed         = True,
6041                         .num_ips        = ctx->addresses_best_num,
6042                         .ips            = ctx->addresses_best,
6043                         .apply_expected = True
6044                 },
6045                 .replica= {
6046                         .type           = WREPL_TYPE_UNIQUE,
6047                         .state          = WREPL_STATE_ACTIVE,
6048                         .node           = WREPL_NODE_B,
6049                         .is_static      = False,
6050                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6051                         .ips            = addresses_B_1,
6052                         .apply_expected = True
6053                 },
6054         },
6055         /*
6056          * mhomed,released vs. unique,tombstone with same ip(s)
6057          */
6058         {
6059                 .line   = __location__,
6060                 .name   = _NBT_NAME("_MR_UT_SI", 0x00, NULL),
6061                 .wins   = {
6062                         .nb_flags       = 0,
6063                         .mhomed         = True,
6064                         .num_ips        = ctx->addresses_best_num,
6065                         .ips            = ctx->addresses_best,
6066                         .apply_expected = True
6067                 },
6068                 .replica= {
6069                         .type           = WREPL_TYPE_UNIQUE,
6070                         .state          = WREPL_STATE_TOMBSTONE,
6071                         .node           = WREPL_NODE_B,
6072                         .is_static      = False,
6073                         .num_ips        = ctx->addresses_best_num,
6074                         .ips            = ctx->addresses_best,
6075                         .apply_expected = True
6076                 },
6077         },
6078         /*
6079          * mhomed,released vs. unique,tombstone with different ip(s)
6080          */
6081         {
6082                 .line   = __location__,
6083                 .name   = _NBT_NAME("_MR_UT_DI", 0x00, NULL),
6084                 .wins   = {
6085                         .nb_flags       = 0,
6086                         .mhomed         = True,
6087                         .num_ips        = ctx->addresses_best_num,
6088                         .ips            = ctx->addresses_best,
6089                         .apply_expected = True
6090                 },
6091                 .replica= {
6092                         .type           = WREPL_TYPE_UNIQUE,
6093                         .state          = WREPL_STATE_TOMBSTONE,
6094                         .node           = WREPL_NODE_B,
6095                         .is_static      = False,
6096                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6097                         .ips            = addresses_B_1,
6098                         .apply_expected = True
6099                 },
6100         },
6101 /* 
6102  * multi homed vs. group section
6103  */
6104         /*
6105          * mhomed,released vs. group,active with same ip(s)
6106          */
6107         {
6108                 .line   = __location__,
6109                 .name   = _NBT_NAME("_MR_GA_SI", 0x00, NULL),
6110                 .wins   = {
6111                         .nb_flags       = 0,
6112                         .mhomed         = True,
6113                         .num_ips        = ctx->addresses_best_num,
6114                         .ips            = ctx->addresses_best,
6115                         .apply_expected = True
6116                 },
6117                 .replica= {
6118                         .type           = WREPL_TYPE_GROUP,
6119                         .state          = WREPL_STATE_ACTIVE,
6120                         .node           = WREPL_NODE_B,
6121                         .is_static      = False,
6122                         .num_ips        = ctx->addresses_best_num,
6123                         .ips            = ctx->addresses_best,
6124                         .apply_expected = True
6125                 },
6126         },
6127         /*
6128          * mhomed,released vs. group,active with different ip(s)
6129          */
6130         {
6131                 .line   = __location__,
6132                 .name   = _NBT_NAME("_MR_GA_DI", 0x00, NULL),
6133                 .wins   = {
6134                         .nb_flags       = 0,
6135                         .mhomed         = True,
6136                         .num_ips        = ctx->addresses_best_num,
6137                         .ips            = ctx->addresses_best,
6138                         .apply_expected = True
6139                 },
6140                 .replica= {
6141                         .type           = WREPL_TYPE_GROUP,
6142                         .state          = WREPL_STATE_ACTIVE,
6143                         .node           = WREPL_NODE_B,
6144                         .is_static      = False,
6145                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6146                         .ips            = addresses_B_1,
6147                         .apply_expected = True
6148                 },
6149         },
6150         /*
6151          * mhomed,released vs. group,tombstone with same ip(s)
6152          */
6153         {
6154                 .line   = __location__,
6155                 .name   = _NBT_NAME("_MR_GT_SI", 0x00, NULL),
6156                 .wins   = {
6157                         .nb_flags       = 0,
6158                         .mhomed         = True,
6159                         .num_ips        = ctx->addresses_best_num,
6160                         .ips            = ctx->addresses_best,
6161                         .apply_expected = True
6162                 },
6163                 .replica= {
6164                         .type           = WREPL_TYPE_GROUP,
6165                         .state          = WREPL_STATE_TOMBSTONE,
6166                         .node           = WREPL_NODE_B,
6167                         .is_static      = False,
6168                         .num_ips        = ctx->addresses_best_num,
6169                         .ips            = ctx->addresses_best,
6170                         .apply_expected = True
6171                 },
6172         },
6173         /*
6174          * mhomed,released vs. group,tombstone with different ip(s)
6175          */
6176         {
6177                 .line   = __location__,
6178                 .name   = _NBT_NAME("_MR_GT_DI", 0x00, NULL),
6179                 .wins   = {
6180                         .nb_flags       = 0,
6181                         .mhomed         = True,
6182                         .num_ips        = ctx->addresses_best_num,
6183                         .ips            = ctx->addresses_best,
6184                         .apply_expected = True
6185                 },
6186                 .replica= {
6187                         .type           = WREPL_TYPE_GROUP,
6188                         .state          = WREPL_STATE_TOMBSTONE,
6189                         .node           = WREPL_NODE_B,
6190                         .is_static      = False,
6191                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6192                         .ips            = addresses_B_1,
6193                         .apply_expected = True
6194                 },
6195         },
6196 /* 
6197  * multi homed vs. special group section
6198  */
6199         /*
6200          * mhomed,released vs. sgroup,active with same ip(s)
6201          */
6202         {
6203                 .line   = __location__,
6204                 .name   = _NBT_NAME("_MR_SA_SI", 0x00, NULL),
6205                 .wins   = {
6206                         .nb_flags       = 0,
6207                         .mhomed         = True,
6208                         .num_ips        = ctx->addresses_best_num,
6209                         .ips            = ctx->addresses_best,
6210                         .apply_expected = True
6211                 },
6212                 .replica= {
6213                         .type           = WREPL_TYPE_SGROUP,
6214                         .state          = WREPL_STATE_ACTIVE,
6215                         .node           = WREPL_NODE_B,
6216                         .is_static      = False,
6217                         .num_ips        = ctx->addresses_best_num,
6218                         .ips            = ctx->addresses_best,
6219                         .apply_expected = True
6220                 },
6221         },
6222         /*
6223          * mhomed,released vs. sgroup,active with different ip(s)
6224          */
6225         {
6226                 .line   = __location__,
6227                 .name   = _NBT_NAME("_MR_SA_DI", 0x00, NULL),
6228                 .wins   = {
6229                         .nb_flags       = 0,
6230                         .mhomed         = True,
6231                         .num_ips        = ctx->addresses_best_num,
6232                         .ips            = ctx->addresses_best,
6233                         .apply_expected = True
6234                 },
6235                 .replica= {
6236                         .type           = WREPL_TYPE_SGROUP,
6237                         .state          = WREPL_STATE_ACTIVE,
6238                         .node           = WREPL_NODE_B,
6239                         .is_static      = False,
6240                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6241                         .ips            = addresses_B_1,
6242                         .apply_expected = True
6243                 },
6244         },
6245         /*
6246          * mhomed,released vs. sgroup,tombstone with same ip(s)
6247          */
6248         {
6249                 .line   = __location__,
6250                 .name   = _NBT_NAME("_MR_ST_SI", 0x00, NULL),
6251                 .wins   = {
6252                         .nb_flags       = 0,
6253                         .mhomed         = True,
6254                         .num_ips        = ctx->addresses_best_num,
6255                         .ips            = ctx->addresses_best,
6256                         .apply_expected = True
6257                 },
6258                 .replica= {
6259                         .type           = WREPL_TYPE_SGROUP,
6260                         .state          = WREPL_STATE_TOMBSTONE,
6261                         .node           = WREPL_NODE_B,
6262                         .is_static      = False,
6263                         .num_ips        = ctx->addresses_best_num,
6264                         .ips            = ctx->addresses_best,
6265                         .apply_expected = True
6266                 },
6267         },
6268         /*
6269          * mhomed,released vs. sgroup,tombstone with different ip(s)
6270          */
6271         {
6272                 .line   = __location__,
6273                 .name   = _NBT_NAME("_MR_ST_DI", 0x00, NULL),
6274                 .wins   = {
6275                         .nb_flags       = 0,
6276                         .mhomed         = True,
6277                         .num_ips        = ctx->addresses_best_num,
6278                         .ips            = ctx->addresses_best,
6279                         .apply_expected = True
6280                 },
6281                 .replica= {
6282                         .type           = WREPL_TYPE_SGROUP,
6283                         .state          = WREPL_STATE_TOMBSTONE,
6284                         .node           = WREPL_NODE_B,
6285                         .is_static      = False,
6286                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6287                         .ips            = addresses_B_1,
6288                         .apply_expected = True
6289                 },
6290         },
6291 /* 
6292  * multi homed vs. multi homed section
6293  */
6294         /*
6295          * mhomed,released vs. mhomed,active with same ip(s)
6296          */
6297         {
6298                 .line   = __location__,
6299                 .name   = _NBT_NAME("_MR_MA_SI", 0x00, NULL),
6300                 .wins   = {
6301                         .nb_flags       = 0,
6302                         .mhomed         = True,
6303                         .num_ips        = ctx->addresses_best_num,
6304                         .ips            = ctx->addresses_best,
6305                         .apply_expected = True
6306                 },
6307                 .replica= {
6308                         .type           = WREPL_TYPE_MHOMED,
6309                         .state          = WREPL_STATE_ACTIVE,
6310                         .node           = WREPL_NODE_B,
6311                         .is_static      = False,
6312                         .num_ips        = ctx->addresses_best_num,
6313                         .ips            = ctx->addresses_best,
6314                         .apply_expected = True
6315                 },
6316         },
6317         /*
6318          * mhomed,released vs. mhomed,active with different ip(s)
6319          */
6320         {
6321                 .line   = __location__,
6322                 .name   = _NBT_NAME("_MR_MA_DI", 0x00, NULL),
6323                 .wins   = {
6324                         .nb_flags       = 0,
6325                         .mhomed         = True,
6326                         .num_ips        = ctx->addresses_best_num,
6327                         .ips            = ctx->addresses_best,
6328                         .apply_expected = True
6329                 },
6330                 .replica= {
6331                         .type           = WREPL_TYPE_MHOMED,
6332                         .state          = WREPL_STATE_ACTIVE,
6333                         .node           = WREPL_NODE_B,
6334                         .is_static      = False,
6335                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6336                         .ips            = addresses_B_1,
6337                         .apply_expected = True
6338                 },
6339         },
6340         /*
6341          * mhomed,released vs. mhomed,tombstone with same ip(s)
6342          */
6343         {
6344                 .line   = __location__,
6345                 .name   = _NBT_NAME("_MR_MT_SI", 0x00, NULL),
6346                 .wins   = {
6347                         .nb_flags       = 0,
6348                         .mhomed         = True,
6349                         .num_ips        = ctx->addresses_best_num,
6350                         .ips            = ctx->addresses_best,
6351                         .apply_expected = True
6352                 },
6353                 .replica= {
6354                         .type           = WREPL_TYPE_MHOMED,
6355                         .state          = WREPL_STATE_TOMBSTONE,
6356                         .node           = WREPL_NODE_B,
6357                         .is_static      = False,
6358                         .num_ips        = ctx->addresses_best_num,
6359                         .ips            = ctx->addresses_best,
6360                         .apply_expected = True
6361                 },
6362         },
6363         /*
6364          * mhomed,released vs. mhomed,tombstone with different ip(s)
6365          */
6366         {
6367                 .line   = __location__,
6368                 .name   = _NBT_NAME("_MR_MT_DI", 0x00, NULL),
6369                 .wins   = {
6370                         .nb_flags       = 0,
6371                         .mhomed         = True,
6372                         .num_ips        = ctx->addresses_best_num,
6373                         .ips            = ctx->addresses_best,
6374                         .apply_expected = True
6375                 },
6376                 .replica= {
6377                         .type           = WREPL_TYPE_MHOMED,
6378                         .state          = WREPL_STATE_TOMBSTONE,
6379                         .node           = WREPL_NODE_B,
6380                         .is_static      = False,
6381                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6382                         .ips            = addresses_B_1,
6383                         .apply_expected = True
6384                 },
6385         },
6386         };
6387
6388         if (!ctx) return False;
6389
6390         printf("Test Replica records vs. owned released records\n");
6391
6392         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
6393                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
6394                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
6395
6396                 /*
6397                  * Setup Register
6398                  */
6399                 name_register->in.name          = records[i].name;
6400                 name_register->in.dest_addr     = ctx->address;
6401                 name_register->in.address       = records[i].wins.ips[0].ip;
6402                 name_register->in.nb_flags      = records[i].wins.nb_flags;
6403                 name_register->in.register_demand= False;
6404                 name_register->in.broadcast     = False;
6405                 name_register->in.multi_homed   = records[i].wins.mhomed;
6406                 name_register->in.ttl           = 300000;
6407                 name_register->in.timeout       = 70;
6408                 name_register->in.retries       = 0;
6409
6410                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
6411                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6412                         printf("No response from %s for name register\n", ctx->address);
6413                         ret = False;
6414                 }
6415                 if (!NT_STATUS_IS_OK(status)) {
6416                         printf("Bad response from %s for name register - %s\n",
6417                                ctx->address, nt_errstr(status));
6418                         ret = False;
6419                 }
6420                 CHECK_VALUE(name_register->out.rcode, 0);
6421                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
6422                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
6423                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
6424                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
6425                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
6426
6427                 /* release the record */
6428                 release->in.name        = records[i].name;
6429                 release->in.dest_addr   = ctx->address;
6430                 release->in.address     = records[i].wins.ips[0].ip;
6431                 release->in.nb_flags    = records[i].wins.nb_flags;
6432                 release->in.broadcast   = False;
6433                 release->in.timeout     = 30;
6434                 release->in.retries     = 0;
6435
6436                 status = nbt_name_release(ctx->nbtsock, ctx, release);
6437                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6438                         printf("No response from %s for name release\n", ctx->address);
6439                         return False;
6440                 }
6441                 if (!NT_STATUS_IS_OK(status)) {
6442                         printf("Bad response from %s for name query - %s\n",
6443                                ctx->address, nt_errstr(status));
6444                         return False;
6445                 }
6446                 CHECK_VALUE(release->out.rcode, 0);
6447
6448                 /*
6449                  * Setup Replica
6450                  */
6451                 wins_name->name         = &records[i].name;
6452                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
6453                                                            records[i].replica.state,
6454                                                            records[i].replica.node,
6455                                                            records[i].replica.is_static);
6456                 wins_name->id           = ++ctx->b.max_version;
6457                 if (wins_name->flags & 2) {
6458                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
6459                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
6460                 } else {
6461                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
6462                 }
6463                 wins_name->unknown      = "255.255.255.255";
6464
6465                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6466                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
6467                                              records[i].replica.apply_expected);
6468
6469                 if (records[i].replica.apply_expected) {
6470                         wins_name->name         = &records[i].name;
6471                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
6472                                                                    WREPL_STATE_TOMBSTONE,
6473                                                                    WREPL_NODE_B, False);
6474                         wins_name->id           = ++ctx->b.max_version;
6475                         wins_name->addresses.ip = addresses_B_1[0].ip;
6476                         wins_name->unknown      = "255.255.255.255";
6477
6478                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6479                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
6480                 } else {
6481                         release->in.name        = records[i].name;
6482                         release->in.dest_addr   = ctx->address;
6483                         release->in.address     = records[i].wins.ips[0].ip;
6484                         release->in.nb_flags    = records[i].wins.nb_flags;
6485                         release->in.broadcast   = False;
6486                         release->in.timeout     = 30;
6487                         release->in.retries     = 0;
6488
6489                         status = nbt_name_release(ctx->nbtsock, ctx, release);
6490                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6491                                 printf("No response from %s for name release\n", ctx->address);
6492                                 return False;
6493                         }
6494                         if (!NT_STATUS_IS_OK(status)) {
6495                                 printf("Bad response from %s for name query - %s\n",
6496                                        ctx->address, nt_errstr(status));
6497                                 return False;
6498                         }
6499                         CHECK_VALUE(release->out.rcode, 0);
6500                 }
6501 done:
6502                 if (!ret) {
6503                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
6504                         return ret;
6505                 }
6506         }
6507
6508         return ret;
6509 }
6510
6511 struct test_conflict_owned_active_vs_replica_struct {
6512         const char *line; /* just better debugging */
6513         const char *section; /* just better debugging */
6514         struct nbt_name name;
6515         BOOL skip;
6516         struct {
6517                 uint32_t nb_flags;
6518                 BOOL mhomed;
6519                 uint32_t num_ips;
6520                 const struct wrepl_ip *ips;
6521                 BOOL apply_expected;
6522         } wins;
6523         struct {
6524                 uint32_t timeout;
6525                 BOOL positive;
6526                 BOOL expect_release;
6527                 BOOL late_release;
6528                 BOOL ret;
6529                 /* when num_ips == 0, then .wins.ips are used */
6530                 uint32_t num_ips;
6531                 const struct wrepl_ip *ips;
6532         } defend;
6533         struct {
6534                 enum wrepl_name_type type;
6535                 enum wrepl_name_state state;
6536                 enum wrepl_name_node node;
6537                 BOOL is_static;
6538                 uint32_t num_ips;
6539                 const struct wrepl_ip *ips;
6540                 BOOL apply_expected;
6541                 BOOL mhomed_merge;
6542                 BOOL sgroup_merge;
6543         } replica;
6544 };
6545
6546 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
6547                                                           struct nbt_name_packet *req_packet, 
6548                                                           const struct nbt_peer_socket *src);
6549
6550 static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx)
6551 {
6552         BOOL ret = True;
6553         NTSTATUS status;
6554         struct wrepl_wins_name wins_name_;
6555         struct wrepl_wins_name *wins_name = &wins_name_;
6556         struct nbt_name_register name_register_;
6557         struct nbt_name_register *name_register = &name_register_;
6558         struct nbt_name_release release_;
6559         struct nbt_name_release *release = &release_;
6560         uint32_t i;
6561         struct test_conflict_owned_active_vs_replica_struct records[] = {
6562 /* 
6563  * unique vs. unique section
6564  */
6565         /*
6566          * unique,active vs. unique,active with same ip(s), unchecked
6567          */
6568         {
6569                 .line   = __location__,
6570                 .name   = _NBT_NAME("_UA_UA_SI_U", 0x00, NULL),
6571                 .wins   = {
6572                         .nb_flags       = 0,
6573                         .mhomed         = False,
6574                         .num_ips        = ctx->addresses_best_num,
6575                         .ips            = ctx->addresses_best,
6576                         .apply_expected = True
6577                 },
6578                 .defend = {
6579                         .timeout        = 0,
6580                 },
6581                 .replica= {
6582                         .type           = WREPL_TYPE_UNIQUE,
6583                         .state          = WREPL_STATE_ACTIVE,
6584                         .node           = WREPL_NODE_B,
6585                         .is_static      = False,
6586                         .num_ips        = ctx->addresses_best_num,
6587                         .ips            = ctx->addresses_best,
6588                         .apply_expected = True
6589                 },
6590         },
6591         /*
6592          * unique,active vs. unique,active with different ip(s), positive response
6593          */
6594         {
6595                 .line   = __location__,
6596                 .name   = _NBT_NAME("_UA_UA_DI_P", 0x00, NULL),
6597                 .wins   = {
6598                         .nb_flags       = 0,
6599                         .mhomed         = False,
6600                         .num_ips        = ctx->addresses_best_num,
6601                         .ips            = ctx->addresses_best,
6602                         .apply_expected = True
6603                 },
6604                 .defend = {
6605                         .timeout        = 10,
6606                         .positive       = True,
6607                 },
6608                 .replica= {
6609                         .type           = WREPL_TYPE_UNIQUE,
6610                         .state          = WREPL_STATE_ACTIVE,
6611                         .node           = WREPL_NODE_B,
6612                         .is_static      = False,
6613                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6614                         .ips            = addresses_B_1,
6615                         .apply_expected = False
6616                 },
6617         },
6618         /*
6619          * unique,active vs. unique,active with different ip(s), positive response other ips
6620          */
6621         {
6622                 .line   = __location__,
6623                 .name   = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL),
6624                 .wins   = {
6625                         .nb_flags       = 0,
6626                         .mhomed         = False,
6627                         .num_ips        = ctx->addresses_best_num,
6628                         .ips            = ctx->addresses_best,
6629                         .apply_expected = True
6630                 },
6631                 .defend = {
6632                         .timeout        = 10,
6633                         .positive       = True,
6634                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
6635                         .ips            = addresses_A_3_4,
6636                 },
6637                 .replica= {
6638                         .type           = WREPL_TYPE_UNIQUE,
6639                         .state          = WREPL_STATE_ACTIVE,
6640                         .node           = WREPL_NODE_B,
6641                         .is_static      = False,
6642                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6643                         .ips            = addresses_B_1,
6644                         .apply_expected = False
6645                 },
6646         },
6647         /*
6648          * unique,active vs. unique,active with different ip(s), negative response
6649          */
6650         {
6651                 .line   = __location__,
6652                 .name   = _NBT_NAME("_UA_UA_DI_N", 0x00, NULL),
6653                 .wins   = {
6654                         .nb_flags       = 0,
6655                         .mhomed         = False,
6656                         .num_ips        = ctx->addresses_best_num,
6657                         .ips            = ctx->addresses_best,
6658                         .apply_expected = True
6659                 },
6660                 .defend = {
6661                         .timeout        = 10,
6662                         .positive       = False,
6663                 },
6664                 .replica= {
6665                         .type           = WREPL_TYPE_UNIQUE,
6666                         .state          = WREPL_STATE_ACTIVE,
6667                         .node           = WREPL_NODE_B,
6668                         .is_static      = False,
6669                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6670                         .ips            = addresses_B_1,
6671                         .apply_expected = True
6672                 },
6673         },
6674         /*
6675          * unique,active vs. unique,tombstone with same ip(s), unchecked
6676          */
6677         {
6678                 .line   = __location__,
6679                 .name   = _NBT_NAME("_UA_UT_SI_U", 0x00, NULL),
6680                 .wins   = {
6681                         .nb_flags       = 0,
6682                         .mhomed         = False,
6683                         .num_ips        = ctx->addresses_best_num,
6684                         .ips            = ctx->addresses_best,
6685                         .apply_expected = True
6686                 },
6687                 .defend = {
6688                         .timeout        = 0,
6689                 },
6690                 .replica= {
6691                         .type           = WREPL_TYPE_UNIQUE,
6692                         .state          = WREPL_STATE_TOMBSTONE,
6693                         .node           = WREPL_NODE_B,
6694                         .is_static      = False,
6695                         .num_ips        = ctx->addresses_best_num,
6696                         .ips            = ctx->addresses_best,
6697                         .apply_expected = False
6698                 },
6699         },
6700         /*
6701          * unique,active vs. unique,tombstone with different ip(s), unchecked
6702          */
6703         {
6704                 .line   = __location__,
6705                 .name   = _NBT_NAME("_UA_UT_DI_U", 0x00, NULL),
6706                 .wins   = {
6707                         .nb_flags       = 0,
6708                         .mhomed         = False,
6709                         .num_ips        = ctx->addresses_best_num,
6710                         .ips            = ctx->addresses_best,
6711                         .apply_expected = True
6712                 },
6713                 .defend = {
6714                         .timeout        = 0,
6715                 },
6716                 .replica= {
6717                         .type           = WREPL_TYPE_UNIQUE,
6718                         .state          = WREPL_STATE_TOMBSTONE,
6719                         .node           = WREPL_NODE_B,
6720                         .is_static      = False,
6721                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6722                         .ips            = addresses_B_1,
6723                         .apply_expected = False
6724                 },
6725         },
6726 /* 
6727  * unique vs. group section
6728  */
6729         /*
6730          * unique,active vs. group,active with same ip(s), release expected
6731          */
6732         {
6733                 .line   = __location__,
6734                 .name   = _NBT_NAME("_UA_GA_SI_R", 0x00, NULL),
6735                 .wins   = {
6736                         .nb_flags       = 0,
6737                         .mhomed         = False,
6738                         .num_ips        = ctx->addresses_best_num,
6739                         .ips            = ctx->addresses_best,
6740                         .apply_expected = True
6741                 },
6742                 .defend = {
6743                         .timeout        = 10,
6744                         .expect_release = True,
6745                 },
6746                 .replica= {
6747                         .type           = WREPL_TYPE_GROUP,
6748                         .state          = WREPL_STATE_ACTIVE,
6749                         .node           = WREPL_NODE_B,
6750                         .is_static      = False,
6751                         .num_ips        = ctx->addresses_best_num,
6752                         .ips            = ctx->addresses_best,
6753                         .apply_expected = True
6754                 },
6755         },
6756         /*
6757          * unique,active vs. group,active with different ip(s), release expected
6758          */
6759         {
6760                 .line   = __location__,
6761                 .name   = _NBT_NAME("_UA_GA_DI_R", 0x00, NULL),
6762                 .wins   = {
6763                         .nb_flags       = 0,
6764                         .mhomed         = False,
6765                         .num_ips        = ctx->addresses_best_num,
6766                         .ips            = ctx->addresses_best,
6767                         .apply_expected = True
6768                 },
6769                 .defend = {
6770                         .timeout        = 10,
6771                         .expect_release = True,
6772                 },
6773                 .replica= {
6774                         .type           = WREPL_TYPE_GROUP,
6775                         .state          = WREPL_STATE_ACTIVE,
6776                         .node           = WREPL_NODE_B,
6777                         .is_static      = False,
6778                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6779                         .ips            = addresses_B_1,
6780                         .apply_expected = True
6781                 },
6782         },
6783         /*
6784          * unique,active vs. group,tombstone with same ip(s), unchecked
6785          */
6786         {
6787                 .line   = __location__,
6788                 .name   = _NBT_NAME("_UA_GT_SI_U", 0x00, NULL),
6789                 .wins   = {
6790                         .nb_flags       = 0,
6791                         .mhomed         = False,
6792                         .num_ips        = ctx->addresses_best_num,
6793                         .ips            = ctx->addresses_best,
6794                         .apply_expected = True
6795                 },
6796                 .defend = {
6797                         .timeout        = 0,
6798                 },
6799                 .replica= {
6800                         .type           = WREPL_TYPE_GROUP,
6801                         .state          = WREPL_STATE_TOMBSTONE,
6802                         .node           = WREPL_NODE_B,
6803                         .is_static      = False,
6804                         .num_ips        = ctx->addresses_best_num,
6805                         .ips            = ctx->addresses_best,
6806                         .apply_expected = False
6807                 },
6808         },
6809         /*
6810          * unique,active vs. group,tombstone with different ip(s), unchecked
6811          */
6812         {
6813                 .line   = __location__,
6814                 .name   = _NBT_NAME("_UA_GT_DI_U", 0x00, NULL),
6815                 .wins   = {
6816                         .nb_flags       = 0,
6817                         .mhomed         = False,
6818                         .num_ips        = ctx->addresses_best_num,
6819                         .ips            = ctx->addresses_best,
6820                         .apply_expected = True
6821                 },
6822                 .defend = {
6823                         .timeout        = 0,
6824                 },
6825                 .replica= {
6826                         .type           = WREPL_TYPE_GROUP,
6827                         .state          = WREPL_STATE_TOMBSTONE,
6828                         .node           = WREPL_NODE_B,
6829                         .is_static      = False,
6830                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6831                         .ips            = addresses_B_1,
6832                         .apply_expected = False
6833                 },
6834         },
6835 /* 
6836  * unique vs. special group section
6837  */
6838         /*
6839          * unique,active vs. sgroup,active with same ip(s), release expected
6840          */
6841         {
6842                 .line   = __location__,
6843                 .name   = _NBT_NAME("_UA_SA_SI_R", 0x00, NULL),
6844                 .wins   = {
6845                         .nb_flags       = 0,
6846                         .mhomed         = False,
6847                         .num_ips        = ctx->addresses_best_num,
6848                         .ips            = ctx->addresses_best,
6849                         .apply_expected = True
6850                 },
6851                 .defend = {
6852                         .timeout        = 10,
6853                         .expect_release = True,
6854                 },
6855                 .replica= {
6856                         .type           = WREPL_TYPE_SGROUP,
6857                         .state          = WREPL_STATE_ACTIVE,
6858                         .node           = WREPL_NODE_B,
6859                         .is_static      = False,
6860                         .num_ips        = ctx->addresses_best_num,
6861                         .ips            = ctx->addresses_best,
6862                         .apply_expected = True
6863                 },
6864         },
6865         /*
6866          * unique,active vs. group,active with different ip(s), release expected
6867          */
6868         {
6869                 .line   = __location__,
6870                 .name   = _NBT_NAME("_UA_SA_DI_R", 0x00, NULL),
6871                 .wins   = {
6872                         .nb_flags       = 0,
6873                         .mhomed         = False,
6874                         .num_ips        = ctx->addresses_best_num,
6875                         .ips            = ctx->addresses_best,
6876                         .apply_expected = True
6877                 },
6878                 .defend = {
6879                         .timeout        = 10,
6880                         .expect_release = True,
6881                 },
6882                 .replica= {
6883                         .type           = WREPL_TYPE_SGROUP,
6884                         .state          = WREPL_STATE_ACTIVE,
6885                         .node           = WREPL_NODE_B,
6886                         .is_static      = False,
6887                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6888                         .ips            = addresses_B_1,
6889                         .apply_expected = True
6890                 },
6891         },
6892         /*
6893          * unique,active vs. sgroup,tombstone with same ip(s), unchecked
6894          */
6895         {
6896                 .line   = __location__,
6897                 .name   = _NBT_NAME("_UA_ST_SI_U", 0x00, NULL),
6898                 .wins   = {
6899                         .nb_flags       = 0,
6900                         .mhomed         = False,
6901                         .num_ips        = ctx->addresses_best_num,
6902                         .ips            = ctx->addresses_best,
6903                         .apply_expected = True
6904                 },
6905                 .defend = {
6906                         .timeout        = 0,
6907                 },
6908                 .replica= {
6909                         .type           = WREPL_TYPE_SGROUP,
6910                         .state          = WREPL_STATE_TOMBSTONE,
6911                         .node           = WREPL_NODE_B,
6912                         .is_static      = False,
6913                         .num_ips        = ctx->addresses_best_num,
6914                         .ips            = ctx->addresses_best,
6915                         .apply_expected = False
6916                 },
6917         },
6918         /*
6919          * unique,active vs. sgroup,tombstone with different ip(s), unchecked
6920          */
6921         {
6922                 .line   = __location__,
6923                 .name   = _NBT_NAME("_UA_ST_DI_U", 0x00, NULL),
6924                 .wins   = {
6925                         .nb_flags       = 0,
6926                         .mhomed         = False,
6927                         .num_ips        = ctx->addresses_best_num,
6928                         .ips            = ctx->addresses_best,
6929                         .apply_expected = True
6930                 },
6931                 .defend = {
6932                         .timeout        = 0,
6933                 },
6934                 .replica= {
6935                         .type           = WREPL_TYPE_SGROUP,
6936                         .state          = WREPL_STATE_TOMBSTONE,
6937                         .node           = WREPL_NODE_B,
6938                         .is_static      = False,
6939                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6940                         .ips            = addresses_B_1,
6941                         .apply_expected = False
6942                 },
6943         },
6944 /* 
6945  * unique vs. multi homed section
6946  */
6947         /*
6948          * unique,active vs. mhomed,active with same ip(s), unchecked
6949          */
6950         {
6951                 .line   = __location__,
6952                 .name   = _NBT_NAME("_UA_MA_SI_U", 0x00, NULL),
6953                 .wins   = {
6954                         .nb_flags       = 0,
6955                         .mhomed         = False,
6956                         .num_ips        = ctx->addresses_best_num,
6957                         .ips            = ctx->addresses_best,
6958                         .apply_expected = True
6959                 },
6960                 .defend = {
6961                         .timeout        = 0,
6962                 },
6963                 .replica= {
6964                         .type           = WREPL_TYPE_MHOMED,
6965                         .state          = WREPL_STATE_ACTIVE,
6966                         .node           = WREPL_NODE_B,
6967                         .is_static      = False,
6968                         .num_ips        = ctx->addresses_best_num,
6969                         .ips            = ctx->addresses_best,
6970                         .apply_expected = True
6971                 },
6972         },
6973         /*
6974          * unique,active vs. mhomed,active with superset ip(s), unchecked
6975          */
6976         {
6977                 .line   = __location__,
6978                 .name   = _NBT_NAME("_UA_MA_SP_U", 0x00, NULL),
6979                 .wins   = {
6980                         .nb_flags       = 0,
6981                         .mhomed         = False,
6982                         .num_ips        = ctx->addresses_best_num,
6983                         .ips            = ctx->addresses_best,
6984                         .apply_expected = True
6985                 },
6986                 .defend = {
6987                         .timeout        = 0,
6988                 },
6989                 .replica= {
6990                         .type           = WREPL_TYPE_MHOMED,
6991                         .state          = WREPL_STATE_ACTIVE,
6992                         .node           = WREPL_NODE_B,
6993                         .is_static      = False,
6994                         .num_ips        = ctx->addresses_all_num,
6995                         .ips            = ctx->addresses_all,
6996                         .apply_expected = True
6997                 },
6998         },
6999         /*
7000          * unique,active vs. mhomed,active with different ip(s), positive response
7001          */
7002         {
7003                 .line   = __location__,
7004                 .name   = _NBT_NAME("_UA_MA_DI_P", 0x00, NULL),
7005                 .wins   = {
7006                         .nb_flags       = 0,
7007                         .mhomed         = False,
7008                         .num_ips        = ctx->addresses_best_num,
7009                         .ips            = ctx->addresses_best,
7010                         .apply_expected = True
7011                 },
7012                 .defend = {
7013                         .timeout        = 10,
7014                         .positive       = True,
7015                 },
7016                 .replica= {
7017                         .type           = WREPL_TYPE_MHOMED,
7018                         .state          = WREPL_STATE_ACTIVE,
7019                         .node           = WREPL_NODE_B,
7020                         .is_static      = False,
7021                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7022                         .ips            = addresses_B_3_4,
7023                         .apply_expected = False
7024                 },
7025         },
7026         /*
7027          * unique,active vs. mhomed,active with different ip(s), positive response other ips
7028          */
7029         {
7030                 .line   = __location__,
7031                 .name   = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL),
7032                 .wins   = {
7033                         .nb_flags       = 0,
7034                         .mhomed         = False,
7035                         .num_ips        = ctx->addresses_best_num,
7036                         .ips            = ctx->addresses_best,
7037                         .apply_expected = True
7038                 },
7039                 .defend = {
7040                         .timeout        = 10,
7041                         .positive       = True,
7042                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7043                         .ips            = addresses_A_3_4,
7044                 },
7045                 .replica= {
7046                         .type           = WREPL_TYPE_MHOMED,
7047                         .state          = WREPL_STATE_ACTIVE,
7048                         .node           = WREPL_NODE_B,
7049                         .is_static      = False,
7050                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7051                         .ips            = addresses_B_3_4,
7052                         .apply_expected = False
7053                 },
7054         },
7055         /*
7056          * unique,active vs. mhomed,active with different ip(s), negative response
7057          */
7058         {
7059                 .line   = __location__,
7060                 .name   = _NBT_NAME("_UA_MA_DI_N", 0x00, NULL),
7061                 .wins   = {
7062                         .nb_flags       = 0,
7063                         .mhomed         = False,
7064                         .num_ips        = ctx->addresses_best_num,
7065                         .ips            = ctx->addresses_best,
7066                         .apply_expected = True
7067                 },
7068                 .defend = {
7069                         .timeout        = 10,
7070                         .positive       = False,
7071                 },
7072                 .replica= {
7073                         .type           = WREPL_TYPE_MHOMED,
7074                         .state          = WREPL_STATE_ACTIVE,
7075                         .node           = WREPL_NODE_B,
7076                         .is_static      = False,
7077                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7078                         .ips            = addresses_B_3_4,
7079                         .apply_expected = True
7080                 },
7081         },
7082         /*
7083          * unique,active vs. mhomed,tombstone with same ip(s), unchecked
7084          */
7085         {
7086                 .line   = __location__,
7087                 .name   = _NBT_NAME("_UA_MT_SI_U", 0x00, NULL),
7088                 .wins   = {
7089                         .nb_flags       = 0,
7090                         .mhomed         = False,
7091                         .num_ips        = ctx->addresses_best_num,
7092                         .ips            = ctx->addresses_best,
7093                         .apply_expected = True
7094                 },
7095                 .defend = {
7096                         .timeout        = 0,
7097                 },
7098                 .replica= {
7099                         .type           = WREPL_TYPE_MHOMED,
7100                         .state          = WREPL_STATE_TOMBSTONE,
7101                         .node           = WREPL_NODE_B,
7102                         .is_static      = False,
7103                         .num_ips        = ctx->addresses_best_num,
7104                         .ips            = ctx->addresses_best,
7105                         .apply_expected = False
7106                 },
7107         },
7108         /*
7109          * unique,active vs. mhomed,tombstone with different ip(s), unchecked
7110          */
7111         {
7112                 .line   = __location__,
7113                 .name   = _NBT_NAME("_UA_MT_DI_U", 0x00, NULL),
7114                 .wins   = {
7115                         .nb_flags       = 0,
7116                         .mhomed         = False,
7117                         .num_ips        = ctx->addresses_best_num,
7118                         .ips            = ctx->addresses_best,
7119                         .apply_expected = True
7120                 },
7121                 .defend = {
7122                         .timeout        = 0,
7123                 },
7124                 .replica= {
7125                         .type           = WREPL_TYPE_MHOMED,
7126                         .state          = WREPL_STATE_TOMBSTONE,
7127                         .node           = WREPL_NODE_B,
7128                         .is_static      = False,
7129                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7130                         .ips            = addresses_B_3_4,
7131                         .apply_expected = False
7132                 },
7133         },
7134 /* 
7135  * normal group vs. unique section
7136  */
7137         /*
7138          * group,active vs. unique,active with same ip(s), unchecked
7139          */
7140         {
7141                 .line   = __location__,
7142                 .name   = _NBT_NAME("_GA_UA_SI_U", 0x00, NULL),
7143                 .wins   = {
7144                         .nb_flags       = NBT_NM_GROUP,
7145                         .mhomed         = False,
7146                         .num_ips        = ctx->addresses_best_num,
7147                         .ips            = ctx->addresses_best,
7148                         .apply_expected = True
7149                 },
7150                 .defend = {
7151                         .timeout        = 0,
7152                 },
7153                 .replica= {
7154                         .type           = WREPL_TYPE_UNIQUE,
7155                         .state          = WREPL_STATE_ACTIVE,
7156                         .node           = WREPL_NODE_B,
7157                         .is_static      = False,
7158                         .num_ips        = ctx->addresses_best_num,
7159                         .ips            = ctx->addresses_best,
7160                         .apply_expected = False
7161                 },
7162         },
7163         /*
7164          * group,active vs. unique,active with different ip(s), unchecked
7165          */
7166         {
7167                 .line   = __location__,
7168                 .name   = _NBT_NAME("_GA_UA_DI_U", 0x00, NULL),
7169                 .wins   = {
7170                         .nb_flags       = NBT_NM_GROUP,
7171                         .mhomed         = False,
7172                         .num_ips        = ctx->addresses_best_num,
7173                         .ips            = ctx->addresses_best,
7174                         .apply_expected = True
7175                 },
7176                 .defend = {
7177                         .timeout        = 0,
7178                 },
7179                 .replica= {
7180                         .type           = WREPL_TYPE_UNIQUE,
7181                         .state          = WREPL_STATE_ACTIVE,
7182                         .node           = WREPL_NODE_B,
7183                         .is_static      = False,
7184                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7185                         .ips            = addresses_B_1,
7186                         .apply_expected = False
7187                 },
7188         },
7189         /*
7190          * group,active vs. unique,tombstone with same ip(s), unchecked
7191          */
7192         {
7193                 .line   = __location__,
7194                 .name   = _NBT_NAME("_GA_UT_SI_U", 0x00, NULL),
7195                 .wins   = {
7196                         .nb_flags       = NBT_NM_GROUP,
7197                         .mhomed         = False,
7198                         .num_ips        = ctx->addresses_best_num,
7199                         .ips            = ctx->addresses_best,
7200                         .apply_expected = True
7201                 },
7202                 .defend = {
7203                         .timeout        = 0,
7204                 },
7205                 .replica= {
7206                         .type           = WREPL_TYPE_UNIQUE,
7207                         .state          = WREPL_STATE_TOMBSTONE,
7208                         .node           = WREPL_NODE_B,
7209                         .is_static      = False,
7210                         .num_ips        = ctx->addresses_best_num,
7211                         .ips            = ctx->addresses_best,
7212                         .apply_expected = False
7213                 },
7214         },
7215         /*
7216          * group,active vs. unique,tombstone with different ip(s), unchecked
7217          */
7218         {
7219                 .line   = __location__,
7220                 .name   = _NBT_NAME("_GA_UT_DI_U", 0x00, NULL),
7221                 .wins   = {
7222                         .nb_flags       = NBT_NM_GROUP,
7223                         .mhomed         = False,
7224                         .num_ips        = ctx->addresses_best_num,
7225                         .ips            = ctx->addresses_best,
7226                         .apply_expected = True
7227                 },
7228                 .defend = {
7229                         .timeout        = 0,
7230                 },
7231                 .replica= {
7232                         .type           = WREPL_TYPE_UNIQUE,
7233                         .state          = WREPL_STATE_TOMBSTONE,
7234                         .node           = WREPL_NODE_B,
7235                         .is_static      = False,
7236                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7237                         .ips            = addresses_B_1,
7238                         .apply_expected = False
7239                 },
7240         },
7241 /* 
7242  * normal group vs. normal group section
7243  */
7244         /*
7245          * group,active vs. group,active with same ip(s), unchecked
7246          */
7247         {
7248                 .line   = __location__,
7249                 .name   = _NBT_NAME("_GA_GA_SI_U", 0x00, NULL),
7250                 .wins   = {
7251                         .nb_flags       = NBT_NM_GROUP,
7252                         .mhomed         = False,
7253                         .num_ips        = ctx->addresses_best_num,
7254                         .ips            = ctx->addresses_best,
7255                         .apply_expected = True
7256                 },
7257                 .defend = {
7258                         .timeout        = 0,
7259                 },
7260                 .replica= {
7261                         .type           = WREPL_TYPE_GROUP,
7262                         .state          = WREPL_STATE_ACTIVE,
7263                         .node           = WREPL_NODE_B,
7264                         .is_static      = False,
7265                         .num_ips        = ctx->addresses_best_num,
7266                         .ips            = ctx->addresses_best,
7267                         .apply_expected = True
7268                 },
7269         },
7270         /*
7271          * group,active vs. group,active with different ip(s), unchecked
7272          */
7273         {
7274                 .line   = __location__,
7275                 .name   = _NBT_NAME("_GA_GA_DI_U", 0x00, NULL),
7276                 .wins   = {
7277                         .nb_flags       = NBT_NM_GROUP,
7278                         .mhomed         = False,
7279                         .num_ips        = ctx->addresses_best_num,
7280                         .ips            = ctx->addresses_best,
7281                         .apply_expected = True
7282                 },
7283                 .defend = {
7284                         .timeout        = 0,
7285                 },
7286                 .replica= {
7287                         .type           = WREPL_TYPE_GROUP,
7288                         .state          = WREPL_STATE_ACTIVE,
7289                         .node           = WREPL_NODE_B,
7290                         .is_static      = False,
7291                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7292                         .ips            = addresses_B_1,
7293                         .apply_expected = True
7294                 },
7295         },
7296         /*
7297          * group,active vs. group,tombstone with same ip(s), unchecked
7298          */
7299         {
7300                 .line   = __location__,
7301                 .name   = _NBT_NAME("_GA_GT_SI_U", 0x00, NULL),
7302                 .wins   = {
7303                         .nb_flags       = NBT_NM_GROUP,
7304                         .mhomed         = False,
7305                         .num_ips        = ctx->addresses_best_num,
7306                         .ips            = ctx->addresses_best,
7307                         .apply_expected = True
7308                 },
7309                 .defend = {
7310                         .timeout        = 0,
7311                 },
7312                 .replica= {
7313                         .type           = WREPL_TYPE_GROUP,
7314                         .state          = WREPL_STATE_TOMBSTONE,
7315                         .node           = WREPL_NODE_B,
7316                         .is_static      = False,
7317                         .num_ips        = ctx->addresses_best_num,
7318                         .ips            = ctx->addresses_best,
7319                         .apply_expected = False
7320                 },
7321         },
7322         /*
7323          * group,active vs. group,tombstone with different ip(s), unchecked
7324          */
7325         {
7326                 .line   = __location__,
7327                 .name   = _NBT_NAME("_GA_GT_DI_U", 0x00, NULL),
7328                 .wins   = {
7329                         .nb_flags       = NBT_NM_GROUP,
7330                         .mhomed         = False,
7331                         .num_ips        = ctx->addresses_best_num,
7332                         .ips            = ctx->addresses_best,
7333                         .apply_expected = True
7334                 },
7335                 .defend = {
7336                         .timeout        = 0,
7337                 },
7338                 .replica= {
7339                         .type           = WREPL_TYPE_GROUP,
7340                         .state          = WREPL_STATE_TOMBSTONE,
7341                         .node           = WREPL_NODE_B,
7342                         .is_static      = False,
7343                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7344                         .ips            = addresses_B_1,
7345                         .apply_expected = False
7346                 },
7347         },
7348 /* 
7349  * normal group vs. special group section
7350  */
7351         /*
7352          * group,active vs. sgroup,active with same ip(s), unchecked
7353          */
7354         {
7355                 .line   = __location__,
7356                 .name   = _NBT_NAME("_GA_SA_SI_U", 0x00, NULL),
7357                 .wins   = {
7358                         .nb_flags       = NBT_NM_GROUP,
7359                         .mhomed         = False,
7360                         .num_ips        = ctx->addresses_best_num,
7361                         .ips            = ctx->addresses_best,
7362                         .apply_expected = True
7363                 },
7364                 .defend = {
7365                         .timeout        = 0,
7366                 },
7367                 .replica= {
7368                         .type           = WREPL_TYPE_SGROUP,
7369                         .state          = WREPL_STATE_ACTIVE,
7370                         .node           = WREPL_NODE_B,
7371                         .is_static      = False,
7372                         .num_ips        = ctx->addresses_best_num,
7373                         .ips            = ctx->addresses_best,
7374                         .apply_expected = False
7375                 },
7376         },
7377         /*
7378          * group,active vs. sgroup,active with different ip(s), unchecked
7379          */
7380         {
7381                 .line   = __location__,
7382                 .name   = _NBT_NAME("_GA_SA_DI_U", 0x00, NULL),
7383                 .wins   = {
7384                         .nb_flags       = NBT_NM_GROUP,
7385                         .mhomed         = False,
7386                         .num_ips        = ctx->addresses_best_num,
7387                         .ips            = ctx->addresses_best,
7388                         .apply_expected = True
7389                 },
7390                 .defend = {
7391                         .timeout        = 0,
7392                 },
7393                 .replica= {
7394                         .type           = WREPL_TYPE_SGROUP,
7395                         .state          = WREPL_STATE_ACTIVE,
7396                         .node           = WREPL_NODE_B,
7397                         .is_static      = False,
7398                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7399                         .ips            = addresses_B_3_4,
7400                         .apply_expected = False
7401                 },
7402         },
7403         /*
7404          * group,active vs. sgroup,tombstone with same ip(s), unchecked
7405          */
7406         {
7407                 .line   = __location__,
7408                 .name   = _NBT_NAME("_GA_ST_SI_U", 0x00, NULL),
7409                 .wins   = {
7410                         .nb_flags       = NBT_NM_GROUP,
7411                         .mhomed         = False,
7412                         .num_ips        = ctx->addresses_best_num,
7413                         .ips            = ctx->addresses_best,
7414                         .apply_expected = True
7415                 },
7416                 .defend = {
7417                         .timeout        = 0,
7418                 },
7419                 .replica= {
7420                         .type           = WREPL_TYPE_SGROUP,
7421                         .state          = WREPL_STATE_TOMBSTONE,
7422                         .node           = WREPL_NODE_B,
7423                         .is_static      = False,
7424                         .num_ips        = ctx->addresses_best_num,
7425                         .ips            = ctx->addresses_best,
7426                         .apply_expected = False
7427                 },
7428         },
7429         /*
7430          * group,active vs. sgroup,tombstone with different ip(s), unchecked
7431          */
7432         {
7433                 .line   = __location__,
7434                 .name   = _NBT_NAME("_GA_ST_DI_U", 0x00, NULL),
7435                 .wins   = {
7436                         .nb_flags       = NBT_NM_GROUP,
7437                         .mhomed         = False,
7438                         .num_ips        = ctx->addresses_best_num,
7439                         .ips            = ctx->addresses_best,
7440                         .apply_expected = True
7441                 },
7442                 .defend = {
7443                         .timeout        = 0,
7444                 },
7445                 .replica= {
7446                         .type           = WREPL_TYPE_SGROUP,
7447                         .state          = WREPL_STATE_TOMBSTONE,
7448                         .node           = WREPL_NODE_B,
7449                         .is_static      = False,
7450                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7451                         .ips            = addresses_B_3_4,
7452                         .apply_expected = False
7453                 },
7454         },
7455 /* 
7456  * normal group vs. multi homed section
7457  */
7458         /*
7459          * group,active vs. mhomed,active with same ip(s), unchecked
7460          */
7461         {
7462                 .line   = __location__,
7463                 .name   = _NBT_NAME("_GA_MA_SI_U", 0x00, NULL),
7464                 .wins   = {
7465                         .nb_flags       = NBT_NM_GROUP,
7466                         .mhomed         = False,
7467                         .num_ips        = ctx->addresses_best_num,
7468                         .ips            = ctx->addresses_best,
7469                         .apply_expected = True
7470                 },
7471                 .defend = {
7472                         .timeout        = 0,
7473                 },
7474                 .replica= {
7475                         .type           = WREPL_TYPE_MHOMED,
7476                         .state          = WREPL_STATE_ACTIVE,
7477                         .node           = WREPL_NODE_B,
7478                         .is_static      = False,
7479                         .num_ips        = ctx->addresses_best_num,
7480                         .ips            = ctx->addresses_best,
7481                         .apply_expected = False
7482                 },
7483         },
7484         /*
7485          * group,active vs. mhomed,active with different ip(s), unchecked
7486          */
7487         {
7488                 .line   = __location__,
7489                 .name   = _NBT_NAME("_GA_MA_DI_U", 0x00, NULL),
7490                 .wins   = {
7491                         .nb_flags       = NBT_NM_GROUP,
7492                         .mhomed         = False,
7493                         .num_ips        = ctx->addresses_best_num,
7494                         .ips            = ctx->addresses_best,
7495                         .apply_expected = True
7496                 },
7497                 .defend = {
7498                         .timeout        = 0,
7499                 },
7500                 .replica= {
7501                         .type           = WREPL_TYPE_MHOMED,
7502                         .state          = WREPL_STATE_ACTIVE,
7503                         .node           = WREPL_NODE_B,
7504                         .is_static      = False,
7505                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7506                         .ips            = addresses_B_3_4,
7507                         .apply_expected = False
7508                 },
7509         },
7510         /*
7511          * group,active vs. mhomed,tombstone with same ip(s), unchecked
7512          */
7513         {
7514                 .line   = __location__,
7515                 .name   = _NBT_NAME("_GA_MT_SI_U", 0x00, NULL),
7516                 .wins   = {
7517                         .nb_flags       = NBT_NM_GROUP,
7518                         .mhomed         = False,
7519                         .num_ips        = ctx->addresses_best_num,
7520                         .ips            = ctx->addresses_best,
7521                         .apply_expected = True
7522                 },
7523                 .defend = {
7524                         .timeout        = 0,
7525                 },
7526                 .replica= {
7527                         .type           = WREPL_TYPE_MHOMED,
7528                         .state          = WREPL_STATE_TOMBSTONE,
7529                         .node           = WREPL_NODE_B,
7530                         .is_static      = False,
7531                         .num_ips        = ctx->addresses_best_num,
7532                         .ips            = ctx->addresses_best,
7533                         .apply_expected = False
7534                 },
7535         },
7536         /*
7537          * group,active vs. mhomed,tombstone with different ip(s), unchecked
7538          */
7539         {
7540                 .line   = __location__,
7541                 .name   = _NBT_NAME("_GA_MT_DI_U", 0x00, NULL),
7542                 .wins   = {
7543                         .nb_flags       = NBT_NM_GROUP,
7544                         .mhomed         = False,
7545                         .num_ips        = ctx->addresses_best_num,
7546                         .ips            = ctx->addresses_best,
7547                         .apply_expected = True
7548                 },
7549                 .defend = {
7550                         .timeout        = 0,
7551                 },
7552                 .replica= {
7553                         .type           = WREPL_TYPE_MHOMED,
7554                         .state          = WREPL_STATE_TOMBSTONE,
7555                         .node           = WREPL_NODE_B,
7556                         .is_static      = False,
7557                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7558                         .ips            = addresses_B_3_4,
7559                         .apply_expected = False
7560                 },
7561         },
7562 /* 
7563  * special group vs. unique section
7564  */
7565         /*
7566          * sgroup,active vs. unique,active with same ip(s), unchecked
7567          */
7568         {
7569                 .line   = __location__,
7570                 .name   = _NBT_NAME("_SA_UA_SI_U", 0x1C, NULL),
7571                 .wins   = {
7572                         .nb_flags       = NBT_NM_GROUP,
7573                         .mhomed         = False,
7574                         .num_ips        = ctx->addresses_best_num,
7575                         .ips            = ctx->addresses_best,
7576                         .apply_expected = True
7577                 },
7578                 .defend = {
7579                         .timeout        = 0,
7580                 },
7581                 .replica= {
7582                         .type           = WREPL_TYPE_UNIQUE,
7583                         .state          = WREPL_STATE_ACTIVE,
7584                         .node           = WREPL_NODE_B,
7585                         .is_static      = False,
7586                         .num_ips        = ctx->addresses_best_num,
7587                         .ips            = ctx->addresses_best,
7588                         .apply_expected = False
7589                 },
7590         },
7591         /*
7592          * sgroup,active vs. unique,active with different ip(s), unchecked
7593          */
7594         {
7595                 .line   = __location__,
7596                 .name   = _NBT_NAME("_SA_UA_DI_U", 0x1C, NULL),
7597                 .wins   = {
7598                         .nb_flags       = NBT_NM_GROUP,
7599                         .mhomed         = False,
7600                         .num_ips        = ctx->addresses_best_num,
7601                         .ips            = ctx->addresses_best,
7602                         .apply_expected = True
7603                 },
7604                 .defend = {
7605                         .timeout        = 0,
7606                 },
7607                 .replica= {
7608                         .type           = WREPL_TYPE_UNIQUE,
7609                         .state          = WREPL_STATE_ACTIVE,
7610                         .node           = WREPL_NODE_B,
7611                         .is_static      = False,
7612                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7613                         .ips            = addresses_B_1,
7614                         .apply_expected = False
7615                 },
7616         },
7617         /*
7618          * sgroup,active vs. unique,tombstone with same ip(s), unchecked
7619          */
7620         {
7621                 .line   = __location__,
7622                 .name   = _NBT_NAME("_SA_UT_SI_U", 0x1C, NULL),
7623                 .wins   = {
7624                         .nb_flags       = NBT_NM_GROUP,
7625                         .mhomed         = False,
7626                         .num_ips        = ctx->addresses_best_num,
7627                         .ips            = ctx->addresses_best,
7628                         .apply_expected = True
7629                 },
7630                 .defend = {
7631                         .timeout        = 0,
7632                 },
7633                 .replica= {
7634                         .type           = WREPL_TYPE_UNIQUE,
7635                         .state          = WREPL_STATE_TOMBSTONE,
7636                         .node           = WREPL_NODE_B,
7637                         .is_static      = False,
7638                         .num_ips        = ctx->addresses_best_num,
7639                         .ips            = ctx->addresses_best,
7640                         .apply_expected = False
7641                 },
7642         },
7643         /*
7644          * sgroup,active vs. unique,tombstone with different ip(s), unchecked
7645          */
7646         {
7647                 .line   = __location__,
7648                 .name   = _NBT_NAME("_SA_UT_DI_U", 0x1C, NULL),
7649                 .wins   = {
7650                         .nb_flags       = NBT_NM_GROUP,
7651                         .mhomed         = False,
7652                         .num_ips        = ctx->addresses_best_num,
7653                         .ips            = ctx->addresses_best,
7654                         .apply_expected = True
7655                 },
7656                 .defend = {
7657                         .timeout        = 0,
7658                 },
7659                 .replica= {
7660                         .type           = WREPL_TYPE_UNIQUE,
7661                         .state          = WREPL_STATE_TOMBSTONE,
7662                         .node           = WREPL_NODE_B,
7663                         .is_static      = False,
7664                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7665                         .ips            = addresses_B_1,
7666                         .apply_expected = False
7667                 },
7668         },
7669 /* 
7670  * special group vs. normal group section
7671  */
7672         /*
7673          * sgroup,active vs. group,active with same ip(s), unchecked
7674          */
7675         {
7676                 .line   = __location__,
7677                 .name   = _NBT_NAME("_SA_GA_SI_U", 0x1C, NULL),
7678                 .wins   = {
7679                         .nb_flags       = NBT_NM_GROUP,
7680                         .mhomed         = False,
7681                         .num_ips        = ctx->addresses_best_num,
7682                         .ips            = ctx->addresses_best,
7683                         .apply_expected = True
7684                 },
7685                 .defend = {
7686                         .timeout        = 0,
7687                 },
7688                 .replica= {
7689                         .type           = WREPL_TYPE_GROUP,
7690                         .state          = WREPL_STATE_ACTIVE,
7691                         .node           = WREPL_NODE_B,
7692                         .is_static      = False,
7693                         .num_ips        = ctx->addresses_best_num,
7694                         .ips            = ctx->addresses_best,
7695                         .apply_expected = False
7696                 },
7697         },
7698         /*
7699          * sgroup,active vs. group,active with different ip(s), unchecked
7700          */
7701         {
7702                 .line   = __location__,
7703                 .name   = _NBT_NAME("_SA_GA_DI_U", 0x1C, NULL),
7704                 .wins   = {
7705                         .nb_flags       = NBT_NM_GROUP,
7706                         .mhomed         = False,
7707                         .num_ips        = ctx->addresses_best_num,
7708                         .ips            = ctx->addresses_best,
7709                         .apply_expected = True
7710                 },
7711                 .defend = {
7712                         .timeout        = 0,
7713                 },
7714                 .replica= {
7715                         .type           = WREPL_TYPE_GROUP,
7716                         .state          = WREPL_STATE_ACTIVE,
7717                         .node           = WREPL_NODE_B,
7718                         .is_static      = False,
7719                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7720                         .ips            = addresses_B_1,
7721                         .apply_expected = False
7722                 },
7723         },
7724         /*
7725          * sgroup,active vs. group,tombstone with same ip(s), unchecked
7726          */
7727         {
7728                 .line   = __location__,
7729                 .name   = _NBT_NAME("_SA_GT_SI_U", 0x1C, NULL),
7730                 .wins   = {
7731                         .nb_flags       = NBT_NM_GROUP,
7732                         .mhomed         = False,
7733                         .num_ips        = ctx->addresses_best_num,
7734                         .ips            = ctx->addresses_best,
7735                         .apply_expected = True
7736                 },
7737                 .defend = {
7738                         .timeout        = 0,
7739                 },
7740                 .replica= {
7741                         .type           = WREPL_TYPE_GROUP,
7742                         .state          = WREPL_STATE_TOMBSTONE,
7743                         .node           = WREPL_NODE_B,
7744                         .is_static      = False,
7745                         .num_ips        = ctx->addresses_best_num,
7746                         .ips            = ctx->addresses_best,
7747                         .apply_expected = False
7748                 },
7749         },
7750         /*
7751          * sgroup,active vs. group,tombstone with different ip(s), unchecked
7752          */
7753         {
7754                 .line   = __location__,
7755                 .name   = _NBT_NAME("_SA_GT_DI_U", 0x1C, NULL),
7756                 .wins   = {
7757                         .nb_flags       = NBT_NM_GROUP,
7758                         .mhomed         = False,
7759                         .num_ips        = ctx->addresses_best_num,
7760                         .ips            = ctx->addresses_best,
7761                         .apply_expected = True
7762                 },
7763                 .defend = {
7764                         .timeout        = 0,
7765                 },
7766                 .replica= {
7767                         .type           = WREPL_TYPE_GROUP,
7768                         .state          = WREPL_STATE_TOMBSTONE,
7769                         .node           = WREPL_NODE_B,
7770                         .is_static      = False,
7771                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7772                         .ips            = addresses_B_1,
7773                         .apply_expected = False
7774                 },
7775         },
7776 /* 
7777  * special group vs. multi homed section
7778  */
7779         /*
7780          * sgroup,active vs. mhomed,active with same ip(s), unchecked
7781          */
7782         {
7783                 .line   = __location__,
7784                 .name   = _NBT_NAME("_SA_MA_SI_U", 0x1C, NULL),
7785                 .wins   = {
7786                         .nb_flags       = NBT_NM_GROUP,
7787                         .mhomed         = False,
7788                         .num_ips        = ctx->addresses_best_num,
7789                         .ips            = ctx->addresses_best,
7790                         .apply_expected = True
7791                 },
7792                 .defend = {
7793                         .timeout        = 0,
7794                 },
7795                 .replica= {
7796                         .type           = WREPL_TYPE_MHOMED,
7797                         .state          = WREPL_STATE_ACTIVE,
7798                         .node           = WREPL_NODE_B,
7799                         .is_static      = False,
7800                         .num_ips        = ctx->addresses_best_num,
7801                         .ips            = ctx->addresses_best,
7802                         .apply_expected = False
7803                 },
7804         },
7805         /*
7806          * sgroup,active vs. mhomed,active with different ip(s), unchecked
7807          */
7808         {
7809                 .line   = __location__,
7810                 .name   = _NBT_NAME("_SA_MA_DI_U", 0x1C, NULL),
7811                 .wins   = {
7812                         .nb_flags       = NBT_NM_GROUP,
7813                         .mhomed         = False,
7814                         .num_ips        = ctx->addresses_best_num,
7815                         .ips            = ctx->addresses_best,
7816                         .apply_expected = True
7817                 },
7818                 .defend = {
7819                         .timeout        = 0,
7820                 },
7821                 .replica= {
7822                         .type           = WREPL_TYPE_MHOMED,
7823                         .state          = WREPL_STATE_ACTIVE,
7824                         .node           = WREPL_NODE_B,
7825                         .is_static      = False,
7826                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7827                         .ips            = addresses_B_1,
7828                         .apply_expected = False
7829                 },
7830         },
7831         /*
7832          * sgroup,active vs. mhomed,tombstone with same ip(s), unchecked
7833          */
7834         {
7835                 .line   = __location__,
7836                 .name   = _NBT_NAME("_SA_MT_SI_U", 0x1C, NULL),
7837                 .wins   = {
7838                         .nb_flags       = NBT_NM_GROUP,
7839                         .mhomed         = False,
7840                         .num_ips        = ctx->addresses_best_num,
7841                         .ips            = ctx->addresses_best,
7842                         .apply_expected = True
7843                 },
7844                 .defend = {
7845                         .timeout        = 0,
7846                 },
7847                 .replica= {
7848                         .type           = WREPL_TYPE_MHOMED,
7849                         .state          = WREPL_STATE_TOMBSTONE,
7850                         .node           = WREPL_NODE_B,
7851                         .is_static      = False,
7852                         .num_ips        = ctx->addresses_best_num,
7853                         .ips            = ctx->addresses_best,
7854                         .apply_expected = False
7855                 },
7856         },
7857         /*
7858          * sgroup,active vs. mhomed,tombstone with different ip(s), unchecked
7859          */
7860         {
7861                 .line   = __location__,
7862                 .name   = _NBT_NAME("_SA_MT_DI_U", 0x1C, NULL),
7863                 .wins   = {
7864                         .nb_flags       = NBT_NM_GROUP,
7865                         .mhomed         = False,
7866                         .num_ips        = ctx->addresses_best_num,
7867                         .ips            = ctx->addresses_best,
7868                         .apply_expected = True
7869                 },
7870                 .defend = {
7871                         .timeout        = 0,
7872                 },
7873                 .replica= {
7874                         .type           = WREPL_TYPE_MHOMED,
7875                         .state          = WREPL_STATE_TOMBSTONE,
7876                         .node           = WREPL_NODE_B,
7877                         .is_static      = False,
7878                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7879                         .ips            = addresses_B_1,
7880                         .apply_expected = False
7881                 },
7882         },
7883 /* 
7884  * multi homed vs. unique section
7885  */
7886         /*
7887          * mhomed,active vs. unique,active with same ip(s), unchecked
7888          */
7889         {
7890                 .line   = __location__,
7891                 .name   = _NBT_NAME("_MA_UA_SI_U", 0x00, NULL),
7892                 .wins   = {
7893                         .nb_flags       = 0,
7894                         .mhomed         = True,
7895                         .num_ips        = ctx->addresses_best_num,
7896                         .ips            = ctx->addresses_best,
7897                         .apply_expected = True
7898                 },
7899                 .defend = {
7900                         .timeout        = 0,
7901                 },
7902                 .replica= {
7903                         .type           = WREPL_TYPE_UNIQUE,
7904                         .state          = WREPL_STATE_ACTIVE,
7905                         .node           = WREPL_NODE_B,
7906                         .is_static      = False,
7907                         .num_ips        = ctx->addresses_best_num,
7908                         .ips            = ctx->addresses_best,
7909                         .apply_expected = True
7910                 },
7911         },
7912         /*
7913          * mhomed,active vs. unique,active with different ip(s), positive response
7914          */
7915         {
7916                 .line   = __location__,
7917                 .name   = _NBT_NAME("_MA_UA_DI_P", 0x00, NULL),
7918                 .wins   = {
7919                         .nb_flags       = 0,
7920                         .mhomed         = True,
7921                         .num_ips        = ctx->addresses_best_num,
7922                         .ips            = ctx->addresses_best,
7923                         .apply_expected = True
7924                 },
7925                 .defend = {
7926                         .timeout        = 10,
7927                         .positive       = True,
7928                 },
7929                 .replica= {
7930                         .type           = WREPL_TYPE_UNIQUE,
7931                         .state          = WREPL_STATE_ACTIVE,
7932                         .node           = WREPL_NODE_B,
7933                         .is_static      = False,
7934                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7935                         .ips            = addresses_B_1,
7936                         .apply_expected = False
7937                 },
7938         },
7939         /*
7940          * mhomed,active vs. unique,active with different ip(s), positive response other ips
7941          */
7942         {
7943                 .line   = __location__,
7944                 .name   = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL),
7945                 .wins   = {
7946                         .nb_flags       = 0,
7947                         .mhomed         = True,
7948                         .num_ips        = ctx->addresses_best_num,
7949                         .ips            = ctx->addresses_best,
7950                         .apply_expected = True
7951                 },
7952                 .defend = {
7953                         .timeout        = 10,
7954                         .positive       = True,
7955                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7956                         .ips            = addresses_A_3_4,
7957                 },
7958                 .replica= {
7959                         .type           = WREPL_TYPE_UNIQUE,
7960                         .state          = WREPL_STATE_ACTIVE,
7961                         .node           = WREPL_NODE_B,
7962                         .is_static      = False,
7963                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7964                         .ips            = addresses_B_1,
7965                         .apply_expected = False
7966                 },
7967         },
7968         /*
7969          * mhomed,active vs. unique,active with different ip(s), negative response
7970          */
7971         {
7972                 .line   = __location__,
7973                 .name   = _NBT_NAME("_MA_UA_DI_N", 0x00, NULL),
7974                 .wins   = {
7975                         .nb_flags       = 0,
7976                         .mhomed         = True,
7977                         .num_ips        = ctx->addresses_best_num,
7978                         .ips            = ctx->addresses_best,
7979                         .apply_expected = True
7980                 },
7981                 .defend = {
7982                         .timeout        = 10,
7983                         .positive       = False,
7984                 },
7985                 .replica= {
7986                         .type           = WREPL_TYPE_UNIQUE,
7987                         .state          = WREPL_STATE_ACTIVE,
7988                         .node           = WREPL_NODE_B,
7989                         .is_static      = False,
7990                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7991                         .ips            = addresses_B_1,
7992                         .apply_expected = True
7993                 },
7994         },
7995         /*
7996          * mhomed,active vs. unique,tombstone with same ip(s), unchecked
7997          */
7998         {
7999                 .line   = __location__,
8000                 .name   = _NBT_NAME("_MA_UT_SI_U", 0x00, NULL),
8001                 .wins   = {
8002                         .nb_flags       = 0,
8003                         .mhomed         = True,
8004                         .num_ips        = ctx->addresses_best_num,
8005                         .ips            = ctx->addresses_best,
8006                         .apply_expected = True
8007                 },
8008                 .defend = {
8009                         .timeout        = 0,
8010                 },
8011                 .replica= {
8012                         .type           = WREPL_TYPE_UNIQUE,
8013                         .state          = WREPL_STATE_TOMBSTONE,
8014                         .node           = WREPL_NODE_B,
8015                         .is_static      = False,
8016                         .num_ips        = ctx->addresses_best_num,
8017                         .ips            = ctx->addresses_best,
8018                         .apply_expected = False
8019                 },
8020         },
8021         /*
8022          * mhomed,active vs. unique,tombstone with different ip(s), unchecked
8023          */
8024         {
8025                 .line   = __location__,
8026                 .name   = _NBT_NAME("_MA_UT_DI_U", 0x00, NULL),
8027                 .wins   = {
8028                         .nb_flags       = 0,
8029                         .mhomed         = True,
8030                         .num_ips        = ctx->addresses_best_num,
8031                         .ips            = ctx->addresses_best,
8032                         .apply_expected = True
8033                 },
8034                 .defend = {
8035                         .timeout        = 0,
8036                 },
8037                 .replica= {
8038                         .type           = WREPL_TYPE_UNIQUE,
8039                         .state          = WREPL_STATE_TOMBSTONE,
8040                         .node           = WREPL_NODE_B,
8041                         .is_static      = False,
8042                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8043                         .ips            = addresses_B_1,
8044                         .apply_expected = False
8045                 },
8046         },
8047 /* 
8048  * multi homed vs. normal group section
8049  */
8050         /*
8051          * mhomed,active vs. group,active with same ip(s), release expected
8052          */
8053         {
8054                 .line   = __location__,
8055                 .name   = _NBT_NAME("_MA_GA_SI_R", 0x00, NULL),
8056                 .wins   = {
8057                         .nb_flags       = 0,
8058                         .mhomed         = True,
8059                         .num_ips        = ctx->addresses_best_num,
8060                         .ips            = ctx->addresses_best,
8061                         .apply_expected = True
8062                 },
8063                 .defend = {
8064                         .timeout        = 10,
8065                         .expect_release = True,
8066                 },
8067                 .replica= {
8068                         .type           = WREPL_TYPE_GROUP,
8069                         .state          = WREPL_STATE_ACTIVE,
8070                         .node           = WREPL_NODE_B,
8071                         .is_static      = False,
8072                         .num_ips        = ctx->addresses_best_num,
8073                         .ips            = ctx->addresses_best,
8074                         .apply_expected = True
8075                 },
8076         },
8077         /*
8078          * mhomed,active vs. group,active with different ip(s), release expected
8079          */
8080         {
8081                 .line   = __location__,
8082                 .name   = _NBT_NAME("_MA_GA_DI_R", 0x00, NULL),
8083                 .wins   = {
8084                         .nb_flags       = 0,
8085                         .mhomed         = True,
8086                         .num_ips        = ctx->addresses_best_num,
8087                         .ips            = ctx->addresses_best,
8088                         .apply_expected = True
8089                 },
8090                 .defend = {
8091                         .timeout        = 10,
8092                         .expect_release = True,
8093                 },
8094                 .replica= {
8095                         .type           = WREPL_TYPE_GROUP,
8096                         .state          = WREPL_STATE_ACTIVE,
8097                         .node           = WREPL_NODE_B,
8098                         .is_static      = False,
8099                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8100                         .ips            = addresses_B_1,
8101                         .apply_expected = True
8102                 },
8103         },
8104         /*
8105          * mhomed,active vs. group,tombstone with same ip(s), unchecked
8106          */
8107         {
8108                 .line   = __location__,
8109                 .name   = _NBT_NAME("_MA_GT_SI_U", 0x00, NULL),
8110                 .wins   = {
8111                         .nb_flags       = 0,
8112                         .mhomed         = True,
8113                         .num_ips        = ctx->addresses_best_num,
8114                         .ips            = ctx->addresses_best,
8115                         .apply_expected = True
8116                 },
8117                 .defend = {
8118                         .timeout        = 0,
8119                 },
8120                 .replica= {
8121                         .type           = WREPL_TYPE_GROUP,
8122                         .state          = WREPL_STATE_TOMBSTONE,
8123                         .node           = WREPL_NODE_B,
8124                         .is_static      = False,
8125                         .num_ips        = ctx->addresses_best_num,
8126                         .ips            = ctx->addresses_best,
8127                         .apply_expected = False
8128                 },
8129         },
8130         /*
8131          * mhomed,active vs. group,tombstone with different ip(s), unchecked
8132          */
8133         {
8134                 .line   = __location__,
8135                 .name   = _NBT_NAME("_MA_GT_DI_U", 0x00, NULL),
8136                 .wins   = {
8137                         .nb_flags       = 0,
8138                         .mhomed         = True,
8139                         .num_ips        = ctx->addresses_best_num,
8140                         .ips            = ctx->addresses_best,
8141                         .apply_expected = True
8142                 },
8143                 .defend = {
8144                         .timeout        = 0,
8145                 },
8146                 .replica= {
8147                         .type           = WREPL_TYPE_GROUP,
8148                         .state          = WREPL_STATE_TOMBSTONE,
8149                         .node           = WREPL_NODE_B,
8150                         .is_static      = False,
8151                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8152                         .ips            = addresses_B_1,
8153                         .apply_expected = False
8154                 },
8155         },
8156 /* 
8157  * multi homed vs. special group section
8158  */
8159         /*
8160          * mhomed,active vs. sgroup,active with same ip(s), release expected
8161          */
8162         {
8163                 .line   = __location__,
8164                 .name   = _NBT_NAME("_MA_SA_SI_R", 0x00, NULL),
8165                 .wins   = {
8166                         .nb_flags       = 0,
8167                         .mhomed         = True,
8168                         .num_ips        = ctx->addresses_best_num,
8169                         .ips            = ctx->addresses_best,
8170                         .apply_expected = True
8171                 },
8172                 .defend = {
8173                         .timeout        = 10,
8174                         .expect_release = True,
8175                 },
8176                 .replica= {
8177                         .type           = WREPL_TYPE_SGROUP,
8178                         .state          = WREPL_STATE_ACTIVE,
8179                         .node           = WREPL_NODE_B,
8180                         .is_static      = False,
8181                         .num_ips        = ctx->addresses_best_num,
8182                         .ips            = ctx->addresses_best,
8183                         .apply_expected = True
8184                 },
8185         },
8186         /*
8187          * mhomed,active vs. group,active with different ip(s), release expected
8188          */
8189         {
8190                 .line   = __location__,
8191                 .name   = _NBT_NAME("_MA_SA_DI_R", 0x00, NULL),
8192                 .wins   = {
8193                         .nb_flags       = 0,
8194                         .mhomed         = True,
8195                         .num_ips        = ctx->addresses_best_num,
8196                         .ips            = ctx->addresses_best,
8197                         .apply_expected = True
8198                 },
8199                 .defend = {
8200                         .timeout        = 10,
8201                         .expect_release = True,
8202                 },
8203                 .replica= {
8204                         .type           = WREPL_TYPE_SGROUP,
8205                         .state          = WREPL_STATE_ACTIVE,
8206                         .node           = WREPL_NODE_B,
8207                         .is_static      = False,
8208                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8209                         .ips            = addresses_B_1,
8210                         .apply_expected = True
8211                 },
8212         },
8213         /*
8214          * mhomed,active vs. sgroup,tombstone with same ip(s), unchecked
8215          */
8216         {
8217                 .line   = __location__,
8218                 .name   = _NBT_NAME("_MA_ST_SI_U", 0x00, NULL),
8219                 .wins   = {
8220                         .nb_flags       = 0,
8221                         .mhomed         = True,
8222                         .num_ips        = ctx->addresses_best_num,
8223                         .ips            = ctx->addresses_best,
8224                         .apply_expected = True
8225                 },
8226                 .defend = {
8227                         .timeout        = 0,
8228                 },
8229                 .replica= {
8230                         .type           = WREPL_TYPE_SGROUP,
8231                         .state          = WREPL_STATE_TOMBSTONE,
8232                         .node           = WREPL_NODE_B,
8233                         .is_static      = False,
8234                         .num_ips        = ctx->addresses_best_num,
8235                         .ips            = ctx->addresses_best,
8236                         .apply_expected = False
8237                 },
8238         },
8239         /*
8240          * mhomed,active vs. sgroup,tombstone with different ip(s), unchecked
8241          */
8242         {
8243                 .line   = __location__,
8244                 .name   = _NBT_NAME("_MA_ST_DI_U", 0x00, NULL),
8245                 .wins   = {
8246                         .nb_flags       = 0,
8247                         .mhomed         = True,
8248                         .num_ips        = ctx->addresses_best_num,
8249                         .ips            = ctx->addresses_best,
8250                         .apply_expected = True
8251                 },
8252                 .defend = {
8253                         .timeout        = 0,
8254                 },
8255                 .replica= {
8256                         .type           = WREPL_TYPE_SGROUP,
8257                         .state          = WREPL_STATE_TOMBSTONE,
8258                         .node           = WREPL_NODE_B,
8259                         .is_static      = False,
8260                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8261                         .ips            = addresses_B_1,
8262                         .apply_expected = False
8263                 },
8264         },
8265 /* 
8266  * multi homed vs. multi homed section
8267  */
8268         /*
8269          * mhomed,active vs. mhomed,active with same ip(s), unchecked
8270          */
8271         {
8272                 .line   = __location__,
8273                 .name   = _NBT_NAME("_MA_MA_SI_U", 0x00, NULL),
8274                 .wins   = {
8275                         .nb_flags       = 0,
8276                         .mhomed         = True,
8277                         .num_ips        = ctx->addresses_best_num,
8278                         .ips            = ctx->addresses_best,
8279                         .apply_expected = True
8280                 },
8281                 .defend = {
8282                         .timeout        = 0,
8283                 },
8284                 .replica= {
8285                         .type           = WREPL_TYPE_MHOMED,
8286                         .state          = WREPL_STATE_ACTIVE,
8287                         .node           = WREPL_NODE_B,
8288                         .is_static      = False,
8289                         .num_ips        = ctx->addresses_best_num,
8290                         .ips            = ctx->addresses_best,
8291                         .apply_expected = True
8292                 },
8293         },
8294         /*
8295          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8296          */
8297         {
8298                 .line   = __location__,
8299                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8300                 .wins   = {
8301                         .nb_flags       = 0,
8302                         .mhomed         = True,
8303                         .num_ips        = ctx->addresses_best_num,
8304                         .ips            = ctx->addresses_best,
8305                         .apply_expected = True
8306                 },
8307                 .defend = {
8308                         .timeout        = 0,
8309                 },
8310                 .replica= {
8311                         .type           = WREPL_TYPE_MHOMED,
8312                         .state          = WREPL_STATE_ACTIVE,
8313                         .node           = WREPL_NODE_B,
8314                         .is_static      = False,
8315                         .num_ips        = ctx->addresses_all_num,
8316                         .ips            = ctx->addresses_all,
8317                         .apply_expected = True
8318                 },
8319         },
8320         /*
8321          * mhomed,active vs. mhomed,active with different ip(s), positive response
8322          */
8323         {
8324                 .line   = __location__,
8325                 .name   = _NBT_NAME("_MA_MA_DI_P", 0x00, NULL),
8326                 .wins   = {
8327                         .nb_flags       = 0,
8328                         .mhomed         = True,
8329                         .num_ips        = ctx->addresses_best_num,
8330                         .ips            = ctx->addresses_best,
8331                         .apply_expected = True
8332                 },
8333                 .defend = {
8334                         .timeout        = 10,
8335                         .positive       = True,
8336                 },
8337                 .replica= {
8338                         .type           = WREPL_TYPE_MHOMED,
8339                         .state          = WREPL_STATE_ACTIVE,
8340                         .node           = WREPL_NODE_B,
8341                         .is_static      = False,
8342                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8343                         .ips            = addresses_B_3_4,
8344                         .apply_expected = False
8345                 },
8346         },
8347         /*
8348          * mhomed,active vs. mhomed,active with different ip(s), positive response other ips
8349          */
8350         {
8351                 .line   = __location__,
8352                 .name   = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL),
8353                 .wins   = {
8354                         .nb_flags       = 0,
8355                         .mhomed         = True,
8356                         .num_ips        = ctx->addresses_best_num,
8357                         .ips            = ctx->addresses_best,
8358                         .apply_expected = True
8359                 },
8360                 .defend = {
8361                         .timeout        = 10,
8362                         .positive       = True,
8363                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
8364                         .ips            = addresses_A_3_4,
8365                 },
8366                 .replica= {
8367                         .type           = WREPL_TYPE_MHOMED,
8368                         .state          = WREPL_STATE_ACTIVE,
8369                         .node           = WREPL_NODE_B,
8370                         .is_static      = False,
8371                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8372                         .ips            = addresses_B_3_4,
8373                         .apply_expected = False
8374                 },
8375         },
8376         /*
8377          * mhomed,active vs. mhomed,active with different ip(s), negative response
8378          */
8379         {
8380                 .line   = __location__,
8381                 .name   = _NBT_NAME("_MA_MA_DI_N", 0x00, NULL),
8382                 .wins   = {
8383                         .nb_flags       = 0,
8384                         .mhomed         = True,
8385                         .num_ips        = ctx->addresses_best_num,
8386                         .ips            = ctx->addresses_best,
8387                         .apply_expected = True
8388                 },
8389                 .defend = {
8390                         .timeout        = 10,
8391                         .positive       = False,
8392                 },
8393                 .replica= {
8394                         .type           = WREPL_TYPE_MHOMED,
8395                         .state          = WREPL_STATE_ACTIVE,
8396                         .node           = WREPL_NODE_B,
8397                         .is_static      = False,
8398                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8399                         .ips            = addresses_B_3_4,
8400                         .apply_expected = True
8401                 },
8402         },
8403         /*
8404          * mhomed,active vs. mhomed,tombstone with same ip(s), unchecked
8405          */
8406         {
8407                 .line   = __location__,
8408                 .name   = _NBT_NAME("_MA_MT_SI_U", 0x00, NULL),
8409                 .wins   = {
8410                         .nb_flags       = 0,
8411                         .mhomed         = True,
8412                         .num_ips        = ctx->addresses_best_num,
8413                         .ips            = ctx->addresses_best,
8414                         .apply_expected = True
8415                 },
8416                 .defend = {
8417                         .timeout        = 0,
8418                 },
8419                 .replica= {
8420                         .type           = WREPL_TYPE_MHOMED,
8421                         .state          = WREPL_STATE_TOMBSTONE,
8422                         .node           = WREPL_NODE_B,
8423                         .is_static      = False,
8424                         .num_ips        = ctx->addresses_best_num,
8425                         .ips            = ctx->addresses_best,
8426                         .apply_expected = False
8427                 },
8428         },
8429         /*
8430          * mhomed,active vs. mhomed,tombstone with different ip(s), unchecked
8431          */
8432         {
8433                 .line   = __location__,
8434                 .name   = _NBT_NAME("_MA_MT_DI_U", 0x00, NULL),
8435                 .wins   = {
8436                         .nb_flags       = 0,
8437                         .mhomed         = True,
8438                         .num_ips        = ctx->addresses_best_num,
8439                         .ips            = ctx->addresses_best,
8440                         .apply_expected = True
8441                 },
8442                 .defend = {
8443                         .timeout        = 0,
8444                 },
8445                 .replica= {
8446                         .type           = WREPL_TYPE_MHOMED,
8447                         .state          = WREPL_STATE_TOMBSTONE,
8448                         .node           = WREPL_NODE_B,
8449                         .is_static      = False,
8450                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8451                         .ips            = addresses_B_3_4,
8452                         .apply_expected = False
8453                 },
8454         },
8455 /*
8456  * some more multi homed test, including merging
8457  */
8458         /*
8459          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8460          */
8461         {
8462                 .line   = __location__,
8463                 .section= "Test Replica vs. owned active: some more MHOMED combinations",
8464                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8465                 .skip   = (ctx->addresses_all_num < 3),
8466                 .wins   = {
8467                         .nb_flags       = 0,
8468                         .mhomed         = True,
8469                         .num_ips        = ctx->addresses_mhomed_num,
8470                         .ips            = ctx->addresses_mhomed,
8471                         .apply_expected = True
8472                 },
8473                 .defend = {
8474                         .timeout        = 0,
8475                 },
8476                 .replica= {
8477                         .type           = WREPL_TYPE_MHOMED,
8478                         .state          = WREPL_STATE_ACTIVE,
8479                         .node           = WREPL_NODE_B,
8480                         .is_static      = False,
8481                         .num_ips        = ctx->addresses_all_num,
8482                         .ips            = ctx->addresses_all,
8483                         .apply_expected = True
8484                 },
8485         },
8486         /*
8487          * mhomed,active vs. mhomed,active with same ips, unchecked
8488          */
8489         {
8490                 .line   = __location__,
8491                 .name   = _NBT_NAME("_MA_MA_SM_U", 0x00, NULL),
8492                 .skip   = (ctx->addresses_mhomed_num != 2),
8493                 .wins   = {
8494                         .nb_flags       = 0,
8495                         .mhomed         = True,
8496                         .num_ips        = ctx->addresses_mhomed_num,
8497                         .ips            = ctx->addresses_mhomed,
8498                         .apply_expected = True
8499                 },
8500                 .defend = {
8501                         .timeout        = 0,
8502                 },
8503                 .replica= {
8504                         .type           = WREPL_TYPE_MHOMED,
8505                         .state          = WREPL_STATE_ACTIVE,
8506                         .node           = WREPL_NODE_B,
8507                         .is_static      = False,
8508                         .num_ips        = ctx->addresses_mhomed_num,
8509                         .ips            = ctx->addresses_mhomed,
8510                         .apply_expected = True
8511                 },
8512         },
8513         /*
8514          * mhomed,active vs. mhomed,active with subset ip(s), positive response
8515          */
8516         {
8517                 .line   = __location__,
8518                 .name   = _NBT_NAME("_MA_MA_SB_P", 0x00, NULL),
8519                 .skip   = (ctx->addresses_mhomed_num != 2),
8520                 .wins   = {
8521                         .nb_flags       = 0,
8522                         .mhomed         = True,
8523                         .num_ips        = ctx->addresses_mhomed_num,
8524                         .ips            = ctx->addresses_mhomed,
8525                         .apply_expected = True
8526                 },
8527                 .defend = {
8528                         .timeout        = 10,
8529                         .positive       = True
8530                 },
8531                 .replica= {
8532                         .type           = WREPL_TYPE_MHOMED,
8533                         .state          = WREPL_STATE_ACTIVE,
8534                         .node           = WREPL_NODE_B,
8535                         .is_static      = False,
8536                         .num_ips        = ctx->addresses_best_num,
8537                         .ips            = ctx->addresses_best,
8538                         .mhomed_merge   = True
8539                 },
8540         },
8541         /*
8542          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with all addresses
8543          */
8544         {
8545                 .line   = __location__,
8546                 .name   = _NBT_NAME("_MA_MA_SB_A", 0x00, NULL),
8547                 .skip   = (ctx->addresses_all_num < 3),
8548                 .wins   = {
8549                         .nb_flags       = 0,
8550                         .mhomed         = True,
8551                         .num_ips        = ctx->addresses_mhomed_num,
8552                         .ips            = ctx->addresses_mhomed,
8553                         .apply_expected = True
8554                 },
8555                 .defend = {
8556                         .timeout        = 10,
8557                         .positive       = True,
8558                         .num_ips        = ctx->addresses_all_num,
8559                         .ips            = ctx->addresses_all,
8560                 },
8561                 .replica= {
8562                         .type           = WREPL_TYPE_MHOMED,
8563                         .state          = WREPL_STATE_ACTIVE,
8564                         .node           = WREPL_NODE_B,
8565                         .is_static      = False,
8566                         .num_ips        = ctx->addresses_best_num,
8567                         .ips            = ctx->addresses_best,
8568                         .mhomed_merge   = True
8569                 },
8570         },
8571         /*
8572          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with replicas addresses
8573          * TODO: check why the server sends a name release demand for one address?
8574          *       the release demand has no effect to the database record...
8575          */
8576         {
8577                 .line   = __location__,
8578                 .name   = _NBT_NAME("_MA_MA_SB_PRA", 0x00, NULL),
8579                 .skip   = (ctx->addresses_all_num < 3),
8580                 .wins   = {
8581                         .nb_flags       = 0,
8582                         .mhomed         = True,
8583                         .num_ips        = ctx->addresses_mhomed_num,
8584                         .ips            = ctx->addresses_mhomed,
8585                         .apply_expected = True
8586                 },
8587                 .defend = {
8588                         .timeout        = 10,
8589                         .positive       = True,
8590                         .num_ips        = ctx->addresses_best_num,
8591                         .ips            = ctx->addresses_best,
8592                         .late_release   = True
8593                 },
8594                 .replica= {
8595                         .type           = WREPL_TYPE_MHOMED,
8596                         .state          = WREPL_STATE_ACTIVE,
8597                         .node           = WREPL_NODE_B,
8598                         .is_static      = False,
8599                         .num_ips        = ctx->addresses_best_num,
8600                         .ips            = ctx->addresses_best,
8601                         .apply_expected = False
8602                 },
8603         },
8604         /*
8605          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with other addresses
8606          */
8607         {
8608                 .line   = __location__,
8609                 .name   = _NBT_NAME("_MA_MA_SB_O", 0x00, NULL),
8610
8611                 .skip   = (ctx->addresses_all_num < 3),
8612                 .wins   = {
8613                         .nb_flags       = 0,
8614                         .mhomed         = True,
8615                         .num_ips        = ctx->addresses_mhomed_num,
8616                         .ips            = ctx->addresses_mhomed,
8617                         .apply_expected = True
8618                 },
8619                 .defend = {
8620                         .timeout        = 10,
8621                         .positive       = True,
8622                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8623                         .ips            = addresses_B_3_4,
8624                 },
8625                 .replica= {
8626                         .type           = WREPL_TYPE_MHOMED,
8627                         .state          = WREPL_STATE_ACTIVE,
8628                         .node           = WREPL_NODE_B,
8629                         .is_static      = False,
8630                         .num_ips        = ctx->addresses_best_num,
8631                         .ips            = ctx->addresses_best,
8632                         .apply_expected = False
8633                 },
8634         },
8635         /*
8636          * mhomed,active vs. mhomed,active with subset ip(s), negative response
8637          */
8638         {
8639                 .line   = __location__,
8640                 .name   = _NBT_NAME("_MA_MA_SB_N", 0x00, NULL),
8641                 .skip   = (ctx->addresses_mhomed_num != 2),
8642                 .wins   = {
8643                         .nb_flags       = 0,
8644                         .mhomed         = True,
8645                         .num_ips        = ctx->addresses_mhomed_num,
8646                         .ips            = ctx->addresses_mhomed,
8647                         .apply_expected = True
8648                 },
8649                 .defend = {
8650                         .timeout        = 10,
8651                         .positive       = False
8652                 },
8653                 .replica= {
8654                         .type           = WREPL_TYPE_MHOMED,
8655                         .state          = WREPL_STATE_ACTIVE,
8656                         .node           = WREPL_NODE_B,
8657                         .is_static      = False,
8658                         .num_ips        = ctx->addresses_best_num,
8659                         .ips            = ctx->addresses_best,
8660                         .apply_expected = True
8661                 },
8662         },
8663 /*
8664  * some more multi homed and unique test, including merging
8665  */
8666         /*
8667          * mhomed,active vs. unique,active with subset ip(s), positive response
8668          */
8669         {
8670                 .line   = __location__,
8671                 .section= "Test Replica vs. owned active: some more UNIQUE,MHOMED combinations",
8672                 .name   = _NBT_NAME("_MA_UA_SB_P", 0x00, NULL),
8673                 .skip   = (ctx->addresses_all_num < 3),
8674                 .wins   = {
8675                         .nb_flags       = 0,
8676                         .mhomed         = True,
8677                         .num_ips        = ctx->addresses_mhomed_num,
8678                         .ips            = ctx->addresses_mhomed,
8679                         .apply_expected = True
8680                 },
8681                 .defend = {
8682                         .timeout        = 10,
8683                         .positive       = True,
8684                 },
8685                 .replica= {
8686                         .type           = WREPL_TYPE_UNIQUE,
8687                         .state          = WREPL_STATE_ACTIVE,
8688                         .node           = WREPL_NODE_B,
8689                         .is_static      = False,
8690                         .num_ips        = ctx->addresses_best_num,
8691                         .ips            = ctx->addresses_best,
8692                         .mhomed_merge   = True
8693                 },
8694         },
8695         /*
8696          * unique,active vs. unique,active with different ip(s), positive response, with all addresses
8697          */
8698         {
8699                 .line   = __location__,
8700                 .name   = _NBT_NAME("_UA_UA_DI_A", 0x00, NULL),
8701                 .skip   = (ctx->addresses_all_num < 3),
8702                 .wins   = {
8703                         .nb_flags       = 0,
8704                         .mhomed         = False,
8705                         .num_ips        = ctx->addresses_best_num,
8706                         .ips            = ctx->addresses_best,
8707                         .apply_expected = True
8708                 },
8709                 .defend = {
8710                         .timeout        = 10,
8711                         .positive       = True,
8712                         .num_ips        = ctx->addresses_all_num,
8713                         .ips            = ctx->addresses_all,
8714                 },
8715                 .replica= {
8716                         .type           = WREPL_TYPE_UNIQUE,
8717                         .state          = WREPL_STATE_ACTIVE,
8718                         .node           = WREPL_NODE_B,
8719                         .is_static      = False,
8720                         .num_ips        = ctx->addresses_best2_num,
8721                         .ips            = ctx->addresses_best2,
8722                         .mhomed_merge   = True,
8723                 },
8724         },
8725         /*
8726          * unique,active vs. mhomed,active with different ip(s), positive response, with all addresses
8727          */
8728         {
8729                 .line   = __location__,
8730                 .name   = _NBT_NAME("_UA_MA_DI_A", 0x00, NULL),
8731                 .skip   = (ctx->addresses_all_num < 3),
8732                 .wins   = {
8733                         .nb_flags       = 0,
8734                         .mhomed         = False,
8735                         .num_ips        = ctx->addresses_best_num,
8736                         .ips            = ctx->addresses_best,
8737                         .apply_expected = True
8738                 },
8739                 .defend = {
8740                         .timeout        = 10,
8741                         .positive       = True,
8742                         .num_ips        = ctx->addresses_all_num,
8743                         .ips            = ctx->addresses_all,
8744                 },
8745                 .replica= {
8746                         .type           = WREPL_TYPE_MHOMED,
8747                         .state          = WREPL_STATE_ACTIVE,
8748                         .node           = WREPL_NODE_B,
8749                         .is_static      = False,
8750                         .num_ips        = ctx->addresses_best2_num,
8751                         .ips            = ctx->addresses_best2,
8752                         .mhomed_merge   = True,
8753                 },
8754         },
8755 /*
8756  * special group vs. special group merging section
8757  */
8758         /*
8759          * sgroup,active vs. sgroup,active with different ip(s)
8760          */
8761         {
8762                 .line   = __location__,
8763                 .section= "Test Replica vs. owned active: SGROUP vs. SGROUP tests",
8764                 .name   = _NBT_NAME("_SA_SA_DI_U", 0x1C, NULL),
8765                 .skip   = (ctx->addresses_all_num < 3),
8766                 .wins   = {
8767                         .nb_flags       = NBT_NM_GROUP,
8768                         .mhomed         = False,
8769                         .num_ips        = ctx->addresses_mhomed_num,
8770                         .ips            = ctx->addresses_mhomed,
8771                         .apply_expected = True
8772                 },
8773                 .defend = {
8774                         .timeout        = 0,
8775                 },
8776                 .replica= {
8777                         .type           = WREPL_TYPE_SGROUP,
8778                         .state          = WREPL_STATE_ACTIVE,
8779                         .node           = WREPL_NODE_B,
8780                         .is_static      = False,
8781                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8782                         .ips            = addresses_B_3_4,
8783                         .sgroup_merge   = True
8784                 },
8785         },
8786         /*
8787          * sgroup,active vs. sgroup,active with same ip(s)
8788          */
8789         {
8790                 .line   = __location__,
8791                 .name   = _NBT_NAME("_SA_SA_SI_U", 0x1C, NULL),
8792                 .skip   = (ctx->addresses_all_num < 3),
8793                 .wins   = {
8794                         .nb_flags       = NBT_NM_GROUP,
8795                         .mhomed         = False,
8796                         .num_ips        = ctx->addresses_mhomed_num,
8797                         .ips            = ctx->addresses_mhomed,
8798                         .apply_expected = True
8799                 },
8800                 .defend = {
8801                         .timeout        = 0,
8802                 },
8803                 .replica= {
8804                         .type           = WREPL_TYPE_SGROUP,
8805                         .state          = WREPL_STATE_ACTIVE,
8806                         .node           = WREPL_NODE_B,
8807                         .is_static      = False,
8808                         .num_ips        = ctx->addresses_mhomed_num,
8809                         .ips            = ctx->addresses_mhomed,
8810                         .sgroup_merge   = True
8811                 },
8812         },
8813         /*
8814          * sgroup,active vs. sgroup,active with superset ip(s)
8815          */
8816         {
8817                 .line   = __location__,
8818                 .name   = _NBT_NAME("_SA_SA_SP_U", 0x1C, NULL),
8819                 .skip   = (ctx->addresses_all_num < 3),
8820                 .wins   = {
8821                         .nb_flags       = NBT_NM_GROUP,
8822                         .mhomed         = False,
8823                         .num_ips        = ctx->addresses_mhomed_num,
8824                         .ips            = ctx->addresses_mhomed,
8825                         .apply_expected = True
8826                 },
8827                 .defend = {
8828                         .timeout        = 0,
8829                 },
8830                 .replica= {
8831                         .type           = WREPL_TYPE_SGROUP,
8832                         .state          = WREPL_STATE_ACTIVE,
8833                         .node           = WREPL_NODE_B,
8834                         .is_static      = False,
8835                         .num_ips        = ctx->addresses_all_num,
8836                         .ips            = ctx->addresses_all,
8837                         .sgroup_merge   = True
8838                 },
8839         },
8840         /*
8841          * sgroup,active vs. sgroup,active with subset ip(s)
8842          */
8843         {
8844                 .line   = __location__,
8845                 .name   = _NBT_NAME("_SA_SA_SB_U", 0x1C, NULL),
8846                 .skip   = (ctx->addresses_all_num < 3),
8847                 .wins   = {
8848                         .nb_flags       = NBT_NM_GROUP,
8849                         .mhomed         = False,
8850                         .num_ips        = ctx->addresses_mhomed_num,
8851                         .ips            = ctx->addresses_mhomed,
8852                         .apply_expected = True
8853                 },
8854                 .defend = {
8855                         .timeout        = 0,
8856                 },
8857                 .replica= {
8858                         .type           = WREPL_TYPE_SGROUP,
8859                         .state          = WREPL_STATE_ACTIVE,
8860                         .node           = WREPL_NODE_B,
8861                         .is_static      = False,
8862                         .num_ips        = ctx->addresses_best_num,
8863                         .ips            = ctx->addresses_best,
8864                         .sgroup_merge   = True
8865                 },
8866         },
8867         /*
8868          * sgroup,active vs. sgroup,tombstone with different ip(s)
8869          */
8870         {
8871                 .line   = __location__,
8872                 .name   = _NBT_NAME("_SA_ST_DI_U", 0x1C, NULL),
8873                 .skip   = (ctx->addresses_all_num < 3),
8874                 .wins   = {
8875                         .nb_flags       = NBT_NM_GROUP,
8876                         .mhomed         = False,
8877                         .num_ips        = ctx->addresses_mhomed_num,
8878                         .ips            = ctx->addresses_mhomed,
8879                         .apply_expected = True
8880                 },
8881                 .defend = {
8882                         .timeout        = 0,
8883                 },
8884                 .replica= {
8885                         .type           = WREPL_TYPE_SGROUP,
8886                         .state          = WREPL_STATE_TOMBSTONE,
8887                         .node           = WREPL_NODE_B,
8888                         .is_static      = False,
8889                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8890                         .ips            = addresses_B_3_4,
8891                         .apply_expected = False
8892                 },
8893         },
8894         /*
8895          * sgroup,active vs. sgroup,tombstone with same ip(s)
8896          */
8897         {
8898                 .line   = __location__,
8899                 .name   = _NBT_NAME("_SA_ST_SI_U", 0x1C, NULL),
8900                 .skip   = (ctx->addresses_all_num < 3),
8901                 .wins   = {
8902                         .nb_flags       = NBT_NM_GROUP,
8903                         .mhomed         = False,
8904                         .num_ips        = ctx->addresses_mhomed_num,
8905                         .ips            = ctx->addresses_mhomed,
8906                         .apply_expected = True
8907                 },
8908                 .defend = {
8909                         .timeout        = 0,
8910                 },
8911                 .replica= {
8912                         .type           = WREPL_TYPE_SGROUP,
8913                         .state          = WREPL_STATE_TOMBSTONE,
8914                         .node           = WREPL_NODE_B,
8915                         .is_static      = False,
8916                         .num_ips        = ctx->addresses_mhomed_num,
8917                         .ips            = ctx->addresses_mhomed,
8918                         .apply_expected = False
8919                 },
8920         },
8921         /*
8922          * sgroup,active vs. sgroup,tombstone with superset ip(s)
8923          */
8924         {
8925                 .line   = __location__,
8926                 .name   = _NBT_NAME("_SA_ST_SP_U", 0x1C, NULL),
8927                 .skip   = (ctx->addresses_all_num < 3),
8928                 .wins   = {
8929                         .nb_flags       = NBT_NM_GROUP,
8930                         .mhomed         = False,
8931                         .num_ips        = ctx->addresses_mhomed_num,
8932                         .ips            = ctx->addresses_mhomed,
8933                         .apply_expected = True
8934                 },
8935                 .defend = {
8936                         .timeout        = 0,
8937                 },
8938                 .replica= {
8939                         .type           = WREPL_TYPE_SGROUP,
8940                         .state          = WREPL_STATE_TOMBSTONE,
8941                         .node           = WREPL_NODE_B,
8942                         .is_static      = False,
8943                         .num_ips        = ctx->addresses_all_num,
8944                         .ips            = ctx->addresses_all,
8945                         .apply_expected = False
8946                 },
8947         },
8948         /*
8949          * sgroup,active vs. sgroup,tombstone with subset ip(s)
8950          */
8951         {
8952                 .line   = __location__,
8953                 .name   = _NBT_NAME("_SA_ST_SB_U", 0x1C, NULL),
8954                 .skip   = (ctx->addresses_all_num < 3),
8955                 .wins   = {
8956                         .nb_flags       = NBT_NM_GROUP,
8957                         .mhomed         = False,
8958                         .num_ips        = ctx->addresses_mhomed_num,
8959                         .ips            = ctx->addresses_mhomed,
8960                         .apply_expected = True
8961                 },
8962                 .defend = {
8963                         .timeout        = 0,
8964                 },
8965                 .replica= {
8966                         .type           = WREPL_TYPE_SGROUP,
8967                         .state          = WREPL_STATE_TOMBSTONE,
8968                         .node           = WREPL_NODE_B,
8969                         .is_static      = False,
8970                         .num_ips        = ctx->addresses_best_num,
8971                         .ips            = ctx->addresses_best,
8972                         .apply_expected = False
8973                 },
8974         },
8975         };
8976
8977         if (!ctx) return False;
8978
8979         if (!ctx->nbtsock_srv) {
8980                 printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
8981                         lp_nbt_port());
8982                 return True;
8983         }
8984
8985         printf("Test Replica records vs. owned active records\n");
8986
8987         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
8988                 struct timeval end;
8989                 struct test_conflict_owned_active_vs_replica_struct record = records[i];
8990                 uint32_t j, count = 1;
8991                 const char *action;
8992
8993                 if (records[i].wins.mhomed || records[i].name.type == 0x1C) {
8994                         count = records[i].wins.num_ips;
8995                 }
8996
8997                 if (records[i].section) {
8998                         printf("%s\n", records[i].section);
8999                 }
9000
9001                 if (records[i].skip) {
9002                         printf("%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name));
9003                         continue;
9004                 }
9005
9006                 if (records[i].replica.mhomed_merge) {
9007                         action = "MHOMED_MERGE";
9008                 } else if (records[i].replica.sgroup_merge) {
9009                         action = "SGROUP_MERGE";
9010                 } else if (records[i].replica.apply_expected) {
9011                         action = "REPLACE";
9012                 } else {
9013                         action = "NOT REPLACE";
9014                 }
9015
9016                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name), action);
9017
9018                 /* Prepare for multi homed registration */
9019                 ZERO_STRUCT(records[i].defend);
9020                 records[i].defend.timeout       = 10;
9021                 records[i].defend.positive      = True;
9022                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9023                                          test_conflict_owned_active_vs_replica_handler,
9024                                          &records[i]);
9025                 if (ctx->nbtsock_srv2) {
9026                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9027                                                  test_conflict_owned_active_vs_replica_handler,
9028                                                  &records[i]);
9029                 }
9030
9031                 /*
9032                  * Setup Register
9033                  */
9034                 for (j=0; j < count; j++) {
9035                         struct nbt_name_request *req;
9036
9037                         name_register->in.name          = records[i].name;
9038                         name_register->in.dest_addr     = ctx->address;
9039                         name_register->in.address       = records[i].wins.ips[j].ip;
9040                         name_register->in.nb_flags      = records[i].wins.nb_flags;
9041                         name_register->in.register_demand= False;
9042                         name_register->in.broadcast     = False;
9043                         name_register->in.multi_homed   = records[i].wins.mhomed;
9044                         name_register->in.ttl           = 300000;
9045                         name_register->in.timeout       = 70;
9046                         name_register->in.retries       = 0;
9047
9048                         req = nbt_name_register_send(ctx->nbtsock, name_register);
9049
9050                         /* push the request on the wire */
9051                         event_loop_once(ctx->nbtsock->event_ctx);
9052
9053                         /*
9054                          * if we register multiple addresses,
9055                          * the server will do name queries to see if the old addresses
9056                          * are still alive
9057                          */
9058                         if (records[i].wins.mhomed && j > 0) {
9059                                 end = timeval_current_ofs(records[i].defend.timeout,0);
9060                                 records[i].defend.ret = True;
9061                                 while (records[i].defend.timeout > 0) {
9062                                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9063                                         if (timeval_expired(&end)) break;
9064                                 }
9065                                 ret &= records[i].defend.ret;
9066                         }
9067
9068                         status = nbt_name_register_recv(req, ctx, name_register);
9069                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9070                                 printf("No response from %s for name register\n", ctx->address);
9071                                 ret = False;
9072                         }
9073                         if (!NT_STATUS_IS_OK(status)) {
9074                                 printf("Bad response from %s for name register - %s\n",
9075                                        ctx->address, nt_errstr(status));
9076                                 ret = False;
9077                         }
9078                         CHECK_VALUE(name_register->out.rcode, 0);
9079                         CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
9080                         CHECK_VALUE(name_register->out.name.type, records[i].name.type);
9081                         CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
9082                         CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
9083                         CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[j].ip);
9084                 }
9085
9086                 /* Prepare for the current test */
9087                 records[i].defend = record.defend;
9088                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9089                                          test_conflict_owned_active_vs_replica_handler,
9090                                          &records[i]);
9091                 if (ctx->nbtsock_srv2) {
9092                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9093                                                  test_conflict_owned_active_vs_replica_handler,
9094                                                  &records[i]);
9095                 }
9096
9097                 /*
9098                  * Setup Replica
9099                  */
9100                 wins_name->name         = &records[i].name;
9101                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
9102                                                            records[i].replica.state,
9103                                                            records[i].replica.node,
9104                                                            records[i].replica.is_static);
9105                 wins_name->id           = ++ctx->b.max_version;
9106                 if (wins_name->flags & 2) {
9107                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
9108                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
9109                 } else {
9110                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
9111                 }
9112                 wins_name->unknown      = "255.255.255.255";
9113
9114                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9115
9116                 /*
9117                  * wait for the name query, which is handled in
9118                  * test_conflict_owned_active_vs_replica_handler()
9119                  */
9120                 end = timeval_current_ofs(records[i].defend.timeout,0);
9121                 records[i].defend.ret = True;
9122                 while (records[i].defend.timeout > 0) {
9123                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9124                         if (timeval_expired(&end)) break;
9125                 }
9126                 ret &= records[i].defend.ret;
9127
9128                 if (records[i].defend.late_release) {
9129                         records[i].defend = record.defend;
9130                         records[i].defend.expect_release = True;
9131                         /*
9132                          * wait for the name release demand, which is handled in
9133                          * test_conflict_owned_active_vs_replica_handler()
9134                          */
9135                         end = timeval_current_ofs(records[i].defend.timeout,0);
9136                         records[i].defend.ret = True;
9137                         while (records[i].defend.timeout > 0) {
9138                                 event_loop_once(ctx->nbtsock_srv->event_ctx);
9139                                 if (timeval_expired(&end)) break;
9140                         }
9141                         ret &= records[i].defend.ret;
9142                 }
9143
9144                 if (records[i].replica.mhomed_merge) {
9145                         ret &= test_wrepl_mhomed_merged(ctx, &ctx->c,
9146                                                         records[i].wins.num_ips, records[i].wins.ips,
9147                                                         &ctx->b,
9148                                                         records[i].replica.num_ips, records[i].replica.ips,
9149                                                         wins_name);
9150                 } else if (records[i].replica.sgroup_merge) {
9151                         ret &= test_wrepl_sgroup_merged(ctx, NULL,
9152                                                         &ctx->c,
9153                                                         records[i].wins.num_ips, records[i].wins.ips,
9154                                                         &ctx->b,
9155                                                         records[i].replica.num_ips, records[i].replica.ips,
9156                                                         wins_name);
9157                 } else {
9158                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
9159                                                      records[i].replica.apply_expected);
9160                 }
9161
9162                 if (records[i].replica.apply_expected ||
9163                     records[i].replica.mhomed_merge) {
9164                         wins_name->name         = &records[i].name;
9165                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9166                                                                    WREPL_STATE_TOMBSTONE,
9167                                                                    WREPL_NODE_B, False);
9168                         wins_name->id           = ++ctx->b.max_version;
9169                         wins_name->addresses.ip = addresses_B_1[0].ip;
9170                         wins_name->unknown      = "255.255.255.255";
9171
9172                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9173                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9174                 } else {
9175                         for (j=0; j < count; j++) {
9176                                 struct nbt_name_socket *nbtsock = ctx->nbtsock;
9177
9178                                 if (ctx->myaddr2 && strcmp(records[i].wins.ips[j].ip, ctx->myaddr2) == 0) {
9179                                         nbtsock = ctx->nbtsock2;
9180                                 }
9181
9182                                 release->in.name        = records[i].name;
9183                                 release->in.dest_addr   = ctx->address;
9184                                 release->in.address     = records[i].wins.ips[j].ip;
9185                                 release->in.nb_flags    = records[i].wins.nb_flags;
9186                                 release->in.broadcast   = False;
9187                                 release->in.timeout     = 30;
9188                                 release->in.retries     = 0;
9189
9190                                 status = nbt_name_release(nbtsock, ctx, release);
9191                                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9192                                         printf("No response from %s for name release\n", ctx->address);
9193                                         return False;
9194                                 }
9195                                 if (!NT_STATUS_IS_OK(status)) {
9196                                         printf("Bad response from %s for name query - %s\n",
9197                                                ctx->address, nt_errstr(status));
9198                                         return False;
9199                                 }
9200                                 CHECK_VALUE(release->out.rcode, 0);
9201                         }
9202
9203                         if (records[i].replica.sgroup_merge) {
9204                                 /* clean up the SGROUP record */
9205                                 wins_name->name         = &records[i].name;
9206                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9207                                                                            WREPL_STATE_ACTIVE,
9208                                                                            WREPL_NODE_B, False);
9209                                 wins_name->id           = ++ctx->b.max_version;
9210                                 wins_name->addresses.addresses.num_ips = 0;
9211                                 wins_name->addresses.addresses.ips     = NULL;
9212                                 wins_name->unknown      = "255.255.255.255";
9213                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9214
9215                                 /* take ownership of the SGROUP record */
9216                                 wins_name->name         = &records[i].name;
9217                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9218                                                                            WREPL_STATE_ACTIVE,
9219                                                                            WREPL_NODE_B, False);
9220                                 wins_name->id           = ++ctx->b.max_version;
9221                                 wins_name->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
9222                                 wins_name->addresses.addresses.ips     = discard_const(addresses_B_1);
9223                                 wins_name->unknown      = "255.255.255.255";
9224                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9225                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9226
9227                                 /* overwrite the SGROUP record with unique,tombstone */
9228                                 wins_name->name         = &records[i].name;
9229                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9230                                                                            WREPL_STATE_TOMBSTONE,
9231                                                                            WREPL_NODE_B, False);
9232                                 wins_name->id           = ++ctx->b.max_version;
9233                                 wins_name->addresses.ip = addresses_A_1[0].ip;
9234                                 wins_name->unknown      = "255.255.255.255";
9235                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9236                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9237                         }
9238                 }
9239
9240 done:
9241                 if (!ret) {
9242                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
9243                         return ret;
9244                 }
9245         }
9246
9247         return ret;
9248 }
9249
9250 #define _NBT_ASSERT(v, correct) do { \
9251         if ((v) != (correct)) { \
9252                 printf("(%s) Incorrect value %s=%d - should be %s (%d)\n", \
9253                        __location__, #v, v, #correct, correct); \
9254                 return; \
9255         } \
9256 } while (0)
9257
9258 #define _NBT_ASSERT_STRING(v, correct) do { \
9259         if ( ((!v) && (correct)) || \
9260              ((v) && (!correct)) || \
9261              ((v) && (correct) && strcmp(v,correct) != 0)) { \
9262                 printf("(%s) Incorrect value %s=%s - should be %s\n", \
9263                        __location__, #v, v, correct); \
9264                 return; \
9265         } \
9266 } while (0)
9267
9268 static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_socket *nbtsock, 
9269                                                                 struct nbt_name_packet *req_packet, 
9270                                                                 const struct nbt_peer_socket *src)
9271 {
9272         struct nbt_name *name;
9273         struct nbt_name_packet *rep_packet;
9274         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9275
9276         _NBT_ASSERT(req_packet->qdcount, 1);
9277         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9278         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9279
9280         name = &req_packet->questions[0].name;
9281
9282         _NBT_ASSERT(name->type, rec->name.type);
9283         _NBT_ASSERT_STRING(name->name, rec->name.name);
9284         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9285
9286         _NBT_ASSERT(rec->defend.expect_release, False);
9287
9288         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9289         if (rep_packet == NULL) return;
9290
9291         rep_packet->name_trn_id = req_packet->name_trn_id;
9292         rep_packet->ancount     = 1;
9293
9294         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9295         if (rep_packet->answers == NULL) return;
9296
9297         rep_packet->answers[0].name      = *name;
9298         rep_packet->answers[0].rr_class  = NBT_QCLASS_IP;
9299         rep_packet->answers[0].ttl       = 0;
9300
9301         if (rec->defend.positive) {
9302                 uint32_t i, num_ips;
9303                 const struct wrepl_ip *ips;             
9304
9305                 if (rec->defend.num_ips > 0) {
9306                         num_ips = rec->defend.num_ips;
9307                         ips     = rec->defend.ips;
9308                 } else {
9309                         num_ips = rec->wins.num_ips;
9310                         ips     = rec->wins.ips;
9311                 }
9312
9313                 /* send a positive reply */
9314                 rep_packet->operation   = 
9315                                         NBT_FLAG_REPLY | 
9316                                         NBT_OPCODE_QUERY | 
9317                                         NBT_FLAG_AUTHORITIVE |
9318                                         NBT_FLAG_RECURSION_DESIRED |
9319                                         NBT_FLAG_RECURSION_AVAIL;
9320
9321                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NETBIOS;
9322
9323                 rep_packet->answers[0].rdata.netbios.length = num_ips*6;
9324                 rep_packet->answers[0].rdata.netbios.addresses = 
9325                         talloc_array(rep_packet->answers, struct nbt_rdata_address, num_ips);
9326                 if (rep_packet->answers[0].rdata.netbios.addresses == NULL) return;
9327
9328                 for (i=0; i < num_ips; i++) {
9329                         struct nbt_rdata_address *addr = 
9330                                 &rep_packet->answers[0].rdata.netbios.addresses[i];
9331                         addr->nb_flags  = rec->wins.nb_flags;
9332                         addr->ipaddr    = ips[i].ip;
9333                 }
9334                 DEBUG(2,("Sending positive name query reply for %s to %s:%d\n", 
9335                         nbt_name_string(rep_packet, name), src->addr, src->port));
9336         } else {
9337                 /* send a negative reply */
9338                 rep_packet->operation   =
9339                                         NBT_FLAG_REPLY | 
9340                                         NBT_OPCODE_QUERY | 
9341                                         NBT_FLAG_AUTHORITIVE |
9342                                         NBT_RCODE_NAM;
9343
9344                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NULL;
9345
9346                 ZERO_STRUCT(rep_packet->answers[0].rdata);
9347
9348                 DEBUG(2,("Sending negative name query reply for %s to %s:%d\n", 
9349                         nbt_name_string(rep_packet, name), src->addr, src->port));
9350         }
9351
9352         nbt_name_reply_send(nbtsock, src, rep_packet);
9353         talloc_free(rep_packet);
9354
9355         /* make sure we push the reply to the wire */
9356         event_loop_once(nbtsock->event_ctx);
9357
9358         rec->defend.timeout     = 0;
9359         rec->defend.ret         = True;
9360 }
9361
9362 static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_name_socket *nbtsock, 
9363                                                                   struct nbt_name_packet *req_packet, 
9364                                                                   const struct nbt_peer_socket *src)
9365 {
9366         struct nbt_name *name;
9367         struct nbt_name_packet *rep_packet;
9368         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9369
9370         _NBT_ASSERT(req_packet->qdcount, 1);
9371         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9372         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9373
9374         name = &req_packet->questions[0].name;
9375
9376         _NBT_ASSERT(name->type, rec->name.type);
9377         _NBT_ASSERT_STRING(name->name, rec->name.name);
9378         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9379
9380         _NBT_ASSERT(rec->defend.expect_release, True);
9381
9382         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9383         if (rep_packet == NULL) return;
9384
9385         rep_packet->name_trn_id = req_packet->name_trn_id;
9386         rep_packet->ancount     = 1;
9387         rep_packet->operation   = 
9388                                 NBT_FLAG_REPLY | 
9389                                 NBT_OPCODE_RELEASE |
9390                                 NBT_FLAG_AUTHORITIVE;
9391
9392         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9393         if (rep_packet->answers == NULL) return;
9394
9395         rep_packet->answers[0].name     = *name;
9396         rep_packet->answers[0].rr_type  = NBT_QTYPE_NETBIOS;
9397         rep_packet->answers[0].rr_class = NBT_QCLASS_IP;
9398         rep_packet->answers[0].ttl      = req_packet->additional[0].ttl;
9399         rep_packet->answers[0].rdata    = req_packet->additional[0].rdata;
9400
9401         DEBUG(2,("Sending name release reply for %s to %s:%d\n", 
9402                 nbt_name_string(rep_packet, name), src->addr, src->port));
9403
9404         nbt_name_reply_send(nbtsock, src, rep_packet);
9405         talloc_free(rep_packet);
9406
9407         /* make sure we push the reply to the wire */
9408         event_loop_once(nbtsock->event_ctx);
9409
9410         rec->defend.timeout     = 0;
9411         rec->defend.ret         = True;
9412 }
9413
9414 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
9415                                                           struct nbt_name_packet *req_packet, 
9416                                                           const struct nbt_peer_socket *src)
9417 {
9418         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9419
9420         rec->defend.ret = False;
9421
9422         switch (req_packet->operation & NBT_OPCODE) {
9423         case NBT_OPCODE_QUERY:
9424                 test_conflict_owned_active_vs_replica_handler_query(nbtsock, req_packet, src);
9425                 break;
9426         case NBT_OPCODE_RELEASE:
9427                 test_conflict_owned_active_vs_replica_handler_release(nbtsock, req_packet, src);
9428                 break;
9429         default:
9430                 printf("%s: unexpected incoming packet\n", __location__);
9431                 return;
9432         }
9433 }
9434
9435 /*
9436   test WINS replication operations
9437 */
9438 BOOL torture_nbt_winsreplication_quick(void)
9439 {
9440         const char *address;
9441         struct nbt_name name;
9442         TALLOC_CTX *mem_ctx = talloc_new(NULL);
9443         NTSTATUS status;
9444         BOOL ret = True;
9445         struct test_wrepl_conflict_conn *ctx;
9446
9447         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
9448
9449         /* do an initial name resolution to find its IP */
9450         status = resolve_name(&name, mem_ctx, &address, NULL);
9451         if (!NT_STATUS_IS_OK(status)) {
9452                 printf("Failed to resolve %s - %s\n",
9453                        name.name, nt_errstr(status));
9454                 talloc_free(mem_ctx);
9455                 return False;
9456         }
9457
9458         ret &= test_assoc_ctx1(mem_ctx, address);
9459         ret &= test_assoc_ctx2(mem_ctx, address);
9460
9461         ret &= test_wins_replication(mem_ctx, address);
9462
9463         ctx = test_create_conflict_ctx(mem_ctx, address);
9464
9465         ret &= test_conflict_same_owner(ctx);
9466         ret &= test_conflict_owned_released_vs_replica(ctx);
9467
9468         talloc_free(mem_ctx);
9469
9470         return ret;
9471 }
9472
9473 /*
9474   test WINS replication operations
9475 */
9476 BOOL torture_nbt_winsreplication(void)
9477 {
9478         const char *address;
9479         struct nbt_name name;
9480         TALLOC_CTX *mem_ctx = talloc_new(NULL);
9481         NTSTATUS status;
9482         BOOL ret = True;
9483         struct test_wrepl_conflict_conn *ctx;
9484
9485         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
9486
9487         /* do an initial name resolution to find its IP */
9488         status = resolve_name(&name, mem_ctx, &address, NULL);
9489         if (!NT_STATUS_IS_OK(status)) {
9490                 printf("Failed to resolve %s - %s\n",
9491                        name.name, nt_errstr(status));
9492                 talloc_free(mem_ctx);
9493                 return False;
9494         }
9495
9496         ret &= test_assoc_ctx1(mem_ctx, address);
9497         ret &= test_assoc_ctx2(mem_ctx, address);
9498
9499         ret &= test_wins_replication(mem_ctx, address);
9500
9501         ctx = test_create_conflict_ctx(mem_ctx, address);
9502
9503         ret &= test_conflict_same_owner(ctx);
9504         ret &= test_conflict_different_owner(ctx);
9505         ret &= test_conflict_owned_released_vs_replica(ctx);
9506         ret &= test_conflict_owned_active_vs_replica(ctx);
9507
9508         talloc_free(mem_ctx);
9509
9510         return ret;
9511 }