summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/libnet/libnet_lookup.c70
-rw-r--r--source4/torture/libnet/libnet_lookup.c58
-rw-r--r--source4/torture/torture.c2
3 files changed, 126 insertions, 4 deletions
diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c
index c517213652..8892ae0e49 100644
--- a/source4/libnet/libnet_lookup.c
+++ b/source4/libnet/libnet_lookup.c
@@ -39,6 +39,12 @@ struct lookup_state {
};
+/**
+ * Sends asynchronous Lookup request
+ *
+ * @param io arguments and result of the call
+ */
+
struct composite_context *libnet_Lookup_send(struct libnet_Lookup *io)
{
struct composite_context *c;
@@ -77,6 +83,15 @@ failed:
}
+/**
+ * Waits for and receives results of asynchronous Lookup call
+ *
+ * @param c composite context returned by asynchronous Lookup call
+ * @param mem_ctx memory context of the call
+ * @param io pointer to results (and arguments) of the call
+ * @return nt status code of execution
+ */
+
NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
struct libnet_Lookup *io)
{
@@ -90,8 +105,63 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
}
+/**
+ * Synchronous version of Lookup call
+ *
+ * @param mem_ctx memory context for the call
+ * @param io arguments and results of the call
+ * @return nt status code of execution
+ */
+
NTSTATUS libnet_Lookup(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
{
struct composite_context *c = libnet_Lookup_send(io);
return libnet_Lookup_recv(c, mem_ctx, io);
}
+
+
+/*
+ * Shortcut functions to find common types of name
+ * (and skip nbt name type argument)
+ */
+
+
+/**
+ * Sends asynchronous LookupHost request
+ */
+struct composite_context* libnet_LookupHost_send(struct libnet_Lookup *io)
+{
+ io->in.type = NBT_NAME_SERVER;
+ return libnet_Lookup_send(io);
+}
+
+
+
+/**
+ * Synchronous version of LookupHost call
+ */
+NTSTATUS libnet_LookupHost(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
+{
+ struct composite_context *c = libnet_LookupHost_send(io);
+ return libnet_Lookup_recv(c, mem_ctx, io);
+}
+
+
+/**
+ * Sends asynchronous LookupPdc request
+ */
+struct composite_context* libnet_LookupPdc_send(struct libnet_Lookup *io)
+{
+ io->in.type = NBT_NAME_PDC;
+ return libnet_Lookup_send(io);
+}
+
+
+/**
+ * Synchronous version of LookupPdc
+ */
+NTSTATUS libnet_LookupPdc(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io)
+{
+ struct composite_context *c = libnet_LookupPdc_send(io);
+ return libnet_Lookup_recv(c, mem_ctx, io);
+}
diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c
index 058d43574c..b101f62960 100644
--- a/source4/torture/libnet/libnet_lookup.c
+++ b/source4/torture/libnet/libnet_lookup.c
@@ -32,21 +32,71 @@ BOOL torture_lookup(void)
TALLOC_CTX *mem_ctx;
struct libnet_Lookup lookup;
const char address[16];
- const char* methods[] = { "wins", "bcast", NULL };
+ const char** methods = lp_name_resolve_order();
- mem_ctx = talloc_init("test_userinfo");
+ mem_ctx = talloc_init("test_lookup");
lookup.in.hostname = lp_netbios_name();
- lookup.in.methods = NULL;
- lookup.in.type = NBT_NAME_SERVER;
+ lookup.in.methods = lp_name_resolve_order();
+ lookup.in.type = NBT_NAME_CLIENT;
lookup.out.address = (const char**)&address;
status = libnet_Lookup(mem_ctx, &lookup);
if (!NT_STATUS_IS_OK(status)) {
+ printf("Couldn't lookup name %s: %s\n", lookup.in.hostname, nt_errstr(status));
+ return False;
+ }
+
+ return True;
+}
+
+
+BOOL torture_lookup_host(void)
+{
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx;
+ struct libnet_Lookup lookup;
+ const char address[16];
+ const char** methods = lp_name_resolve_order();
+
+ mem_ctx = talloc_init("test_lookup_host");
+
+ lookup.in.hostname = lp_netbios_name();
+ lookup.in.methods = lp_name_resolve_order();
+ lookup.out.address = (const char**)&address;
+
+ status = libnet_LookupHost(mem_ctx, &lookup);
+
+ if (!NT_STATUS_IS_OK(status)) {
printf("Couldn't lookup host %s: %s\n", lookup.in.hostname, nt_errstr(status));
return False;
}
return True;
}
+
+
+BOOL torture_lookup_pdc(void)
+{
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx;
+ struct libnet_Lookup lookup;
+ const char address[16];
+ const char** methods = lp_name_resolve_order();
+
+ mem_ctx = talloc_init("test_lookup_pdc");
+
+ lookup.in.hostname = lp_workgroup();
+ lookup.in.methods = lp_name_resolve_order();
+ lookup.out.address = (const char**)&address;
+
+ status = libnet_LookupPdc(mem_ctx, &lookup);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Couldn't lookup pdc %s: %s\n", lookup.in.hostname, nt_errstr(status));
+ return False;
+ }
+
+ return True;
+}
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 68a0f610fe..2cb9a22bcb 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -2343,6 +2343,8 @@ static struct {
{"NET-USERDEL", torture_userdel, 0},
{"NET-DOMOPEN", torture_domainopen, 0},
{"NET-API-LOOKUP", torture_lookup, 0},
+ {"NET-API-LOOKUPHOST", torture_lookup_host, 0},
+ {"NET-API-LOOKUPPDC", torture_lookup_pdc, 0},
{"NET-API-CREATEUSER", torture_createuser, 0},
{NULL, NULL, 0}};