STEP03c: HACK s3 client dcerpc_connection_set_use_trans_fn
[metze/samba/wip.git] / source3 / rpc_client / cli_pipe.c
index 2c7766035ba89d29d17ea2bcea277e1aa21df114..93fb387a49d4dcf093e1a65d20a20e5a048aa31e 100644 (file)
@@ -36,6 +36,7 @@
 #include "auth/gensec/gensec.h"
 #include "auth/credentials/credentials.h"
 #include "../libcli/smb/smbXcli_base.h"
+#include "../libcli/smb/tstream_smbXcli_np.h"
 #include "librpc/rpc/dcerpc_connection.h"
 
 #undef DBGC_CLASS
@@ -2244,6 +2245,7 @@ static void rpccli_bh_auth_info(struct dcerpc_binding_handle *h,
 }
 
 struct rpccli_bh_raw_call_state {
+       struct dcerpc_call *call;
        DATA_BLOB in_data;
        DATA_BLOB out_data;
        uint32_t out_flags;
@@ -2266,6 +2268,7 @@ static struct tevent_req *rpccli_bh_raw_call_send(TALLOC_CTX *mem_ctx,
        struct rpccli_bh_raw_call_state *state;
        bool ok;
        struct tevent_req *subreq;
+       bool bigendian = false;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct rpccli_bh_raw_call_state);
@@ -2281,8 +2284,20 @@ static struct tevent_req *rpccli_bh_raw_call_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       subreq = rpc_api_pipe_req_send(state, ev, hs->rpc_cli,
-                                      opnum, object, &state->in_data);
+       state->call = dcerpc_call_allocate(state,
+                                          hs->rpc_cli->assoc,
+                                          hs->rpc_cli->sec,
+                                          hs->rpc_cli->pres);
+
+       if (in_flags & LIBNDR_FLAG_BIGENDIAN) {
+               bigendian = true;
+       }
+
+       subreq = dcerpc_do_request_send(state, ev, hs->rpc_cli->conn,
+                                       state->call, object, opnum,
+                                       &state->in_data, bigendian);
+//     subreq = rpc_api_pipe_req_send(state, ev, hs->rpc_cli,
+//                                    opnum, &state->in_data);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -2300,18 +2315,25 @@ static void rpccli_bh_raw_call_done(struct tevent_req *subreq)
                tevent_req_data(req,
                struct rpccli_bh_raw_call_state);
        NTSTATUS status;
+       bool bigendian = false;
 
        state->out_flags = 0;
 
        /* TODO: support bigendian responses */
 
-       status = rpc_api_pipe_req_recv(subreq, state, &state->out_data);
+       status = dcerpc_do_request_recv(subreq, state, &state->out_data,
+                                       &bigendian);
+       //status = rpc_api_pipe_req_recv(subreq, state, &state->out_data);
        TALLOC_FREE(subreq);
        if (!NT_STATUS_IS_OK(status)) {
                tevent_req_nterror(req, status);
                return;
        }
 
+       if (bigendian) {
+               state->out_flags |= LIBNDR_FLAG_BIGENDIAN;
+       }
+
        tevent_req_done(req);
 }
 
@@ -3063,6 +3085,8 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
        result->assoc = dcerpc_association_create(result, 0);
        result->conn = dcerpc_connection_create(result, result->assoc,
                                                &result->transport->stream);
+       dcerpc_connection_set_use_trans_fn(result->conn,
+                                          tstream_smbXcli_np_use_trans);
        result->pres = dcerpc_presentation_allocate(result, result->conn, table,
                                                    &ndr_transfer_syntax_ndr);
        result->sec = dcerpc_security_allocate(result, result->conn,