summaryrefslogtreecommitdiff
path: root/source4/libnet
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libnet')
-rw-r--r--source4/libnet/libnet.c17
-rw-r--r--source4/libnet/libnet.h7
-rw-r--r--source4/libnet/libnet_lookup.c38
3 files changed, 47 insertions, 15 deletions
diff --git a/source4/libnet/libnet.c b/source4/libnet/libnet.c
index 5d66005a27..963e824497 100644
--- a/source4/libnet/libnet.c
+++ b/source4/libnet/libnet.c
@@ -24,13 +24,19 @@
struct libnet_context *libnet_context_init(struct event_context *ev)
{
+ /* default name resolution methods */
+ const char *nr_methods[] = { "lmhosts", "wins", "host", "bcast", NULL };
+ int nr_count = 0, nr_i;
+
struct libnet_context *ctx;
+ /* create brand new libnet context */
ctx = talloc(NULL, struct libnet_context);
if (!ctx) {
return NULL;
}
+ /* events */
if (ev == NULL) {
ev = event_context_init(ctx);
if (ev == NULL) {
@@ -40,6 +46,15 @@ struct libnet_context *libnet_context_init(struct event_context *ev)
}
ctx->event_ctx = ev;
+ /* count name resolution methods */
+ while (nr_methods[nr_count]) nr_count++;
+
+ /* assign name resolution methods */
+ ctx->name_res_methods = talloc_array(ctx, char*, nr_count+1);
+ for (nr_i = 0; nr_i < nr_count; nr_i++) {
+ ctx->name_res_methods[nr_i] = talloc_strdup(ctx, nr_methods[nr_i]);
+ }
+ ctx->name_res_methods[nr_count+1] = NULL;
+
return ctx;
}
-
diff --git a/source4/libnet/libnet.h b/source4/libnet/libnet.h
index 470c98dca9..18dc376628 100644
--- a/source4/libnet/libnet.h
+++ b/source4/libnet/libnet.h
@@ -25,13 +25,16 @@ struct libnet_context {
*/
struct cli_credentials *cred;
- /* dcerpc pipes */
- struct dcerpc_pipe *samr;
+ /* pipe */
+ struct dcerpc_pipe *pipe;
/* opened handles */
struct policy_handle domain_handle;
struct policy_handle user_handle;
+ /* name resolution methods */
+ char **name_res_methods;
+
struct event_context *event_ctx;
};
diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c
index 8892ae0e49..ba806e4e44 100644
--- a/source4/libnet/libnet_lookup.c
+++ b/source4/libnet/libnet_lookup.c
@@ -45,10 +45,12 @@ struct lookup_state {
* @param io arguments and result of the call
*/
-struct composite_context *libnet_Lookup_send(struct libnet_Lookup *io)
+struct composite_context *libnet_Lookup_send(struct libnet_context *ctx,
+ struct libnet_Lookup *io)
{
struct composite_context *c;
struct lookup_state *s;
+ const char** methods;
if (!io) return NULL;
@@ -69,11 +71,18 @@ struct composite_context *libnet_Lookup_send(struct libnet_Lookup *io)
s->hostname.scope = NULL;
s->address = io->out.address;
+ /* name resolution methods */
+ if (io->in.methods) {
+ methods = io->in.methods;
+ } else {
+ methods = (const char**)ctx->name_res_methods;
+ }
+
c->private = s;
c->state = SMBCLI_REQUEST_SEND;
/* send resolve request */
- s->resolve_ctx = resolve_name_send(&s->hostname, c->event_ctx, io->in.methods);
+ s->resolve_ctx = resolve_name_send(&s->hostname, c->event_ctx, methods);
return c;
@@ -113,9 +122,10 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
* @return nt status code of execution
*/
-NTSTATUS libnet_Lookup(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
+NTSTATUS libnet_Lookup(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+ struct libnet_Lookup *io)
{
- struct composite_context *c = libnet_Lookup_send(io);
+ struct composite_context *c = libnet_Lookup_send(ctx, io);
return libnet_Lookup_recv(c, mem_ctx, io);
}
@@ -129,10 +139,11 @@ NTSTATUS libnet_Lookup(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
/**
* Sends asynchronous LookupHost request
*/
-struct composite_context* libnet_LookupHost_send(struct libnet_Lookup *io)
+struct composite_context* libnet_LookupHost_send(struct libnet_context *ctx,
+ struct libnet_Lookup *io)
{
io->in.type = NBT_NAME_SERVER;
- return libnet_Lookup_send(io);
+ return libnet_Lookup_send(ctx, io);
}
@@ -140,9 +151,10 @@ struct composite_context* libnet_LookupHost_send(struct libnet_Lookup *io)
/**
* Synchronous version of LookupHost call
*/
-NTSTATUS libnet_LookupHost(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
+NTSTATUS libnet_LookupHost(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+ struct libnet_Lookup *io)
{
- struct composite_context *c = libnet_LookupHost_send(io);
+ struct composite_context *c = libnet_LookupHost_send(ctx, io);
return libnet_Lookup_recv(c, mem_ctx, io);
}
@@ -150,18 +162,20 @@ NTSTATUS libnet_LookupHost(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
/**
* Sends asynchronous LookupPdc request
*/
-struct composite_context* libnet_LookupPdc_send(struct libnet_Lookup *io)
+struct composite_context* libnet_LookupPdc_send(struct libnet_context *ctx,
+ struct libnet_Lookup *io)
{
io->in.type = NBT_NAME_PDC;
- return libnet_Lookup_send(io);
+ return libnet_Lookup_send(ctx, io);
}
/**
* Synchronous version of LookupPdc
*/
-NTSTATUS libnet_LookupPdc(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
+NTSTATUS libnet_LookupPdc(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+ struct libnet_Lookup *io)
{
- struct composite_context *c = libnet_LookupPdc_send(io);
+ struct composite_context *c = libnet_LookupPdc_send(ctx, io);
return libnet_Lookup_recv(c, mem_ctx, io);
}