librpc/rpc: move dcerpc_pull_ncacn_packet() from source3/librpc/rpc/ to the toplevel
authorStefan Metzmacher <metze@samba.org>
Wed, 28 Oct 2015 11:23:00 +0000 (12:23 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 26 Oct 2016 09:20:13 +0000 (11:20 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: G√ľnther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
librpc/rpc/dcerpc_util.c
librpc/rpc/rpc_common.h
source3/librpc/rpc/dcerpc.h
source3/librpc/rpc/dcerpc_helpers.c

index df149481559e1b72caaa6397b3ff1c43737bdb9e..e978b7ef17da73a13f75ddf66e697fa0a7b56b75 100644 (file)
@@ -63,6 +63,50 @@ uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob)
        return blob->data[DCERPC_DREP_OFFSET];
 }
 
+/**
+* @brief Decodes a ncacn_packet
+*
+* @param mem_ctx       The memory context on which to allocate the packet
+*                      elements
+* @param blob          The blob of data to decode
+* @param r             An empty ncacn_packet, must not be NULL
+*
+* @return a NTSTATUS error code
+*/
+NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
+                                 const DATA_BLOB *blob,
+                                 struct ncacn_packet *r)
+{
+       enum ndr_err_code ndr_err;
+       struct ndr_pull *ndr;
+
+       ndr = ndr_pull_init_blob(blob, mem_ctx);
+       if (!ndr) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (!(CVAL(ndr->data, DCERPC_DREP_OFFSET) & DCERPC_DREP_LE)) {
+               ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
+       }
+
+       if (CVAL(ndr->data, DCERPC_PFC_OFFSET) & DCERPC_PFC_FLAG_OBJECT_UUID) {
+               ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
+       }
+
+       ndr_err = ndr_pull_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, r);
+
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(ndr);
+               return ndr_map_error2ntstatus(ndr_err);
+       }
+       talloc_free(ndr);
+
+       if (r->frag_length != blob->length) {
+               return NT_STATUS_RPC_PROTOCOL_ERROR;
+       }
+
+       return NT_STATUS_OK;
+}
 
 /**
 * @brief       Pull a dcerpc_auth structure, taking account of any auth
index bd0985ad6a9b3a6e05892f978e68f70802484ff6..1b10b7ea7351fd4152e24aab41d34fbb48af4f73 100644 (file)
@@ -168,6 +168,10 @@ const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
                                              enum dcerpc_transport_t transport,
                                              const struct ndr_interface_table *table);
 
+NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
+                                 const DATA_BLOB *blob,
+                                 struct ncacn_packet *r);
+
 /**
 * @brief       Pull a dcerpc_auth structure, taking account of any auth
 *              padding in the blob. For request/response packets we pass
index f58ef4c3bef3bb987798858c7e736d58f6beca7d..e032a7479e644a71374e08ce114f13714508339c 100644 (file)
@@ -59,9 +59,6 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
                                  uint32_t call_id,
                                  union dcerpc_payload *u,
                                  DATA_BLOB *blob);
-NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
-                                 const DATA_BLOB *blob,
-                                 struct ncacn_packet *r);
 NTSTATUS dcerpc_push_dcerpc_auth(TALLOC_CTX *mem_ctx,
                                 enum dcerpc_AuthType auth_type,
                                 enum dcerpc_AuthLevel auth_level,
index aeb6cadae91e4fbd58f865fded808e7c1483741a..88d27d0fafdc81618edb233a2d8c75c48b796ae3 100644 (file)
@@ -81,51 +81,6 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
-/**
-* @brief Decodes a ncacn_packet
-*
-* @param mem_ctx       The memory context on which to allocate the packet
-*                      elements
-* @param blob          The blob of data to decode
-* @param r             An empty ncacn_packet, must not be NULL
-*
-* @return a NTSTATUS error code
-*/
-NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
-                                 const DATA_BLOB *blob,
-                                 struct ncacn_packet *r)
-{
-       enum ndr_err_code ndr_err;
-       struct ndr_pull *ndr;
-
-       ndr = ndr_pull_init_blob(blob, mem_ctx);
-       if (!ndr) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       if (!(CVAL(ndr->data, DCERPC_DREP_OFFSET) & DCERPC_DREP_LE)) {
-               ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
-       }
-
-       if (CVAL(ndr->data, DCERPC_PFC_OFFSET) & DCERPC_PFC_FLAG_OBJECT_UUID) {
-               ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
-       }
-
-       ndr_err = ndr_pull_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, r);
-
-       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               talloc_free(ndr);
-               return ndr_map_error2ntstatus(ndr_err);
-       }
-       talloc_free(ndr);
-
-       if (r->frag_length != blob->length) {
-               return NT_STATUS_RPC_PROTOCOL_ERROR;
-       }
-
-       return NT_STATUS_OK;
-}
-
 /**
 * @brief NDR Encodes a dcerpc_auth structure
 *