summaryrefslogtreecommitdiff
path: root/source4/winbind/wb_cmd_getdcname.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-11-05 09:34:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:47 -0500
commit6b6a739eca1e16c0c101289b1984a639fce10223 (patch)
treeeb3e8b8e54449535e1d713c79f90e08d0850f0a9 /source4/winbind/wb_cmd_getdcname.c
parent687dea8de634d6d0e1e4ee9a0550f258cd63a014 (diff)
downloadsamba-6b6a739eca1e16c0c101289b1984a639fce10223.tar.gz
samba-6b6a739eca1e16c0c101289b1984a639fce10223.tar.bz2
samba-6b6a739eca1e16c0c101289b1984a639fce10223.zip
r11517: Cleanup time, this looks larger than it is. This mainly gets rid of
wb_domain_request, now that we have queued rpc requests. Volker (This used to be commit 848522d1b64c1c283ac1ea7ce7f1a7a1b014a2aa)
Diffstat (limited to 'source4/winbind/wb_cmd_getdcname.c')
-rw-r--r--source4/winbind/wb_cmd_getdcname.c123
1 files changed, 49 insertions, 74 deletions
diff --git a/source4/winbind/wb_cmd_getdcname.c b/source4/winbind/wb_cmd_getdcname.c
index 72e0ba0efd..8cca3197a1 100644
--- a/source4/winbind/wb_cmd_getdcname.c
+++ b/source4/winbind/wb_cmd_getdcname.c
@@ -28,49 +28,6 @@
#include "librpc/gen_ndr/ndr_netlogon.h"
-static void composite_netr_GetAnyDCName_recv_rpc(struct rpc_request *req);
-
-static struct composite_context *composite_netr_GetAnyDCName_send(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx,
- struct netr_GetAnyDCName *r)
-{
- struct composite_context *result;
- struct rpc_request *req;
-
- result = talloc(mem_ctx, struct composite_context);
- if (result == NULL) goto failed;
- result->state = COMPOSITE_STATE_IN_PROGRESS;
- result->async.fn = NULL;
- result->event_ctx = p->conn->event_ctx;
-
- req = dcerpc_netr_GetAnyDCName_send(p, mem_ctx, r);
- if (req == NULL) goto failed;
- req->async.callback = composite_netr_GetAnyDCName_recv_rpc;
- req->async.private = result;
- return result;
-
- failed:
- talloc_free(result);
- return NULL;
-}
-
-static void composite_netr_GetAnyDCName_recv_rpc(struct rpc_request *req)
-{
- struct composite_context *ctx =
- talloc_get_type(req->async.private, struct composite_context);
-
- ctx->status = dcerpc_ndr_request_recv(req);
- if (!composite_is_ok(ctx)) return;
- composite_done(ctx);
-}
-
-static NTSTATUS composite_netr_GetAnyDCName_recv(struct composite_context *ctx)
-{
- NTSTATUS status = composite_wait(ctx);
- talloc_free(ctx);
- return status;
-}
-
struct cmd_getdcname_state {
struct composite_context *ctx;
const char *domain_name;
@@ -78,59 +35,77 @@ struct cmd_getdcname_state {
struct netr_GetAnyDCName g;
};
-static struct composite_context *getdcname_send_req(struct wbsrv_domain *domain,
- void *p);
-static NTSTATUS getdcname_recv_req(struct composite_context *ctx, void *p);
+static void getdcname_recv_domain(struct composite_context *ctx);
+static void getdcname_recv_dcname(struct rpc_request *req);
-struct composite_context *wb_cmd_getdcname_send(struct wbsrv_service *service,
- struct wbsrv_domain *domain,
+struct composite_context *wb_cmd_getdcname_send(TALLOC_CTX *mem_ctx,
+ struct wbsrv_service *service,
const char *domain_name)
{
+ struct composite_context *result, *ctx;
struct cmd_getdcname_state *state;
- state = talloc(NULL, struct cmd_getdcname_state);
+ result = talloc(mem_ctx, struct composite_context);
+ if (result == NULL) goto failed;
+ result->state = COMPOSITE_STATE_IN_PROGRESS;
+ result->async.fn = NULL;
+ result->event_ctx = service->task->event_ctx;
+
+ state = talloc(result, struct cmd_getdcname_state);
+ if (state == NULL) goto failed;
+ state->ctx = result;
+ result->private_data = state;
+
state->domain_name = talloc_strdup(state, domain_name);
- state->ctx = wb_domain_request_send(state, service,
- service->primary_sid,
- getdcname_send_req,
- getdcname_recv_req,
- state);
- if (state->ctx == NULL) {
- talloc_free(state);
- return NULL;
- }
- state->ctx->private_data = state;
- return state->ctx;
+ if (state->domain_name == NULL) goto failed;
+
+ ctx = wb_sid2domain_send(state, service, service->primary_sid);
+ if (ctx == NULL) goto failed;
+
+ ctx->async.fn = getdcname_recv_domain;
+ ctx->async.private_data = state;
+ return result;
+
+ failed:
+ talloc_free(result);
+ return NULL;
}
-static struct composite_context *getdcname_send_req(struct wbsrv_domain *domain, void *p)
+static void getdcname_recv_domain(struct composite_context *ctx)
{
struct cmd_getdcname_state *state =
- talloc_get_type(p, struct cmd_getdcname_state);
+ talloc_get_type(ctx->async.private_data,
+ struct cmd_getdcname_state);
+ struct wbsrv_domain *domain;
+ struct rpc_request *req;
+
+ state->ctx->status = wb_sid2domain_recv(ctx, &domain);
+ if (!composite_is_ok(state->ctx)) return;
state->g.in.logon_server = talloc_asprintf(
state, "\\\\%s",
dcerpc_server_name(domain->netlogon_pipe));
state->g.in.domainname = state->domain_name;
- return composite_netr_GetAnyDCName_send(domain->netlogon_pipe,
- state, &state->g);
+ req = dcerpc_netr_GetAnyDCName_send(domain->netlogon_pipe, state,
+ &state->g);
+ if (composite_nomem(req, state->ctx)) return;
+
+ composite_continue_rpc(state->ctx, req, getdcname_recv_dcname, state);
}
-static NTSTATUS getdcname_recv_req(struct composite_context *ctx, void *p)
+static void getdcname_recv_dcname(struct rpc_request *req)
{
struct cmd_getdcname_state *state =
- talloc_get_type(p, struct cmd_getdcname_state);
- NTSTATUS status;
+ talloc_get_type(req->async.private,
+ struct cmd_getdcname_state);
- status = composite_netr_GetAnyDCName_recv(ctx);
- NT_STATUS_NOT_OK_RETURN(status);
-
- if (!W_ERROR_IS_OK(state->g.out.result)) {
- return werror_to_ntstatus(state->g.out.result);
- }
+ state->ctx->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(state->ctx)) return;
+ state->ctx->status = werror_to_ntstatus(state->g.out.result);
+ if (!composite_is_ok(state->ctx)) return;
- return NT_STATUS_OK;
+ composite_done(state->ctx);
}
NTSTATUS wb_cmd_getdcname_recv(struct composite_context *c,