1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | helper routines for FRSRPC marshalling
|
---|
5 |
|
---|
6 | Copyright (C) Stefan (metze) Metzmacher 2009
|
---|
7 |
|
---|
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.
|
---|
12 |
|
---|
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.
|
---|
17 |
|
---|
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/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 | #include "librpc/gen_ndr/ndr_frsrpc.h"
|
---|
24 |
|
---|
25 | enum ndr_err_code ndr_push_frsrpc_CommPktChunkCtr(struct ndr_push *ndr,
|
---|
26 | int ndr_flags,
|
---|
27 | const struct frsrpc_CommPktChunkCtr *r)
|
---|
28 | {
|
---|
29 | uint32_t cntr_chunks_0;
|
---|
30 | {
|
---|
31 | uint32_t _flags_save_STRUCT = ndr->flags;
|
---|
32 | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
|
---|
33 | if (ndr_flags & NDR_SCALARS) {
|
---|
34 | NDR_CHECK(ndr_push_align(ndr, 2));
|
---|
35 | for (cntr_chunks_0 = 0; cntr_chunks_0 < r->num_chunks; cntr_chunks_0++) {
|
---|
36 | NDR_CHECK(ndr_push_frsrpc_CommPktChunk(ndr, NDR_SCALARS, &r->chunks[cntr_chunks_0]));
|
---|
37 | }
|
---|
38 | }
|
---|
39 | if (ndr_flags & NDR_BUFFERS) {
|
---|
40 | }
|
---|
41 | ndr->flags = _flags_save_STRUCT;
|
---|
42 | }
|
---|
43 | return NDR_ERR_SUCCESS;
|
---|
44 | }
|
---|
45 |
|
---|
46 | #define _TMP_PULL_REALLOC_N(ndr, s, t, n) do { \
|
---|
47 | _NDR_PULL_FIX_CURRENT_MEM_CTX(ndr);\
|
---|
48 | (s) = talloc_realloc(ndr->current_mem_ctx, (s), t, n); \
|
---|
49 | if (!(s)) { \
|
---|
50 | return ndr_pull_error(ndr, NDR_ERR_ALLOC, \
|
---|
51 | "Alloc %u * %s failed: %s\n", \
|
---|
52 | (unsigned)n, # s, __location__); \
|
---|
53 | } \
|
---|
54 | } while (0)
|
---|
55 |
|
---|
56 | enum ndr_err_code ndr_pull_frsrpc_CommPktChunkCtr(struct ndr_pull *ndr,
|
---|
57 | int ndr_flags,
|
---|
58 | struct frsrpc_CommPktChunkCtr *r)
|
---|
59 | {
|
---|
60 | uint32_t cntr_chunks_0;
|
---|
61 | {
|
---|
62 | uint32_t _flags_save_STRUCT = ndr->flags;
|
---|
63 | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
|
---|
64 | if (ndr_flags & NDR_SCALARS) {
|
---|
65 | uint32_t remaining = ndr->data_size - ndr->offset;
|
---|
66 | r->num_chunks = 0;
|
---|
67 | r->chunks = NULL;
|
---|
68 | for (cntr_chunks_0 = 0; remaining > 0; cntr_chunks_0++) {
|
---|
69 | r->num_chunks += 1;
|
---|
70 | _TMP_PULL_REALLOC_N(ndr, r->chunks,
|
---|
71 | struct frsrpc_CommPktChunk,
|
---|
72 | r->num_chunks);
|
---|
73 | NDR_CHECK(ndr_pull_frsrpc_CommPktChunk(ndr,
|
---|
74 | NDR_SCALARS,
|
---|
75 | &r->chunks[cntr_chunks_0]));
|
---|
76 | remaining = ndr->data_size - ndr->offset;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | if (ndr_flags & NDR_BUFFERS) {
|
---|
80 | }
|
---|
81 | ndr->flags = _flags_save_STRUCT;
|
---|
82 | }
|
---|
83 | return NDR_ERR_SUCCESS;
|
---|
84 | }
|
---|
85 |
|
---|
86 | size_t ndr_size_frsrpc_CommPktChunkCtr(const struct frsrpc_CommPktChunkCtr *r,
|
---|
87 | int flags)
|
---|
88 | {
|
---|
89 | flags |= LIBNDR_FLAG_NOALIGN;
|
---|
90 | return ndr_size_struct(r, flags,
|
---|
91 | (ndr_push_flags_fn_t)ndr_push_frsrpc_CommPktChunkCtr);
|
---|
92 | }
|
---|