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