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