This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
+#include "param/param.h"
+
struct lookup_state {
struct nbt_name hostname;
const char *address;
struct composite_context *c;
struct lookup_state *s;
struct composite_context *cresolve_req;
- const char** methods;
+ struct resolve_context *resolve_ctx;
/* allocate context and state structures */
- c = talloc_zero(NULL, struct composite_context);
+ c = composite_create(ctx, ctx->event_ctx);
if (c == NULL) return NULL;
s = talloc_zero(c, struct lookup_state);
- if (s == NULL) {
- composite_error(c, NT_STATUS_NO_MEMORY);
- return c;
- }
-
- /* prepare event context */
- c->event_ctx = event_context_find(c);
- if (c->event_ctx == NULL) {
- composite_error(c, NT_STATUS_NO_MEMORY);
- return c;
- }
+ if (composite_nomem(s, c)) return c;
+
+ c->private_data = s;
if (io == NULL || io->in.hostname == NULL) {
composite_error(c, NT_STATUS_INVALID_PARAMETER);
/* parameters */
s->hostname.name = talloc_strdup(s, io->in.hostname);
+ if (composite_nomem(s->hostname.name, c)) return c;
+
s->hostname.type = io->in.type;
s->hostname.scope = NULL;
/* name resolution methods */
- if (io->in.methods) {
- methods = io->in.methods;
+ if (io->in.resolve_ctx) {
+ resolve_ctx = io->in.resolve_ctx;
} else {
- methods = ctx->name_res_methods;
+ resolve_ctx = ctx->resolve_ctx;
}
- c->private_data = s;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
-
/* send resolve request */
- cresolve_req = resolve_name_send(&s->hostname, c->event_ctx, methods);
+ cresolve_req = resolve_name_send(resolve_ctx, &s->hostname, c->event_ctx);
+ if (composite_nomem(cresolve_req, c)) return c;
composite_continue(c, cresolve_req, continue_name_resolved, c);
-
return c;
}
struct libnet_LookupDCs *io)
{
struct composite_context *c;
- struct messaging_context *msg_ctx = messaging_client_init(mem_ctx, ctx->event_ctx);
+ struct messaging_context *msg_ctx =
+ messaging_client_init(mem_ctx, lp_messaging_path(mem_ctx, ctx->lp_ctx), ctx->event_ctx);
- c = finddcs_send(mem_ctx, io->in.domain_name, io->in.name_type,
- NULL, ctx->name_res_methods, ctx->event_ctx, msg_ctx);
+ c = finddcs_send(mem_ctx, lp_netbios_name(ctx->lp_ctx),
+ io->in.domain_name, io->in.name_type,
+ NULL, ctx->resolve_ctx, ctx->event_ctx, msg_ctx);
return c;
}
struct composite_context *c;
struct lookup_name_state *s;
struct rpc_request *lookup_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
c = composite_create(mem_ctx, ctx->event_ctx);
if (c == NULL) return NULL;
struct composite_context *c;
struct lookup_name_state *s;
- c = talloc_get_type(req->async.private, struct composite_context);
+ c = talloc_get_type(req->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct lookup_name_state);
c->status = dcerpc_ndr_request_recv(req);