2 Unix SMB/CIFS implementation.
4 Copyright (C) Rafal Szczesniak 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 a composite function for name resolving
26 #include "libcli/raw/libcliraw.h"
27 #include "lib/events/events.h"
28 #include "libcli/composite/composite.h"
29 #include "libcli/composite/monitor.h"
30 #include "libnet/composite.h"
31 #include "librpc/gen_ndr/ndr_nbt.h"
35 struct composite_context *resolve_ctx;
36 struct nbt_name hostname;
41 struct composite_context *libnet_Lookup_send(struct libnet_lookup *io)
43 struct composite_context *c;
44 struct lookup_state *s;
48 /* allocate context and state structures */
49 c = talloc_zero(NULL, struct composite_context);
50 if (c == NULL) goto failed;
52 s = talloc_zero(c, struct lookup_state);
53 if (s == NULL) goto failed;
55 /* prepare event context */
56 c->event_ctx = event_context_init(c);
57 if (c->event_ctx == NULL) goto failed;
60 s->hostname.name = talloc_strdup(s, io->in.hostname);
61 s->hostname.type = io->in.type;
62 s->hostname.scope = NULL;
65 c->state = SMBCLI_REQUEST_SEND;
67 /* send resolve request */
68 s->resolve_ctx = resolve_name_send(&s->hostname, c->event_ctx, io->in.methods);
78 NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
79 struct libnet_lookup *io)
82 struct lookup_state *s;
84 s = talloc_get_type(c->private, struct lookup_state);
86 status = resolve_name_recv(s->resolve_ctx, mem_ctx, io->out.address);
91 NTSTATUS libnet_Lookup(TALLOC_CTX *mem_ctx, struct libnet_lookup *io)
93 struct composite_context *c = libnet_Lookup_send(io);
94 return libnet_Lookup_recv(c, mem_ctx, io);