summaryrefslogtreecommitdiff
path: root/source4/libnet/libnet_lookup.c
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2005-07-02 14:32:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:05 -0500
commite6b54f7acf45abcbc81d192bf618034a075c4d18 (patch)
tree542335a09bdfd1f8bfac30b081d52b475f9ce25b /source4/libnet/libnet_lookup.c
parentd5f76aad22de307e407628c3cbb825c4956f1f79 (diff)
downloadsamba-e6b54f7acf45abcbc81d192bf618034a075c4d18.tar.gz
samba-e6b54f7acf45abcbc81d192bf618034a075c4d18.tar.bz2
samba-e6b54f7acf45abcbc81d192bf618034a075c4d18.zip
r8076: Put name resolution methods into libnet_context. This allows libnet based
application use methods of their own choice and makes it less dependent on smb.conf parameters. Use libnet_context in libnet_Lookup functions which is the way to pass default name resolution methods if caller doesn't want to bother with specifying them. rafal (This used to be commit d0ea136356bcb9c6c01120d8683b71e8689d5e5b)
Diffstat (limited to 'source4/libnet/libnet_lookup.c')
-rw-r--r--source4/libnet/libnet_lookup.c38
1 files changed, 26 insertions, 12 deletions
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);
}