2 Unix SMB/CIFS implementation.
4 low level WINS replication client code
6 Copyright (C) Andrew Tridgell 2005
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.
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.
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.
24 #include "lib/events/events.h"
25 #include "dlinklist.h"
26 #include "lib/socket/socket.h"
27 #include "libcli/wrepl/winsrepl.h"
28 #include "lib/stream/packet.h"
29 #include "libcli/composite/composite.h"
31 static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status);
34 mark all pending requests as dead - called when a socket error happens
36 static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status)
38 wrepl_socket->dead = True;
40 if (wrepl_socket->packet) {
41 packet_recv_disable(wrepl_socket->packet);
42 packet_set_fde(wrepl_socket->packet, NULL);
43 packet_set_socket(wrepl_socket->packet, NULL);
46 if (wrepl_socket->event.fde) {
47 talloc_free(wrepl_socket->event.fde);
48 wrepl_socket->event.fde = NULL;
51 if (wrepl_socket->sock) {
52 talloc_free(wrepl_socket->sock);
53 wrepl_socket->sock = NULL;
56 if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) {
57 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
59 while (wrepl_socket->recv_queue) {
60 struct wrepl_request *req = wrepl_socket->recv_queue;
61 DLIST_REMOVE(wrepl_socket->recv_queue, req);
62 wrepl_request_finished(req, status);
65 talloc_set_destructor(wrepl_socket, NULL);
66 if (wrepl_socket->free_skipped) {
67 talloc_free(wrepl_socket);
71 static void wrepl_request_timeout_handler(struct event_context *ev, struct timed_event *te,
72 struct timeval t, void *ptr)
74 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
75 wrepl_socket_dead(req->wrepl_socket, NT_STATUS_IO_TIMEOUT);
81 static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in)
83 struct wrepl_socket *wrepl_socket = talloc_get_type(private, struct wrepl_socket);
84 struct wrepl_request *req = wrepl_socket->recv_queue;
87 req->packet = talloc(req, struct wrepl_packet);
88 NT_STATUS_HAVE_NO_MEMORY(req->packet);
90 blob.data = packet_blob_in.data + 4;
91 blob.length = packet_blob_in.length - 4;
93 /* we have a full request - parse it */
94 req->status = ndr_pull_struct_blob(&blob,
95 req->packet, req->packet,
96 (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
97 if (!NT_STATUS_IS_OK(req->status)) {
98 wrepl_request_finished(req, req->status);
103 DEBUG(10,("Received WINS packet of length %u\n", packet_blob_in.length));
104 NDR_PRINT_DEBUG(wrepl_packet, req->packet);
107 wrepl_request_finished(req, req->status);
112 handler for winrepl events
114 static void wrepl_handler(struct event_context *ev, struct fd_event *fde,
115 uint16_t flags, void *private)
117 struct wrepl_socket *wrepl_socket = talloc_get_type(private,
118 struct wrepl_socket);
119 if (flags & EVENT_FD_READ) {
120 packet_recv(wrepl_socket->packet);
123 if (flags & EVENT_FD_WRITE) {
124 packet_queue_run(wrepl_socket->packet);
128 static void wrepl_error(void *private, NTSTATUS status)
130 struct wrepl_socket *wrepl_socket = talloc_get_type(private,
131 struct wrepl_socket);
132 wrepl_socket_dead(wrepl_socket, status);
137 destroy a wrepl_socket destructor
139 static int wrepl_socket_destructor(void *ptr)
141 struct wrepl_socket *sock = talloc_get_type(ptr, struct wrepl_socket);
143 sock->free_skipped = True;
146 wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT);
151 initialise a wrepl_socket. The event_ctx is optional, if provided then
152 operations will use that event context
154 struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
155 struct event_context *event_ctx)
157 struct wrepl_socket *wrepl_socket;
160 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
161 if (!wrepl_socket) return NULL;
163 if (event_ctx == NULL) {
164 wrepl_socket->event.ctx = event_context_init(wrepl_socket);
166 wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
168 if (!wrepl_socket->event.ctx) goto failed;
170 status = socket_create("ip", SOCKET_TYPE_STREAM, &wrepl_socket->sock, 0);
171 if (!NT_STATUS_IS_OK(status)) goto failed;
173 talloc_steal(wrepl_socket, wrepl_socket->sock);
175 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT;
177 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
182 talloc_free(wrepl_socket);
187 initialise a wrepl_socket from an already existing connection
189 struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx,
190 struct event_context *event_ctx,
191 struct socket_context *socket,
192 struct packet_context *packet)
194 struct wrepl_socket *wrepl_socket;
196 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
197 if (wrepl_socket == NULL) goto failed;
199 wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
200 if (wrepl_socket->event.ctx == NULL) goto failed;
202 wrepl_socket->sock = socket;
203 talloc_steal(wrepl_socket, wrepl_socket->sock);
206 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT;
208 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket,
209 socket_get_fd(wrepl_socket->sock),
211 wrepl_handler, wrepl_socket);
212 if (wrepl_socket->event.fde == NULL) {
216 wrepl_socket->packet = packet;
217 talloc_steal(wrepl_socket, wrepl_socket->packet);
218 packet_set_private(wrepl_socket->packet, wrepl_socket);
219 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock);
220 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv);
221 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32);
222 packet_set_error_handler(wrepl_socket->packet, wrepl_error);
223 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx);
224 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde);
225 packet_set_serialise(wrepl_socket->packet);
227 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
232 talloc_free(wrepl_socket);
237 destroy a wrepl_request
239 static int wrepl_request_destructor(void *ptr)
241 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
242 if (req->state == WREPL_REQUEST_RECV) {
243 DLIST_REMOVE(req->wrepl_socket->recv_queue, req);
245 req->state = WREPL_REQUEST_ERROR;
250 wait for a request to complete
252 static NTSTATUS wrepl_request_wait(struct wrepl_request *req)
254 NT_STATUS_HAVE_NO_MEMORY(req);
255 while (req->state < WREPL_REQUEST_DONE) {
256 event_loop_once(req->wrepl_socket->event.ctx);
261 struct wrepl_connect_state {
262 struct composite_context *result;
263 struct wrepl_socket *wrepl_socket;
264 struct composite_context *creq;
268 handler for winrepl connection completion
270 static void wrepl_connect_handler(struct composite_context *creq)
272 struct wrepl_connect_state *state = talloc_get_type(creq->async.private_data,
273 struct wrepl_connect_state);
274 struct wrepl_socket *wrepl_socket = state->wrepl_socket;
275 struct composite_context *result = state->result;
277 result->status = socket_connect_recv(state->creq);
278 if (!composite_is_ok(result)) return;
280 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket,
281 socket_get_fd(wrepl_socket->sock),
283 wrepl_handler, wrepl_socket);
284 if (composite_nomem(wrepl_socket->event.fde, result)) return;
286 /* setup the stream -> packet parser */
287 wrepl_socket->packet = packet_init(wrepl_socket);
288 if (composite_nomem(wrepl_socket->packet, result)) return;
289 packet_set_private(wrepl_socket->packet, wrepl_socket);
290 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock);
291 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv);
292 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32);
293 packet_set_error_handler(wrepl_socket->packet, wrepl_error);
294 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx);
295 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde);
296 packet_set_serialise(wrepl_socket->packet);
298 composite_done(result);
302 connect a wrepl_socket to a WINS server
304 struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket,
305 const char *our_ip, const char *peer_ip)
307 struct composite_context *result;
308 struct wrepl_connect_state *state;
310 result = talloc_zero(wrepl_socket, struct composite_context);
311 if (!result) return NULL;
313 result->state = COMPOSITE_STATE_IN_PROGRESS;
314 result->event_ctx = wrepl_socket->event.ctx;
316 state = talloc_zero(result, struct wrepl_connect_state);
317 if (composite_nomem(state, result)) return result;
318 result->private_data = state;
319 state->result = result;
320 state->wrepl_socket = wrepl_socket;
323 our_ip = iface_best_ip(peer_ip);
326 state->creq = socket_connect_send(wrepl_socket->sock, our_ip, 0,
327 peer_ip, WINS_REPLICATION_PORT,
328 0, wrepl_socket->event.ctx);
329 composite_continue(result, state->creq, wrepl_connect_handler, state);
334 connect a wrepl_socket to a WINS server - recv side
336 NTSTATUS wrepl_connect_recv(struct composite_context *result)
338 struct wrepl_connect_state *state = talloc_get_type(result->private_data,
339 struct wrepl_connect_state);
340 struct wrepl_socket *wrepl_socket = state->wrepl_socket;
341 NTSTATUS status = composite_wait(result);
343 if (!NT_STATUS_IS_OK(status)) {
344 wrepl_socket_dead(wrepl_socket, status);
352 connect a wrepl_socket to a WINS server - sync API
354 NTSTATUS wrepl_connect(struct wrepl_socket *wrepl_socket, const char *our_ip, const char *peer_ip)
356 struct composite_context *c_req = wrepl_connect_send(wrepl_socket, our_ip, peer_ip);
357 return wrepl_connect_recv(c_req);
361 callback from wrepl_request_trigger()
363 static void wrepl_request_trigger_handler(struct event_context *ev, struct timed_event *te,
364 struct timeval t, void *ptr)
366 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
373 trigger an immediate event on a wrepl_request
374 the return value should only be used in wrepl_request_send()
375 this is the only place where req->trigger is True
377 static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status)
379 struct timed_event *te;
381 if (req->state == WREPL_REQUEST_RECV) {
382 DLIST_REMOVE(req->wrepl_socket->recv_queue, req);
385 if (!NT_STATUS_IS_OK(status)) {
386 req->state = WREPL_REQUEST_ERROR;
388 req->state = WREPL_REQUEST_DONE;
391 req->status = status;
394 req->trigger = False;
395 /* a zero timeout means immediate */
396 te = event_add_timed(req->wrepl_socket->event.ctx,
398 wrepl_request_trigger_handler, req);
412 struct wrepl_send_ctrl_state {
413 struct wrepl_send_ctrl ctrl;
414 struct wrepl_request *req;
415 struct wrepl_socket *wrepl_sock;
418 static int wrepl_send_ctrl_destructor(void *ptr)
420 struct wrepl_send_ctrl_state *s = talloc_get_type(ptr, struct wrepl_send_ctrl_state);
421 struct wrepl_request *req = s->wrepl_sock->recv_queue;
423 /* check if the request is still in WREPL_STATE_RECV,
424 * we need this here because the caller has may called
425 * talloc_free(req) and wrepl_send_ctrl_state isn't
426 * a talloc child of the request, so our s->req pointer
429 for (; req; req = req->next) {
430 if (req == s->req) break;
434 /* here, we need to make sure the async request handler is called
435 * later in the next event_loop and now now
438 wrepl_request_finished(req, NT_STATUS_OK);
440 if (s->ctrl.disconnect_after_send) {
441 wrepl_socket_dead(s->wrepl_sock, NT_STATUS_LOCAL_DISCONNECT);
448 send a generic wins replication request
450 struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
451 struct wrepl_packet *packet,
452 struct wrepl_send_ctrl *ctrl)
454 struct wrepl_request *req;
455 struct wrepl_wrap wrap;
458 req = talloc_zero(wrepl_socket, struct wrepl_request);
459 if (!req) return NULL;
460 req->wrepl_socket = wrepl_socket;
461 req->state = WREPL_REQUEST_RECV;
464 DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
465 talloc_set_destructor(req, wrepl_request_destructor);
467 if (wrepl_socket->dead) {
468 return wrepl_request_finished(req, NT_STATUS_INVALID_CONNECTION);
471 wrap.packet = *packet;
472 req->status = ndr_push_struct_blob(&blob, req, &wrap,
473 (ndr_push_flags_fn_t)ndr_push_wrepl_wrap);
474 if (!NT_STATUS_IS_OK(req->status)) {
475 return wrepl_request_finished(req, req->status);
479 DEBUG(10,("Sending WINS packet of length %u\n", blob.length));
480 NDR_PRINT_DEBUG(wrepl_packet, &wrap.packet);
483 if (wrepl_socket->request_timeout > 0) {
484 req->te = event_add_timed(wrepl_socket->event.ctx, req,
485 timeval_current_ofs(wrepl_socket->request_timeout, 0),
486 wrepl_request_timeout_handler, req);
487 if (!req->te) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY);
490 if (ctrl && (ctrl->send_only || ctrl->disconnect_after_send)) {
491 struct wrepl_send_ctrl_state *s = talloc(blob.data, struct wrepl_send_ctrl_state);
492 if (!s) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY);
495 s->wrepl_sock = wrepl_socket;
496 talloc_set_destructor(s, wrepl_send_ctrl_destructor);
499 req->status = packet_send(wrepl_socket->packet, blob);
500 if (!NT_STATUS_IS_OK(req->status)) {
501 return wrepl_request_finished(req, req->status);
504 req->trigger = False;
509 receive a generic WINS replication reply
511 NTSTATUS wrepl_request_recv(struct wrepl_request *req,
513 struct wrepl_packet **packet)
515 NTSTATUS status = wrepl_request_wait(req);
516 if (NT_STATUS_IS_OK(status) && packet) {
517 *packet = talloc_steal(mem_ctx, req->packet);
524 a full WINS replication request/response
526 NTSTATUS wrepl_request(struct wrepl_socket *wrepl_socket,
528 struct wrepl_packet *req_packet,
529 struct wrepl_packet **reply_packet)
531 struct wrepl_request *req = wrepl_request_send(wrepl_socket, req_packet, NULL);
532 return wrepl_request_recv(req, mem_ctx, reply_packet);
537 setup an association - send
539 struct wrepl_request *wrepl_associate_send(struct wrepl_socket *wrepl_socket,
540 struct wrepl_associate *io)
542 struct wrepl_packet *packet;
543 struct wrepl_request *req;
545 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
546 if (packet == NULL) return NULL;
548 packet->opcode = WREPL_OPCODE_BITS;
549 packet->mess_type = WREPL_START_ASSOCIATION;
550 packet->message.start.minor_version = 2;
551 packet->message.start.major_version = 5;
553 req = wrepl_request_send(wrepl_socket, packet, NULL);
561 setup an association - recv
563 NTSTATUS wrepl_associate_recv(struct wrepl_request *req,
564 struct wrepl_associate *io)
566 struct wrepl_packet *packet=NULL;
568 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
569 NT_STATUS_NOT_OK_RETURN(status);
570 if (packet->mess_type != WREPL_START_ASSOCIATION_REPLY) {
571 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
573 if (NT_STATUS_IS_OK(status)) {
574 io->out.assoc_ctx = packet->message.start_reply.assoc_ctx;
581 setup an association - sync api
583 NTSTATUS wrepl_associate(struct wrepl_socket *wrepl_socket,
584 struct wrepl_associate *io)
586 struct wrepl_request *req = wrepl_associate_send(wrepl_socket, io);
587 return wrepl_associate_recv(req, io);
592 stop an association - send
594 struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socket,
595 struct wrepl_associate_stop *io)
597 struct wrepl_packet *packet;
598 struct wrepl_request *req;
599 struct wrepl_send_ctrl ctrl;
601 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
602 if (packet == NULL) return NULL;
604 packet->opcode = WREPL_OPCODE_BITS;
605 packet->assoc_ctx = io->in.assoc_ctx;
606 packet->mess_type = WREPL_STOP_ASSOCIATION;
607 packet->message.stop.reason = io->in.reason;
610 if (io->in.reason == 0) {
611 ctrl.send_only = True;
612 ctrl.disconnect_after_send = True;
615 req = wrepl_request_send(wrepl_socket, packet, &ctrl);
623 stop an association - recv
625 NTSTATUS wrepl_associate_stop_recv(struct wrepl_request *req,
626 struct wrepl_associate_stop *io)
628 struct wrepl_packet *packet=NULL;
630 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
631 NT_STATUS_NOT_OK_RETURN(status);
637 setup an association - sync api
639 NTSTATUS wrepl_associate_stop(struct wrepl_socket *wrepl_socket,
640 struct wrepl_associate_stop *io)
642 struct wrepl_request *req = wrepl_associate_stop_send(wrepl_socket, io);
643 return wrepl_associate_stop_recv(req, io);
647 fetch the partner tables - send
649 struct wrepl_request *wrepl_pull_table_send(struct wrepl_socket *wrepl_socket,
650 struct wrepl_pull_table *io)
652 struct wrepl_packet *packet;
653 struct wrepl_request *req;
655 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
656 if (packet == NULL) return NULL;
658 packet->opcode = WREPL_OPCODE_BITS;
659 packet->assoc_ctx = io->in.assoc_ctx;
660 packet->mess_type = WREPL_REPLICATION;
661 packet->message.replication.command = WREPL_REPL_TABLE_QUERY;
663 req = wrepl_request_send(wrepl_socket, packet, NULL);
672 fetch the partner tables - recv
674 NTSTATUS wrepl_pull_table_recv(struct wrepl_request *req,
676 struct wrepl_pull_table *io)
678 struct wrepl_packet *packet=NULL;
680 struct wrepl_table *table;
683 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
684 NT_STATUS_NOT_OK_RETURN(status);
685 if (packet->mess_type != WREPL_REPLICATION) {
686 status = NT_STATUS_NETWORK_ACCESS_DENIED;
687 } else if (packet->message.replication.command != WREPL_REPL_TABLE_REPLY) {
688 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
690 if (!NT_STATUS_IS_OK(status)) goto failed;
692 table = &packet->message.replication.info.table;
693 io->out.num_partners = table->partner_count;
694 io->out.partners = talloc_steal(mem_ctx, table->partners);
695 for (i=0;i<io->out.num_partners;i++) {
696 talloc_steal(io->out.partners, io->out.partners[i].address);
706 fetch the partner table - sync api
708 NTSTATUS wrepl_pull_table(struct wrepl_socket *wrepl_socket,
710 struct wrepl_pull_table *io)
712 struct wrepl_request *req = wrepl_pull_table_send(wrepl_socket, io);
713 return wrepl_pull_table_recv(req, mem_ctx, io);
718 fetch the names for a WINS partner - send
720 struct wrepl_request *wrepl_pull_names_send(struct wrepl_socket *wrepl_socket,
721 struct wrepl_pull_names *io)
723 struct wrepl_packet *packet;
724 struct wrepl_request *req;
726 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
727 if (packet == NULL) return NULL;
729 packet->opcode = WREPL_OPCODE_BITS;
730 packet->assoc_ctx = io->in.assoc_ctx;
731 packet->mess_type = WREPL_REPLICATION;
732 packet->message.replication.command = WREPL_REPL_SEND_REQUEST;
733 packet->message.replication.info.owner = io->in.partner;
735 req = wrepl_request_send(wrepl_socket, packet, NULL);
743 fetch the names for a WINS partner - recv
745 NTSTATUS wrepl_pull_names_recv(struct wrepl_request *req,
747 struct wrepl_pull_names *io)
749 struct wrepl_packet *packet=NULL;
753 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
754 NT_STATUS_NOT_OK_RETURN(status);
755 if (packet->mess_type != WREPL_REPLICATION ||
756 packet->message.replication.command != WREPL_REPL_SEND_REPLY) {
757 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
759 if (!NT_STATUS_IS_OK(status)) goto failed;
761 io->out.num_names = packet->message.replication.info.reply.num_names;
763 io->out.names = talloc_array(packet, struct wrepl_name, io->out.num_names);
764 if (io->out.names == NULL) goto nomem;
766 /* convert the list of names and addresses to a sane format */
767 for (i=0;i<io->out.num_names;i++) {
768 struct wrepl_wins_name *wname = &packet->message.replication.info.reply.names[i];
769 struct wrepl_name *name = &io->out.names[i];
771 name->name = *wname->name;
772 talloc_steal(io->out.names, wname->name);
773 name->type = WREPL_NAME_TYPE(wname->flags);
774 name->state = WREPL_NAME_STATE(wname->flags);
775 name->node = WREPL_NAME_NODE(wname->flags);
776 name->is_static = WREPL_NAME_IS_STATIC(wname->flags);
777 name->raw_flags = wname->flags;
778 name->version_id= wname->id;
779 name->owner = talloc_strdup(io->out.names, io->in.partner.address);
780 if (name->owner == NULL) goto nomem;
782 /* trying to save 1 or 2 bytes on the wire isn't a good idea */
783 if (wname->flags & 2) {
786 name->num_addresses = wname->addresses.addresses.num_ips;
787 name->addresses = talloc_array(io->out.names,
788 struct wrepl_address,
789 name->num_addresses);
790 if (name->addresses == NULL) goto nomem;
791 for (j=0;j<name->num_addresses;j++) {
792 name->addresses[j].owner =
793 talloc_steal(name->addresses,
794 wname->addresses.addresses.ips[j].owner);
795 name->addresses[j].address =
796 talloc_steal(name->addresses,
797 wname->addresses.addresses.ips[j].ip);
800 name->num_addresses = 1;
801 name->addresses = talloc(io->out.names, struct wrepl_address);
802 if (name->addresses == NULL) goto nomem;
803 name->addresses[0].owner = talloc_strdup(name->addresses,io->in.partner.address);
804 if (name->addresses[0].owner == NULL) goto nomem;
805 name->addresses[0].address = talloc_steal(name->addresses,
806 wname->addresses.ip);
810 talloc_steal(mem_ctx, io->out.names);
814 status = NT_STATUS_NO_MEMORY;
823 fetch the names for a WINS partner - sync api
825 NTSTATUS wrepl_pull_names(struct wrepl_socket *wrepl_socket,
827 struct wrepl_pull_names *io)
829 struct wrepl_request *req = wrepl_pull_names_send(wrepl_socket, io);
830 return wrepl_pull_names_recv(req, mem_ctx, io);