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 talloc_set_destructor(wrepl_socket, NULL);
39 wrepl_socket->dead = True;
41 if (wrepl_socket->packet) {
42 packet_recv_disable(wrepl_socket->packet);
43 packet_set_fde(wrepl_socket->packet, NULL);
44 packet_set_socket(wrepl_socket->packet, NULL);
47 if (wrepl_socket->event.fde) {
48 talloc_free(wrepl_socket->event.fde);
49 wrepl_socket->event.fde = NULL;
52 if (wrepl_socket->sock) {
53 talloc_free(wrepl_socket->sock);
54 wrepl_socket->sock = NULL;
57 if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) {
58 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
60 while (wrepl_socket->recv_queue) {
61 struct wrepl_request *req = wrepl_socket->recv_queue;
62 DLIST_REMOVE(wrepl_socket->recv_queue, req);
63 wrepl_request_finished(req, status);
67 static void wrepl_request_timeout_handler(struct event_context *ev, struct timed_event *te,
68 struct timeval t, void *ptr)
70 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
71 wrepl_socket_dead(req->wrepl_socket, NT_STATUS_IO_TIMEOUT);
77 static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in)
79 struct wrepl_socket *wrepl_socket = talloc_get_type(private, struct wrepl_socket);
80 struct wrepl_request *req = wrepl_socket->recv_queue;
83 req->packet = talloc(req, struct wrepl_packet);
84 NT_STATUS_HAVE_NO_MEMORY(req->packet);
86 blob.data = packet_blob_in.data + 4;
87 blob.length = packet_blob_in.length - 4;
89 /* we have a full request - parse it */
90 req->status = ndr_pull_struct_blob(&blob,
91 req->packet, req->packet,
92 (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
93 if (!NT_STATUS_IS_OK(req->status)) {
94 wrepl_request_finished(req, req->status);
99 DEBUG(10,("Received WINS packet of length %u\n", packet_blob_in.length));
100 NDR_PRINT_DEBUG(wrepl_packet, req->packet);
103 wrepl_request_finished(req, req->status);
108 handler for winrepl events
110 static void wrepl_handler(struct event_context *ev, struct fd_event *fde,
111 uint16_t flags, void *private)
113 struct wrepl_socket *wrepl_socket = talloc_get_type(private,
114 struct wrepl_socket);
115 if (flags & EVENT_FD_READ) {
116 packet_recv(wrepl_socket->packet);
119 if (flags & EVENT_FD_WRITE) {
120 packet_queue_run(wrepl_socket->packet);
124 static void wrepl_error(void *private, NTSTATUS status)
126 struct wrepl_socket *wrepl_socket = talloc_get_type(private,
127 struct wrepl_socket);
128 wrepl_socket_dead(wrepl_socket, status);
133 destroy a wrepl_socket destructor
135 static int wrepl_socket_destructor(void *ptr)
137 struct wrepl_socket *sock = talloc_get_type(ptr, struct wrepl_socket);
138 wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT);
143 initialise a wrepl_socket. The event_ctx is optional, if provided then
144 operations will use that event context
146 struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
147 struct event_context *event_ctx)
149 struct wrepl_socket *wrepl_socket;
152 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
153 if (!wrepl_socket) return NULL;
155 if (event_ctx == NULL) {
156 wrepl_socket->event.ctx = event_context_init(wrepl_socket);
158 wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
160 if (!wrepl_socket->event.ctx) goto failed;
162 status = socket_create("ip", SOCKET_TYPE_STREAM, &wrepl_socket->sock, 0);
163 if (!NT_STATUS_IS_OK(status)) goto failed;
165 talloc_steal(wrepl_socket, wrepl_socket->sock);
167 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT;
169 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
174 talloc_free(wrepl_socket);
179 initialise a wrepl_socket from an already existing connection
181 struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx,
182 struct event_context *event_ctx,
183 struct socket_context *socket,
184 struct packet_context *packet)
186 struct wrepl_socket *wrepl_socket;
188 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
189 if (wrepl_socket == NULL) goto failed;
191 wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
192 if (wrepl_socket->event.ctx == NULL) goto failed;
194 wrepl_socket->sock = socket;
195 talloc_steal(wrepl_socket, wrepl_socket->sock);
198 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT;
200 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket,
201 socket_get_fd(wrepl_socket->sock),
203 wrepl_handler, wrepl_socket);
204 if (wrepl_socket->event.fde == NULL) {
208 wrepl_socket->packet = packet;
209 talloc_steal(wrepl_socket, wrepl_socket->packet);
210 packet_set_private(wrepl_socket->packet, wrepl_socket);
211 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock);
212 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv);
213 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32);
214 packet_set_error_handler(wrepl_socket->packet, wrepl_error);
215 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx);
216 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde);
217 packet_set_serialise(wrepl_socket->packet);
219 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);
224 talloc_free(wrepl_socket);
229 destroy a wrepl_request
231 static int wrepl_request_destructor(void *ptr)
233 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
234 if (req->state == WREPL_REQUEST_RECV) {
235 DLIST_REMOVE(req->wrepl_socket->recv_queue, req);
237 req->state = WREPL_REQUEST_ERROR;
242 wait for a request to complete
244 static NTSTATUS wrepl_request_wait(struct wrepl_request *req)
246 NT_STATUS_HAVE_NO_MEMORY(req);
247 while (req->state < WREPL_REQUEST_DONE) {
248 event_loop_once(req->wrepl_socket->event.ctx);
253 struct wrepl_connect_state {
254 struct composite_context *result;
255 struct wrepl_socket *wrepl_socket;
256 struct composite_context *creq;
260 handler for winrepl connection completion
262 static void wrepl_connect_handler(struct composite_context *creq)
264 struct wrepl_connect_state *state = talloc_get_type(creq->async.private_data,
265 struct wrepl_connect_state);
266 struct wrepl_socket *wrepl_socket = state->wrepl_socket;
267 struct composite_context *result = state->result;
269 result->status = socket_connect_recv(state->creq);
270 if (!composite_is_ok(result)) return;
272 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket,
273 socket_get_fd(wrepl_socket->sock),
275 wrepl_handler, wrepl_socket);
276 if (composite_nomem(wrepl_socket->event.fde, result)) return;
278 /* setup the stream -> packet parser */
279 wrepl_socket->packet = packet_init(wrepl_socket);
280 if (composite_nomem(wrepl_socket->packet, result)) return;
281 packet_set_private(wrepl_socket->packet, wrepl_socket);
282 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock);
283 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv);
284 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32);
285 packet_set_error_handler(wrepl_socket->packet, wrepl_error);
286 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx);
287 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde);
288 packet_set_serialise(wrepl_socket->packet);
290 composite_done(result);
294 connect a wrepl_socket to a WINS server
296 struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket,
297 const char *our_ip, const char *peer_ip)
299 struct composite_context *result;
300 struct wrepl_connect_state *state;
302 result = talloc_zero(wrepl_socket, struct composite_context);
303 if (!result) return NULL;
305 result->state = COMPOSITE_STATE_IN_PROGRESS;
306 result->event_ctx = wrepl_socket->event.ctx;
308 state = talloc_zero(result, struct wrepl_connect_state);
309 if (composite_nomem(state, result)) return result;
310 result->private_data = state;
311 state->result = result;
312 state->wrepl_socket = wrepl_socket;
315 our_ip = iface_best_ip(peer_ip);
318 state->creq = socket_connect_send(wrepl_socket->sock, our_ip, 0,
319 peer_ip, WINS_REPLICATION_PORT,
320 0, wrepl_socket->event.ctx);
321 composite_continue(result, state->creq, wrepl_connect_handler, state);
326 connect a wrepl_socket to a WINS server - recv side
328 NTSTATUS wrepl_connect_recv(struct composite_context *result)
330 struct wrepl_connect_state *state = talloc_get_type(result->private_data,
331 struct wrepl_connect_state);
332 struct wrepl_socket *wrepl_socket = state->wrepl_socket;
333 NTSTATUS status = composite_wait(result);
335 if (!NT_STATUS_IS_OK(status)) {
336 wrepl_socket_dead(wrepl_socket, status);
344 connect a wrepl_socket to a WINS server - sync API
346 NTSTATUS wrepl_connect(struct wrepl_socket *wrepl_socket, const char *our_ip, const char *peer_ip)
348 struct composite_context *c_req = wrepl_connect_send(wrepl_socket, our_ip, peer_ip);
349 return wrepl_connect_recv(c_req);
353 callback from wrepl_request_trigger()
355 static void wrepl_request_trigger_handler(struct event_context *ev, struct timed_event *te,
356 struct timeval t, void *ptr)
358 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
365 trigger an immediate event on a wrepl_request
366 the return value should only be used in wrepl_request_send()
367 this is the only place where req->trigger is True
369 static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status)
371 struct timed_event *te;
373 if (req->state == WREPL_REQUEST_RECV) {
374 DLIST_REMOVE(req->wrepl_socket->recv_queue, req);
377 if (!NT_STATUS_IS_OK(status)) {
378 req->state = WREPL_REQUEST_ERROR;
380 req->state = WREPL_REQUEST_DONE;
383 req->status = status;
386 req->trigger = False;
387 /* a zero timeout means immediate */
388 te = event_add_timed(req->wrepl_socket->event.ctx,
390 wrepl_request_trigger_handler, req);
404 struct wrepl_send_ctrl_state {
405 struct wrepl_send_ctrl ctrl;
406 struct wrepl_request *req;
407 struct wrepl_socket *wrepl_sock;
410 static int wrepl_send_ctrl_destructor(void *ptr)
412 struct wrepl_send_ctrl_state *s = talloc_get_type(ptr, struct wrepl_send_ctrl_state);
413 struct wrepl_request *req = s->wrepl_sock->recv_queue;
415 /* check if the request is still in WREPL_STATE_RECV,
416 * we need this here because the caller has may called
417 * talloc_free(req) and wrepl_send_ctrl_state isn't
418 * a talloc child of the request, so our s->req pointer
421 for (; req; req = req->next) {
422 if (req == s->req) break;
426 /* here, we need to make sure the async request handler is called
427 * later in the next event_loop and now now
430 wrepl_request_finished(req, NT_STATUS_OK);
432 if (s->ctrl.disconnect_after_send) {
433 wrepl_socket_dead(s->wrepl_sock, NT_STATUS_LOCAL_DISCONNECT);
440 send a generic wins replication request
442 struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
443 struct wrepl_packet *packet,
444 struct wrepl_send_ctrl *ctrl)
446 struct wrepl_request *req;
447 struct wrepl_wrap wrap;
450 req = talloc_zero(wrepl_socket, struct wrepl_request);
451 if (!req) return NULL;
452 req->wrepl_socket = wrepl_socket;
453 req->state = WREPL_REQUEST_RECV;
456 DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
457 talloc_set_destructor(req, wrepl_request_destructor);
459 if (wrepl_socket->dead) {
460 return wrepl_request_finished(req, NT_STATUS_INVALID_CONNECTION);
463 wrap.packet = *packet;
464 req->status = ndr_push_struct_blob(&blob, req, &wrap,
465 (ndr_push_flags_fn_t)ndr_push_wrepl_wrap);
466 if (!NT_STATUS_IS_OK(req->status)) {
467 return wrepl_request_finished(req, req->status);
471 DEBUG(10,("Sending WINS packet of length %u\n", blob.length));
472 NDR_PRINT_DEBUG(wrepl_packet, &wrap.packet);
475 if (wrepl_socket->request_timeout > 0) {
476 req->te = event_add_timed(wrepl_socket->event.ctx, req,
477 timeval_current_ofs(wrepl_socket->request_timeout, 0),
478 wrepl_request_timeout_handler, req);
479 if (!req->te) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY);
482 if (ctrl && (ctrl->send_only || ctrl->disconnect_after_send)) {
483 struct wrepl_send_ctrl_state *s = talloc(blob.data, struct wrepl_send_ctrl_state);
484 if (!s) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY);
487 s->wrepl_sock = wrepl_socket;
488 talloc_set_destructor(s, wrepl_send_ctrl_destructor);
491 req->status = packet_send(wrepl_socket->packet, blob);
492 if (!NT_STATUS_IS_OK(req->status)) {
493 return wrepl_request_finished(req, req->status);
496 req->trigger = False;
501 receive a generic WINS replication reply
503 NTSTATUS wrepl_request_recv(struct wrepl_request *req,
505 struct wrepl_packet **packet)
507 NTSTATUS status = wrepl_request_wait(req);
508 if (NT_STATUS_IS_OK(status) && packet) {
509 *packet = talloc_steal(mem_ctx, req->packet);
516 a full WINS replication request/response
518 NTSTATUS wrepl_request(struct wrepl_socket *wrepl_socket,
520 struct wrepl_packet *req_packet,
521 struct wrepl_packet **reply_packet)
523 struct wrepl_request *req = wrepl_request_send(wrepl_socket, req_packet, NULL);
524 return wrepl_request_recv(req, mem_ctx, reply_packet);
529 setup an association - send
531 struct wrepl_request *wrepl_associate_send(struct wrepl_socket *wrepl_socket,
532 struct wrepl_associate *io)
534 struct wrepl_packet *packet;
535 struct wrepl_request *req;
537 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
538 if (packet == NULL) return NULL;
540 packet->opcode = WREPL_OPCODE_BITS;
541 packet->mess_type = WREPL_START_ASSOCIATION;
542 packet->message.start.minor_version = 2;
543 packet->message.start.major_version = 5;
545 req = wrepl_request_send(wrepl_socket, packet, NULL);
553 setup an association - recv
555 NTSTATUS wrepl_associate_recv(struct wrepl_request *req,
556 struct wrepl_associate *io)
558 struct wrepl_packet *packet=NULL;
560 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
561 NT_STATUS_NOT_OK_RETURN(status);
562 if (packet->mess_type != WREPL_START_ASSOCIATION_REPLY) {
563 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
565 if (NT_STATUS_IS_OK(status)) {
566 io->out.assoc_ctx = packet->message.start_reply.assoc_ctx;
573 setup an association - sync api
575 NTSTATUS wrepl_associate(struct wrepl_socket *wrepl_socket,
576 struct wrepl_associate *io)
578 struct wrepl_request *req = wrepl_associate_send(wrepl_socket, io);
579 return wrepl_associate_recv(req, io);
584 stop an association - send
586 struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socket,
587 struct wrepl_associate_stop *io)
589 struct wrepl_packet *packet;
590 struct wrepl_request *req;
591 struct wrepl_send_ctrl ctrl;
593 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
594 if (packet == NULL) return NULL;
596 packet->opcode = WREPL_OPCODE_BITS;
597 packet->assoc_ctx = io->in.assoc_ctx;
598 packet->mess_type = WREPL_STOP_ASSOCIATION;
599 packet->message.stop.reason = io->in.reason;
602 if (io->in.reason == 0) {
603 ctrl.send_only = True;
604 ctrl.disconnect_after_send = True;
607 req = wrepl_request_send(wrepl_socket, packet, &ctrl);
615 stop an association - recv
617 NTSTATUS wrepl_associate_stop_recv(struct wrepl_request *req,
618 struct wrepl_associate_stop *io)
620 struct wrepl_packet *packet=NULL;
622 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
623 NT_STATUS_NOT_OK_RETURN(status);
629 setup an association - sync api
631 NTSTATUS wrepl_associate_stop(struct wrepl_socket *wrepl_socket,
632 struct wrepl_associate_stop *io)
634 struct wrepl_request *req = wrepl_associate_stop_send(wrepl_socket, io);
635 return wrepl_associate_stop_recv(req, io);
639 fetch the partner tables - send
641 struct wrepl_request *wrepl_pull_table_send(struct wrepl_socket *wrepl_socket,
642 struct wrepl_pull_table *io)
644 struct wrepl_packet *packet;
645 struct wrepl_request *req;
647 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
648 if (packet == NULL) return NULL;
650 packet->opcode = WREPL_OPCODE_BITS;
651 packet->assoc_ctx = io->in.assoc_ctx;
652 packet->mess_type = WREPL_REPLICATION;
653 packet->message.replication.command = WREPL_REPL_TABLE_QUERY;
655 req = wrepl_request_send(wrepl_socket, packet, NULL);
664 fetch the partner tables - recv
666 NTSTATUS wrepl_pull_table_recv(struct wrepl_request *req,
668 struct wrepl_pull_table *io)
670 struct wrepl_packet *packet=NULL;
672 struct wrepl_table *table;
675 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
676 NT_STATUS_NOT_OK_RETURN(status);
677 if (packet->mess_type != WREPL_REPLICATION) {
678 status = NT_STATUS_NETWORK_ACCESS_DENIED;
679 } else if (packet->message.replication.command != WREPL_REPL_TABLE_REPLY) {
680 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
682 if (!NT_STATUS_IS_OK(status)) goto failed;
684 table = &packet->message.replication.info.table;
685 io->out.num_partners = table->partner_count;
686 io->out.partners = talloc_steal(mem_ctx, table->partners);
687 for (i=0;i<io->out.num_partners;i++) {
688 talloc_steal(io->out.partners, io->out.partners[i].address);
698 fetch the partner table - sync api
700 NTSTATUS wrepl_pull_table(struct wrepl_socket *wrepl_socket,
702 struct wrepl_pull_table *io)
704 struct wrepl_request *req = wrepl_pull_table_send(wrepl_socket, io);
705 return wrepl_pull_table_recv(req, mem_ctx, io);
710 fetch the names for a WINS partner - send
712 struct wrepl_request *wrepl_pull_names_send(struct wrepl_socket *wrepl_socket,
713 struct wrepl_pull_names *io)
715 struct wrepl_packet *packet;
716 struct wrepl_request *req;
718 packet = talloc_zero(wrepl_socket, struct wrepl_packet);
719 if (packet == NULL) return NULL;
721 packet->opcode = WREPL_OPCODE_BITS;
722 packet->assoc_ctx = io->in.assoc_ctx;
723 packet->mess_type = WREPL_REPLICATION;
724 packet->message.replication.command = WREPL_REPL_SEND_REQUEST;
725 packet->message.replication.info.owner = io->in.partner;
727 req = wrepl_request_send(wrepl_socket, packet, NULL);
735 fetch the names for a WINS partner - recv
737 NTSTATUS wrepl_pull_names_recv(struct wrepl_request *req,
739 struct wrepl_pull_names *io)
741 struct wrepl_packet *packet=NULL;
745 status = wrepl_request_recv(req, req->wrepl_socket, &packet);
746 NT_STATUS_NOT_OK_RETURN(status);
747 if (packet->mess_type != WREPL_REPLICATION ||
748 packet->message.replication.command != WREPL_REPL_SEND_REPLY) {
749 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
751 if (!NT_STATUS_IS_OK(status)) goto failed;
753 io->out.num_names = packet->message.replication.info.reply.num_names;
755 io->out.names = talloc_array(packet, struct wrepl_name, io->out.num_names);
756 if (io->out.names == NULL) goto nomem;
758 /* convert the list of names and addresses to a sane format */
759 for (i=0;i<io->out.num_names;i++) {
760 struct wrepl_wins_name *wname = &packet->message.replication.info.reply.names[i];
761 struct wrepl_name *name = &io->out.names[i];
763 name->name = *wname->name;
764 talloc_steal(io->out.names, wname->name);
765 name->type = WREPL_NAME_TYPE(wname->flags);
766 name->state = WREPL_NAME_STATE(wname->flags);
767 name->node = WREPL_NAME_NODE(wname->flags);
768 name->is_static = WREPL_NAME_IS_STATIC(wname->flags);
769 name->raw_flags = wname->flags;
770 name->version_id= wname->id;
771 name->owner = talloc_strdup(io->out.names, io->in.partner.address);
772 if (name->owner == NULL) goto nomem;
774 /* trying to save 1 or 2 bytes on the wire isn't a good idea */
775 if (wname->flags & 2) {
778 name->num_addresses = wname->addresses.addresses.num_ips;
779 name->addresses = talloc_array(io->out.names,
780 struct wrepl_address,
781 name->num_addresses);
782 if (name->addresses == NULL) goto nomem;
783 for (j=0;j<name->num_addresses;j++) {
784 name->addresses[j].owner =
785 talloc_steal(name->addresses,
786 wname->addresses.addresses.ips[j].owner);
787 name->addresses[j].address =
788 talloc_steal(name->addresses,
789 wname->addresses.addresses.ips[j].ip);
792 name->num_addresses = 1;
793 name->addresses = talloc(io->out.names, struct wrepl_address);
794 if (name->addresses == NULL) goto nomem;
795 name->addresses[0].owner = talloc_strdup(name->addresses,io->in.partner.address);
796 if (name->addresses[0].owner == NULL) goto nomem;
797 name->addresses[0].address = talloc_steal(name->addresses,
798 wname->addresses.ip);
802 talloc_steal(mem_ctx, io->out.names);
806 status = NT_STATUS_NO_MEMORY;
815 fetch the names for a WINS partner - sync api
817 NTSTATUS wrepl_pull_names(struct wrepl_socket *wrepl_socket,
819 struct wrepl_pull_names *io)
821 struct wrepl_request *req = wrepl_pull_names_send(wrepl_socket, io);
822 return wrepl_pull_names_recv(req, mem_ctx, io);