From 4d4c6315fa65b9938d1b4222832d12055c46e681 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 12 Mar 2011 10:18:56 +0100 Subject: s4:librpc/rpc: remove unused dcerpc_ndr_request* code metze Autobuild-User: Stefan Metzmacher Autobuild-Date: Sun Mar 13 11:19:59 CET 2011 on sn-devel-104 --- source4/librpc/rpc/dcerpc.c | 189 -------------------------------------------- 1 file changed, 189 deletions(-) (limited to 'source4/librpc/rpc/dcerpc.c') diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index d467845472..3e1aa6f10c 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -1747,195 +1747,6 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcecli_connection *c, return NT_STATUS_OK; } - -/** - send a rpc request given a dcerpc_call structure - */ -struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p, - const struct GUID *object, - const struct ndr_interface_table *table, - uint32_t opnum, - bool async, - TALLOC_CTX *mem_ctx, - void *r) -{ - const struct ndr_interface_call *call; - struct ndr_push *push; - NTSTATUS status; - DATA_BLOB request; - struct rpc_request *req; - enum ndr_err_code ndr_err; - - call = &table->calls[opnum]; - - /* setup for a ndr_push_* call */ - push = ndr_push_init_ctx(mem_ctx); - if (!push) { - return NULL; - } - - if (p->conn->flags & DCERPC_PUSH_BIGENDIAN) { - push->flags |= LIBNDR_FLAG_BIGENDIAN; - } - - if (p->conn->flags & DCERPC_NDR64) { - push->flags |= LIBNDR_FLAG_NDR64; - } - - /* push the structure into a blob */ - ndr_err = call->ndr_push(push, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - status = ndr_map_error2ntstatus(ndr_err); - DEBUG(2,("Unable to ndr_push structure in dcerpc_ndr_request_send - %s\n", - nt_errstr(status))); - talloc_free(push); - return NULL; - } - - /* retrieve the blob */ - request = ndr_push_blob(push); - - if (p->conn->flags & DCERPC_DEBUG_VALIDATE_IN) { - status = dcerpc_ndr_validate_in(p->conn, push, request, call->struct_size, - call->ndr_push, call->ndr_pull); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(2,("Validation failed in dcerpc_ndr_request_send - %s\n", - nt_errstr(status))); - talloc_free(push); - return NULL; - } - } - - DEBUG(10,("rpc request data:\n")); - dump_data(10, request.data, request.length); - - /* make the actual dcerpc request */ - req = dcerpc_request_send(p, object, opnum, &request); - - if (req != NULL) { - req->ndr.table = table; - req->ndr.opnum = opnum; - req->ndr.struct_ptr = r; - req->ndr.mem_ctx = mem_ctx; - } - - talloc_free(push); - - return req; -} - -/* - receive the answer from a dcerpc_ndr_request_send() -*/ -_PUBLIC_ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req) -{ - struct dcerpc_pipe *p = req->p; - NTSTATUS status; - DATA_BLOB response; - struct ndr_pull *pull; - unsigned int flags; - TALLOC_CTX *mem_ctx = req->ndr.mem_ctx; - void *r = req->ndr.struct_ptr; - uint32_t opnum = req->ndr.opnum; - const struct ndr_interface_table *table = req->ndr.table; - const struct ndr_interface_call *call = &table->calls[opnum]; - enum ndr_err_code ndr_err; - - /* make sure the recv code doesn't free the request, as we - need to grab the flags element before it is freed */ - if (talloc_reference(p, req) == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_request_recv(req, mem_ctx, &response); - if (!NT_STATUS_IS_OK(status)) { - talloc_unlink(p, req); - return status; - } - - flags = req->flags; - - /* prepare for ndr_pull_* */ - pull = ndr_pull_init_flags(p->conn, &response, mem_ctx); - if (!pull) { - talloc_unlink(p, req); - return NT_STATUS_NO_MEMORY; - } - - if (pull->data) { - pull->data = talloc_steal(pull, pull->data); - } - talloc_unlink(p, req); - - if (flags & DCERPC_PULL_BIGENDIAN) { - pull->flags |= LIBNDR_FLAG_BIGENDIAN; - } - - DEBUG(10,("rpc reply data:\n")); - dump_data(10, pull->data, pull->data_size); - - /* pull the structure from the blob */ - ndr_err = call->ndr_pull(pull, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - status = ndr_map_error2ntstatus(ndr_err); - dcerpc_log_packet(p->conn->packet_log_dir, - table, opnum, NDR_OUT, - &response); - return status; - } - - if (p->conn->flags & DCERPC_DEBUG_VALIDATE_OUT) { - status = dcerpc_ndr_validate_out(p->conn, pull, r, call->struct_size, - call->ndr_push, call->ndr_pull, - call->ndr_print); - if (!NT_STATUS_IS_OK(status)) { - dcerpc_log_packet(p->conn->packet_log_dir, - table, opnum, NDR_OUT, - &response); - return status; - } - } - - if (pull->offset != pull->data_size) { - DEBUG(0,("Warning! ignoring %d unread bytes in rpc packet!\n", - pull->data_size - pull->offset)); - /* we used to return NT_STATUS_INFO_LENGTH_MISMATCH here, - but it turns out that early versions of NT - (specifically NT3.1) add junk onto the end of rpc - packets, so if we want to interoperate at all with - those versions then we need to ignore this error */ - } - - /* TODO: make pull context independent from the output mem_ctx and free the pull context */ - - return NT_STATUS_OK; -} - - -/* - a useful helper function for synchronous rpc requests - - this can be used when you have ndr push/pull functions in the - standard format -*/ -_PUBLIC_ NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p, - const struct GUID *object, - const struct ndr_interface_table *table, - uint32_t opnum, - TALLOC_CTX *mem_ctx, - void *r) -{ - struct rpc_request *req; - - req = dcerpc_ndr_request_send(p, object, table, opnum, false, mem_ctx, r); - if (req == NULL) { - return NT_STATUS_NO_MEMORY; - } - - return dcerpc_ndr_request_recv(req); -} - - /* a useful function for retrieving the server name we connected to */ -- cgit