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