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