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