libsmb: Add cli_chmod
[samba4-gss.git] / librpc / rpc / dcerpc_util.h
blob4e49e3e85725d83794e8c0f3d911af6f3ce1501c
1 /*
2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2010-2011
5 Copyright (C) Andrew Tridgell 2010-2011
6 Copyright (C) Simo Sorce 2010
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __LIBRPC_RPC_DCERPC_UTIL_H__
23 #define __LIBRPC_RPC_DCERPC_UTIL_H__
25 #include "replace.h"
26 #include <talloc.h>
27 #include "lib/util/data_blob.h"
28 #include "librpc/rpc/rpc_common.h"
29 #include "librpc/gen_ndr/dcerpc.h"
31 void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
32 uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
33 void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
34 uint16_t dcerpc_get_auth_length(const DATA_BLOB *blob);
35 uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
36 uint8_t dcerpc_get_auth_type(const DATA_BLOB *blob);
37 uint8_t dcerpc_get_auth_level(const DATA_BLOB *blob);
38 uint32_t dcerpc_get_auth_context_id(const DATA_BLOB *blob);
39 const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
40 enum dcerpc_transport_t transport,
41 const struct ndr_interface_table *table);
43 NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
44 const DATA_BLOB *blob,
45 struct ncacn_packet *r);
47 /**
48 * @brief Pull a dcerpc_auth structure, taking account of any auth
49 * padding in the blob. For request/response packets we pass
50 * the whole data blob, so auth_data_only must be set to false
51 * as the blob contains data+pad+auth and no just pad+auth.
53 * @param pkt - The ncacn_packet structure
54 * @param mem_ctx - The mem_ctx used to allocate dcerpc_auth elements
55 * @param pkt_trailer - The packet trailer data, usually the trailing
56 * auth_info blob, but in the request/response case
57 * this is the stub_and_verifier blob.
58 * @param auth - A preallocated dcerpc_auth *empty* structure
59 * @param auth_length - The length of the auth trail, sum of auth header
60 * length and pkt->auth_length
61 * @param auth_data_only - Whether the pkt_trailer includes only the auth_blob
62 * (+ padding) or also other data.
64 * @return - A NTSTATUS error code.
66 NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt,
67 TALLOC_CTX *mem_ctx,
68 const DATA_BLOB *pkt_trailer,
69 struct dcerpc_auth *auth,
70 uint32_t *auth_length,
71 bool auth_data_only);
72 NTSTATUS dcerpc_verify_ncacn_packet_header(const struct ncacn_packet *pkt,
73 enum dcerpc_pkt_type ptype,
74 size_t max_auth_info,
75 uint8_t required_flags,
76 uint8_t optional_flags);
77 struct tevent_req *dcerpc_read_ncacn_packet_send(TALLOC_CTX *mem_ctx,
78 struct tevent_context *ev,
79 struct tstream_context *stream);
80 NTSTATUS dcerpc_read_ncacn_packet_recv(struct tevent_req *req,
81 TALLOC_CTX *mem_ctx,
82 struct ncacn_packet **pkt,
83 DATA_BLOB *buffer);
85 #endif