From 76691e9eaf9520429c7ea0ef6b2955c143b068e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 5 Aug 2010 18:22:02 +0200 Subject: pidl:Samba4/NDR/Client: make use of the new dcerpc_binding_handle_call() infrastructure metze --- pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 109 +++++-------------------------- 1 file changed, 15 insertions(+), 94 deletions(-) (limited to 'pidl/lib/Parse') diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index 65d5dd00f0..8b5330b50c 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -16,64 +16,6 @@ use strict; my($res,$res_hdr); -sub ParseFunctionOldSend($$$) -{ - my ($interface, $fn, $name) = @_; - my $uname = uc $name; - - if (has_property($fn, "todo")) { - return; - } - - my $proto = "static struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)"; - - $res .= "$proto\n{\n"; - - $res .= " - if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { - NDR_PRINT_IN_DEBUG($name, r); - } - - return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME}, - NDR_$uname, true, mem_ctx, r); -"; - - $res .= "}\n\n"; -} - -sub ParseFunctionOldRecv($$$) -{ - my ($interface, $fn, $name) = @_; - my $uname = uc $name; - - if (has_property($fn, "todo")) { - return; - } - - my $proto = "static NTSTATUS dcerpc_$name\_recv(struct rpc_request *rreq)"; - - $res .= "$proto\n{\n"; - - $res .= "NTSTATUS status; - struct dcerpc_pipe *p = rreq->p; - struct $name *r = (struct $name *)rreq->ndr.struct_ptr; - - status = dcerpc_ndr_request_recv(rreq); - - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - status = dcerpc_fault_to_nt_status(p->last_fault_code); - } - - if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { - NDR_PRINT_OUT_DEBUG($name, r); - } - - return status; -"; - - $res .= "}\n\n"; -} - sub ParseFunction_r_State($$$) { my ($interface, $fn, $name) = @_; @@ -87,7 +29,7 @@ sub ParseFunction_r_State($$$) $res .= "\tTALLOC_CTX *out_mem_ctx;\n"; $res .= "};\n"; $res .= "\n"; - $res .= "static void dcerpc_$name\_r_done(struct rpc_request *subreq);\n"; + $res .= "static void dcerpc_$name\_r_done(struct tevent_req *subreq);\n"; $res .= "\n"; } @@ -111,10 +53,7 @@ sub ParseFunction_r_Send($$$) $res .= "\tstruct tevent_req *req;\n"; $res .= "\tstruct dcerpc_$name\_r_state *state;\n"; - $res .= "\tstruct dcerpc_pipe *p =\n"; - $res .= "\t\ttalloc_get_type_abort(h->private_data,\n"; - $res .= "\t\tstruct dcerpc_pipe);\n"; - $res .= "\tstruct rpc_request *subreq;\n"; + $res .= "\tstruct tevent_req *subreq;\n"; $res .= "\n"; $res .= "\treq = tevent_req_create(mem_ctx, &state,\n"; @@ -144,12 +83,13 @@ sub ParseFunction_r_Send($$$) $submem = "state"; } - $res .= "\tsubreq = dcerpc_$name\_send(p, $submem, r);\n"; + $res .= "\tsubreq = dcerpc_binding_handle_call_send(state, ev, h,\n"; + $res .= "\t\t\tNULL, &ndr_table_$interface->{NAME},\n"; + $res .= "\t\t\tNDR_$uname, $submem, r);\n"; $res .= "\tif (tevent_req_nomem(subreq, req)) {\n"; $res .= "\t\treturn tevent_req_post(req, ev);\n"; $res .= "\t}\n"; - $res .= "\tsubreq->async.callback = dcerpc_$name\_r_done;\n"; - $res .= "\tsubreq->async.private_data = req;\n"; + $res .= "\ttevent_req_set_callback(subreq, dcerpc_$name\_r_done, req);\n"; $res .= "\n"; $res .= "\treturn req;\n"; @@ -166,18 +106,18 @@ sub ParseFunction_r_Done($$$) return; } - my $proto = "static void dcerpc_$name\_r_done(struct rpc_request *subreq)"; + my $proto = "static void dcerpc_$name\_r_done(struct tevent_req *subreq)"; $res .= "$proto\n"; $res .= "{\n"; $res .= "\tstruct tevent_req *req =\n"; - $res .= "\t\ttalloc_get_type_abort(subreq->async.private_data,\n"; + $res .= "\t\ttevent_req_callback_data(subreq,\n"; $res .= "\t\tstruct tevent_req);\n"; $res .= "\tNTSTATUS status;\n"; $res .= "\n"; - $res .= "\tstatus = dcerpc_$name\_recv(subreq);\n"; + $res .= "\tstatus = dcerpc_binding_handle_call_recv(subreq);\n"; $res .= "\tif (!NT_STATUS_IS_OK(status)) {\n"; $res .= "\t\ttevent_req_nterror(req, status);\n"; $res .= "\t\treturn;\n"; @@ -238,31 +178,14 @@ sub ParseFunction_r_Sync($$$) $res_hdr .= "\n$proto;\n"; $res .= "$proto\n{\n"; - - $res .= "\tstruct dcerpc_pipe *p =\n"; - $res .= "\t\ttalloc_get_type_abort(h->private_data,\n"; - $res .= "\t\tstruct dcerpc_pipe);\n"; + $res .= "\tNTSTATUS status;\n"; $res .= "\n"; - $res .= " - NTSTATUS status; - - if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { - NDR_PRINT_IN_DEBUG($name, r); - } - - status = dcerpc_ndr_request(p, NULL, &ndr_table_$interface->{NAME}, - NDR_$uname, mem_ctx, r); - - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - status = dcerpc_fault_to_nt_status(p->last_fault_code); - } - - if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { - NDR_PRINT_OUT_DEBUG($name, r); - } - return status; -"; + $res .= "\tstatus = dcerpc_binding_handle_call(h,\n"; + $res .= "\t\t\tNULL, &ndr_table_$interface->{NAME},\n"; + $res .= "\t\t\tNDR_$uname, mem_ctx, r);\n"; + $res .= "\n"; + $res .= "\treturn status;\n"; $res .= "}\n"; $res .= "\n"; @@ -274,8 +197,6 @@ sub ParseFunction($$) { my ($interface, $fn) = @_; - ParseFunctionOldSend($interface, $fn, $fn->{NAME}); - ParseFunctionOldRecv($interface, $fn, $fn->{NAME}); ParseFunction_r_State($interface, $fn, $fn->{NAME}); ParseFunction_r_Send($interface, $fn, $fn->{NAME}); ParseFunction_r_Done($interface, $fn, $fn->{NAME}); -- cgit