r11897: add 2 more sgroup vs. sgroup tests with the replica having no addresses
[samba.git] / source4 / 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, v, 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, 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                        partner->max_version, 
300                        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                         /* clean up the SGROUP record */
4757                         wins_name_r1->name      = &records[i].name;
4758                         wins_name_r1->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4759                                                                    WREPL_STATE_ACTIVE,
4760                                                                    WREPL_NODE_B, False);
4761                         wins_name_r1->id        = ++records[i].r1.owner->max_version;
4762                         wins_name_r1->addresses.addresses.num_ips = 0;
4763                         wins_name_r1->addresses.addresses.ips     = NULL;
4764                         wins_name_r1->unknown   = "255.255.255.255";
4765                         ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
4766
4767                         /* here we test how names from an owner are deleted */
4768                         if (records[i].r2.sgroup_merge && records[i].r2.num_ips) {
4769                                 ret &= test_wrepl_sgroup_merged(ctx, NULL,
4770                                                                 records[i].r2.owner,
4771                                                                 records[i].r2.num_ips, records[i].r2.ips,
4772                                                                 records[i].r1.owner,
4773                                                                 0, NULL,
4774                                                                 wins_name_r2);
4775                         }
4776
4777                         /* clean up the SGROUP record */
4778                         wins_name_r2->name      = &records[i].name;
4779                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4780                                                                    WREPL_STATE_ACTIVE,
4781                                                                    WREPL_NODE_B, False);
4782                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4783                         wins_name_r2->addresses.addresses.num_ips = 0;
4784                         wins_name_r2->addresses.addresses.ips     = NULL;
4785                         wins_name_r2->unknown   = "255.255.255.255";
4786                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4787
4788                         /* take ownership of the SGROUP record */
4789                         wins_name_r2->name      = &records[i].name;
4790                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4791                                                                    WREPL_STATE_ACTIVE,
4792                                                                    WREPL_NODE_B, False);
4793                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4794                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4795                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4796                         wins_name_r2->unknown   = "255.255.255.255";
4797                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4798                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4799
4800                         /* overwrite the SGROUP record with unique,tombstone */
4801                         wins_name_r2->name      = &records[i].name;
4802                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4803                                                                    WREPL_STATE_TOMBSTONE,
4804                                                                    WREPL_NODE_B, False);
4805                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4806                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4807                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4808                         wins_name_r2->unknown   = "255.255.255.255";
4809                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4810                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4811                 }
4812
4813                 /* the first one is a cleanup run */
4814                 if (!ret && i == 0) ret = True;
4815
4816                 if (!ret) {
4817                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
4818                         return ret;
4819                 }
4820         }
4821
4822         return ret;
4823 }
4824
4825 static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx)
4826 {
4827         BOOL ret = True;
4828         NTSTATUS status;
4829         struct wrepl_wins_name wins_name_;
4830         struct wrepl_wins_name *wins_name = &wins_name_;
4831         struct nbt_name_register name_register_;
4832         struct nbt_name_register *name_register = &name_register_;
4833         struct nbt_name_release release_;
4834         struct nbt_name_release *release = &release_;
4835         uint32_t i;
4836         struct {
4837                 const char *line; /* just better debugging */
4838                 struct nbt_name name;
4839                 struct {
4840                         uint32_t nb_flags;
4841                         BOOL mhomed;
4842                         uint32_t num_ips;
4843                         const struct wrepl_ip *ips;
4844                         BOOL apply_expected;
4845                 } wins;
4846                 struct {
4847                         enum wrepl_name_type type;
4848                         enum wrepl_name_state state;
4849                         enum wrepl_name_node node;
4850                         BOOL is_static;
4851                         uint32_t num_ips;
4852                         const struct wrepl_ip *ips;
4853                         BOOL apply_expected;
4854                 } replica;
4855         } records[] = {
4856 /* 
4857  * unique vs. unique section
4858  */
4859         /*
4860          * unique,released vs. unique,active with same ip(s)
4861          */
4862         {
4863                 .line   = __location__,
4864                 .name   = _NBT_NAME("_UR_UA_SI", 0x00, NULL),
4865                 .wins   = {
4866                         .nb_flags       = 0,
4867                         .mhomed         = False,
4868                         .num_ips        = ctx->addresses_best_num,
4869                         .ips            = ctx->addresses_best,
4870                         .apply_expected = True
4871                 },
4872                 .replica= {
4873                         .type           = WREPL_TYPE_UNIQUE,
4874                         .state          = WREPL_STATE_ACTIVE,
4875                         .node           = WREPL_NODE_B,
4876                         .is_static      = False,
4877                         .num_ips        = ctx->addresses_best_num,
4878                         .ips            = ctx->addresses_best,
4879                         .apply_expected = True
4880                 },
4881         },
4882         /*
4883          * unique,released vs. unique,active with different ip(s)
4884          */
4885         {
4886                 .line   = __location__,
4887                 .name   = _NBT_NAME("_UR_UA_DI", 0x00, NULL),
4888                 .wins   = {
4889                         .nb_flags       = 0,
4890                         .mhomed         = False,
4891                         .num_ips        = ctx->addresses_best_num,
4892                         .ips            = ctx->addresses_best,
4893                         .apply_expected = True
4894                 },
4895                 .replica= {
4896                         .type           = WREPL_TYPE_UNIQUE,
4897                         .state          = WREPL_STATE_ACTIVE,
4898                         .node           = WREPL_NODE_B,
4899                         .is_static      = False,
4900                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4901                         .ips            = addresses_B_1,
4902                         .apply_expected = True
4903                 },
4904         },
4905         /*
4906          * unique,released vs. unique,tombstone with same ip(s)
4907          */
4908         {
4909                 .line   = __location__,
4910                 .name   = _NBT_NAME("_UR_UT_SI", 0x00, NULL),
4911                 .wins   = {
4912                         .nb_flags       = 0,
4913                         .mhomed         = False,
4914                         .num_ips        = ctx->addresses_best_num,
4915                         .ips            = ctx->addresses_best,
4916                         .apply_expected = True
4917                 },
4918                 .replica= {
4919                         .type           = WREPL_TYPE_UNIQUE,
4920                         .state          = WREPL_STATE_TOMBSTONE,
4921                         .node           = WREPL_NODE_B,
4922                         .is_static      = False,
4923                         .num_ips        = ctx->addresses_best_num,
4924                         .ips            = ctx->addresses_best,
4925                         .apply_expected = True
4926                 },
4927         },
4928         /*
4929          * unique,released vs. unique,tombstone with different ip(s)
4930          */
4931         {
4932                 .line   = __location__,
4933                 .name   = _NBT_NAME("_UR_UT_DI", 0x00, NULL),
4934                 .wins   = {
4935                         .nb_flags       = 0,
4936                         .mhomed         = False,
4937                         .num_ips        = ctx->addresses_best_num,
4938                         .ips            = ctx->addresses_best,
4939                         .apply_expected = True
4940                 },
4941                 .replica= {
4942                         .type           = WREPL_TYPE_UNIQUE,
4943                         .state          = WREPL_STATE_TOMBSTONE,
4944                         .node           = WREPL_NODE_B,
4945                         .is_static      = False,
4946                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4947                         .ips            = addresses_B_1,
4948                         .apply_expected = True
4949                 },
4950         },
4951 /* 
4952  * unique vs. group section
4953  */
4954         /*
4955          * unique,released vs. group,active with same ip(s)
4956          */
4957         {
4958                 .line   = __location__,
4959                 .name   = _NBT_NAME("_UR_GA_SI", 0x00, NULL),
4960                 .wins   = {
4961                         .nb_flags       = 0,
4962                         .mhomed         = False,
4963                         .num_ips        = ctx->addresses_best_num,
4964                         .ips            = ctx->addresses_best,
4965                         .apply_expected = True
4966                 },
4967                 .replica= {
4968                         .type           = WREPL_TYPE_GROUP,
4969                         .state          = WREPL_STATE_ACTIVE,
4970                         .node           = WREPL_NODE_B,
4971                         .is_static      = False,
4972                         .num_ips        = ctx->addresses_best_num,
4973                         .ips            = ctx->addresses_best,
4974                         .apply_expected = True
4975                 },
4976         },
4977         /*
4978          * unique,released vs. group,active with different ip(s)
4979          */
4980         {
4981                 .line   = __location__,
4982                 .name   = _NBT_NAME("_UR_GA_DI", 0x00, NULL),
4983                 .wins   = {
4984                         .nb_flags       = 0,
4985                         .mhomed         = False,
4986                         .num_ips        = ctx->addresses_best_num,
4987                         .ips            = ctx->addresses_best,
4988                         .apply_expected = True
4989                 },
4990                 .replica= {
4991                         .type           = WREPL_TYPE_GROUP,
4992                         .state          = WREPL_STATE_ACTIVE,
4993                         .node           = WREPL_NODE_B,
4994                         .is_static      = False,
4995                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4996                         .ips            = addresses_B_1,
4997                         .apply_expected = True
4998                 },
4999         },
5000         /*
5001          * unique,released vs. group,tombstone with same ip(s)
5002          */
5003         {
5004                 .line   = __location__,
5005                 .name   = _NBT_NAME("_UR_GT_SI", 0x00, NULL),
5006                 .wins   = {
5007                         .nb_flags       = 0,
5008                         .mhomed         = False,
5009                         .num_ips        = ctx->addresses_best_num,
5010                         .ips            = ctx->addresses_best,
5011                         .apply_expected = True
5012                 },
5013                 .replica= {
5014                         .type           = WREPL_TYPE_GROUP,
5015                         .state          = WREPL_STATE_TOMBSTONE,
5016                         .node           = WREPL_NODE_B,
5017                         .is_static      = False,
5018                         .num_ips        = ctx->addresses_best_num,
5019                         .ips            = ctx->addresses_best,
5020                         .apply_expected = True
5021                 },
5022         },
5023         /*
5024          * unique,released vs. group,tombstone with different ip(s)
5025          */
5026         {
5027                 .line   = __location__,
5028                 .name   = _NBT_NAME("_UR_GT_DI", 0x00, NULL),
5029                 .wins   = {
5030                         .nb_flags       = 0,
5031                         .mhomed         = False,
5032                         .num_ips        = ctx->addresses_best_num,
5033                         .ips            = ctx->addresses_best,
5034                         .apply_expected = True
5035                 },
5036                 .replica= {
5037                         .type           = WREPL_TYPE_GROUP,
5038                         .state          = WREPL_STATE_TOMBSTONE,
5039                         .node           = WREPL_NODE_B,
5040                         .is_static      = False,
5041                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5042                         .ips            = addresses_B_1,
5043                         .apply_expected = True
5044                 },
5045         },
5046 /* 
5047  * unique vs. special group section
5048  */
5049         /*
5050          * unique,released vs. sgroup,active with same ip(s)
5051          */
5052         {
5053                 .line   = __location__,
5054                 .name   = _NBT_NAME("_UR_SA_SI", 0x00, NULL),
5055                 .wins   = {
5056                         .nb_flags       = 0,
5057                         .mhomed         = False,
5058                         .num_ips        = ctx->addresses_best_num,
5059                         .ips            = ctx->addresses_best,
5060                         .apply_expected = True
5061                 },
5062                 .replica= {
5063                         .type           = WREPL_TYPE_SGROUP,
5064                         .state          = WREPL_STATE_ACTIVE,
5065                         .node           = WREPL_NODE_B,
5066                         .is_static      = False,
5067                         .num_ips        = ctx->addresses_best_num,
5068                         .ips            = ctx->addresses_best,
5069                         .apply_expected = True
5070                 },
5071         },
5072         /*
5073          * unique,released vs. sgroup,active with different ip(s)
5074          */
5075         {
5076                 .line   = __location__,
5077                 .name   = _NBT_NAME("_UR_SA_DI", 0x00, NULL),
5078                 .wins   = {
5079                         .nb_flags       = 0,
5080                         .mhomed         = False,
5081                         .num_ips        = ctx->addresses_best_num,
5082                         .ips            = ctx->addresses_best,
5083                         .apply_expected = True
5084                 },
5085                 .replica= {
5086                         .type           = WREPL_TYPE_SGROUP,
5087                         .state          = WREPL_STATE_ACTIVE,
5088                         .node           = WREPL_NODE_B,
5089                         .is_static      = False,
5090                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5091                         .ips            = addresses_B_1,
5092                         .apply_expected = True
5093                 },
5094         },
5095         /*
5096          * unique,released vs. sgroup,tombstone with same ip(s)
5097          */
5098         {
5099                 .line   = __location__,
5100                 .name   = _NBT_NAME("_UR_ST_SI", 0x00, NULL),
5101                 .wins   = {
5102                         .nb_flags       = 0,
5103                         .mhomed         = False,
5104                         .num_ips        = ctx->addresses_best_num,
5105                         .ips            = ctx->addresses_best,
5106                         .apply_expected = True
5107                 },
5108                 .replica= {
5109                         .type           = WREPL_TYPE_SGROUP,
5110                         .state          = WREPL_STATE_TOMBSTONE,
5111                         .node           = WREPL_NODE_B,
5112                         .is_static      = False,
5113                         .num_ips        = ctx->addresses_best_num,
5114                         .ips            = ctx->addresses_best,
5115                         .apply_expected = True
5116                 },
5117         },
5118         /*
5119          * unique,released vs. sgroup,tombstone with different ip(s)
5120          */
5121         {
5122                 .line   = __location__,
5123                 .name   = _NBT_NAME("_UR_ST_DI", 0x00, NULL),
5124                 .wins   = {
5125                         .nb_flags       = 0,
5126                         .mhomed         = False,
5127                         .num_ips        = ctx->addresses_best_num,
5128                         .ips            = ctx->addresses_best,
5129                         .apply_expected = True
5130                 },
5131                 .replica= {
5132                         .type           = WREPL_TYPE_SGROUP,
5133                         .state          = WREPL_STATE_TOMBSTONE,
5134                         .node           = WREPL_NODE_B,
5135                         .is_static      = False,
5136                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5137                         .ips            = addresses_B_1,
5138                         .apply_expected = True
5139                 },
5140         },
5141 /* 
5142  * unique vs. multi homed section
5143  */
5144         /*
5145          * unique,released vs. mhomed,active with same ip(s)
5146          */
5147         {
5148                 .line   = __location__,
5149                 .name   = _NBT_NAME("_UR_MA_SI", 0x00, NULL),
5150                 .wins   = {
5151                         .nb_flags       = 0,
5152                         .mhomed         = False,
5153                         .num_ips        = ctx->addresses_best_num,
5154                         .ips            = ctx->addresses_best,
5155                         .apply_expected = True
5156                 },
5157                 .replica= {
5158                         .type           = WREPL_TYPE_MHOMED,
5159                         .state          = WREPL_STATE_ACTIVE,
5160                         .node           = WREPL_NODE_B,
5161                         .is_static      = False,
5162                         .num_ips        = ctx->addresses_best_num,
5163                         .ips            = ctx->addresses_best,
5164                         .apply_expected = True
5165                 },
5166         },
5167         /*
5168          * unique,released vs. mhomed,active with different ip(s)
5169          */
5170         {
5171                 .line   = __location__,
5172                 .name   = _NBT_NAME("_UR_MA_DI", 0x00, NULL),
5173                 .wins   = {
5174                         .nb_flags       = 0,
5175                         .mhomed         = False,
5176                         .num_ips        = ctx->addresses_best_num,
5177                         .ips            = ctx->addresses_best,
5178                         .apply_expected = True
5179                 },
5180                 .replica= {
5181                         .type           = WREPL_TYPE_MHOMED,
5182                         .state          = WREPL_STATE_ACTIVE,
5183                         .node           = WREPL_NODE_B,
5184                         .is_static      = False,
5185                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5186                         .ips            = addresses_B_1,
5187                         .apply_expected = True
5188                 },
5189         },
5190         /*
5191          * unique,released vs. mhomed,tombstone with same ip(s)
5192          */
5193         {
5194                 .line   = __location__,
5195                 .name   = _NBT_NAME("_UR_MT_SI", 0x00, NULL),
5196                 .wins   = {
5197                         .nb_flags       = 0,
5198                         .mhomed         = False,
5199                         .num_ips        = ctx->addresses_best_num,
5200                         .ips            = ctx->addresses_best,
5201                         .apply_expected = True
5202                 },
5203                 .replica= {
5204                         .type           = WREPL_TYPE_MHOMED,
5205                         .state          = WREPL_STATE_TOMBSTONE,
5206                         .node           = WREPL_NODE_B,
5207                         .is_static      = False,
5208                         .num_ips        = ctx->addresses_best_num,
5209                         .ips            = ctx->addresses_best,
5210                         .apply_expected = True
5211                 },
5212         },
5213         /*
5214          * unique,released vs. mhomed,tombstone with different ip(s)
5215          */
5216         {
5217                 .line   = __location__,
5218                 .name   = _NBT_NAME("_UR_MT_DI", 0x00, NULL),
5219                 .wins   = {
5220                         .nb_flags       = 0,
5221                         .mhomed         = False,
5222                         .num_ips        = ctx->addresses_best_num,
5223                         .ips            = ctx->addresses_best,
5224                         .apply_expected = True
5225                 },
5226                 .replica= {
5227                         .type           = WREPL_TYPE_MHOMED,
5228                         .state          = WREPL_STATE_TOMBSTONE,
5229                         .node           = WREPL_NODE_B,
5230                         .is_static      = False,
5231                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5232                         .ips            = addresses_B_1,
5233                         .apply_expected = True
5234                 },
5235         },
5236 /* 
5237  * group vs. unique section
5238  */
5239         /*
5240          * group,released vs. unique,active with same ip(s)
5241          */
5242         {
5243                 .line   = __location__,
5244                 .name   = _NBT_NAME("_GR_UA_SI", 0x00, NULL),
5245                 .wins   = {
5246                         .nb_flags       = NBT_NM_GROUP,
5247                         .mhomed         = False,
5248                         .num_ips        = ctx->addresses_best_num,
5249                         .ips            = ctx->addresses_best,
5250                         .apply_expected = True
5251                 },
5252                 .replica= {
5253                         .type           = WREPL_TYPE_UNIQUE,
5254                         .state          = WREPL_STATE_ACTIVE,
5255                         .node           = WREPL_NODE_B,
5256                         .is_static      = False,
5257                         .num_ips        = ctx->addresses_best_num,
5258                         .ips            = ctx->addresses_best,
5259                         .apply_expected = False
5260                 },
5261         },
5262         /*
5263          * group,released vs. unique,active with different ip(s)
5264          */
5265         {
5266                 .line   = __location__,
5267                 .name   = _NBT_NAME("_GR_UA_DI", 0x00, NULL),
5268                 .wins   = {
5269                         .nb_flags       = NBT_NM_GROUP,
5270                         .mhomed         = False,
5271                         .num_ips        = ctx->addresses_best_num,
5272                         .ips            = ctx->addresses_best,
5273                         .apply_expected = True
5274                 },
5275                 .replica= {
5276                         .type           = WREPL_TYPE_UNIQUE,
5277                         .state          = WREPL_STATE_ACTIVE,
5278                         .node           = WREPL_NODE_B,
5279                         .is_static      = False,
5280                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5281                         .ips            = addresses_B_1,
5282                         .apply_expected = False
5283                 },
5284         },
5285         /*
5286          * group,released vs. unique,tombstone with same ip(s)
5287          */
5288         {
5289                 .line   = __location__,
5290                 .name   = _NBT_NAME("_GR_UT_SI", 0x00, NULL),
5291                 .wins   = {
5292                         .nb_flags       = NBT_NM_GROUP,
5293                         .mhomed         = False,
5294                         .num_ips        = ctx->addresses_best_num,
5295                         .ips            = ctx->addresses_best,
5296                         .apply_expected = True
5297                 },
5298                 .replica= {
5299                         .type           = WREPL_TYPE_UNIQUE,
5300                         .state          = WREPL_STATE_TOMBSTONE,
5301                         .node           = WREPL_NODE_B,
5302                         .is_static      = False,
5303                         .num_ips        = ctx->addresses_best_num,
5304                         .ips            = ctx->addresses_best,
5305                         .apply_expected = False
5306                 },
5307         },
5308         /*
5309          * group,released vs. unique,tombstone with different ip(s)
5310          */
5311         {
5312                 .line   = __location__,
5313                 .name   = _NBT_NAME("_GR_UT_DI", 0x00, NULL),
5314                 .wins   = {
5315                         .nb_flags       = NBT_NM_GROUP,
5316                         .mhomed         = False,
5317                         .num_ips        = ctx->addresses_best_num,
5318                         .ips            = ctx->addresses_best,
5319                         .apply_expected = True
5320                 },
5321                 .replica= {
5322                         .type           = WREPL_TYPE_UNIQUE,
5323                         .state          = WREPL_STATE_TOMBSTONE,
5324                         .node           = WREPL_NODE_B,
5325                         .is_static      = False,
5326                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5327                         .ips            = addresses_B_1,
5328                         .apply_expected = False
5329                 },
5330         },
5331 /* 
5332  * group vs. group section
5333  */
5334         /*
5335          * group,released vs. group,active with same ip(s)
5336          */
5337         {
5338                 .line   = __location__,
5339                 .name   = _NBT_NAME("_GR_GA_SI", 0x00, NULL),
5340                 .wins   = {
5341                         .nb_flags       = NBT_NM_GROUP,
5342                         .mhomed         = False,
5343                         .num_ips        = ctx->addresses_best_num,
5344                         .ips            = ctx->addresses_best,
5345                         .apply_expected = True
5346                 },
5347                 .replica= {
5348                         .type           = WREPL_TYPE_GROUP,
5349                         .state          = WREPL_STATE_ACTIVE,
5350                         .node           = WREPL_NODE_B,
5351                         .is_static      = False,
5352                         .num_ips        = ctx->addresses_best_num,
5353                         .ips            = ctx->addresses_best,
5354                         .apply_expected = True
5355                 },
5356         },
5357         /*
5358          * group,released vs. group,active with different ip(s)
5359          */
5360         {
5361                 .line   = __location__,
5362                 .name   = _NBT_NAME("_GR_GA_DI", 0x00, NULL),
5363                 .wins   = {
5364                         .nb_flags       = NBT_NM_GROUP,
5365                         .mhomed         = False,
5366                         .num_ips        = ctx->addresses_best_num,
5367                         .ips            = ctx->addresses_best,
5368                         .apply_expected = True
5369                 },
5370                 .replica= {
5371                         .type           = WREPL_TYPE_GROUP,
5372                         .state          = WREPL_STATE_ACTIVE,
5373                         .node           = WREPL_NODE_B,
5374                         .is_static      = False,
5375                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5376                         .ips            = addresses_B_1,
5377                         .apply_expected = True
5378                 },
5379         },
5380         /*
5381          * group,released vs. group,tombstone with same ip(s)
5382          */
5383         {
5384                 .line   = __location__,
5385                 .name   = _NBT_NAME("_GR_GT_SI", 0x00, NULL),
5386                 .wins   = {
5387                         .nb_flags       = NBT_NM_GROUP,
5388                         .mhomed         = False,
5389                         .num_ips        = ctx->addresses_best_num,
5390                         .ips            = ctx->addresses_best,
5391                         .apply_expected = True
5392                 },
5393                 .replica= {
5394                         .type           = WREPL_TYPE_GROUP,
5395                         .state          = WREPL_STATE_TOMBSTONE,
5396                         .node           = WREPL_NODE_B,
5397                         .is_static      = False,
5398                         .num_ips        = ctx->addresses_best_num,
5399                         .ips            = ctx->addresses_best,
5400                         .apply_expected = True
5401                 },
5402         },
5403         /*
5404          * group,released vs. group,tombstone with different ip(s)
5405          */
5406         {
5407                 .line   = __location__,
5408                 .name   = _NBT_NAME("_GR_GT_DI", 0x00, NULL),
5409                 .wins   = {
5410                         .nb_flags       = NBT_NM_GROUP,
5411                         .mhomed         = False,
5412                         .num_ips        = ctx->addresses_best_num,
5413                         .ips            = ctx->addresses_best,
5414                         .apply_expected = True
5415                 },
5416                 .replica= {
5417                         .type           = WREPL_TYPE_GROUP,
5418                         .state          = WREPL_STATE_TOMBSTONE,
5419                         .node           = WREPL_NODE_B,
5420                         .is_static      = False,
5421                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5422                         .ips            = addresses_B_1,
5423                         .apply_expected = True
5424                 },
5425         },
5426 /* 
5427  * group vs. special group section
5428  */
5429         /*
5430          * group,released vs. sgroup,active with same ip(s)
5431          */
5432         {
5433                 .line   = __location__,
5434                 .name   = _NBT_NAME("_GR_SA_SI", 0x00, NULL),
5435                 .wins   = {
5436                         .nb_flags       = NBT_NM_GROUP,
5437                         .mhomed         = False,
5438                         .num_ips        = ctx->addresses_best_num,
5439                         .ips            = ctx->addresses_best,
5440                         .apply_expected = True
5441                 },
5442                 .replica= {
5443                         .type           = WREPL_TYPE_SGROUP,
5444                         .state          = WREPL_STATE_ACTIVE,
5445                         .node           = WREPL_NODE_B,
5446                         .is_static      = False,
5447                         .num_ips        = ctx->addresses_best_num,
5448                         .ips            = ctx->addresses_best,
5449                         .apply_expected = False
5450                 },
5451         },
5452         /*
5453          * group,released vs. sgroup,active with different ip(s)
5454          */
5455         {
5456                 .line   = __location__,
5457                 .name   = _NBT_NAME("_GR_SA_DI", 0x00, NULL),
5458                 .wins   = {
5459                         .nb_flags       = NBT_NM_GROUP,
5460                         .mhomed         = False,
5461                         .num_ips        = ctx->addresses_best_num,
5462                         .ips            = ctx->addresses_best,
5463                         .apply_expected = True
5464                 },
5465                 .replica= {
5466                         .type           = WREPL_TYPE_SGROUP,
5467                         .state          = WREPL_STATE_ACTIVE,
5468                         .node           = WREPL_NODE_B,
5469                         .is_static      = False,
5470                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5471                         .ips            = addresses_B_1,
5472                         .apply_expected = False
5473                 },
5474         },
5475         /*
5476          * group,released vs. sgroup,tombstone with same ip(s)
5477          */
5478         {
5479                 .line   = __location__,
5480                 .name   = _NBT_NAME("_GR_ST_SI", 0x00, NULL),
5481                 .wins   = {
5482                         .nb_flags       = NBT_NM_GROUP,
5483                         .mhomed         = False,
5484                         .num_ips        = ctx->addresses_best_num,
5485                         .ips            = ctx->addresses_best,
5486                         .apply_expected = True
5487                 },
5488                 .replica= {
5489                         .type           = WREPL_TYPE_SGROUP,
5490                         .state          = WREPL_STATE_TOMBSTONE,
5491                         .node           = WREPL_NODE_B,
5492                         .is_static      = False,
5493                         .num_ips        = ctx->addresses_best_num,
5494                         .ips            = ctx->addresses_best,
5495                         .apply_expected = False
5496                 },
5497         },
5498         /*
5499          * group,released vs. sgroup,tombstone with different ip(s)
5500          */
5501         {
5502                 .line   = __location__,
5503                 .name   = _NBT_NAME("_GR_ST_DI", 0x00, NULL),
5504                 .wins   = {
5505                         .nb_flags       = NBT_NM_GROUP,
5506                         .mhomed         = False,
5507                         .num_ips        = ctx->addresses_best_num,
5508                         .ips            = ctx->addresses_best,
5509                         .apply_expected = True
5510                 },
5511                 .replica= {
5512                         .type           = WREPL_TYPE_SGROUP,
5513                         .state          = WREPL_STATE_TOMBSTONE,
5514                         .node           = WREPL_NODE_B,
5515                         .is_static      = False,
5516                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5517                         .ips            = addresses_B_1,
5518                         .apply_expected = False
5519                 },
5520         },
5521 /* 
5522  * group vs. multi homed section
5523  */
5524         /*
5525          * group,released vs. mhomed,active with same ip(s)
5526          */
5527         {
5528                 .line   = __location__,
5529                 .name   = _NBT_NAME("_GR_MA_SI", 0x00, NULL),
5530                 .wins   = {
5531                         .nb_flags       = NBT_NM_GROUP,
5532                         .mhomed         = False,
5533                         .num_ips        = ctx->addresses_best_num,
5534                         .ips            = ctx->addresses_best,
5535                         .apply_expected = True
5536                 },
5537                 .replica= {
5538                         .type           = WREPL_TYPE_MHOMED,
5539                         .state          = WREPL_STATE_ACTIVE,
5540                         .node           = WREPL_NODE_B,
5541                         .is_static      = False,
5542                         .num_ips        = ctx->addresses_best_num,
5543                         .ips            = ctx->addresses_best,
5544                         .apply_expected = False
5545                 },
5546         },
5547         /*
5548          * group,released vs. mhomed,active with different ip(s)
5549          */
5550         {
5551                 .line   = __location__,
5552                 .name   = _NBT_NAME("_GR_MA_DI", 0x00, NULL),
5553                 .wins   = {
5554                         .nb_flags       = NBT_NM_GROUP,
5555                         .mhomed         = False,
5556                         .num_ips        = ctx->addresses_best_num,
5557                         .ips            = ctx->addresses_best,
5558                         .apply_expected = True
5559                 },
5560                 .replica= {
5561                         .type           = WREPL_TYPE_MHOMED,
5562                         .state          = WREPL_STATE_ACTIVE,
5563                         .node           = WREPL_NODE_B,
5564                         .is_static      = False,
5565                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5566                         .ips            = addresses_B_1,
5567                         .apply_expected = False
5568                 },
5569         },
5570         /*
5571          * group,released vs. mhomed,tombstone with same ip(s)
5572          */
5573         {
5574                 .line   = __location__,
5575                 .name   = _NBT_NAME("_GR_MT_SI", 0x00, NULL),
5576                 .wins   = {
5577                         .nb_flags       = NBT_NM_GROUP,
5578                         .mhomed         = False,
5579                         .num_ips        = ctx->addresses_best_num,
5580                         .ips            = ctx->addresses_best,
5581                         .apply_expected = True
5582                 },
5583                 .replica= {
5584                         .type           = WREPL_TYPE_MHOMED,
5585                         .state          = WREPL_STATE_TOMBSTONE,
5586                         .node           = WREPL_NODE_B,
5587                         .is_static      = False,
5588                         .num_ips        = ctx->addresses_best_num,
5589                         .ips            = ctx->addresses_best,
5590                         .apply_expected = False
5591                 },
5592         },
5593         /*
5594          * group,released vs. mhomed,tombstone with different ip(s)
5595          */
5596         {
5597                 .line   = __location__,
5598                 .name   = _NBT_NAME("_GR_MT_DI", 0x00, NULL),
5599                 .wins   = {
5600                         .nb_flags       = NBT_NM_GROUP,
5601                         .mhomed         = False,
5602                         .num_ips        = ctx->addresses_best_num,
5603                         .ips            = ctx->addresses_best,
5604                         .apply_expected = True
5605                 },
5606                 .replica= {
5607                         .type           = WREPL_TYPE_MHOMED,
5608                         .state          = WREPL_STATE_TOMBSTONE,
5609                         .node           = WREPL_NODE_B,
5610                         .is_static      = False,
5611                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5612                         .ips            = addresses_B_1,
5613                         .apply_expected = False
5614                 },
5615         },
5616 /* 
5617  * special group vs. unique section
5618  */
5619         /*
5620          * sgroup,released vs. unique,active with same ip(s)
5621          */
5622         {
5623                 .line   = __location__,
5624                 .name   = _NBT_NAME("_SR_UA_SI", 0x1C, NULL),
5625                 .wins   = {
5626                         .nb_flags       = NBT_NM_GROUP,
5627                         .mhomed         = False,
5628                         .num_ips        = ctx->addresses_best_num,
5629                         .ips            = ctx->addresses_best,
5630                         .apply_expected = True
5631                 },
5632                 .replica= {
5633                         .type           = WREPL_TYPE_UNIQUE,
5634                         .state          = WREPL_STATE_ACTIVE,
5635                         .node           = WREPL_NODE_B,
5636                         .is_static      = False,
5637                         .num_ips        = ctx->addresses_best_num,
5638                         .ips            = ctx->addresses_best,
5639                         .apply_expected = True
5640                 },
5641         },
5642         /*
5643          * sgroup,released vs. unique,active with different ip(s)
5644          */
5645         {
5646                 .line   = __location__,
5647                 .name   = _NBT_NAME("_SR_UA_DI", 0x1C, NULL),
5648                 .wins   = {
5649                         .nb_flags       = NBT_NM_GROUP,
5650                         .mhomed         = False,
5651                         .num_ips        = ctx->addresses_best_num,
5652                         .ips            = ctx->addresses_best,
5653                         .apply_expected = True
5654                 },
5655                 .replica= {
5656                         .type           = WREPL_TYPE_UNIQUE,
5657                         .state          = WREPL_STATE_ACTIVE,
5658                         .node           = WREPL_NODE_B,
5659                         .is_static      = False,
5660                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5661                         .ips            = addresses_B_1,
5662                         .apply_expected = True
5663                 },
5664         },
5665         /*
5666          * sgroup,released vs. unique,tombstone with same ip(s)
5667          */
5668         {
5669                 .line   = __location__,
5670                 .name   = _NBT_NAME("_SR_UT_SI", 0x1C, NULL),
5671                 .wins   = {
5672                         .nb_flags       = NBT_NM_GROUP,
5673                         .mhomed         = False,
5674                         .num_ips        = ctx->addresses_best_num,
5675                         .ips            = ctx->addresses_best,
5676                         .apply_expected = True
5677                 },
5678                 .replica= {
5679                         .type           = WREPL_TYPE_UNIQUE,
5680                         .state          = WREPL_STATE_TOMBSTONE,
5681                         .node           = WREPL_NODE_B,
5682                         .is_static      = False,
5683                         .num_ips        = ctx->addresses_best_num,
5684                         .ips            = ctx->addresses_best,
5685                         .apply_expected = True
5686                 },
5687         },
5688         /*
5689          * sgroup,released vs. unique,tombstone with different ip(s)
5690          */
5691         {
5692                 .line   = __location__,
5693                 .name   = _NBT_NAME("_SR_UT_DI", 0x1C, NULL),
5694                 .wins   = {
5695                         .nb_flags       = NBT_NM_GROUP,
5696                         .mhomed         = False,
5697                         .num_ips        = ctx->addresses_best_num,
5698                         .ips            = ctx->addresses_best,
5699                         .apply_expected = True
5700                 },
5701                 .replica= {
5702                         .type           = WREPL_TYPE_UNIQUE,
5703                         .state          = WREPL_STATE_TOMBSTONE,
5704                         .node           = WREPL_NODE_B,
5705                         .is_static      = False,
5706                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5707                         .ips            = addresses_B_1,
5708                         .apply_expected = True
5709                 },
5710         },
5711 /* 
5712  * special group vs. group section
5713  */
5714         /*
5715          * sgroup,released vs. group,active with same ip(s)
5716          */
5717         {
5718                 .line   = __location__,
5719                 .name   = _NBT_NAME("_SR_GA_SI", 0x1C, NULL),
5720                 .wins   = {
5721                         .nb_flags       = NBT_NM_GROUP,
5722                         .mhomed         = False,
5723                         .num_ips        = ctx->addresses_best_num,
5724                         .ips            = ctx->addresses_best,
5725                         .apply_expected = True
5726                 },
5727                 .replica= {
5728                         .type           = WREPL_TYPE_GROUP,
5729                         .state          = WREPL_STATE_ACTIVE,
5730                         .node           = WREPL_NODE_B,
5731                         .is_static      = False,
5732                         .num_ips        = ctx->addresses_best_num,
5733                         .ips            = ctx->addresses_best,
5734                         .apply_expected = True
5735                 },
5736         },
5737         /*
5738          * sgroup,released vs. group,active with different ip(s)
5739          */
5740         {
5741                 .line   = __location__,
5742                 .name   = _NBT_NAME("_SR_GA_DI", 0x1C, NULL),
5743                 .wins   = {
5744                         .nb_flags       = NBT_NM_GROUP,
5745                         .mhomed         = False,
5746                         .num_ips        = ctx->addresses_best_num,
5747                         .ips            = ctx->addresses_best,
5748                         .apply_expected = True
5749                 },
5750                 .replica= {
5751                         .type           = WREPL_TYPE_GROUP,
5752                         .state          = WREPL_STATE_ACTIVE,
5753                         .node           = WREPL_NODE_B,
5754                         .is_static      = False,
5755                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5756                         .ips            = addresses_B_1,
5757                         .apply_expected = True
5758                 },
5759         },
5760         /*
5761          * sgroup,released vs. group,tombstone with same ip(s)
5762          */
5763         {
5764                 .line   = __location__,
5765                 .name   = _NBT_NAME("_SR_GT_SI", 0x1C, NULL),
5766                 .wins   = {
5767                         .nb_flags       = NBT_NM_GROUP,
5768                         .mhomed         = False,
5769                         .num_ips        = ctx->addresses_best_num,
5770                         .ips            = ctx->addresses_best,
5771                         .apply_expected = True
5772                 },
5773                 .replica= {
5774                         .type           = WREPL_TYPE_GROUP,
5775                         .state          = WREPL_STATE_TOMBSTONE,
5776                         .node           = WREPL_NODE_B,
5777                         .is_static      = False,
5778                         .num_ips        = ctx->addresses_best_num,
5779                         .ips            = ctx->addresses_best,
5780                         .apply_expected = True
5781                 },
5782         },
5783         /*
5784          * sgroup,released vs. group,tombstone with different ip(s)
5785          */
5786         {
5787                 .line   = __location__,
5788                 .name   = _NBT_NAME("_SR_GT_DI", 0x1C, NULL),
5789                 .wins   = {
5790                         .nb_flags       = NBT_NM_GROUP,
5791                         .mhomed         = False,
5792                         .num_ips        = ctx->addresses_best_num,
5793                         .ips            = ctx->addresses_best,
5794                         .apply_expected = True
5795                 },
5796                 .replica= {
5797                         .type           = WREPL_TYPE_GROUP,
5798                         .state          = WREPL_STATE_TOMBSTONE,
5799                         .node           = WREPL_NODE_B,
5800                         .is_static      = False,
5801                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5802                         .ips            = addresses_B_1,
5803                         .apply_expected = True
5804                 },
5805         },
5806 /* 
5807  * special group vs. special group section
5808  */
5809         /*
5810          * sgroup,released vs. sgroup,active with same ip(s)
5811          */
5812         {
5813                 .line   = __location__,
5814                 .name   = _NBT_NAME("_SR_SA_SI", 0x1C, NULL),
5815                 .wins   = {
5816                         .nb_flags       = NBT_NM_GROUP,
5817                         .mhomed         = False,
5818                         .num_ips        = ctx->addresses_best_num,
5819                         .ips            = ctx->addresses_best,
5820                         .apply_expected = True
5821                 },
5822                 .replica= {
5823                         .type           = WREPL_TYPE_SGROUP,
5824                         .state          = WREPL_STATE_ACTIVE,
5825                         .node           = WREPL_NODE_B,
5826                         .is_static      = False,
5827                         .num_ips        = ctx->addresses_best_num,
5828                         .ips            = ctx->addresses_best,
5829                         .apply_expected = True
5830                 },
5831         },
5832         /*
5833          * sgroup,released vs. sgroup,active with different ip(s)
5834          */
5835         {
5836                 .line   = __location__,
5837                 .name   = _NBT_NAME("_SR_SA_DI", 0x1C, NULL),
5838                 .wins   = {
5839                         .nb_flags       = NBT_NM_GROUP,
5840                         .mhomed         = False,
5841                         .num_ips        = ctx->addresses_best_num,
5842                         .ips            = ctx->addresses_best,
5843                         .apply_expected = True
5844                 },
5845                 .replica= {
5846                         .type           = WREPL_TYPE_SGROUP,
5847                         .state          = WREPL_STATE_ACTIVE,
5848                         .node           = WREPL_NODE_B,
5849                         .is_static      = False,
5850                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5851                         .ips            = addresses_B_1,
5852                         .apply_expected = True
5853                 },
5854         },
5855         /*
5856          * sgroup,released vs. sgroup,tombstone with same ip(s)
5857          */
5858         {
5859                 .line   = __location__,
5860                 .name   = _NBT_NAME("_SR_ST_SI", 0x1C, NULL),
5861                 .wins   = {
5862                         .nb_flags       = NBT_NM_GROUP,
5863                         .mhomed         = False,
5864                         .num_ips        = ctx->addresses_best_num,
5865                         .ips            = ctx->addresses_best,
5866                         .apply_expected = True
5867                 },
5868                 .replica= {
5869                         .type           = WREPL_TYPE_SGROUP,
5870                         .state          = WREPL_STATE_TOMBSTONE,
5871                         .node           = WREPL_NODE_B,
5872                         .is_static      = False,
5873                         .num_ips        = ctx->addresses_best_num,
5874                         .ips            = ctx->addresses_best,
5875                         .apply_expected = True
5876                 },
5877         },
5878         /*
5879          * sgroup,released vs. sgroup,tombstone with different ip(s)
5880          */
5881         {
5882                 .line   = __location__,
5883                 .name   = _NBT_NAME("_SR_ST_DI", 0x1C, NULL),
5884                 .wins   = {
5885                         .nb_flags       = NBT_NM_GROUP,
5886                         .mhomed         = False,
5887                         .num_ips        = ctx->addresses_best_num,
5888                         .ips            = ctx->addresses_best,
5889                         .apply_expected = True
5890                 },
5891                 .replica= {
5892                         .type           = WREPL_TYPE_SGROUP,
5893                         .state          = WREPL_STATE_TOMBSTONE,
5894                         .node           = WREPL_NODE_B,
5895                         .is_static      = False,
5896                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5897                         .ips            = addresses_B_1,
5898                         .apply_expected = True
5899                 },
5900         },
5901 /* 
5902  * special group vs. multi homed section
5903  */
5904         /*
5905          * sgroup,released vs. mhomed,active with same ip(s)
5906          */
5907         {
5908                 .line   = __location__,
5909                 .name   = _NBT_NAME("_SR_MA_SI", 0x1C, NULL),
5910                 .wins   = {
5911                         .nb_flags       = NBT_NM_GROUP,
5912                         .mhomed         = False,
5913                         .num_ips        = ctx->addresses_best_num,
5914                         .ips            = ctx->addresses_best,
5915                         .apply_expected = True
5916                 },
5917                 .replica= {
5918                         .type           = WREPL_TYPE_MHOMED,
5919                         .state          = WREPL_STATE_ACTIVE,
5920                         .node           = WREPL_NODE_B,
5921                         .is_static      = False,
5922                         .num_ips        = ctx->addresses_best_num,
5923                         .ips            = ctx->addresses_best,
5924                         .apply_expected = True
5925                 },
5926         },
5927         /*
5928          * sgroup,released vs. mhomed,active with different ip(s)
5929          */
5930         {
5931                 .line   = __location__,
5932                 .name   = _NBT_NAME("_SR_MA_DI", 0x1C, NULL),
5933                 .wins   = {
5934                         .nb_flags       = NBT_NM_GROUP,
5935                         .mhomed         = False,
5936                         .num_ips        = ctx->addresses_best_num,
5937                         .ips            = ctx->addresses_best,
5938                         .apply_expected = True
5939                 },
5940                 .replica= {
5941                         .type           = WREPL_TYPE_MHOMED,
5942                         .state          = WREPL_STATE_ACTIVE,
5943                         .node           = WREPL_NODE_B,
5944                         .is_static      = False,
5945                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5946                         .ips            = addresses_B_1,
5947                         .apply_expected = True
5948                 },
5949         },
5950         /*
5951          * sgroup,released vs. mhomed,tombstone with same ip(s)
5952          */
5953         {
5954                 .line   = __location__,
5955                 .name   = _NBT_NAME("_SR_MT_SI", 0x1C, NULL),
5956                 .wins   = {
5957                         .nb_flags       = NBT_NM_GROUP,
5958                         .mhomed         = False,
5959                         .num_ips        = ctx->addresses_best_num,
5960                         .ips            = ctx->addresses_best,
5961                         .apply_expected = True
5962                 },
5963                 .replica= {
5964                         .type           = WREPL_TYPE_MHOMED,
5965                         .state          = WREPL_STATE_TOMBSTONE,
5966                         .node           = WREPL_NODE_B,
5967                         .is_static      = False,
5968                         .num_ips        = ctx->addresses_best_num,
5969                         .ips            = ctx->addresses_best,
5970                         .apply_expected = True
5971                 },
5972         },
5973         /*
5974          * sgroup,released vs. mhomed,tombstone with different ip(s)
5975          */
5976         {
5977                 .line   = __location__,
5978                 .name   = _NBT_NAME("_SR_MT_DI", 0x1C, NULL),
5979                 .wins   = {
5980                         .nb_flags       = NBT_NM_GROUP,
5981                         .mhomed         = False,
5982                         .num_ips        = ctx->addresses_best_num,
5983                         .ips            = ctx->addresses_best,
5984                         .apply_expected = True
5985                 },
5986                 .replica= {
5987                         .type           = WREPL_TYPE_MHOMED,
5988                         .state          = WREPL_STATE_TOMBSTONE,
5989                         .node           = WREPL_NODE_B,
5990                         .is_static      = False,
5991                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5992                         .ips            = addresses_B_1,
5993                         .apply_expected = True
5994                 },
5995         },
5996 /* 
5997  * multi homed vs. unique section
5998  */
5999         /*
6000          * mhomed,released vs. unique,active with same ip(s)
6001          */
6002         {
6003                 .line   = __location__,
6004                 .name   = _NBT_NAME("_MR_UA_SI", 0x00, NULL),
6005                 .wins   = {
6006                         .nb_flags       = 0,
6007                         .mhomed         = True,
6008                         .num_ips        = ctx->addresses_best_num,
6009                         .ips            = ctx->addresses_best,
6010                         .apply_expected = True
6011                 },
6012                 .replica= {
6013                         .type           = WREPL_TYPE_UNIQUE,
6014                         .state          = WREPL_STATE_ACTIVE,
6015                         .node           = WREPL_NODE_B,
6016                         .is_static      = False,
6017                         .num_ips        = ctx->addresses_best_num,
6018                         .ips            = ctx->addresses_best,
6019                         .apply_expected = True
6020                 },
6021         },
6022         /*
6023          * mhomed,released vs. unique,active with different ip(s)
6024          */
6025         {
6026                 .line   = __location__,
6027                 .name   = _NBT_NAME("_MR_UA_DI", 0x00, NULL),
6028                 .wins   = {
6029                         .nb_flags       = 0,
6030                         .mhomed         = True,
6031                         .num_ips        = ctx->addresses_best_num,
6032                         .ips            = ctx->addresses_best,
6033                         .apply_expected = True
6034                 },
6035                 .replica= {
6036                         .type           = WREPL_TYPE_UNIQUE,
6037                         .state          = WREPL_STATE_ACTIVE,
6038                         .node           = WREPL_NODE_B,
6039                         .is_static      = False,
6040                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6041                         .ips            = addresses_B_1,
6042                         .apply_expected = True
6043                 },
6044         },
6045         /*
6046          * mhomed,released vs. unique,tombstone with same ip(s)
6047          */
6048         {
6049                 .line   = __location__,
6050                 .name   = _NBT_NAME("_MR_UT_SI", 0x00, NULL),
6051                 .wins   = {
6052                         .nb_flags       = 0,
6053                         .mhomed         = True,
6054                         .num_ips        = ctx->addresses_best_num,
6055                         .ips            = ctx->addresses_best,
6056                         .apply_expected = True
6057                 },
6058                 .replica= {
6059                         .type           = WREPL_TYPE_UNIQUE,
6060                         .state          = WREPL_STATE_TOMBSTONE,
6061                         .node           = WREPL_NODE_B,
6062                         .is_static      = False,
6063                         .num_ips        = ctx->addresses_best_num,
6064                         .ips            = ctx->addresses_best,
6065                         .apply_expected = True
6066                 },
6067         },
6068         /*
6069          * mhomed,released vs. unique,tombstone with different ip(s)
6070          */
6071         {
6072                 .line   = __location__,
6073                 .name   = _NBT_NAME("_MR_UT_DI", 0x00, NULL),
6074                 .wins   = {
6075                         .nb_flags       = 0,
6076                         .mhomed         = True,
6077                         .num_ips        = ctx->addresses_best_num,
6078                         .ips            = ctx->addresses_best,
6079                         .apply_expected = True
6080                 },
6081                 .replica= {
6082                         .type           = WREPL_TYPE_UNIQUE,
6083                         .state          = WREPL_STATE_TOMBSTONE,
6084                         .node           = WREPL_NODE_B,
6085                         .is_static      = False,
6086                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6087                         .ips            = addresses_B_1,
6088                         .apply_expected = True
6089                 },
6090         },
6091 /* 
6092  * multi homed vs. group section
6093  */
6094         /*
6095          * mhomed,released vs. group,active with same ip(s)
6096          */
6097         {
6098                 .line   = __location__,
6099                 .name   = _NBT_NAME("_MR_GA_SI", 0x00, NULL),
6100                 .wins   = {
6101                         .nb_flags       = 0,
6102                         .mhomed         = True,
6103                         .num_ips        = ctx->addresses_best_num,
6104                         .ips            = ctx->addresses_best,
6105                         .apply_expected = True
6106                 },
6107                 .replica= {
6108                         .type           = WREPL_TYPE_GROUP,
6109                         .state          = WREPL_STATE_ACTIVE,
6110                         .node           = WREPL_NODE_B,
6111                         .is_static      = False,
6112                         .num_ips        = ctx->addresses_best_num,
6113                         .ips            = ctx->addresses_best,
6114                         .apply_expected = True
6115                 },
6116         },
6117         /*
6118          * mhomed,released vs. group,active with different ip(s)
6119          */
6120         {
6121                 .line   = __location__,
6122                 .name   = _NBT_NAME("_MR_GA_DI", 0x00, NULL),
6123                 .wins   = {
6124                         .nb_flags       = 0,
6125                         .mhomed         = True,
6126                         .num_ips        = ctx->addresses_best_num,
6127                         .ips            = ctx->addresses_best,
6128                         .apply_expected = True
6129                 },
6130                 .replica= {
6131                         .type           = WREPL_TYPE_GROUP,
6132                         .state          = WREPL_STATE_ACTIVE,
6133                         .node           = WREPL_NODE_B,
6134                         .is_static      = False,
6135                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6136                         .ips            = addresses_B_1,
6137                         .apply_expected = True
6138                 },
6139         },
6140         /*
6141          * mhomed,released vs. group,tombstone with same ip(s)
6142          */
6143         {
6144                 .line   = __location__,
6145                 .name   = _NBT_NAME("_MR_GT_SI", 0x00, NULL),
6146                 .wins   = {
6147                         .nb_flags       = 0,
6148                         .mhomed         = True,
6149                         .num_ips        = ctx->addresses_best_num,
6150                         .ips            = ctx->addresses_best,
6151                         .apply_expected = True
6152                 },
6153                 .replica= {
6154                         .type           = WREPL_TYPE_GROUP,
6155                         .state          = WREPL_STATE_TOMBSTONE,
6156                         .node           = WREPL_NODE_B,
6157                         .is_static      = False,
6158                         .num_ips        = ctx->addresses_best_num,
6159                         .ips            = ctx->addresses_best,
6160                         .apply_expected = True
6161                 },
6162         },
6163         /*
6164          * mhomed,released vs. group,tombstone with different ip(s)
6165          */
6166         {
6167                 .line   = __location__,
6168                 .name   = _NBT_NAME("_MR_GT_DI", 0x00, NULL),
6169                 .wins   = {
6170                         .nb_flags       = 0,
6171                         .mhomed         = True,
6172                         .num_ips        = ctx->addresses_best_num,
6173                         .ips            = ctx->addresses_best,
6174                         .apply_expected = True
6175                 },
6176                 .replica= {
6177                         .type           = WREPL_TYPE_GROUP,
6178                         .state          = WREPL_STATE_TOMBSTONE,
6179                         .node           = WREPL_NODE_B,
6180                         .is_static      = False,
6181                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6182                         .ips            = addresses_B_1,
6183                         .apply_expected = True
6184                 },
6185         },
6186 /* 
6187  * multi homed vs. special group section
6188  */
6189         /*
6190          * mhomed,released vs. sgroup,active with same ip(s)
6191          */
6192         {
6193                 .line   = __location__,
6194                 .name   = _NBT_NAME("_MR_SA_SI", 0x00, NULL),
6195                 .wins   = {
6196                         .nb_flags       = 0,
6197                         .mhomed         = True,
6198                         .num_ips        = ctx->addresses_best_num,
6199                         .ips            = ctx->addresses_best,
6200                         .apply_expected = True
6201                 },
6202                 .replica= {
6203                         .type           = WREPL_TYPE_SGROUP,
6204                         .state          = WREPL_STATE_ACTIVE,
6205                         .node           = WREPL_NODE_B,
6206                         .is_static      = False,
6207                         .num_ips        = ctx->addresses_best_num,
6208                         .ips            = ctx->addresses_best,
6209                         .apply_expected = True
6210                 },
6211         },
6212         /*
6213          * mhomed,released vs. sgroup,active with different ip(s)
6214          */
6215         {
6216                 .line   = __location__,
6217                 .name   = _NBT_NAME("_MR_SA_DI", 0x00, NULL),
6218                 .wins   = {
6219                         .nb_flags       = 0,
6220                         .mhomed         = True,
6221                         .num_ips        = ctx->addresses_best_num,
6222                         .ips            = ctx->addresses_best,
6223                         .apply_expected = True
6224                 },
6225                 .replica= {
6226                         .type           = WREPL_TYPE_SGROUP,
6227                         .state          = WREPL_STATE_ACTIVE,
6228                         .node           = WREPL_NODE_B,
6229                         .is_static      = False,
6230                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6231                         .ips            = addresses_B_1,
6232                         .apply_expected = True
6233                 },
6234         },
6235         /*
6236          * mhomed,released vs. sgroup,tombstone with same ip(s)
6237          */
6238         {
6239                 .line   = __location__,
6240                 .name   = _NBT_NAME("_MR_ST_SI", 0x00, NULL),
6241                 .wins   = {
6242                         .nb_flags       = 0,
6243                         .mhomed         = True,
6244                         .num_ips        = ctx->addresses_best_num,
6245                         .ips            = ctx->addresses_best,
6246                         .apply_expected = True
6247                 },
6248                 .replica= {
6249                         .type           = WREPL_TYPE_SGROUP,
6250                         .state          = WREPL_STATE_TOMBSTONE,
6251                         .node           = WREPL_NODE_B,
6252                         .is_static      = False,
6253                         .num_ips        = ctx->addresses_best_num,
6254                         .ips            = ctx->addresses_best,
6255                         .apply_expected = True
6256                 },
6257         },
6258         /*
6259          * mhomed,released vs. sgroup,tombstone with different ip(s)
6260          */
6261         {
6262                 .line   = __location__,
6263                 .name   = _NBT_NAME("_MR_ST_DI", 0x00, NULL),
6264                 .wins   = {
6265                         .nb_flags       = 0,
6266                         .mhomed         = True,
6267                         .num_ips        = ctx->addresses_best_num,
6268                         .ips            = ctx->addresses_best,
6269                         .apply_expected = True
6270                 },
6271                 .replica= {
6272                         .type           = WREPL_TYPE_SGROUP,
6273                         .state          = WREPL_STATE_TOMBSTONE,
6274                         .node           = WREPL_NODE_B,
6275                         .is_static      = False,
6276                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6277                         .ips            = addresses_B_1,
6278                         .apply_expected = True
6279                 },
6280         },
6281 /* 
6282  * multi homed vs. multi homed section
6283  */
6284         /*
6285          * mhomed,released vs. mhomed,active with same ip(s)
6286          */
6287         {
6288                 .line   = __location__,
6289                 .name   = _NBT_NAME("_MR_MA_SI", 0x00, NULL),
6290                 .wins   = {
6291                         .nb_flags       = 0,
6292                         .mhomed         = True,
6293                         .num_ips        = ctx->addresses_best_num,
6294                         .ips            = ctx->addresses_best,
6295                         .apply_expected = True
6296                 },
6297                 .replica= {
6298                         .type           = WREPL_TYPE_MHOMED,
6299                         .state          = WREPL_STATE_ACTIVE,
6300                         .node           = WREPL_NODE_B,
6301                         .is_static      = False,
6302                         .num_ips        = ctx->addresses_best_num,
6303                         .ips            = ctx->addresses_best,
6304                         .apply_expected = True
6305                 },
6306         },
6307         /*
6308          * mhomed,released vs. mhomed,active with different ip(s)
6309          */
6310         {
6311                 .line   = __location__,
6312                 .name   = _NBT_NAME("_MR_MA_DI", 0x00, NULL),
6313                 .wins   = {
6314                         .nb_flags       = 0,
6315                         .mhomed         = True,
6316                         .num_ips        = ctx->addresses_best_num,
6317                         .ips            = ctx->addresses_best,
6318                         .apply_expected = True
6319                 },
6320                 .replica= {
6321                         .type           = WREPL_TYPE_MHOMED,
6322                         .state          = WREPL_STATE_ACTIVE,
6323                         .node           = WREPL_NODE_B,
6324                         .is_static      = False,
6325                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6326                         .ips            = addresses_B_1,
6327                         .apply_expected = True
6328                 },
6329         },
6330         /*
6331          * mhomed,released vs. mhomed,tombstone with same ip(s)
6332          */
6333         {
6334                 .line   = __location__,
6335                 .name   = _NBT_NAME("_MR_MT_SI", 0x00, NULL),
6336                 .wins   = {
6337                         .nb_flags       = 0,
6338                         .mhomed         = True,
6339                         .num_ips        = ctx->addresses_best_num,
6340                         .ips            = ctx->addresses_best,
6341                         .apply_expected = True
6342                 },
6343                 .replica= {
6344                         .type           = WREPL_TYPE_MHOMED,
6345                         .state          = WREPL_STATE_TOMBSTONE,
6346                         .node           = WREPL_NODE_B,
6347                         .is_static      = False,
6348                         .num_ips        = ctx->addresses_best_num,
6349                         .ips            = ctx->addresses_best,
6350                         .apply_expected = True
6351                 },
6352         },
6353         /*
6354          * mhomed,released vs. mhomed,tombstone with different ip(s)
6355          */
6356         {
6357                 .line   = __location__,
6358                 .name   = _NBT_NAME("_MR_MT_DI", 0x00, NULL),
6359                 .wins   = {
6360                         .nb_flags       = 0,
6361                         .mhomed         = True,
6362                         .num_ips        = ctx->addresses_best_num,
6363                         .ips            = ctx->addresses_best,
6364                         .apply_expected = True
6365                 },
6366                 .replica= {
6367                         .type           = WREPL_TYPE_MHOMED,
6368                         .state          = WREPL_STATE_TOMBSTONE,
6369                         .node           = WREPL_NODE_B,
6370                         .is_static      = False,
6371                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6372                         .ips            = addresses_B_1,
6373                         .apply_expected = True
6374                 },
6375         },
6376         };
6377
6378         if (!ctx) return False;
6379
6380         printf("Test Replica records vs. owned released records\n");
6381
6382         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
6383                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
6384                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
6385
6386                 /*
6387                  * Setup Register
6388                  */
6389                 name_register->in.name          = records[i].name;
6390                 name_register->in.dest_addr     = ctx->address;
6391                 name_register->in.address       = records[i].wins.ips[0].ip;
6392                 name_register->in.nb_flags      = records[i].wins.nb_flags;
6393                 name_register->in.register_demand= False;
6394                 name_register->in.broadcast     = False;
6395                 name_register->in.multi_homed   = records[i].wins.mhomed;
6396                 name_register->in.ttl           = 300000;
6397                 name_register->in.timeout       = 70;
6398                 name_register->in.retries       = 0;
6399
6400                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
6401                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6402                         printf("No response from %s for name register\n", ctx->address);
6403                         ret = False;
6404                 }
6405                 if (!NT_STATUS_IS_OK(status)) {
6406                         printf("Bad response from %s for name register - %s\n",
6407                                ctx->address, nt_errstr(status));
6408                         ret = False;
6409                 }
6410                 CHECK_VALUE(name_register->out.rcode, 0);
6411                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
6412                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
6413                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
6414                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
6415                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
6416
6417                 /* release the record */
6418                 release->in.name        = records[i].name;
6419                 release->in.dest_addr   = ctx->address;
6420                 release->in.address     = records[i].wins.ips[0].ip;
6421                 release->in.nb_flags    = records[i].wins.nb_flags;
6422                 release->in.broadcast   = False;
6423                 release->in.timeout     = 30;
6424                 release->in.retries     = 0;
6425
6426                 status = nbt_name_release(ctx->nbtsock, ctx, release);
6427                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6428                         printf("No response from %s for name release\n", ctx->address);
6429                         return False;
6430                 }
6431                 if (!NT_STATUS_IS_OK(status)) {
6432                         printf("Bad response from %s for name query - %s\n",
6433                                ctx->address, nt_errstr(status));
6434                         return False;
6435                 }
6436                 CHECK_VALUE(release->out.rcode, 0);
6437
6438                 /*
6439                  * Setup Replica
6440                  */
6441                 wins_name->name         = &records[i].name;
6442                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
6443                                                            records[i].replica.state,
6444                                                            records[i].replica.node,
6445                                                            records[i].replica.is_static);
6446                 wins_name->id           = ++ctx->b.max_version;
6447                 if (wins_name->flags & 2) {
6448                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
6449                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
6450                 } else {
6451                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
6452                 }
6453                 wins_name->unknown      = "255.255.255.255";
6454
6455                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6456                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
6457                                              records[i].replica.apply_expected);
6458
6459                 if (records[i].replica.apply_expected) {
6460                         wins_name->name         = &records[i].name;
6461                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
6462                                                                    WREPL_STATE_TOMBSTONE,
6463                                                                    WREPL_NODE_B, False);
6464                         wins_name->id           = ++ctx->b.max_version;
6465                         wins_name->addresses.ip = addresses_B_1[0].ip;
6466                         wins_name->unknown      = "255.255.255.255";
6467
6468                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6469                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
6470                 } else {
6471                         release->in.name        = records[i].name;
6472                         release->in.dest_addr   = ctx->address;
6473                         release->in.address     = records[i].wins.ips[0].ip;
6474                         release->in.nb_flags    = records[i].wins.nb_flags;
6475                         release->in.broadcast   = False;
6476                         release->in.timeout     = 30;
6477                         release->in.retries     = 0;
6478
6479                         status = nbt_name_release(ctx->nbtsock, ctx, release);
6480                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6481                                 printf("No response from %s for name release\n", ctx->address);
6482                                 return False;
6483                         }
6484                         if (!NT_STATUS_IS_OK(status)) {
6485                                 printf("Bad response from %s for name query - %s\n",
6486                                        ctx->address, nt_errstr(status));
6487                                 return False;
6488                         }
6489                         CHECK_VALUE(release->out.rcode, 0);
6490                 }
6491 done:
6492                 if (!ret) {
6493                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
6494                         return ret;
6495                 }
6496         }
6497
6498         return ret;
6499 }
6500
6501 struct test_conflict_owned_active_vs_replica_struct {
6502         const char *line; /* just better debugging */
6503         const char *section; /* just better debugging */
6504         struct nbt_name name;
6505         BOOL skip;
6506         struct {
6507                 uint32_t nb_flags;
6508                 BOOL mhomed;
6509                 uint32_t num_ips;
6510                 const struct wrepl_ip *ips;
6511                 BOOL apply_expected;
6512         } wins;
6513         struct {
6514                 uint32_t timeout;
6515                 BOOL positive;
6516                 BOOL expect_release;
6517                 BOOL late_release;
6518                 BOOL ret;
6519                 /* when num_ips == 0, then .wins.ips are used */
6520                 uint32_t num_ips;
6521                 const struct wrepl_ip *ips;
6522         } defend;
6523         struct {
6524                 enum wrepl_name_type type;
6525                 enum wrepl_name_state state;
6526                 enum wrepl_name_node node;
6527                 BOOL is_static;
6528                 uint32_t num_ips;
6529                 const struct wrepl_ip *ips;
6530                 BOOL apply_expected;
6531                 BOOL mhomed_merge;
6532                 BOOL sgroup_merge;
6533         } replica;
6534 };
6535
6536 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
6537                                                           struct nbt_name_packet *req_packet, 
6538                                                           const struct nbt_peer_socket *src);
6539
6540 static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx)
6541 {
6542         BOOL ret = True;
6543         NTSTATUS status;
6544         struct wrepl_wins_name wins_name_;
6545         struct wrepl_wins_name *wins_name = &wins_name_;
6546         struct nbt_name_register name_register_;
6547         struct nbt_name_register *name_register = &name_register_;
6548         struct nbt_name_release release_;
6549         struct nbt_name_release *release = &release_;
6550         uint32_t i;
6551         struct test_conflict_owned_active_vs_replica_struct records[] = {
6552 /* 
6553  * unique vs. unique section
6554  */
6555         /*
6556          * unique,active vs. unique,active with same ip(s), unchecked
6557          */
6558         {
6559                 .line   = __location__,
6560                 .name   = _NBT_NAME("_UA_UA_SI_U", 0x00, NULL),
6561                 .wins   = {
6562                         .nb_flags       = 0,
6563                         .mhomed         = False,
6564                         .num_ips        = ctx->addresses_best_num,
6565                         .ips            = ctx->addresses_best,
6566                         .apply_expected = True
6567                 },
6568                 .defend = {
6569                         .timeout        = 0,
6570                 },
6571                 .replica= {
6572                         .type           = WREPL_TYPE_UNIQUE,
6573                         .state          = WREPL_STATE_ACTIVE,
6574                         .node           = WREPL_NODE_B,
6575                         .is_static      = False,
6576                         .num_ips        = ctx->addresses_best_num,
6577                         .ips            = ctx->addresses_best,
6578                         .apply_expected = True
6579                 },
6580         },
6581         /*
6582          * unique,active vs. unique,active with different ip(s), positive response
6583          */
6584         {
6585                 .line   = __location__,
6586                 .name   = _NBT_NAME("_UA_UA_DI_P", 0x00, NULL),
6587                 .wins   = {
6588                         .nb_flags       = 0,
6589                         .mhomed         = False,
6590                         .num_ips        = ctx->addresses_best_num,
6591                         .ips            = ctx->addresses_best,
6592                         .apply_expected = True
6593                 },
6594                 .defend = {
6595                         .timeout        = 10,
6596                         .positive       = True,
6597                 },
6598                 .replica= {
6599                         .type           = WREPL_TYPE_UNIQUE,
6600                         .state          = WREPL_STATE_ACTIVE,
6601                         .node           = WREPL_NODE_B,
6602                         .is_static      = False,
6603                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6604                         .ips            = addresses_B_1,
6605                         .apply_expected = False
6606                 },
6607         },
6608         /*
6609          * unique,active vs. unique,active with different ip(s), positive response other ips
6610          */
6611         {
6612                 .line   = __location__,
6613                 .name   = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL),
6614                 .wins   = {
6615                         .nb_flags       = 0,
6616                         .mhomed         = False,
6617                         .num_ips        = ctx->addresses_best_num,
6618                         .ips            = ctx->addresses_best,
6619                         .apply_expected = True
6620                 },
6621                 .defend = {
6622                         .timeout        = 10,
6623                         .positive       = True,
6624                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
6625                         .ips            = addresses_A_3_4,
6626                 },
6627                 .replica= {
6628                         .type           = WREPL_TYPE_UNIQUE,
6629                         .state          = WREPL_STATE_ACTIVE,
6630                         .node           = WREPL_NODE_B,
6631                         .is_static      = False,
6632                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6633                         .ips            = addresses_B_1,
6634                         .apply_expected = False
6635                 },
6636         },
6637         /*
6638          * unique,active vs. unique,active with different ip(s), negative response
6639          */
6640         {
6641                 .line   = __location__,
6642                 .name   = _NBT_NAME("_UA_UA_DI_N", 0x00, NULL),
6643                 .wins   = {
6644                         .nb_flags       = 0,
6645                         .mhomed         = False,
6646                         .num_ips        = ctx->addresses_best_num,
6647                         .ips            = ctx->addresses_best,
6648                         .apply_expected = True
6649                 },
6650                 .defend = {
6651                         .timeout        = 10,
6652                         .positive       = False,
6653                 },
6654                 .replica= {
6655                         .type           = WREPL_TYPE_UNIQUE,
6656                         .state          = WREPL_STATE_ACTIVE,
6657                         .node           = WREPL_NODE_B,
6658                         .is_static      = False,
6659                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6660                         .ips            = addresses_B_1,
6661                         .apply_expected = True
6662                 },
6663         },
6664         /*
6665          * unique,active vs. unique,tombstone with same ip(s), unchecked
6666          */
6667         {
6668                 .line   = __location__,
6669                 .name   = _NBT_NAME("_UA_UT_SI_U", 0x00, NULL),
6670                 .wins   = {
6671                         .nb_flags       = 0,
6672                         .mhomed         = False,
6673                         .num_ips        = ctx->addresses_best_num,
6674                         .ips            = ctx->addresses_best,
6675                         .apply_expected = True
6676                 },
6677                 .defend = {
6678                         .timeout        = 0,
6679                 },
6680                 .replica= {
6681                         .type           = WREPL_TYPE_UNIQUE,
6682                         .state          = WREPL_STATE_TOMBSTONE,
6683                         .node           = WREPL_NODE_B,
6684                         .is_static      = False,
6685                         .num_ips        = ctx->addresses_best_num,
6686                         .ips            = ctx->addresses_best,
6687                         .apply_expected = False
6688                 },
6689         },
6690         /*
6691          * unique,active vs. unique,tombstone with different ip(s), unchecked
6692          */
6693         {
6694                 .line   = __location__,
6695                 .name   = _NBT_NAME("_UA_UT_DI_U", 0x00, NULL),
6696                 .wins   = {
6697                         .nb_flags       = 0,
6698                         .mhomed         = False,
6699                         .num_ips        = ctx->addresses_best_num,
6700                         .ips            = ctx->addresses_best,
6701                         .apply_expected = True
6702                 },
6703                 .defend = {
6704                         .timeout        = 0,
6705                 },
6706                 .replica= {
6707                         .type           = WREPL_TYPE_UNIQUE,
6708                         .state          = WREPL_STATE_TOMBSTONE,
6709                         .node           = WREPL_NODE_B,
6710                         .is_static      = False,
6711                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6712                         .ips            = addresses_B_1,
6713                         .apply_expected = False
6714                 },
6715         },
6716 /* 
6717  * unique vs. group section
6718  */
6719         /*
6720          * unique,active vs. group,active with same ip(s), release expected
6721          */
6722         {
6723                 .line   = __location__,
6724                 .name   = _NBT_NAME("_UA_GA_SI_R", 0x00, NULL),
6725                 .wins   = {
6726                         .nb_flags       = 0,
6727                         .mhomed         = False,
6728                         .num_ips        = ctx->addresses_best_num,
6729                         .ips            = ctx->addresses_best,
6730                         .apply_expected = True
6731                 },
6732                 .defend = {
6733                         .timeout        = 10,
6734                         .expect_release = True,
6735                 },
6736                 .replica= {
6737                         .type           = WREPL_TYPE_GROUP,
6738                         .state          = WREPL_STATE_ACTIVE,
6739                         .node           = WREPL_NODE_B,
6740                         .is_static      = False,
6741                         .num_ips        = ctx->addresses_best_num,
6742                         .ips            = ctx->addresses_best,
6743                         .apply_expected = True
6744                 },
6745         },
6746         /*
6747          * unique,active vs. group,active with different ip(s), release expected
6748          */
6749         {
6750                 .line   = __location__,
6751                 .name   = _NBT_NAME("_UA_GA_DI_R", 0x00, NULL),
6752                 .wins   = {
6753                         .nb_flags       = 0,
6754                         .mhomed         = False,
6755                         .num_ips        = ctx->addresses_best_num,
6756                         .ips            = ctx->addresses_best,
6757                         .apply_expected = True
6758                 },
6759                 .defend = {
6760                         .timeout        = 10,
6761                         .expect_release = True,
6762                 },
6763                 .replica= {
6764                         .type           = WREPL_TYPE_GROUP,
6765                         .state          = WREPL_STATE_ACTIVE,
6766                         .node           = WREPL_NODE_B,
6767                         .is_static      = False,
6768                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6769                         .ips            = addresses_B_1,
6770                         .apply_expected = True
6771                 },
6772         },
6773         /*
6774          * unique,active vs. group,tombstone with same ip(s), unchecked
6775          */
6776         {
6777                 .line   = __location__,
6778                 .name   = _NBT_NAME("_UA_GT_SI_U", 0x00, NULL),
6779                 .wins   = {
6780                         .nb_flags       = 0,
6781                         .mhomed         = False,
6782                         .num_ips        = ctx->addresses_best_num,
6783                         .ips            = ctx->addresses_best,
6784                         .apply_expected = True
6785                 },
6786                 .defend = {
6787                         .timeout        = 0,
6788                 },
6789                 .replica= {
6790                         .type           = WREPL_TYPE_GROUP,
6791                         .state          = WREPL_STATE_TOMBSTONE,
6792                         .node           = WREPL_NODE_B,
6793                         .is_static      = False,
6794                         .num_ips        = ctx->addresses_best_num,
6795                         .ips            = ctx->addresses_best,
6796                         .apply_expected = False
6797                 },
6798         },
6799         /*
6800          * unique,active vs. group,tombstone with different ip(s), unchecked
6801          */
6802         {
6803                 .line   = __location__,
6804                 .name   = _NBT_NAME("_UA_GT_DI_U", 0x00, NULL),
6805                 .wins   = {
6806                         .nb_flags       = 0,
6807                         .mhomed         = False,
6808                         .num_ips        = ctx->addresses_best_num,
6809                         .ips            = ctx->addresses_best,
6810                         .apply_expected = True
6811                 },
6812                 .defend = {
6813                         .timeout        = 0,
6814                 },
6815                 .replica= {
6816                         .type           = WREPL_TYPE_GROUP,
6817                         .state          = WREPL_STATE_TOMBSTONE,
6818                         .node           = WREPL_NODE_B,
6819                         .is_static      = False,
6820                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6821                         .ips            = addresses_B_1,
6822                         .apply_expected = False
6823                 },
6824         },
6825 /* 
6826  * unique vs. special group section
6827  */
6828         /*
6829          * unique,active vs. sgroup,active with same ip(s), release expected
6830          */
6831         {
6832                 .line   = __location__,
6833                 .name   = _NBT_NAME("_UA_SA_SI_R", 0x00, NULL),
6834                 .wins   = {
6835                         .nb_flags       = 0,
6836                         .mhomed         = False,
6837                         .num_ips        = ctx->addresses_best_num,
6838                         .ips            = ctx->addresses_best,
6839                         .apply_expected = True
6840                 },
6841                 .defend = {
6842                         .timeout        = 10,
6843                         .expect_release = True,
6844                 },
6845                 .replica= {
6846                         .type           = WREPL_TYPE_SGROUP,
6847                         .state          = WREPL_STATE_ACTIVE,
6848                         .node           = WREPL_NODE_B,
6849                         .is_static      = False,
6850                         .num_ips        = ctx->addresses_best_num,
6851                         .ips            = ctx->addresses_best,
6852                         .apply_expected = True
6853                 },
6854         },
6855         /*
6856          * unique,active vs. group,active with different ip(s), release expected
6857          */
6858         {
6859                 .line   = __location__,
6860                 .name   = _NBT_NAME("_UA_SA_DI_R", 0x00, NULL),
6861                 .wins   = {
6862                         .nb_flags       = 0,
6863                         .mhomed         = False,
6864                         .num_ips        = ctx->addresses_best_num,
6865                         .ips            = ctx->addresses_best,
6866                         .apply_expected = True
6867                 },
6868                 .defend = {
6869                         .timeout        = 10,
6870                         .expect_release = True,
6871                 },
6872                 .replica= {
6873                         .type           = WREPL_TYPE_SGROUP,
6874                         .state          = WREPL_STATE_ACTIVE,
6875                         .node           = WREPL_NODE_B,
6876                         .is_static      = False,
6877                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6878                         .ips            = addresses_B_1,
6879                         .apply_expected = True
6880                 },
6881         },
6882         /*
6883          * unique,active vs. sgroup,tombstone with same ip(s), unchecked
6884          */
6885         {
6886                 .line   = __location__,
6887                 .name   = _NBT_NAME("_UA_ST_SI_U", 0x00, NULL),
6888                 .wins   = {
6889                         .nb_flags       = 0,
6890                         .mhomed         = False,
6891                         .num_ips        = ctx->addresses_best_num,
6892                         .ips            = ctx->addresses_best,
6893                         .apply_expected = True
6894                 },
6895                 .defend = {
6896                         .timeout        = 0,
6897                 },
6898                 .replica= {
6899                         .type           = WREPL_TYPE_SGROUP,
6900                         .state          = WREPL_STATE_TOMBSTONE,
6901                         .node           = WREPL_NODE_B,
6902                         .is_static      = False,
6903                         .num_ips        = ctx->addresses_best_num,
6904                         .ips            = ctx->addresses_best,
6905                         .apply_expected = False
6906                 },
6907         },
6908         /*
6909          * unique,active vs. sgroup,tombstone with different ip(s), unchecked
6910          */
6911         {
6912                 .line   = __location__,
6913                 .name   = _NBT_NAME("_UA_ST_DI_U", 0x00, NULL),
6914                 .wins   = {
6915                         .nb_flags       = 0,
6916                         .mhomed         = False,
6917                         .num_ips        = ctx->addresses_best_num,
6918                         .ips            = ctx->addresses_best,
6919                         .apply_expected = True
6920                 },
6921                 .defend = {
6922                         .timeout        = 0,
6923                 },
6924                 .replica= {
6925                         .type           = WREPL_TYPE_SGROUP,
6926                         .state          = WREPL_STATE_TOMBSTONE,
6927                         .node           = WREPL_NODE_B,
6928                         .is_static      = False,
6929                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6930                         .ips            = addresses_B_1,
6931                         .apply_expected = False
6932                 },
6933         },
6934 /* 
6935  * unique vs. multi homed section
6936  */
6937         /*
6938          * unique,active vs. mhomed,active with same ip(s), unchecked
6939          */
6940         {
6941                 .line   = __location__,
6942                 .name   = _NBT_NAME("_UA_MA_SI_U", 0x00, NULL),
6943                 .wins   = {
6944                         .nb_flags       = 0,
6945                         .mhomed         = False,
6946                         .num_ips        = ctx->addresses_best_num,
6947                         .ips            = ctx->addresses_best,
6948                         .apply_expected = True
6949                 },
6950                 .defend = {
6951                         .timeout        = 0,
6952                 },
6953                 .replica= {
6954                         .type           = WREPL_TYPE_MHOMED,
6955                         .state          = WREPL_STATE_ACTIVE,
6956                         .node           = WREPL_NODE_B,
6957                         .is_static      = False,
6958                         .num_ips        = ctx->addresses_best_num,
6959                         .ips            = ctx->addresses_best,
6960                         .apply_expected = True
6961                 },
6962         },
6963         /*
6964          * unique,active vs. mhomed,active with superset ip(s), unchecked
6965          */
6966         {
6967                 .line   = __location__,
6968                 .name   = _NBT_NAME("_UA_MA_SP_U", 0x00, NULL),
6969                 .wins   = {
6970                         .nb_flags       = 0,
6971                         .mhomed         = False,
6972                         .num_ips        = ctx->addresses_best_num,
6973                         .ips            = ctx->addresses_best,
6974                         .apply_expected = True
6975                 },
6976                 .defend = {
6977                         .timeout        = 0,
6978                 },
6979                 .replica= {
6980                         .type           = WREPL_TYPE_MHOMED,
6981                         .state          = WREPL_STATE_ACTIVE,
6982                         .node           = WREPL_NODE_B,
6983                         .is_static      = False,
6984                         .num_ips        = ctx->addresses_all_num,
6985                         .ips            = ctx->addresses_all,
6986                         .apply_expected = True
6987                 },
6988         },
6989         /*
6990          * unique,active vs. mhomed,active with different ip(s), positive response
6991          */
6992         {
6993                 .line   = __location__,
6994                 .name   = _NBT_NAME("_UA_MA_DI_P", 0x00, NULL),
6995                 .wins   = {
6996                         .nb_flags       = 0,
6997                         .mhomed         = False,
6998                         .num_ips        = ctx->addresses_best_num,
6999                         .ips            = ctx->addresses_best,
7000                         .apply_expected = True
7001                 },
7002                 .defend = {
7003                         .timeout        = 10,
7004                         .positive       = True,
7005                 },
7006                 .replica= {
7007                         .type           = WREPL_TYPE_MHOMED,
7008                         .state          = WREPL_STATE_ACTIVE,
7009                         .node           = WREPL_NODE_B,
7010                         .is_static      = False,
7011                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7012                         .ips            = addresses_B_3_4,
7013                         .apply_expected = False
7014                 },
7015         },
7016         /*
7017          * unique,active vs. mhomed,active with different ip(s), positive response other ips
7018          */
7019         {
7020                 .line   = __location__,
7021                 .name   = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL),
7022                 .wins   = {
7023                         .nb_flags       = 0,
7024                         .mhomed         = False,
7025                         .num_ips        = ctx->addresses_best_num,
7026                         .ips            = ctx->addresses_best,
7027                         .apply_expected = True
7028                 },
7029                 .defend = {
7030                         .timeout        = 10,
7031                         .positive       = True,
7032                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7033                         .ips            = addresses_A_3_4,
7034                 },
7035                 .replica= {
7036                         .type           = WREPL_TYPE_MHOMED,
7037                         .state          = WREPL_STATE_ACTIVE,
7038                         .node           = WREPL_NODE_B,
7039                         .is_static      = False,
7040                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7041                         .ips            = addresses_B_3_4,
7042                         .apply_expected = False
7043                 },
7044         },
7045         /*
7046          * unique,active vs. mhomed,active with different ip(s), negative response
7047          */
7048         {
7049                 .line   = __location__,
7050                 .name   = _NBT_NAME("_UA_MA_DI_N", 0x00, NULL),
7051                 .wins   = {
7052                         .nb_flags       = 0,
7053                         .mhomed         = False,
7054                         .num_ips        = ctx->addresses_best_num,
7055                         .ips            = ctx->addresses_best,
7056                         .apply_expected = True
7057                 },
7058                 .defend = {
7059                         .timeout        = 10,
7060                         .positive       = False,
7061                 },
7062                 .replica= {
7063                         .type           = WREPL_TYPE_MHOMED,
7064                         .state          = WREPL_STATE_ACTIVE,
7065                         .node           = WREPL_NODE_B,
7066                         .is_static      = False,
7067                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7068                         .ips            = addresses_B_3_4,
7069                         .apply_expected = True
7070                 },
7071         },
7072         /*
7073          * unique,active vs. mhomed,tombstone with same ip(s), unchecked
7074          */
7075         {
7076                 .line   = __location__,
7077                 .name   = _NBT_NAME("_UA_MT_SI_U", 0x00, NULL),
7078                 .wins   = {
7079                         .nb_flags       = 0,
7080                         .mhomed         = False,
7081                         .num_ips        = ctx->addresses_best_num,
7082                         .ips            = ctx->addresses_best,
7083                         .apply_expected = True
7084                 },
7085                 .defend = {
7086                         .timeout        = 0,
7087                 },
7088                 .replica= {
7089                         .type           = WREPL_TYPE_MHOMED,
7090                         .state          = WREPL_STATE_TOMBSTONE,
7091                         .node           = WREPL_NODE_B,
7092                         .is_static      = False,
7093                         .num_ips        = ctx->addresses_best_num,
7094                         .ips            = ctx->addresses_best,
7095                         .apply_expected = False
7096                 },
7097         },
7098         /*
7099          * unique,active vs. mhomed,tombstone with different ip(s), unchecked
7100          */
7101         {
7102                 .line   = __location__,
7103                 .name   = _NBT_NAME("_UA_MT_DI_U", 0x00, NULL),
7104                 .wins   = {
7105                         .nb_flags       = 0,
7106                         .mhomed         = False,
7107                         .num_ips        = ctx->addresses_best_num,
7108                         .ips            = ctx->addresses_best,
7109                         .apply_expected = True
7110                 },
7111                 .defend = {
7112                         .timeout        = 0,
7113                 },
7114                 .replica= {
7115                         .type           = WREPL_TYPE_MHOMED,
7116                         .state          = WREPL_STATE_TOMBSTONE,
7117                         .node           = WREPL_NODE_B,
7118                         .is_static      = False,
7119                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7120                         .ips            = addresses_B_3_4,
7121                         .apply_expected = False
7122                 },
7123         },
7124 /* 
7125  * normal group vs. unique section
7126  */
7127         /*
7128          * group,active vs. unique,active with same ip(s), unchecked
7129          */
7130         {
7131                 .line   = __location__,
7132                 .name   = _NBT_NAME("_GA_UA_SI_U", 0x00, NULL),
7133                 .wins   = {
7134                         .nb_flags       = NBT_NM_GROUP,
7135                         .mhomed         = False,
7136                         .num_ips        = ctx->addresses_best_num,
7137                         .ips            = ctx->addresses_best,
7138                         .apply_expected = True
7139                 },
7140                 .defend = {
7141                         .timeout        = 0,
7142                 },
7143                 .replica= {
7144                         .type           = WREPL_TYPE_UNIQUE,
7145                         .state          = WREPL_STATE_ACTIVE,
7146                         .node           = WREPL_NODE_B,
7147                         .is_static      = False,
7148                         .num_ips        = ctx->addresses_best_num,
7149                         .ips            = ctx->addresses_best,
7150                         .apply_expected = False
7151                 },
7152         },
7153         /*
7154          * group,active vs. unique,active with different ip(s), unchecked
7155          */
7156         {
7157                 .line   = __location__,
7158                 .name   = _NBT_NAME("_GA_UA_DI_U", 0x00, NULL),
7159                 .wins   = {
7160                         .nb_flags       = NBT_NM_GROUP,
7161                         .mhomed         = False,
7162                         .num_ips        = ctx->addresses_best_num,
7163                         .ips            = ctx->addresses_best,
7164                         .apply_expected = True
7165                 },
7166                 .defend = {
7167                         .timeout        = 0,
7168                 },
7169                 .replica= {
7170                         .type           = WREPL_TYPE_UNIQUE,
7171                         .state          = WREPL_STATE_ACTIVE,
7172                         .node           = WREPL_NODE_B,
7173                         .is_static      = False,
7174                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7175                         .ips            = addresses_B_1,
7176                         .apply_expected = False
7177                 },
7178         },
7179         /*
7180          * group,active vs. unique,tombstone with same ip(s), unchecked
7181          */
7182         {
7183                 .line   = __location__,
7184                 .name   = _NBT_NAME("_GA_UT_SI_U", 0x00, NULL),
7185                 .wins   = {
7186                         .nb_flags       = NBT_NM_GROUP,
7187                         .mhomed         = False,
7188                         .num_ips        = ctx->addresses_best_num,
7189                         .ips            = ctx->addresses_best,
7190                         .apply_expected = True
7191                 },
7192                 .defend = {
7193                         .timeout        = 0,
7194                 },
7195                 .replica= {
7196                         .type           = WREPL_TYPE_UNIQUE,
7197                         .state          = WREPL_STATE_TOMBSTONE,
7198                         .node           = WREPL_NODE_B,
7199                         .is_static      = False,
7200                         .num_ips        = ctx->addresses_best_num,
7201                         .ips            = ctx->addresses_best,
7202                         .apply_expected = False
7203                 },
7204         },
7205         /*
7206          * group,active vs. unique,tombstone with different ip(s), unchecked
7207          */
7208         {
7209                 .line   = __location__,
7210                 .name   = _NBT_NAME("_GA_UT_DI_U", 0x00, NULL),
7211                 .wins   = {
7212                         .nb_flags       = NBT_NM_GROUP,
7213                         .mhomed         = False,
7214                         .num_ips        = ctx->addresses_best_num,
7215                         .ips            = ctx->addresses_best,
7216                         .apply_expected = True
7217                 },
7218                 .defend = {
7219                         .timeout        = 0,
7220                 },
7221                 .replica= {
7222                         .type           = WREPL_TYPE_UNIQUE,
7223                         .state          = WREPL_STATE_TOMBSTONE,
7224                         .node           = WREPL_NODE_B,
7225                         .is_static      = False,
7226                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7227                         .ips            = addresses_B_1,
7228                         .apply_expected = False
7229                 },
7230         },
7231 /* 
7232  * normal group vs. normal group section
7233  */
7234         /*
7235          * group,active vs. group,active with same ip(s), unchecked
7236          */
7237         {
7238                 .line   = __location__,
7239                 .name   = _NBT_NAME("_GA_GA_SI_U", 0x00, NULL),
7240                 .wins   = {
7241                         .nb_flags       = NBT_NM_GROUP,
7242                         .mhomed         = False,
7243                         .num_ips        = ctx->addresses_best_num,
7244                         .ips            = ctx->addresses_best,
7245                         .apply_expected = True
7246                 },
7247                 .defend = {
7248                         .timeout        = 0,
7249                 },
7250                 .replica= {
7251                         .type           = WREPL_TYPE_GROUP,
7252                         .state          = WREPL_STATE_ACTIVE,
7253                         .node           = WREPL_NODE_B,
7254                         .is_static      = False,
7255                         .num_ips        = ctx->addresses_best_num,
7256                         .ips            = ctx->addresses_best,
7257                         .apply_expected = True
7258                 },
7259         },
7260         /*
7261          * group,active vs. group,active with different ip(s), unchecked
7262          */
7263         {
7264                 .line   = __location__,
7265                 .name   = _NBT_NAME("_GA_GA_DI_U", 0x00, NULL),
7266                 .wins   = {
7267                         .nb_flags       = NBT_NM_GROUP,
7268                         .mhomed         = False,
7269                         .num_ips        = ctx->addresses_best_num,
7270                         .ips            = ctx->addresses_best,
7271                         .apply_expected = True
7272                 },
7273                 .defend = {
7274                         .timeout        = 0,
7275                 },
7276                 .replica= {
7277                         .type           = WREPL_TYPE_GROUP,
7278                         .state          = WREPL_STATE_ACTIVE,
7279                         .node           = WREPL_NODE_B,
7280                         .is_static      = False,
7281                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7282                         .ips            = addresses_B_1,
7283                         .apply_expected = True
7284                 },
7285         },
7286         /*
7287          * group,active vs. group,tombstone with same ip(s), unchecked
7288          */
7289         {
7290                 .line   = __location__,
7291                 .name   = _NBT_NAME("_GA_GT_SI_U", 0x00, NULL),
7292                 .wins   = {
7293                         .nb_flags       = NBT_NM_GROUP,
7294                         .mhomed         = False,
7295                         .num_ips        = ctx->addresses_best_num,
7296                         .ips            = ctx->addresses_best,
7297                         .apply_expected = True
7298                 },
7299                 .defend = {
7300                         .timeout        = 0,
7301                 },
7302                 .replica= {
7303                         .type           = WREPL_TYPE_GROUP,
7304                         .state          = WREPL_STATE_TOMBSTONE,
7305                         .node           = WREPL_NODE_B,
7306                         .is_static      = False,
7307                         .num_ips        = ctx->addresses_best_num,
7308                         .ips            = ctx->addresses_best,
7309                         .apply_expected = False
7310                 },
7311         },
7312         /*
7313          * group,active vs. group,tombstone with different ip(s), unchecked
7314          */
7315         {
7316                 .line   = __location__,
7317                 .name   = _NBT_NAME("_GA_GT_DI_U", 0x00, NULL),
7318                 .wins   = {
7319                         .nb_flags       = NBT_NM_GROUP,
7320                         .mhomed         = False,
7321                         .num_ips        = ctx->addresses_best_num,
7322                         .ips            = ctx->addresses_best,
7323                         .apply_expected = True
7324                 },
7325                 .defend = {
7326                         .timeout        = 0,
7327                 },
7328                 .replica= {
7329                         .type           = WREPL_TYPE_GROUP,
7330                         .state          = WREPL_STATE_TOMBSTONE,
7331                         .node           = WREPL_NODE_B,
7332                         .is_static      = False,
7333                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7334                         .ips            = addresses_B_1,
7335                         .apply_expected = False
7336                 },
7337         },
7338 /* 
7339  * normal group vs. special group section
7340  */
7341         /*
7342          * group,active vs. sgroup,active with same ip(s), unchecked
7343          */
7344         {
7345                 .line   = __location__,
7346                 .name   = _NBT_NAME("_GA_SA_SI_U", 0x00, NULL),
7347                 .wins   = {
7348                         .nb_flags       = NBT_NM_GROUP,
7349                         .mhomed         = False,
7350                         .num_ips        = ctx->addresses_best_num,
7351                         .ips            = ctx->addresses_best,
7352                         .apply_expected = True
7353                 },
7354                 .defend = {
7355                         .timeout        = 0,
7356                 },
7357                 .replica= {
7358                         .type           = WREPL_TYPE_SGROUP,
7359                         .state          = WREPL_STATE_ACTIVE,
7360                         .node           = WREPL_NODE_B,
7361                         .is_static      = False,
7362                         .num_ips        = ctx->addresses_best_num,
7363                         .ips            = ctx->addresses_best,
7364                         .apply_expected = False
7365                 },
7366         },
7367         /*
7368          * group,active vs. sgroup,active with different ip(s), unchecked
7369          */
7370         {
7371                 .line   = __location__,
7372                 .name   = _NBT_NAME("_GA_SA_DI_U", 0x00, NULL),
7373                 .wins   = {
7374                         .nb_flags       = NBT_NM_GROUP,
7375                         .mhomed         = False,
7376                         .num_ips        = ctx->addresses_best_num,
7377                         .ips            = ctx->addresses_best,
7378                         .apply_expected = True
7379                 },
7380                 .defend = {
7381                         .timeout        = 0,
7382                 },
7383                 .replica= {
7384                         .type           = WREPL_TYPE_SGROUP,
7385                         .state          = WREPL_STATE_ACTIVE,
7386                         .node           = WREPL_NODE_B,
7387                         .is_static      = False,
7388                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7389                         .ips            = addresses_B_3_4,
7390                         .apply_expected = False
7391                 },
7392         },
7393         /*
7394          * group,active vs. sgroup,tombstone with same ip(s), unchecked
7395          */
7396         {
7397                 .line   = __location__,
7398                 .name   = _NBT_NAME("_GA_ST_SI_U", 0x00, NULL),
7399                 .wins   = {
7400                         .nb_flags       = NBT_NM_GROUP,
7401                         .mhomed         = False,
7402                         .num_ips        = ctx->addresses_best_num,
7403                         .ips            = ctx->addresses_best,
7404                         .apply_expected = True
7405                 },
7406                 .defend = {
7407                         .timeout        = 0,
7408                 },
7409                 .replica= {
7410                         .type           = WREPL_TYPE_SGROUP,
7411                         .state          = WREPL_STATE_TOMBSTONE,
7412                         .node           = WREPL_NODE_B,
7413                         .is_static      = False,
7414                         .num_ips        = ctx->addresses_best_num,
7415                         .ips            = ctx->addresses_best,
7416                         .apply_expected = False
7417                 },
7418         },
7419         /*
7420          * group,active vs. sgroup,tombstone with different ip(s), unchecked
7421          */
7422         {
7423                 .line   = __location__,
7424                 .name   = _NBT_NAME("_GA_ST_DI_U", 0x00, NULL),
7425                 .wins   = {
7426                         .nb_flags       = NBT_NM_GROUP,
7427                         .mhomed         = False,
7428                         .num_ips        = ctx->addresses_best_num,
7429                         .ips            = ctx->addresses_best,
7430                         .apply_expected = True
7431                 },
7432                 .defend = {
7433                         .timeout        = 0,
7434                 },
7435                 .replica= {
7436                         .type           = WREPL_TYPE_SGROUP,
7437                         .state          = WREPL_STATE_TOMBSTONE,
7438                         .node           = WREPL_NODE_B,
7439                         .is_static      = False,
7440                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7441                         .ips            = addresses_B_3_4,
7442                         .apply_expected = False
7443                 },
7444         },
7445 /* 
7446  * normal group vs. multi homed section
7447  */
7448         /*
7449          * group,active vs. mhomed,active with same ip(s), unchecked
7450          */
7451         {
7452                 .line   = __location__,
7453                 .name   = _NBT_NAME("_GA_MA_SI_U", 0x00, NULL),
7454                 .wins   = {
7455                         .nb_flags       = NBT_NM_GROUP,
7456                         .mhomed         = False,
7457                         .num_ips        = ctx->addresses_best_num,
7458                         .ips            = ctx->addresses_best,
7459                         .apply_expected = True
7460                 },
7461                 .defend = {
7462                         .timeout        = 0,
7463                 },
7464                 .replica= {
7465                         .type           = WREPL_TYPE_MHOMED,
7466                         .state          = WREPL_STATE_ACTIVE,
7467                         .node           = WREPL_NODE_B,
7468                         .is_static      = False,
7469                         .num_ips        = ctx->addresses_best_num,
7470                         .ips            = ctx->addresses_best,
7471                         .apply_expected = False
7472                 },
7473         },
7474         /*
7475          * group,active vs. mhomed,active with different ip(s), unchecked
7476          */
7477         {
7478                 .line   = __location__,
7479                 .name   = _NBT_NAME("_GA_MA_DI_U", 0x00, NULL),
7480                 .wins   = {
7481                         .nb_flags       = NBT_NM_GROUP,
7482                         .mhomed         = False,
7483                         .num_ips        = ctx->addresses_best_num,
7484                         .ips            = ctx->addresses_best,
7485                         .apply_expected = True
7486                 },
7487                 .defend = {
7488                         .timeout        = 0,
7489                 },
7490                 .replica= {
7491                         .type           = WREPL_TYPE_MHOMED,
7492                         .state          = WREPL_STATE_ACTIVE,
7493                         .node           = WREPL_NODE_B,
7494                         .is_static      = False,
7495                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7496                         .ips            = addresses_B_3_4,
7497                         .apply_expected = False
7498                 },
7499         },
7500         /*
7501          * group,active vs. mhomed,tombstone with same ip(s), unchecked
7502          */
7503         {
7504                 .line   = __location__,
7505                 .name   = _NBT_NAME("_GA_MT_SI_U", 0x00, NULL),
7506                 .wins   = {
7507                         .nb_flags       = NBT_NM_GROUP,
7508                         .mhomed         = False,
7509                         .num_ips        = ctx->addresses_best_num,
7510                         .ips            = ctx->addresses_best,
7511                         .apply_expected = True
7512                 },
7513                 .defend = {
7514                         .timeout        = 0,
7515                 },
7516                 .replica= {
7517                         .type           = WREPL_TYPE_MHOMED,
7518                         .state          = WREPL_STATE_TOMBSTONE,
7519                         .node           = WREPL_NODE_B,
7520                         .is_static      = False,
7521                         .num_ips        = ctx->addresses_best_num,
7522                         .ips            = ctx->addresses_best,
7523                         .apply_expected = False
7524                 },
7525         },
7526         /*
7527          * group,active vs. mhomed,tombstone with different ip(s), unchecked
7528          */
7529         {
7530                 .line   = __location__,
7531                 .name   = _NBT_NAME("_GA_MT_DI_U", 0x00, NULL),
7532                 .wins   = {
7533                         .nb_flags       = NBT_NM_GROUP,
7534                         .mhomed         = False,
7535                         .num_ips        = ctx->addresses_best_num,
7536                         .ips            = ctx->addresses_best,
7537                         .apply_expected = True
7538                 },
7539                 .defend = {
7540                         .timeout        = 0,
7541                 },
7542                 .replica= {
7543                         .type           = WREPL_TYPE_MHOMED,
7544                         .state          = WREPL_STATE_TOMBSTONE,
7545                         .node           = WREPL_NODE_B,
7546                         .is_static      = False,
7547                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7548                         .ips            = addresses_B_3_4,
7549                         .apply_expected = False
7550                 },
7551         },
7552 /* 
7553  * special group vs. unique section
7554  */
7555         /*
7556          * sgroup,active vs. unique,active with same ip(s), unchecked
7557          */
7558         {
7559                 .line   = __location__,
7560                 .name   = _NBT_NAME("_SA_UA_SI_U", 0x1C, NULL),
7561                 .wins   = {
7562                         .nb_flags       = NBT_NM_GROUP,
7563                         .mhomed         = False,
7564                         .num_ips        = ctx->addresses_best_num,
7565                         .ips            = ctx->addresses_best,
7566                         .apply_expected = True
7567                 },
7568                 .defend = {
7569                         .timeout        = 0,
7570                 },
7571                 .replica= {
7572                         .type           = WREPL_TYPE_UNIQUE,
7573                         .state          = WREPL_STATE_ACTIVE,
7574                         .node           = WREPL_NODE_B,
7575                         .is_static      = False,
7576                         .num_ips        = ctx->addresses_best_num,
7577                         .ips            = ctx->addresses_best,
7578                         .apply_expected = False
7579                 },
7580         },
7581         /*
7582          * sgroup,active vs. unique,active with different ip(s), unchecked
7583          */
7584         {
7585                 .line   = __location__,
7586                 .name   = _NBT_NAME("_SA_UA_DI_U", 0x1C, NULL),
7587                 .wins   = {
7588                         .nb_flags       = NBT_NM_GROUP,
7589                         .mhomed         = False,
7590                         .num_ips        = ctx->addresses_best_num,
7591                         .ips            = ctx->addresses_best,
7592                         .apply_expected = True
7593                 },
7594                 .defend = {
7595                         .timeout        = 0,
7596                 },
7597                 .replica= {
7598                         .type           = WREPL_TYPE_UNIQUE,
7599                         .state          = WREPL_STATE_ACTIVE,
7600                         .node           = WREPL_NODE_B,
7601                         .is_static      = False,
7602                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7603                         .ips            = addresses_B_1,
7604                         .apply_expected = False
7605                 },
7606         },
7607         /*
7608          * sgroup,active vs. unique,tombstone with same ip(s), unchecked
7609          */
7610         {
7611                 .line   = __location__,
7612                 .name   = _NBT_NAME("_SA_UT_SI_U", 0x1C, NULL),
7613                 .wins   = {
7614                         .nb_flags       = NBT_NM_GROUP,
7615                         .mhomed         = False,
7616                         .num_ips        = ctx->addresses_best_num,
7617                         .ips            = ctx->addresses_best,
7618                         .apply_expected = True
7619                 },
7620                 .defend = {
7621                         .timeout        = 0,
7622                 },
7623                 .replica= {
7624                         .type           = WREPL_TYPE_UNIQUE,
7625                         .state          = WREPL_STATE_TOMBSTONE,
7626                         .node           = WREPL_NODE_B,
7627                         .is_static      = False,
7628                         .num_ips        = ctx->addresses_best_num,
7629                         .ips            = ctx->addresses_best,
7630                         .apply_expected = False
7631                 },
7632         },
7633         /*
7634          * sgroup,active vs. unique,tombstone with different ip(s), unchecked
7635          */
7636         {
7637                 .line   = __location__,
7638                 .name   = _NBT_NAME("_SA_UT_DI_U", 0x1C, NULL),
7639                 .wins   = {
7640                         .nb_flags       = NBT_NM_GROUP,
7641                         .mhomed         = False,
7642                         .num_ips        = ctx->addresses_best_num,
7643                         .ips            = ctx->addresses_best,
7644                         .apply_expected = True
7645                 },
7646                 .defend = {
7647                         .timeout        = 0,
7648                 },
7649                 .replica= {
7650                         .type           = WREPL_TYPE_UNIQUE,
7651                         .state          = WREPL_STATE_TOMBSTONE,
7652                         .node           = WREPL_NODE_B,
7653                         .is_static      = False,
7654                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7655                         .ips            = addresses_B_1,
7656                         .apply_expected = False
7657                 },
7658         },
7659 /* 
7660  * special group vs. normal group section
7661  */
7662         /*
7663          * sgroup,active vs. group,active with same ip(s), unchecked
7664          */
7665         {
7666                 .line   = __location__,
7667                 .name   = _NBT_NAME("_SA_GA_SI_U", 0x1C, NULL),
7668                 .wins   = {
7669                         .nb_flags       = NBT_NM_GROUP,
7670                         .mhomed         = False,
7671                         .num_ips        = ctx->addresses_best_num,
7672                         .ips            = ctx->addresses_best,
7673                         .apply_expected = True
7674                 },
7675                 .defend = {
7676                         .timeout        = 0,
7677                 },
7678                 .replica= {
7679                         .type           = WREPL_TYPE_GROUP,
7680                         .state          = WREPL_STATE_ACTIVE,
7681                         .node           = WREPL_NODE_B,
7682                         .is_static      = False,
7683                         .num_ips        = ctx->addresses_best_num,
7684                         .ips            = ctx->addresses_best,
7685                         .apply_expected = False
7686                 },
7687         },
7688         /*
7689          * sgroup,active vs. group,active with different ip(s), unchecked
7690          */
7691         {
7692                 .line   = __location__,
7693                 .name   = _NBT_NAME("_SA_GA_DI_U", 0x1C, NULL),
7694                 .wins   = {
7695                         .nb_flags       = NBT_NM_GROUP,
7696                         .mhomed         = False,
7697                         .num_ips        = ctx->addresses_best_num,
7698                         .ips            = ctx->addresses_best,
7699                         .apply_expected = True
7700                 },
7701                 .defend = {
7702                         .timeout        = 0,
7703                 },
7704                 .replica= {
7705                         .type           = WREPL_TYPE_GROUP,
7706                         .state          = WREPL_STATE_ACTIVE,
7707                         .node           = WREPL_NODE_B,
7708                         .is_static      = False,
7709                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7710                         .ips            = addresses_B_1,
7711                         .apply_expected = False
7712                 },
7713         },
7714         /*
7715          * sgroup,active vs. group,tombstone with same ip(s), unchecked
7716          */
7717         {
7718                 .line   = __location__,
7719                 .name   = _NBT_NAME("_SA_GT_SI_U", 0x1C, NULL),
7720                 .wins   = {
7721                         .nb_flags       = NBT_NM_GROUP,
7722                         .mhomed         = False,
7723                         .num_ips        = ctx->addresses_best_num,
7724                         .ips            = ctx->addresses_best,
7725                         .apply_expected = True
7726                 },
7727                 .defend = {
7728                         .timeout        = 0,
7729                 },
7730                 .replica= {
7731                         .type           = WREPL_TYPE_GROUP,
7732                         .state          = WREPL_STATE_TOMBSTONE,
7733                         .node           = WREPL_NODE_B,
7734                         .is_static      = False,
7735                         .num_ips        = ctx->addresses_best_num,
7736                         .ips            = ctx->addresses_best,
7737                         .apply_expected = False
7738                 },
7739         },
7740         /*
7741          * sgroup,active vs. group,tombstone with different ip(s), unchecked
7742          */
7743         {
7744                 .line   = __location__,
7745                 .name   = _NBT_NAME("_SA_GT_DI_U", 0x1C, NULL),
7746                 .wins   = {
7747                         .nb_flags       = NBT_NM_GROUP,
7748                         .mhomed         = False,
7749                         .num_ips        = ctx->addresses_best_num,
7750                         .ips            = ctx->addresses_best,
7751                         .apply_expected = True
7752                 },
7753                 .defend = {
7754                         .timeout        = 0,
7755                 },
7756                 .replica= {
7757                         .type           = WREPL_TYPE_GROUP,
7758                         .state          = WREPL_STATE_TOMBSTONE,
7759                         .node           = WREPL_NODE_B,
7760                         .is_static      = False,
7761                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7762                         .ips            = addresses_B_1,
7763                         .apply_expected = False
7764                 },
7765         },
7766 /* 
7767  * special group vs. multi homed section
7768  */
7769         /*
7770          * sgroup,active vs. mhomed,active with same ip(s), unchecked
7771          */
7772         {
7773                 .line   = __location__,
7774                 .name   = _NBT_NAME("_SA_MA_SI_U", 0x1C, NULL),
7775                 .wins   = {
7776                         .nb_flags       = NBT_NM_GROUP,
7777                         .mhomed         = False,
7778                         .num_ips        = ctx->addresses_best_num,
7779                         .ips            = ctx->addresses_best,
7780                         .apply_expected = True
7781                 },
7782                 .defend = {
7783                         .timeout        = 0,
7784                 },
7785                 .replica= {
7786                         .type           = WREPL_TYPE_MHOMED,
7787                         .state          = WREPL_STATE_ACTIVE,
7788                         .node           = WREPL_NODE_B,
7789                         .is_static      = False,
7790                         .num_ips        = ctx->addresses_best_num,
7791                         .ips            = ctx->addresses_best,
7792                         .apply_expected = False
7793                 },
7794         },
7795         /*
7796          * sgroup,active vs. mhomed,active with different ip(s), unchecked
7797          */
7798         {
7799                 .line   = __location__,
7800                 .name   = _NBT_NAME("_SA_MA_DI_U", 0x1C, NULL),
7801                 .wins   = {
7802                         .nb_flags       = NBT_NM_GROUP,
7803                         .mhomed         = False,
7804                         .num_ips        = ctx->addresses_best_num,
7805                         .ips            = ctx->addresses_best,
7806                         .apply_expected = True
7807                 },
7808                 .defend = {
7809                         .timeout        = 0,
7810                 },
7811                 .replica= {
7812                         .type           = WREPL_TYPE_MHOMED,
7813                         .state          = WREPL_STATE_ACTIVE,
7814                         .node           = WREPL_NODE_B,
7815                         .is_static      = False,
7816                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7817                         .ips            = addresses_B_1,
7818                         .apply_expected = False
7819                 },
7820         },
7821         /*
7822          * sgroup,active vs. mhomed,tombstone with same ip(s), unchecked
7823          */
7824         {
7825                 .line   = __location__,
7826                 .name   = _NBT_NAME("_SA_MT_SI_U", 0x1C, NULL),
7827                 .wins   = {
7828                         .nb_flags       = NBT_NM_GROUP,
7829                         .mhomed         = False,
7830                         .num_ips        = ctx->addresses_best_num,
7831                         .ips            = ctx->addresses_best,
7832                         .apply_expected = True
7833                 },
7834                 .defend = {
7835                         .timeout        = 0,
7836                 },
7837                 .replica= {
7838                         .type           = WREPL_TYPE_MHOMED,
7839                         .state          = WREPL_STATE_TOMBSTONE,
7840                         .node           = WREPL_NODE_B,
7841                         .is_static      = False,
7842                         .num_ips        = ctx->addresses_best_num,
7843                         .ips            = ctx->addresses_best,
7844                         .apply_expected = False
7845                 },
7846         },
7847         /*
7848          * sgroup,active vs. mhomed,tombstone with different ip(s), unchecked
7849          */
7850         {
7851                 .line   = __location__,
7852                 .name   = _NBT_NAME("_SA_MT_DI_U", 0x1C, NULL),
7853                 .wins   = {
7854                         .nb_flags       = NBT_NM_GROUP,
7855                         .mhomed         = False,
7856                         .num_ips        = ctx->addresses_best_num,
7857                         .ips            = ctx->addresses_best,
7858                         .apply_expected = True
7859                 },
7860                 .defend = {
7861                         .timeout        = 0,
7862                 },
7863                 .replica= {
7864                         .type           = WREPL_TYPE_MHOMED,
7865                         .state          = WREPL_STATE_TOMBSTONE,
7866                         .node           = WREPL_NODE_B,
7867                         .is_static      = False,
7868                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7869                         .ips            = addresses_B_1,
7870                         .apply_expected = False
7871                 },
7872         },
7873 /* 
7874  * multi homed vs. unique section
7875  */
7876         /*
7877          * mhomed,active vs. unique,active with same ip(s), unchecked
7878          */
7879         {
7880                 .line   = __location__,
7881                 .name   = _NBT_NAME("_MA_UA_SI_U", 0x00, NULL),
7882                 .wins   = {
7883                         .nb_flags       = 0,
7884                         .mhomed         = True,
7885                         .num_ips        = ctx->addresses_best_num,
7886                         .ips            = ctx->addresses_best,
7887                         .apply_expected = True
7888                 },
7889                 .defend = {
7890                         .timeout        = 0,
7891                 },
7892                 .replica= {
7893                         .type           = WREPL_TYPE_UNIQUE,
7894                         .state          = WREPL_STATE_ACTIVE,
7895                         .node           = WREPL_NODE_B,
7896                         .is_static      = False,
7897                         .num_ips        = ctx->addresses_best_num,
7898                         .ips            = ctx->addresses_best,
7899                         .apply_expected = True
7900                 },
7901         },
7902         /*
7903          * mhomed,active vs. unique,active with different ip(s), positive response
7904          */
7905         {
7906                 .line   = __location__,
7907                 .name   = _NBT_NAME("_MA_UA_DI_P", 0x00, NULL),
7908                 .wins   = {
7909                         .nb_flags       = 0,
7910                         .mhomed         = True,
7911                         .num_ips        = ctx->addresses_best_num,
7912                         .ips            = ctx->addresses_best,
7913                         .apply_expected = True
7914                 },
7915                 .defend = {
7916                         .timeout        = 10,
7917                         .positive       = True,
7918                 },
7919                 .replica= {
7920                         .type           = WREPL_TYPE_UNIQUE,
7921                         .state          = WREPL_STATE_ACTIVE,
7922                         .node           = WREPL_NODE_B,
7923                         .is_static      = False,
7924                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7925                         .ips            = addresses_B_1,
7926                         .apply_expected = False
7927                 },
7928         },
7929         /*
7930          * mhomed,active vs. unique,active with different ip(s), positive response other ips
7931          */
7932         {
7933                 .line   = __location__,
7934                 .name   = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL),
7935                 .wins   = {
7936                         .nb_flags       = 0,
7937                         .mhomed         = True,
7938                         .num_ips        = ctx->addresses_best_num,
7939                         .ips            = ctx->addresses_best,
7940                         .apply_expected = True
7941                 },
7942                 .defend = {
7943                         .timeout        = 10,
7944                         .positive       = True,
7945                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7946                         .ips            = addresses_A_3_4,
7947                 },
7948                 .replica= {
7949                         .type           = WREPL_TYPE_UNIQUE,
7950                         .state          = WREPL_STATE_ACTIVE,
7951                         .node           = WREPL_NODE_B,
7952                         .is_static      = False,
7953                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7954                         .ips            = addresses_B_1,
7955                         .apply_expected = False
7956                 },
7957         },
7958         /*
7959          * mhomed,active vs. unique,active with different ip(s), negative response
7960          */
7961         {
7962                 .line   = __location__,
7963                 .name   = _NBT_NAME("_MA_UA_DI_N", 0x00, NULL),
7964                 .wins   = {
7965                         .nb_flags       = 0,
7966                         .mhomed         = True,
7967                         .num_ips        = ctx->addresses_best_num,
7968                         .ips            = ctx->addresses_best,
7969                         .apply_expected = True
7970                 },
7971                 .defend = {
7972                         .timeout        = 10,
7973                         .positive       = False,
7974                 },
7975                 .replica= {
7976                         .type           = WREPL_TYPE_UNIQUE,
7977                         .state          = WREPL_STATE_ACTIVE,
7978                         .node           = WREPL_NODE_B,
7979                         .is_static      = False,
7980                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7981                         .ips            = addresses_B_1,
7982                         .apply_expected = True
7983                 },
7984         },
7985         /*
7986          * mhomed,active vs. unique,tombstone with same ip(s), unchecked
7987          */
7988         {
7989                 .line   = __location__,
7990                 .name   = _NBT_NAME("_MA_UT_SI_U", 0x00, NULL),
7991                 .wins   = {
7992                         .nb_flags       = 0,
7993                         .mhomed         = True,
7994                         .num_ips        = ctx->addresses_best_num,
7995                         .ips            = ctx->addresses_best,
7996                         .apply_expected = True
7997                 },
7998                 .defend = {
7999                         .timeout        = 0,
8000                 },
8001                 .replica= {
8002                         .type           = WREPL_TYPE_UNIQUE,
8003                         .state          = WREPL_STATE_TOMBSTONE,
8004                         .node           = WREPL_NODE_B,
8005                         .is_static      = False,
8006                         .num_ips        = ctx->addresses_best_num,
8007                         .ips            = ctx->addresses_best,
8008                         .apply_expected = False
8009                 },
8010         },
8011         /*
8012          * mhomed,active vs. unique,tombstone with different ip(s), unchecked
8013          */
8014         {
8015                 .line   = __location__,
8016                 .name   = _NBT_NAME("_MA_UT_DI_U", 0x00, NULL),
8017                 .wins   = {
8018                         .nb_flags       = 0,
8019                         .mhomed         = True,
8020                         .num_ips        = ctx->addresses_best_num,
8021                         .ips            = ctx->addresses_best,
8022                         .apply_expected = True
8023                 },
8024                 .defend = {
8025                         .timeout        = 0,
8026                 },
8027                 .replica= {
8028                         .type           = WREPL_TYPE_UNIQUE,
8029                         .state          = WREPL_STATE_TOMBSTONE,
8030                         .node           = WREPL_NODE_B,
8031                         .is_static      = False,
8032                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8033                         .ips            = addresses_B_1,
8034                         .apply_expected = False
8035                 },
8036         },
8037 /* 
8038  * multi homed vs. normal group section
8039  */
8040         /*
8041          * mhomed,active vs. group,active with same ip(s), release expected
8042          */
8043         {
8044                 .line   = __location__,
8045                 .name   = _NBT_NAME("_MA_GA_SI_R", 0x00, NULL),
8046                 .wins   = {
8047                         .nb_flags       = 0,
8048                         .mhomed         = True,
8049                         .num_ips        = ctx->addresses_best_num,
8050                         .ips            = ctx->addresses_best,
8051                         .apply_expected = True
8052                 },
8053                 .defend = {
8054                         .timeout        = 10,
8055                         .expect_release = True,
8056                 },
8057                 .replica= {
8058                         .type           = WREPL_TYPE_GROUP,
8059                         .state          = WREPL_STATE_ACTIVE,
8060                         .node           = WREPL_NODE_B,
8061                         .is_static      = False,
8062                         .num_ips        = ctx->addresses_best_num,
8063                         .ips            = ctx->addresses_best,
8064                         .apply_expected = True
8065                 },
8066         },
8067         /*
8068          * mhomed,active vs. group,active with different ip(s), release expected
8069          */
8070         {
8071                 .line   = __location__,
8072                 .name   = _NBT_NAME("_MA_GA_DI_R", 0x00, NULL),
8073                 .wins   = {
8074                         .nb_flags       = 0,
8075                         .mhomed         = True,
8076                         .num_ips        = ctx->addresses_best_num,
8077                         .ips            = ctx->addresses_best,
8078                         .apply_expected = True
8079                 },
8080                 .defend = {
8081                         .timeout        = 10,
8082                         .expect_release = True,
8083                 },
8084                 .replica= {
8085                         .type           = WREPL_TYPE_GROUP,
8086                         .state          = WREPL_STATE_ACTIVE,
8087                         .node           = WREPL_NODE_B,
8088                         .is_static      = False,
8089                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8090                         .ips            = addresses_B_1,
8091                         .apply_expected = True
8092                 },
8093         },
8094         /*
8095          * mhomed,active vs. group,tombstone with same ip(s), unchecked
8096          */
8097         {
8098                 .line   = __location__,
8099                 .name   = _NBT_NAME("_MA_GT_SI_U", 0x00, NULL),
8100                 .wins   = {
8101                         .nb_flags       = 0,
8102                         .mhomed         = True,
8103                         .num_ips        = ctx->addresses_best_num,
8104                         .ips            = ctx->addresses_best,
8105                         .apply_expected = True
8106                 },
8107                 .defend = {
8108                         .timeout        = 0,
8109                 },
8110                 .replica= {
8111                         .type           = WREPL_TYPE_GROUP,
8112                         .state          = WREPL_STATE_TOMBSTONE,
8113                         .node           = WREPL_NODE_B,
8114                         .is_static      = False,
8115                         .num_ips        = ctx->addresses_best_num,
8116                         .ips            = ctx->addresses_best,
8117                         .apply_expected = False
8118                 },
8119         },
8120         /*
8121          * mhomed,active vs. group,tombstone with different ip(s), unchecked
8122          */
8123         {
8124                 .line   = __location__,
8125                 .name   = _NBT_NAME("_MA_GT_DI_U", 0x00, NULL),
8126                 .wins   = {
8127                         .nb_flags       = 0,
8128                         .mhomed         = True,
8129                         .num_ips        = ctx->addresses_best_num,
8130                         .ips            = ctx->addresses_best,
8131                         .apply_expected = True
8132                 },
8133                 .defend = {
8134                         .timeout        = 0,
8135                 },
8136                 .replica= {
8137                         .type           = WREPL_TYPE_GROUP,
8138                         .state          = WREPL_STATE_TOMBSTONE,
8139                         .node           = WREPL_NODE_B,
8140                         .is_static      = False,
8141                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8142                         .ips            = addresses_B_1,
8143                         .apply_expected = False
8144                 },
8145         },
8146 /* 
8147  * multi homed vs. special group section
8148  */
8149         /*
8150          * mhomed,active vs. sgroup,active with same ip(s), release expected
8151          */
8152         {
8153                 .line   = __location__,
8154                 .name   = _NBT_NAME("_MA_SA_SI_R", 0x00, NULL),
8155                 .wins   = {
8156                         .nb_flags       = 0,
8157                         .mhomed         = True,
8158                         .num_ips        = ctx->addresses_best_num,
8159                         .ips            = ctx->addresses_best,
8160                         .apply_expected = True
8161                 },
8162                 .defend = {
8163                         .timeout        = 10,
8164                         .expect_release = True,
8165                 },
8166                 .replica= {
8167                         .type           = WREPL_TYPE_SGROUP,
8168                         .state          = WREPL_STATE_ACTIVE,
8169                         .node           = WREPL_NODE_B,
8170                         .is_static      = False,
8171                         .num_ips        = ctx->addresses_best_num,
8172                         .ips            = ctx->addresses_best,
8173                         .apply_expected = True
8174                 },
8175         },
8176         /*
8177          * mhomed,active vs. group,active with different ip(s), release expected
8178          */
8179         {
8180                 .line   = __location__,
8181                 .name   = _NBT_NAME("_MA_SA_DI_R", 0x00, NULL),
8182                 .wins   = {
8183                         .nb_flags       = 0,
8184                         .mhomed         = True,
8185                         .num_ips        = ctx->addresses_best_num,
8186                         .ips            = ctx->addresses_best,
8187                         .apply_expected = True
8188                 },
8189                 .defend = {
8190                         .timeout        = 10,
8191                         .expect_release = True,
8192                 },
8193                 .replica= {
8194                         .type           = WREPL_TYPE_SGROUP,
8195                         .state          = WREPL_STATE_ACTIVE,
8196                         .node           = WREPL_NODE_B,
8197                         .is_static      = False,
8198                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8199                         .ips            = addresses_B_1,
8200                         .apply_expected = True
8201                 },
8202         },
8203         /*
8204          * mhomed,active vs. sgroup,tombstone with same ip(s), unchecked
8205          */
8206         {
8207                 .line   = __location__,
8208                 .name   = _NBT_NAME("_MA_ST_SI_U", 0x00, NULL),
8209                 .wins   = {
8210                         .nb_flags       = 0,
8211                         .mhomed         = True,
8212                         .num_ips        = ctx->addresses_best_num,
8213                         .ips            = ctx->addresses_best,
8214                         .apply_expected = True
8215                 },
8216                 .defend = {
8217                         .timeout        = 0,
8218                 },
8219                 .replica= {
8220                         .type           = WREPL_TYPE_SGROUP,
8221                         .state          = WREPL_STATE_TOMBSTONE,
8222                         .node           = WREPL_NODE_B,
8223                         .is_static      = False,
8224                         .num_ips        = ctx->addresses_best_num,
8225                         .ips            = ctx->addresses_best,
8226                         .apply_expected = False
8227                 },
8228         },
8229         /*
8230          * mhomed,active vs. sgroup,tombstone with different ip(s), unchecked
8231          */
8232         {
8233                 .line   = __location__,
8234                 .name   = _NBT_NAME("_MA_ST_DI_U", 0x00, NULL),
8235                 .wins   = {
8236                         .nb_flags       = 0,
8237                         .mhomed         = True,
8238                         .num_ips        = ctx->addresses_best_num,
8239                         .ips            = ctx->addresses_best,
8240                         .apply_expected = True
8241                 },
8242                 .defend = {
8243                         .timeout        = 0,
8244                 },
8245                 .replica= {
8246                         .type           = WREPL_TYPE_SGROUP,
8247                         .state          = WREPL_STATE_TOMBSTONE,
8248                         .node           = WREPL_NODE_B,
8249                         .is_static      = False,
8250                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8251                         .ips            = addresses_B_1,
8252                         .apply_expected = False
8253                 },
8254         },
8255 /* 
8256  * multi homed vs. multi homed section
8257  */
8258         /*
8259          * mhomed,active vs. mhomed,active with same ip(s), unchecked
8260          */
8261         {
8262                 .line   = __location__,
8263                 .name   = _NBT_NAME("_MA_MA_SI_U", 0x00, NULL),
8264                 .wins   = {
8265                         .nb_flags       = 0,
8266                         .mhomed         = True,
8267                         .num_ips        = ctx->addresses_best_num,
8268                         .ips            = ctx->addresses_best,
8269                         .apply_expected = True
8270                 },
8271                 .defend = {
8272                         .timeout        = 0,
8273                 },
8274                 .replica= {
8275                         .type           = WREPL_TYPE_MHOMED,
8276                         .state          = WREPL_STATE_ACTIVE,
8277                         .node           = WREPL_NODE_B,
8278                         .is_static      = False,
8279                         .num_ips        = ctx->addresses_best_num,
8280                         .ips            = ctx->addresses_best,
8281                         .apply_expected = True
8282                 },
8283         },
8284         /*
8285          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8286          */
8287         {
8288                 .line   = __location__,
8289                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8290                 .wins   = {
8291                         .nb_flags       = 0,
8292                         .mhomed         = True,
8293                         .num_ips        = ctx->addresses_best_num,
8294                         .ips            = ctx->addresses_best,
8295                         .apply_expected = True
8296                 },
8297                 .defend = {
8298                         .timeout        = 0,
8299                 },
8300                 .replica= {
8301                         .type           = WREPL_TYPE_MHOMED,
8302                         .state          = WREPL_STATE_ACTIVE,
8303                         .node           = WREPL_NODE_B,
8304                         .is_static      = False,
8305                         .num_ips        = ctx->addresses_all_num,
8306                         .ips            = ctx->addresses_all,
8307                         .apply_expected = True
8308                 },
8309         },
8310         /*
8311          * mhomed,active vs. mhomed,active with different ip(s), positive response
8312          */
8313         {
8314                 .line   = __location__,
8315                 .name   = _NBT_NAME("_MA_MA_DI_P", 0x00, NULL),
8316                 .wins   = {
8317                         .nb_flags       = 0,
8318                         .mhomed         = True,
8319                         .num_ips        = ctx->addresses_best_num,
8320                         .ips            = ctx->addresses_best,
8321                         .apply_expected = True
8322                 },
8323                 .defend = {
8324                         .timeout        = 10,
8325                         .positive       = True,
8326                 },
8327                 .replica= {
8328                         .type           = WREPL_TYPE_MHOMED,
8329                         .state          = WREPL_STATE_ACTIVE,
8330                         .node           = WREPL_NODE_B,
8331                         .is_static      = False,
8332                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8333                         .ips            = addresses_B_3_4,
8334                         .apply_expected = False
8335                 },
8336         },
8337         /*
8338          * mhomed,active vs. mhomed,active with different ip(s), positive response other ips
8339          */
8340         {
8341                 .line   = __location__,
8342                 .name   = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL),
8343                 .wins   = {
8344                         .nb_flags       = 0,
8345                         .mhomed         = True,
8346                         .num_ips        = ctx->addresses_best_num,
8347                         .ips            = ctx->addresses_best,
8348                         .apply_expected = True
8349                 },
8350                 .defend = {
8351                         .timeout        = 10,
8352                         .positive       = True,
8353                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
8354                         .ips            = addresses_A_3_4,
8355                 },
8356                 .replica= {
8357                         .type           = WREPL_TYPE_MHOMED,
8358                         .state          = WREPL_STATE_ACTIVE,
8359                         .node           = WREPL_NODE_B,
8360                         .is_static      = False,
8361                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8362                         .ips            = addresses_B_3_4,
8363                         .apply_expected = False
8364                 },
8365         },
8366         /*
8367          * mhomed,active vs. mhomed,active with different ip(s), negative response
8368          */
8369         {
8370                 .line   = __location__,
8371                 .name   = _NBT_NAME("_MA_MA_DI_N", 0x00, NULL),
8372                 .wins   = {
8373                         .nb_flags       = 0,
8374                         .mhomed         = True,
8375                         .num_ips        = ctx->addresses_best_num,
8376                         .ips            = ctx->addresses_best,
8377                         .apply_expected = True
8378                 },
8379                 .defend = {
8380                         .timeout        = 10,
8381                         .positive       = False,
8382                 },
8383                 .replica= {
8384                         .type           = WREPL_TYPE_MHOMED,
8385                         .state          = WREPL_STATE_ACTIVE,
8386                         .node           = WREPL_NODE_B,
8387                         .is_static      = False,
8388                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8389                         .ips            = addresses_B_3_4,
8390                         .apply_expected = True
8391                 },
8392         },
8393         /*
8394          * mhomed,active vs. mhomed,tombstone with same ip(s), unchecked
8395          */
8396         {
8397                 .line   = __location__,
8398                 .name   = _NBT_NAME("_MA_MT_SI_U", 0x00, NULL),
8399                 .wins   = {
8400                         .nb_flags       = 0,
8401                         .mhomed         = True,
8402                         .num_ips        = ctx->addresses_best_num,
8403                         .ips            = ctx->addresses_best,
8404                         .apply_expected = True
8405                 },
8406                 .defend = {
8407                         .timeout        = 0,
8408                 },
8409                 .replica= {
8410                         .type           = WREPL_TYPE_MHOMED,
8411                         .state          = WREPL_STATE_TOMBSTONE,
8412                         .node           = WREPL_NODE_B,
8413                         .is_static      = False,
8414                         .num_ips        = ctx->addresses_best_num,
8415                         .ips            = ctx->addresses_best,
8416                         .apply_expected = False
8417                 },
8418         },
8419         /*
8420          * mhomed,active vs. mhomed,tombstone with different ip(s), unchecked
8421          */
8422         {
8423                 .line   = __location__,
8424                 .name   = _NBT_NAME("_MA_MT_DI_U", 0x00, NULL),
8425                 .wins   = {
8426                         .nb_flags       = 0,
8427                         .mhomed         = True,
8428                         .num_ips        = ctx->addresses_best_num,
8429                         .ips            = ctx->addresses_best,
8430                         .apply_expected = True
8431                 },
8432                 .defend = {
8433                         .timeout        = 0,
8434                 },
8435                 .replica= {
8436                         .type           = WREPL_TYPE_MHOMED,
8437                         .state          = WREPL_STATE_TOMBSTONE,
8438                         .node           = WREPL_NODE_B,
8439                         .is_static      = False,
8440                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8441                         .ips            = addresses_B_3_4,
8442                         .apply_expected = False
8443                 },
8444         },
8445 /*
8446  * some more multi homed test, including merging
8447  */
8448         /*
8449          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8450          */
8451         {
8452                 .line   = __location__,
8453                 .section= "Test Replica vs. owned active: some more MHOMED combinations",
8454                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8455                 .skip   = (ctx->addresses_all_num < 3),
8456                 .wins   = {
8457                         .nb_flags       = 0,
8458                         .mhomed         = True,
8459                         .num_ips        = ctx->addresses_mhomed_num,
8460                         .ips            = ctx->addresses_mhomed,
8461                         .apply_expected = True
8462                 },
8463                 .defend = {
8464                         .timeout        = 0,
8465                 },
8466                 .replica= {
8467                         .type           = WREPL_TYPE_MHOMED,
8468                         .state          = WREPL_STATE_ACTIVE,
8469                         .node           = WREPL_NODE_B,
8470                         .is_static      = False,
8471                         .num_ips        = ctx->addresses_all_num,
8472                         .ips            = ctx->addresses_all,
8473                         .apply_expected = True
8474                 },
8475         },
8476         /*
8477          * mhomed,active vs. mhomed,active with same ips, unchecked
8478          */
8479         {
8480                 .line   = __location__,
8481                 .name   = _NBT_NAME("_MA_MA_SM_U", 0x00, NULL),
8482                 .skip   = (ctx->addresses_mhomed_num != 2),
8483                 .wins   = {
8484                         .nb_flags       = 0,
8485                         .mhomed         = True,
8486                         .num_ips        = ctx->addresses_mhomed_num,
8487                         .ips            = ctx->addresses_mhomed,
8488                         .apply_expected = True
8489                 },
8490                 .defend = {
8491                         .timeout        = 0,
8492                 },
8493                 .replica= {
8494                         .type           = WREPL_TYPE_MHOMED,
8495                         .state          = WREPL_STATE_ACTIVE,
8496                         .node           = WREPL_NODE_B,
8497                         .is_static      = False,
8498                         .num_ips        = ctx->addresses_mhomed_num,
8499                         .ips            = ctx->addresses_mhomed,
8500                         .apply_expected = True
8501                 },
8502         },
8503         /*
8504          * mhomed,active vs. mhomed,active with subset ip(s), positive response
8505          */
8506         {
8507                 .line   = __location__,
8508                 .name   = _NBT_NAME("_MA_MA_SB_P", 0x00, NULL),
8509                 .skip   = (ctx->addresses_mhomed_num != 2),
8510                 .wins   = {
8511                         .nb_flags       = 0,
8512                         .mhomed         = True,
8513                         .num_ips        = ctx->addresses_mhomed_num,
8514                         .ips            = ctx->addresses_mhomed,
8515                         .apply_expected = True
8516                 },
8517                 .defend = {
8518                         .timeout        = 10,
8519                         .positive       = True
8520                 },
8521                 .replica= {
8522                         .type           = WREPL_TYPE_MHOMED,
8523                         .state          = WREPL_STATE_ACTIVE,
8524                         .node           = WREPL_NODE_B,
8525                         .is_static      = False,
8526                         .num_ips        = ctx->addresses_best_num,
8527                         .ips            = ctx->addresses_best,
8528                         .mhomed_merge   = True
8529                 },
8530         },
8531         /*
8532          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with all addresses
8533          */
8534         {
8535                 .line   = __location__,
8536                 .name   = _NBT_NAME("_MA_MA_SB_A", 0x00, NULL),
8537                 .skip   = (ctx->addresses_all_num < 3),
8538                 .wins   = {
8539                         .nb_flags       = 0,
8540                         .mhomed         = True,
8541                         .num_ips        = ctx->addresses_mhomed_num,
8542                         .ips            = ctx->addresses_mhomed,
8543                         .apply_expected = True
8544                 },
8545                 .defend = {
8546                         .timeout        = 10,
8547                         .positive       = True,
8548                         .num_ips        = ctx->addresses_all_num,
8549                         .ips            = ctx->addresses_all,
8550                 },
8551                 .replica= {
8552                         .type           = WREPL_TYPE_MHOMED,
8553                         .state          = WREPL_STATE_ACTIVE,
8554                         .node           = WREPL_NODE_B,
8555                         .is_static      = False,
8556                         .num_ips        = ctx->addresses_best_num,
8557                         .ips            = ctx->addresses_best,
8558                         .mhomed_merge   = True
8559                 },
8560         },
8561         /*
8562          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with replicas addresses
8563          * TODO: check why the server sends a name release demand for one address?
8564          *       the release demand has no effect to the database record...
8565          */
8566         {
8567                 .line   = __location__,
8568                 .name   = _NBT_NAME("_MA_MA_SB_PRA", 0x00, NULL),
8569                 .skip   = (ctx->addresses_all_num < 3),
8570                 .wins   = {
8571                         .nb_flags       = 0,
8572                         .mhomed         = True,
8573                         .num_ips        = ctx->addresses_mhomed_num,
8574                         .ips            = ctx->addresses_mhomed,
8575                         .apply_expected = True
8576                 },
8577                 .defend = {
8578                         .timeout        = 10,
8579                         .positive       = True,
8580                         .num_ips        = ctx->addresses_best_num,
8581                         .ips            = ctx->addresses_best,
8582                         .late_release   = True
8583                 },
8584                 .replica= {
8585                         .type           = WREPL_TYPE_MHOMED,
8586                         .state          = WREPL_STATE_ACTIVE,
8587                         .node           = WREPL_NODE_B,
8588                         .is_static      = False,
8589                         .num_ips        = ctx->addresses_best_num,
8590                         .ips            = ctx->addresses_best,
8591                         .apply_expected = False
8592                 },
8593         },
8594         /*
8595          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with other addresses
8596          */
8597         {
8598                 .line   = __location__,
8599                 .name   = _NBT_NAME("_MA_MA_SB_O", 0x00, NULL),
8600
8601                 .skip   = (ctx->addresses_all_num < 3),
8602                 .wins   = {
8603                         .nb_flags       = 0,
8604                         .mhomed         = True,
8605                         .num_ips        = ctx->addresses_mhomed_num,
8606                         .ips            = ctx->addresses_mhomed,
8607                         .apply_expected = True
8608                 },
8609                 .defend = {
8610                         .timeout        = 10,
8611                         .positive       = True,
8612                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8613                         .ips            = addresses_B_3_4,
8614                 },
8615                 .replica= {
8616                         .type           = WREPL_TYPE_MHOMED,
8617                         .state          = WREPL_STATE_ACTIVE,
8618                         .node           = WREPL_NODE_B,
8619                         .is_static      = False,
8620                         .num_ips        = ctx->addresses_best_num,
8621                         .ips            = ctx->addresses_best,
8622                         .apply_expected = False
8623                 },
8624         },
8625         /*
8626          * mhomed,active vs. mhomed,active with subset ip(s), negative response
8627          */
8628         {
8629                 .line   = __location__,
8630                 .name   = _NBT_NAME("_MA_MA_SB_N", 0x00, NULL),
8631                 .skip   = (ctx->addresses_mhomed_num != 2),
8632                 .wins   = {
8633                         .nb_flags       = 0,
8634                         .mhomed         = True,
8635                         .num_ips        = ctx->addresses_mhomed_num,
8636                         .ips            = ctx->addresses_mhomed,
8637                         .apply_expected = True
8638                 },
8639                 .defend = {
8640                         .timeout        = 10,
8641                         .positive       = False
8642                 },
8643                 .replica= {
8644                         .type           = WREPL_TYPE_MHOMED,
8645                         .state          = WREPL_STATE_ACTIVE,
8646                         .node           = WREPL_NODE_B,
8647                         .is_static      = False,
8648                         .num_ips        = ctx->addresses_best_num,
8649                         .ips            = ctx->addresses_best,
8650                         .apply_expected = True
8651                 },
8652         },
8653 /*
8654  * some more multi homed and unique test, including merging
8655  */
8656         /*
8657          * mhomed,active vs. unique,active with subset ip(s), positive response
8658          */
8659         {
8660                 .line   = __location__,
8661                 .section= "Test Replica vs. owned active: some more UNIQUE,MHOMED combinations",
8662                 .name   = _NBT_NAME("_MA_UA_SB_P", 0x00, NULL),
8663                 .skip   = (ctx->addresses_all_num < 3),
8664                 .wins   = {
8665                         .nb_flags       = 0,
8666                         .mhomed         = True,
8667                         .num_ips        = ctx->addresses_mhomed_num,
8668                         .ips            = ctx->addresses_mhomed,
8669                         .apply_expected = True
8670                 },
8671                 .defend = {
8672                         .timeout        = 10,
8673                         .positive       = True,
8674                 },
8675                 .replica= {
8676                         .type           = WREPL_TYPE_UNIQUE,
8677                         .state          = WREPL_STATE_ACTIVE,
8678                         .node           = WREPL_NODE_B,
8679                         .is_static      = False,
8680                         .num_ips        = ctx->addresses_best_num,
8681                         .ips            = ctx->addresses_best,
8682                         .mhomed_merge   = True
8683                 },
8684         },
8685         /*
8686          * unique,active vs. unique,active with different ip(s), positive response, with all addresses
8687          */
8688         {
8689                 .line   = __location__,
8690                 .name   = _NBT_NAME("_UA_UA_DI_A", 0x00, NULL),
8691                 .skip   = (ctx->addresses_all_num < 3),
8692                 .wins   = {
8693                         .nb_flags       = 0,
8694                         .mhomed         = False,
8695                         .num_ips        = ctx->addresses_best_num,
8696                         .ips            = ctx->addresses_best,
8697                         .apply_expected = True
8698                 },
8699                 .defend = {
8700                         .timeout        = 10,
8701                         .positive       = True,
8702                         .num_ips        = ctx->addresses_all_num,
8703                         .ips            = ctx->addresses_all,
8704                 },
8705                 .replica= {
8706                         .type           = WREPL_TYPE_UNIQUE,
8707                         .state          = WREPL_STATE_ACTIVE,
8708                         .node           = WREPL_NODE_B,
8709                         .is_static      = False,
8710                         .num_ips        = ctx->addresses_best2_num,
8711                         .ips            = ctx->addresses_best2,
8712                         .mhomed_merge   = True,
8713                 },
8714         },
8715         /*
8716          * unique,active vs. mhomed,active with different ip(s), positive response, with all addresses
8717          */
8718         {
8719                 .line   = __location__,
8720                 .name   = _NBT_NAME("_UA_MA_DI_A", 0x00, NULL),
8721                 .skip   = (ctx->addresses_all_num < 3),
8722                 .wins   = {
8723                         .nb_flags       = 0,
8724                         .mhomed         = False,
8725                         .num_ips        = ctx->addresses_best_num,
8726                         .ips            = ctx->addresses_best,
8727                         .apply_expected = True
8728                 },
8729                 .defend = {
8730                         .timeout        = 10,
8731                         .positive       = True,
8732                         .num_ips        = ctx->addresses_all_num,
8733                         .ips            = ctx->addresses_all,
8734                 },
8735                 .replica= {
8736                         .type           = WREPL_TYPE_MHOMED,
8737                         .state          = WREPL_STATE_ACTIVE,
8738                         .node           = WREPL_NODE_B,
8739                         .is_static      = False,
8740                         .num_ips        = ctx->addresses_best2_num,
8741                         .ips            = ctx->addresses_best2,
8742                         .mhomed_merge   = True,
8743                 },
8744         },
8745 /*
8746  * special group vs. special group merging section
8747  */
8748         /*
8749          * sgroup,active vs. sgroup,active with different ip(s)
8750          */
8751         {
8752                 .line   = __location__,
8753                 .section= "Test Replica vs. owned active: SGROUP vs. SGROUP tests",
8754                 .name   = _NBT_NAME("_SA_SA_DI_U", 0x1C, NULL),
8755                 .skip   = (ctx->addresses_all_num < 3),
8756                 .wins   = {
8757                         .nb_flags       = NBT_NM_GROUP,
8758                         .mhomed         = False,
8759                         .num_ips        = ctx->addresses_mhomed_num,
8760                         .ips            = ctx->addresses_mhomed,
8761                         .apply_expected = True
8762                 },
8763                 .defend = {
8764                         .timeout        = 0,
8765                 },
8766                 .replica= {
8767                         .type           = WREPL_TYPE_SGROUP,
8768                         .state          = WREPL_STATE_ACTIVE,
8769                         .node           = WREPL_NODE_B,
8770                         .is_static      = False,
8771                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8772                         .ips            = addresses_B_3_4,
8773                         .sgroup_merge   = True
8774                 },
8775         },
8776         /*
8777          * sgroup,active vs. sgroup,active with same ip(s)
8778          */
8779         {
8780                 .line   = __location__,
8781                 .name   = _NBT_NAME("_SA_SA_SI_U", 0x1C, NULL),
8782                 .skip   = (ctx->addresses_all_num < 3),
8783                 .wins   = {
8784                         .nb_flags       = NBT_NM_GROUP,
8785                         .mhomed         = False,
8786                         .num_ips        = ctx->addresses_mhomed_num,
8787                         .ips            = ctx->addresses_mhomed,
8788                         .apply_expected = True
8789                 },
8790                 .defend = {
8791                         .timeout        = 0,
8792                 },
8793                 .replica= {
8794                         .type           = WREPL_TYPE_SGROUP,
8795                         .state          = WREPL_STATE_ACTIVE,
8796                         .node           = WREPL_NODE_B,
8797                         .is_static      = False,
8798                         .num_ips        = ctx->addresses_mhomed_num,
8799                         .ips            = ctx->addresses_mhomed,
8800                         .sgroup_merge   = True
8801                 },
8802         },
8803         /*
8804          * sgroup,active vs. sgroup,active with superset ip(s)
8805          */
8806         {
8807                 .line   = __location__,
8808                 .name   = _NBT_NAME("_SA_SA_SP_U", 0x1C, NULL),
8809                 .skip   = (ctx->addresses_all_num < 3),
8810                 .wins   = {
8811                         .nb_flags       = NBT_NM_GROUP,
8812                         .mhomed         = False,
8813                         .num_ips        = ctx->addresses_mhomed_num,
8814                         .ips            = ctx->addresses_mhomed,
8815                         .apply_expected = True
8816                 },
8817                 .defend = {
8818                         .timeout        = 0,
8819                 },
8820                 .replica= {
8821                         .type           = WREPL_TYPE_SGROUP,
8822                         .state          = WREPL_STATE_ACTIVE,
8823                         .node           = WREPL_NODE_B,
8824                         .is_static      = False,
8825                         .num_ips        = ctx->addresses_all_num,
8826                         .ips            = ctx->addresses_all,
8827                         .sgroup_merge   = True
8828                 },
8829         },
8830         /*
8831          * sgroup,active vs. sgroup,active with subset ip(s)
8832          */
8833         {
8834                 .line   = __location__,
8835                 .name   = _NBT_NAME("_SA_SA_SB_U", 0x1C, NULL),
8836                 .skip   = (ctx->addresses_all_num < 3),
8837                 .wins   = {
8838                         .nb_flags       = NBT_NM_GROUP,
8839                         .mhomed         = False,
8840                         .num_ips        = ctx->addresses_mhomed_num,
8841                         .ips            = ctx->addresses_mhomed,
8842                         .apply_expected = True
8843                 },
8844                 .defend = {
8845                         .timeout        = 0,
8846                 },
8847                 .replica= {
8848                         .type           = WREPL_TYPE_SGROUP,
8849                         .state          = WREPL_STATE_ACTIVE,
8850                         .node           = WREPL_NODE_B,
8851                         .is_static      = False,
8852                         .num_ips        = ctx->addresses_best_num,
8853                         .ips            = ctx->addresses_best,
8854                         .sgroup_merge   = True
8855                 },
8856         },
8857         /*
8858          * sgroup,active vs. sgroup,tombstone with different ip(s)
8859          */
8860         {
8861                 .line   = __location__,
8862                 .name   = _NBT_NAME("_SA_ST_DI_U", 0x1C, NULL),
8863                 .skip   = (ctx->addresses_all_num < 3),
8864                 .wins   = {
8865                         .nb_flags       = NBT_NM_GROUP,
8866                         .mhomed         = False,
8867                         .num_ips        = ctx->addresses_mhomed_num,
8868                         .ips            = ctx->addresses_mhomed,
8869                         .apply_expected = True
8870                 },
8871                 .defend = {
8872                         .timeout        = 0,
8873                 },
8874                 .replica= {
8875                         .type           = WREPL_TYPE_SGROUP,
8876                         .state          = WREPL_STATE_TOMBSTONE,
8877                         .node           = WREPL_NODE_B,
8878                         .is_static      = False,
8879                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8880                         .ips            = addresses_B_3_4,
8881                         .apply_expected = False
8882                 },
8883         },
8884         /*
8885          * sgroup,active vs. sgroup,tombstone with same ip(s)
8886          */
8887         {
8888                 .line   = __location__,
8889                 .name   = _NBT_NAME("_SA_ST_SI_U", 0x1C, NULL),
8890                 .skip   = (ctx->addresses_all_num < 3),
8891                 .wins   = {
8892                         .nb_flags       = NBT_NM_GROUP,
8893                         .mhomed         = False,
8894                         .num_ips        = ctx->addresses_mhomed_num,
8895                         .ips            = ctx->addresses_mhomed,
8896                         .apply_expected = True
8897                 },
8898                 .defend = {
8899                         .timeout        = 0,
8900                 },
8901                 .replica= {
8902                         .type           = WREPL_TYPE_SGROUP,
8903                         .state          = WREPL_STATE_TOMBSTONE,
8904                         .node           = WREPL_NODE_B,
8905                         .is_static      = False,
8906                         .num_ips        = ctx->addresses_mhomed_num,
8907                         .ips            = ctx->addresses_mhomed,
8908                         .apply_expected = False
8909                 },
8910         },
8911         /*
8912          * sgroup,active vs. sgroup,tombstone with superset ip(s)
8913          */
8914         {
8915                 .line   = __location__,
8916                 .name   = _NBT_NAME("_SA_ST_SP_U", 0x1C, NULL),
8917                 .skip   = (ctx->addresses_all_num < 3),
8918                 .wins   = {
8919                         .nb_flags       = NBT_NM_GROUP,
8920                         .mhomed         = False,
8921                         .num_ips        = ctx->addresses_mhomed_num,
8922                         .ips            = ctx->addresses_mhomed,
8923                         .apply_expected = True
8924                 },
8925                 .defend = {
8926                         .timeout        = 0,
8927                 },
8928                 .replica= {
8929                         .type           = WREPL_TYPE_SGROUP,
8930                         .state          = WREPL_STATE_TOMBSTONE,
8931                         .node           = WREPL_NODE_B,
8932                         .is_static      = False,
8933                         .num_ips        = ctx->addresses_all_num,
8934                         .ips            = ctx->addresses_all,
8935                         .apply_expected = False
8936                 },
8937         },
8938         /*
8939          * sgroup,active vs. sgroup,tombstone with subset ip(s)
8940          */
8941         {
8942                 .line   = __location__,
8943                 .name   = _NBT_NAME("_SA_ST_SB_U", 0x1C, NULL),
8944                 .skip   = (ctx->addresses_all_num < 3),
8945                 .wins   = {
8946                         .nb_flags       = NBT_NM_GROUP,
8947                         .mhomed         = False,
8948                         .num_ips        = ctx->addresses_mhomed_num,
8949                         .ips            = ctx->addresses_mhomed,
8950                         .apply_expected = True
8951                 },
8952                 .defend = {
8953                         .timeout        = 0,
8954                 },
8955                 .replica= {
8956                         .type           = WREPL_TYPE_SGROUP,
8957                         .state          = WREPL_STATE_TOMBSTONE,
8958                         .node           = WREPL_NODE_B,
8959                         .is_static      = False,
8960                         .num_ips        = ctx->addresses_best_num,
8961                         .ips            = ctx->addresses_best,
8962                         .apply_expected = False
8963                 },
8964         },
8965         };
8966
8967         if (!ctx) return False;
8968
8969         if (!ctx->nbtsock_srv) {
8970                 printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
8971                         lp_nbt_port());
8972                 return True;
8973         }
8974
8975         printf("Test Replica records vs. owned active records\n");
8976
8977         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
8978                 struct timeval end;
8979                 struct test_conflict_owned_active_vs_replica_struct record = records[i];
8980                 uint32_t j, count = 1;
8981                 const char *action;
8982
8983                 if (records[i].wins.mhomed || records[i].name.type == 0x1C) {
8984                         count = records[i].wins.num_ips;
8985                 }
8986
8987                 if (records[i].section) {
8988                         printf("%s\n", records[i].section);
8989                 }
8990
8991                 if (records[i].skip) {
8992                         printf("%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name));
8993                         continue;
8994                 }
8995
8996                 if (records[i].replica.mhomed_merge) {
8997                         action = "MHOMED_MERGE";
8998                 } else if (records[i].replica.sgroup_merge) {
8999                         action = "SGROUP_MERGE";
9000                 } else if (records[i].replica.apply_expected) {
9001                         action = "REPLACE";
9002                 } else {
9003                         action = "NOT REPLACE";
9004                 }
9005
9006                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name), action);
9007
9008                 /* Prepare for multi homed registration */
9009                 ZERO_STRUCT(records[i].defend);
9010                 records[i].defend.timeout       = 10;
9011                 records[i].defend.positive      = True;
9012                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9013                                          test_conflict_owned_active_vs_replica_handler,
9014                                          &records[i]);
9015                 if (ctx->nbtsock_srv2) {
9016                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9017                                                  test_conflict_owned_active_vs_replica_handler,
9018                                                  &records[i]);
9019                 }
9020
9021                 /*
9022                  * Setup Register
9023                  */
9024                 for (j=0; j < count; j++) {
9025                         struct nbt_name_request *req;
9026
9027                         name_register->in.name          = records[i].name;
9028                         name_register->in.dest_addr     = ctx->address;
9029                         name_register->in.address       = records[i].wins.ips[j].ip;
9030                         name_register->in.nb_flags      = records[i].wins.nb_flags;
9031                         name_register->in.register_demand= False;
9032                         name_register->in.broadcast     = False;
9033                         name_register->in.multi_homed   = records[i].wins.mhomed;
9034                         name_register->in.ttl           = 300000;
9035                         name_register->in.timeout       = 70;
9036                         name_register->in.retries       = 0;
9037
9038                         req = nbt_name_register_send(ctx->nbtsock, name_register);
9039
9040                         /* push the request on the wire */
9041                         event_loop_once(ctx->nbtsock->event_ctx);
9042
9043                         /*
9044                          * if we register multiple addresses,
9045                          * the server will do name queries to see if the old addresses
9046                          * are still alive
9047                          */
9048                         if (records[i].wins.mhomed && j > 0) {
9049                                 end = timeval_current_ofs(records[i].defend.timeout,0);
9050                                 records[i].defend.ret = True;
9051                                 while (records[i].defend.timeout > 0) {
9052                                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9053                                         if (timeval_expired(&end)) break;
9054                                 }
9055                                 ret &= records[i].defend.ret;
9056                         }
9057
9058                         status = nbt_name_register_recv(req, ctx, name_register);
9059                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9060                                 printf("No response from %s for name register\n", ctx->address);
9061                                 ret = False;
9062                         }
9063                         if (!NT_STATUS_IS_OK(status)) {
9064                                 printf("Bad response from %s for name register - %s\n",
9065                                        ctx->address, nt_errstr(status));
9066                                 ret = False;
9067                         }
9068                         CHECK_VALUE(name_register->out.rcode, 0);
9069                         CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
9070                         CHECK_VALUE(name_register->out.name.type, records[i].name.type);
9071                         CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
9072                         CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
9073                         CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[j].ip);
9074                 }
9075
9076                 /* Prepare for the current test */
9077                 records[i].defend = record.defend;
9078                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9079                                          test_conflict_owned_active_vs_replica_handler,
9080                                          &records[i]);
9081                 if (ctx->nbtsock_srv2) {
9082                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9083                                                  test_conflict_owned_active_vs_replica_handler,
9084                                                  &records[i]);
9085                 }
9086
9087                 /*
9088                  * Setup Replica
9089                  */
9090                 wins_name->name         = &records[i].name;
9091                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
9092                                                            records[i].replica.state,
9093                                                            records[i].replica.node,
9094                                                            records[i].replica.is_static);
9095                 wins_name->id           = ++ctx->b.max_version;
9096                 if (wins_name->flags & 2) {
9097                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
9098                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
9099                 } else {
9100                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
9101                 }
9102                 wins_name->unknown      = "255.255.255.255";
9103
9104                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9105
9106                 /*
9107                  * wait for the name query, which is handled in
9108                  * test_conflict_owned_active_vs_replica_handler()
9109                  */
9110                 end = timeval_current_ofs(records[i].defend.timeout,0);
9111                 records[i].defend.ret = True;
9112                 while (records[i].defend.timeout > 0) {
9113                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9114                         if (timeval_expired(&end)) break;
9115                 }
9116                 ret &= records[i].defend.ret;
9117
9118                 if (records[i].defend.late_release) {
9119                         records[i].defend = record.defend;
9120                         records[i].defend.expect_release = True;
9121                         /*
9122                          * wait for the name release demand, which is handled in
9123                          * test_conflict_owned_active_vs_replica_handler()
9124                          */
9125                         end = timeval_current_ofs(records[i].defend.timeout,0);
9126                         records[i].defend.ret = True;
9127                         while (records[i].defend.timeout > 0) {
9128                                 event_loop_once(ctx->nbtsock_srv->event_ctx);
9129                                 if (timeval_expired(&end)) break;
9130                         }
9131                         ret &= records[i].defend.ret;
9132                 }
9133
9134                 if (records[i].replica.mhomed_merge) {
9135                         ret &= test_wrepl_mhomed_merged(ctx, &ctx->c,
9136                                                         records[i].wins.num_ips, records[i].wins.ips,
9137                                                         &ctx->b,
9138                                                         records[i].replica.num_ips, records[i].replica.ips,
9139                                                         wins_name);
9140                 } else if (records[i].replica.sgroup_merge) {
9141                         ret &= test_wrepl_sgroup_merged(ctx, NULL,
9142                                                         &ctx->c,
9143                                                         records[i].wins.num_ips, records[i].wins.ips,
9144                                                         &ctx->b,
9145                                                         records[i].replica.num_ips, records[i].replica.ips,
9146                                                         wins_name);
9147                 } else {
9148                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
9149                                                      records[i].replica.apply_expected);
9150                 }
9151
9152                 if (records[i].replica.apply_expected ||
9153                     records[i].replica.mhomed_merge) {
9154                         wins_name->name         = &records[i].name;
9155                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9156                                                                    WREPL_STATE_TOMBSTONE,
9157                                                                    WREPL_NODE_B, False);
9158                         wins_name->id           = ++ctx->b.max_version;
9159                         wins_name->addresses.ip = addresses_B_1[0].ip;
9160                         wins_name->unknown      = "255.255.255.255";
9161
9162                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9163                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9164                 } else {
9165                         for (j=0; j < count; j++) {
9166                                 struct nbt_name_socket *nbtsock = ctx->nbtsock;
9167
9168                                 if (ctx->myaddr2 && strcmp(records[i].wins.ips[j].ip, ctx->myaddr2) == 0) {
9169                                         nbtsock = ctx->nbtsock2;
9170                                 }
9171
9172                                 release->in.name        = records[i].name;
9173                                 release->in.dest_addr   = ctx->address;
9174                                 release->in.address     = records[i].wins.ips[j].ip;
9175                                 release->in.nb_flags    = records[i].wins.nb_flags;
9176                                 release->in.broadcast   = False;
9177                                 release->in.timeout     = 30;
9178                                 release->in.retries     = 0;
9179
9180                                 status = nbt_name_release(nbtsock, ctx, release);
9181                                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9182                                         printf("No response from %s for name release\n", ctx->address);
9183                                         return False;
9184                                 }
9185                                 if (!NT_STATUS_IS_OK(status)) {
9186                                         printf("Bad response from %s for name query - %s\n",
9187                                                ctx->address, nt_errstr(status));
9188                                         return False;
9189                                 }
9190                                 CHECK_VALUE(release->out.rcode, 0);
9191                         }
9192
9193                         if (records[i].replica.sgroup_merge) {
9194                                 /* clean up the SGROUP record */
9195                                 wins_name->name         = &records[i].name;
9196                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9197                                                                            WREPL_STATE_ACTIVE,
9198                                                                            WREPL_NODE_B, False);
9199                                 wins_name->id           = ++ctx->b.max_version;
9200                                 wins_name->addresses.addresses.num_ips = 0;
9201                                 wins_name->addresses.addresses.ips     = NULL;
9202                                 wins_name->unknown      = "255.255.255.255";
9203                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9204
9205                                 /* take ownership of the SGROUP record */
9206                                 wins_name->name         = &records[i].name;
9207                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9208                                                                            WREPL_STATE_ACTIVE,
9209                                                                            WREPL_NODE_B, False);
9210                                 wins_name->id           = ++ctx->b.max_version;
9211                                 wins_name->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
9212                                 wins_name->addresses.addresses.ips     = discard_const(addresses_B_1);
9213                                 wins_name->unknown      = "255.255.255.255";
9214                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9215                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9216
9217                                 /* overwrite the SGROUP record with unique,tombstone */
9218                                 wins_name->name         = &records[i].name;
9219                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9220                                                                            WREPL_STATE_TOMBSTONE,
9221                                                                            WREPL_NODE_B, False);
9222                                 wins_name->id           = ++ctx->b.max_version;
9223                                 wins_name->addresses.ip = addresses_A_1[0].ip;
9224                                 wins_name->unknown      = "255.255.255.255";
9225                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9226                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9227                         }
9228                 }
9229
9230 done:
9231                 if (!ret) {
9232                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
9233                         return ret;
9234                 }
9235         }
9236
9237         return ret;
9238 }
9239
9240 #define _NBT_ASSERT(v, correct) do { \
9241         if ((v) != (correct)) { \
9242                 printf("(%s) Incorrect value %s=%d - should be %s (%d)\n", \
9243                        __location__, #v, v, #correct, correct); \
9244                 return; \
9245         } \
9246 } while (0)
9247
9248 #define _NBT_ASSERT_STRING(v, correct) do { \
9249         if ( ((!v) && (correct)) || \
9250              ((v) && (!correct)) || \
9251              ((v) && (correct) && strcmp(v,correct) != 0)) { \
9252                 printf("(%s) Incorrect value %s=%s - should be %s\n", \
9253                        __location__, #v, v, correct); \
9254                 return; \
9255         } \
9256 } while (0)
9257
9258 static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_socket *nbtsock, 
9259                                                                 struct nbt_name_packet *req_packet, 
9260                                                                 const struct nbt_peer_socket *src)
9261 {
9262         struct nbt_name *name;
9263         struct nbt_name_packet *rep_packet;
9264         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9265
9266         _NBT_ASSERT(req_packet->qdcount, 1);
9267         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9268         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9269
9270         name = &req_packet->questions[0].name;
9271
9272         _NBT_ASSERT(name->type, rec->name.type);
9273         _NBT_ASSERT_STRING(name->name, rec->name.name);
9274         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9275
9276         _NBT_ASSERT(rec->defend.expect_release, False);
9277
9278         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9279         if (rep_packet == NULL) return;
9280
9281         rep_packet->name_trn_id = req_packet->name_trn_id;
9282         rep_packet->ancount     = 1;
9283
9284         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9285         if (rep_packet->answers == NULL) return;
9286
9287         rep_packet->answers[0].name      = *name;
9288         rep_packet->answers[0].rr_class  = NBT_QCLASS_IP;
9289         rep_packet->answers[0].ttl       = 0;
9290
9291         if (rec->defend.positive) {
9292                 uint32_t i, num_ips;
9293                 const struct wrepl_ip *ips;             
9294
9295                 if (rec->defend.num_ips > 0) {
9296                         num_ips = rec->defend.num_ips;
9297                         ips     = rec->defend.ips;
9298                 } else {
9299                         num_ips = rec->wins.num_ips;
9300                         ips     = rec->wins.ips;
9301                 }
9302
9303                 /* send a positive reply */
9304                 rep_packet->operation   = 
9305                                         NBT_FLAG_REPLY | 
9306                                         NBT_OPCODE_QUERY | 
9307                                         NBT_FLAG_AUTHORITIVE |
9308                                         NBT_FLAG_RECURSION_DESIRED |
9309                                         NBT_FLAG_RECURSION_AVAIL;
9310
9311                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NETBIOS;
9312
9313                 rep_packet->answers[0].rdata.netbios.length = num_ips*6;
9314                 rep_packet->answers[0].rdata.netbios.addresses = 
9315                         talloc_array(rep_packet->answers, struct nbt_rdata_address, num_ips);
9316                 if (rep_packet->answers[0].rdata.netbios.addresses == NULL) return;
9317
9318                 for (i=0; i < num_ips; i++) {
9319                         struct nbt_rdata_address *addr = 
9320                                 &rep_packet->answers[0].rdata.netbios.addresses[i];
9321                         addr->nb_flags  = rec->wins.nb_flags;
9322                         addr->ipaddr    = ips[i].ip;
9323                 }
9324                 DEBUG(2,("Sending positive name query reply for %s to %s:%d\n", 
9325                         nbt_name_string(rep_packet, name), src->addr, src->port));
9326         } else {
9327                 /* send a negative reply */
9328                 rep_packet->operation   =
9329                                         NBT_FLAG_REPLY | 
9330                                         NBT_OPCODE_QUERY | 
9331                                         NBT_FLAG_AUTHORITIVE |
9332                                         NBT_RCODE_NAM;
9333
9334                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NULL;
9335
9336                 ZERO_STRUCT(rep_packet->answers[0].rdata);
9337
9338                 DEBUG(2,("Sending negative name query reply for %s to %s:%d\n", 
9339                         nbt_name_string(rep_packet, name), src->addr, src->port));
9340         }
9341
9342         nbt_name_reply_send(nbtsock, src, rep_packet);
9343         talloc_free(rep_packet);
9344
9345         /* make sure we push the reply to the wire */
9346         event_loop_once(nbtsock->event_ctx);
9347
9348         rec->defend.timeout     = 0;
9349         rec->defend.ret         = True;
9350 }
9351
9352 static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_name_socket *nbtsock, 
9353                                                                   struct nbt_name_packet *req_packet, 
9354                                                                   const struct nbt_peer_socket *src)
9355 {
9356         struct nbt_name *name;
9357         struct nbt_name_packet *rep_packet;
9358         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9359
9360         _NBT_ASSERT(req_packet->qdcount, 1);
9361         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9362         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9363
9364         name = &req_packet->questions[0].name;
9365
9366         _NBT_ASSERT(name->type, rec->name.type);
9367         _NBT_ASSERT_STRING(name->name, rec->name.name);
9368         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9369
9370         _NBT_ASSERT(rec->defend.expect_release, True);
9371
9372         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9373         if (rep_packet == NULL) return;
9374
9375         rep_packet->name_trn_id = req_packet->name_trn_id;
9376         rep_packet->ancount     = 1;
9377         rep_packet->operation   = 
9378                                 NBT_FLAG_REPLY | 
9379                                 NBT_OPCODE_RELEASE |
9380                                 NBT_FLAG_AUTHORITIVE;
9381
9382         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9383         if (rep_packet->answers == NULL) return;
9384
9385         rep_packet->answers[0].name     = *name;
9386         rep_packet->answers[0].rr_type  = NBT_QTYPE_NETBIOS;
9387         rep_packet->answers[0].rr_class = NBT_QCLASS_IP;
9388         rep_packet->answers[0].ttl      = req_packet->additional[0].ttl;
9389         rep_packet->answers[0].rdata    = req_packet->additional[0].rdata;
9390
9391         DEBUG(2,("Sending name release reply for %s to %s:%d\n", 
9392                 nbt_name_string(rep_packet, name), src->addr, src->port));
9393
9394         nbt_name_reply_send(nbtsock, src, rep_packet);
9395         talloc_free(rep_packet);
9396
9397         /* make sure we push the reply to the wire */
9398         event_loop_once(nbtsock->event_ctx);
9399
9400         rec->defend.timeout     = 0;
9401         rec->defend.ret         = True;
9402 }
9403
9404 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
9405                                                           struct nbt_name_packet *req_packet, 
9406                                                           const struct nbt_peer_socket *src)
9407 {
9408         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9409
9410         rec->defend.ret = False;
9411
9412         switch (req_packet->operation & NBT_OPCODE) {
9413         case NBT_OPCODE_QUERY:
9414                 test_conflict_owned_active_vs_replica_handler_query(nbtsock, req_packet, src);
9415                 break;
9416         case NBT_OPCODE_RELEASE:
9417                 test_conflict_owned_active_vs_replica_handler_release(nbtsock, req_packet, src);
9418                 break;
9419         default:
9420                 printf("%s: unexpected incoming packet\n", __location__);
9421                 return;
9422         }
9423 }
9424
9425 /*
9426   test WINS replication operations
9427 */
9428 BOOL torture_nbt_winsreplication_quick(void)
9429 {
9430         const char *address;
9431         struct nbt_name name;
9432         TALLOC_CTX *mem_ctx = talloc_new(NULL);
9433         NTSTATUS status;
9434         BOOL ret = True;
9435         struct test_wrepl_conflict_conn *ctx;
9436
9437         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
9438
9439         /* do an initial name resolution to find its IP */
9440         status = resolve_name(&name, mem_ctx, &address, NULL);
9441         if (!NT_STATUS_IS_OK(status)) {
9442                 printf("Failed to resolve %s - %s\n",
9443                        name.name, nt_errstr(status));
9444                 talloc_free(mem_ctx);
9445                 return False;
9446         }
9447
9448         ret &= test_assoc_ctx1(mem_ctx, address);
9449         ret &= test_assoc_ctx2(mem_ctx, address);
9450
9451         ret &= test_wins_replication(mem_ctx, address);
9452
9453         ctx = test_create_conflict_ctx(mem_ctx, address);
9454
9455         ret &= test_conflict_same_owner(ctx);
9456
9457         talloc_free(mem_ctx);
9458
9459         return ret;
9460 }
9461
9462 /*
9463   test WINS replication operations
9464 */
9465 BOOL torture_nbt_winsreplication(void)
9466 {
9467         const char *address;
9468         struct nbt_name name;
9469         TALLOC_CTX *mem_ctx = talloc_new(NULL);
9470         NTSTATUS status;
9471         BOOL ret = True;
9472         struct test_wrepl_conflict_conn *ctx;
9473
9474         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
9475
9476         /* do an initial name resolution to find its IP */
9477         status = resolve_name(&name, mem_ctx, &address, NULL);
9478         if (!NT_STATUS_IS_OK(status)) {
9479                 printf("Failed to resolve %s - %s\n",
9480                        name.name, nt_errstr(status));
9481                 talloc_free(mem_ctx);
9482                 return False;
9483         }
9484
9485         ret &= test_assoc_ctx1(mem_ctx, address);
9486         ret &= test_assoc_ctx2(mem_ctx, address);
9487
9488         ret &= test_wins_replication(mem_ctx, address);
9489
9490         ctx = test_create_conflict_ctx(mem_ctx, address);
9491
9492         ret &= test_conflict_same_owner(ctx);
9493         ret &= test_conflict_different_owner(ctx);
9494         ret &= test_conflict_owned_released_vs_replica(ctx);
9495         ret &= test_conflict_owned_active_vs_replica(ctx);
9496
9497         talloc_free(mem_ctx);
9498
9499         return ret;
9500 }