s3-dcerpc: Use DATA_BLOB instead of prs_struct for reply_pdu
[kamenim/samba.git] / source3 / rpc_client / ndr.c
index 1db6ff72904832275b96b8e5b52327c075bcd0f8..2fb96552077a7bd3d6ac291e036877a16b633104 100644 (file)
@@ -24,7 +24,8 @@
 
 struct cli_do_rpc_ndr_state {
        const struct ndr_interface_call *call;
-       prs_struct q_ps, r_ps;
+       prs_struct q_ps;
+       DATA_BLOB r_pdu;
        void *r;
 };
 
@@ -33,15 +34,12 @@ static void cli_do_rpc_ndr_done(struct tevent_req *subreq);
 struct tevent_req *cli_do_rpc_ndr_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
                                       struct rpc_pipe_client *cli,
-                                      const char *interface,
-                                      uint32_t interface_version,
+                                      const struct ndr_interface_table *table,
                                       uint32_t opnum,
                                       void *r)
 {
        struct tevent_req *req, *subreq;
        struct cli_do_rpc_ndr_state *state;
-       struct ndr_syntax_id syntax;
-       const struct ndr_interface_table *table;
        struct ndr_push *push;
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
@@ -53,17 +51,6 @@ struct tevent_req *cli_do_rpc_ndr_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       if (!ndr_syntax_from_string(interface, interface_version, &syntax)) {
-               tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
-               return tevent_req_post(req, ev);
-       }
-
-       table = get_iface_from_syntax(&syntax);
-       if (table == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
-               return tevent_req_post(req, ev);
-       }
-
        if (!ndr_syntax_id_equal(&table->syntax_id, &cli->abstract_syntax)
            || (opnum >= table->num_calls)) {
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -78,7 +65,7 @@ struct tevent_req *cli_do_rpc_ndr_send(TALLOC_CTX *mem_ctx,
                                         state->call->name, NDR_IN, r);
        }
 
-       push = ndr_push_init_ctx(talloc_tos(), NULL);
+       push = ndr_push_init_ctx(talloc_tos());
        if (tevent_req_nomem(push, req)) {
                return tevent_req_post(req, ev);
        }
@@ -115,9 +102,8 @@ static void cli_do_rpc_ndr_done(struct tevent_req *subreq)
                req, struct cli_do_rpc_ndr_state);
        NTSTATUS status;
 
-       status = rpc_api_pipe_req_recv(subreq, state, &state->r_ps);
+       status = rpc_api_pipe_req_recv(subreq, state, &state->r_pdu);
        TALLOC_FREE(subreq);
-       prs_mem_free(&state->q_ps);
        if (!NT_STATUS_IS_OK(status)) {
                tevent_req_nterror(req, status);
                return;
@@ -132,20 +118,12 @@ NTSTATUS cli_do_rpc_ndr_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
        struct ndr_pull *pull;
        enum ndr_err_code ndr_err;
        NTSTATUS status;
-       DATA_BLOB blob;
-       bool ret;
 
        if (tevent_req_is_nterror(req, &status)) {
                return status;
        }
 
-       ret = prs_data_blob(&state->r_ps, &blob, talloc_tos());
-       prs_mem_free(&state->r_ps);
-       if (!ret) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       pull = ndr_pull_init_blob(&blob, mem_ctx, NULL);
+       pull = ndr_pull_init_blob(&state->r_pdu, mem_ctx);
        if (pull == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -170,7 +148,7 @@ NTSTATUS cli_do_rpc_ndr_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
 
 NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
                        TALLOC_CTX *mem_ctx,
-                       const char *interface, uint32_t interface_version,
+                       const struct ndr_interface_table *table,
                        uint32_t opnum, void *r)
 {
        TALLOC_CTX *frame = talloc_stackframe();
@@ -184,8 +162,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
                goto fail;
        }
 
-       req = cli_do_rpc_ndr_send(frame, ev, cli, interface, interface_version,
-                                 opnum, r);
+       req = cli_do_rpc_ndr_send(frame, ev, cli, table, opnum, r);
        if (req == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
@@ -197,6 +174,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
        }
 
        status = cli_do_rpc_ndr_recv(req, mem_ctx);
+
  fail:
        TALLOC_FREE(frame);
        return status;