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