summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-09-03 11:13:01 +0200
committerStefan Metzmacher <metze@samba.org>2010-09-03 17:00:19 +0200
commit3c4150522cc85fd5774ca3346ff11f9d481bca7a (patch)
tree253da834f6e58c90b97252a500a5e027c7bb086d /source4
parentf2422a0faab4443649633d6b378a4357eff194f2 (diff)
downloadsamba-3c4150522cc85fd5774ca3346ff11f9d481bca7a.tar.gz
samba-3c4150522cc85fd5774ca3346ff11f9d481bca7a.tar.bz2
samba-3c4150522cc85fd5774ca3346ff11f9d481bca7a.zip
s4:libcli/finddcs: use irpc_binding_handle_by_name()
metze
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/finddcs.c40
-rw-r--r--source4/libcli/wscript_build2
2 files changed, 22 insertions, 20 deletions
diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c
index bb4c77dab0..104ad17e00 100644
--- a/source4/libcli/finddcs.c
+++ b/source4/libcli/finddcs.c
@@ -21,8 +21,9 @@
*/
#include "include/includes.h"
+#include <tevent.h>
#include "lib/messaging/irpc.h"
-#include "librpc/gen_ndr/ndr_irpc.h"
+#include "librpc/gen_ndr/ndr_irpc_c.h"
#include "librpc/gen_ndr/samr.h"
#include "libcli/composite/composite.h"
#include "libcli/libcli.h"
@@ -46,7 +47,7 @@ struct finddcs_state {
};
static void finddcs_name_resolved(struct composite_context *ctx);
-static void finddcs_getdc_replied(struct irpc_request *ireq);
+static void finddcs_getdc_replied(struct tevent_req *subreq);
static void fallback_node_status(struct finddcs_state *state);
static void fallback_node_status_replied(struct nbt_name_request *name_req);
@@ -116,8 +117,8 @@ static void finddcs_name_resolved(struct composite_context *ctx)
{
struct finddcs_state *state =
talloc_get_type(ctx->async.private_data, struct finddcs_state);
- struct irpc_request *ireq;
- struct server_id *nbt_servers;
+ struct tevent_req *subreq;
+ struct dcerpc_binding_handle *irpc_handle;
const char *address;
state->ctx->status = resolve_name_recv(ctx, state, &address);
@@ -141,8 +142,9 @@ static void finddcs_name_resolved(struct composite_context *ctx)
return;
}
- nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
+ irpc_handle = irpc_binding_handle_by_name(state, state->msg_ctx,
+ "nbt_server", &ndr_table_irpc);
+ if (irpc_handle == NULL) {
fallback_node_status(state);
return;
}
@@ -158,25 +160,25 @@ static void finddcs_name_resolved(struct composite_context *ctx)
state->r.in.domain_sid = talloc_zero(state, struct dom_sid);
}
- ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
- &ndr_table_irpc, NDR_NBTD_GETDCNAME,
- &state->r, state);
- if (!ireq) {
- fallback_node_status(state);
- return;
- }
-
- composite_continue_irpc(state->ctx, ireq, finddcs_getdc_replied, state);
+ subreq = dcerpc_nbtd_getdcname_r_send(state, state->ctx->event_ctx,
+ irpc_handle, &state->r);
+ if (composite_nomem(subreq, state->ctx)) return;
+ tevent_req_set_callback(subreq, finddcs_getdc_replied, state);
}
/* Called when the GetDC request returns */
-static void finddcs_getdc_replied(struct irpc_request *ireq)
+static void finddcs_getdc_replied(struct tevent_req *subreq)
{
struct finddcs_state *state =
- talloc_get_type(ireq->async.private_data, struct finddcs_state);
+ tevent_req_callback_data(subreq,
+ struct finddcs_state);
+ NTSTATUS status;
- state->ctx->status = irpc_call_recv(ireq);
- if (!composite_is_ok(state->ctx)) return;
+ status = dcerpc_nbtd_getdcname_r_recv(subreq, state);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ fallback_node_status(state);
+ }
state->dcs[0].name = talloc_steal(state->dcs, state->r.out.dcname);
composite_done(state->ctx);
diff --git a/source4/libcli/wscript_build b/source4/libcli/wscript_build
index 82f0253ffc..8a2111dab8 100644
--- a/source4/libcli/wscript_build
+++ b/source4/libcli/wscript_build
@@ -71,7 +71,7 @@ bld.SAMBA_SUBSYSTEM('LP_RESOLVE',
bld.SAMBA_SUBSYSTEM('LIBCLI_FINDDCS',
source='finddcs.c',
autoproto='finddcs.h',
- public_deps='LIBCLI_NBT MESSAGING'
+ public_deps='LIBCLI_NBT MESSAGING RPC_NDR_IRPC'
)