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