2 Unix SMB/CIFS implementation.
4 routines for marshalling/unmarshalling witness structures
6 Copyright (C) Guenther Deschner 2015
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/>.
23 #include "librpc/gen_ndr/ndr_witness.h"
25 _PUBLIC_
enum ndr_err_code
ndr_push_witness_notifyResponse(struct ndr_push
*ndr
, int ndr_flags
, const struct witness_notifyResponse
*r
)
27 uint32_t cntr_messages_0
;
29 uint32_t _flags_save_STRUCT
= ndr
->flags
;
30 ndr_set_flags(&ndr
->flags
, LIBNDR_PRINT_ARRAY_HEX
);
31 NDR_PUSH_CHECK_FLAGS(ndr
, ndr_flags
);
32 if (ndr_flags
& NDR_SCALARS
) {
33 NDR_CHECK(ndr_push_align(ndr
, 4));
34 NDR_CHECK(ndr_push_witness_notifyResponse_type(ndr
, NDR_SCALARS
, r
->type
));
35 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, ndr_size_witness_notifyResponse(r
, ndr
->flags
) - 20));
36 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->num
));
37 NDR_CHECK(ndr_push_unique_ptr(ndr
, r
->messages
));
39 uint32_t _flags_save_witness_notifyResponse_message
= ndr
->flags
;
40 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
);
42 struct ndr_push
*_ndr_messages
;
43 NDR_CHECK(ndr_push_subcontext_start(ndr
, &_ndr_messages
, 4, ndr_size_witness_notifyResponse(r
, ndr
->flags
) - 20));
44 for (cntr_messages_0
= 0; cntr_messages_0
< (r
->num
); cntr_messages_0
++) {
45 NDR_CHECK(ndr_push_set_switch_value(_ndr_messages
, &r
->messages
[cntr_messages_0
], r
->type
));
46 NDR_CHECK(ndr_push_witness_notifyResponse_message(_ndr_messages
, NDR_SCALARS
, &r
->messages
[cntr_messages_0
]));
48 NDR_CHECK(ndr_push_subcontext_end(ndr
, _ndr_messages
, 4, ndr_size_witness_notifyResponse(r
, ndr
->flags
) - 20));
50 ndr
->flags
= _flags_save_witness_notifyResponse_message
;
52 NDR_CHECK(ndr_push_trailer_align(ndr
, 4));
54 if (ndr_flags
& NDR_BUFFERS
) {
56 ndr
->flags
= _flags_save_STRUCT
;
58 return NDR_ERR_SUCCESS
;
61 _PUBLIC_
enum ndr_err_code
ndr_pull_witness_notifyResponse(struct ndr_pull
*ndr
, int ndr_flags
, struct witness_notifyResponse
*r
)
63 uint32_t _flags_save_STRUCT
= ndr
->flags
;
64 ndr_set_flags(&ndr
->flags
, LIBNDR_PRINT_ARRAY_HEX
);
65 NDR_PULL_CHECK_FLAGS(ndr
, ndr_flags
);
66 if (ndr_flags
& NDR_SCALARS
) {
67 NDR_CHECK(ndr_pull_align(ndr
, 4));
68 NDR_CHECK(ndr_pull_witness_notifyResponse_type(ndr
, NDR_SCALARS
, &r
->type
));
69 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->length
));
70 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->num
));
72 uint32_t _flags_save_witness_notifyResponse_message
= ndr
->flags
;
73 uint32_t _ptr_messages
;
74 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
);
75 NDR_CHECK(ndr_pull_generic_ptr(ndr
, &_ptr_messages
));
77 NDR_PULL_ALLOC(ndr
, r
->messages
);
82 uint32_t size_messages_0
= 0;
83 uint32_t cntr_messages_0
;
84 TALLOC_CTX
*_mem_save_messages_0
;
86 size_messages_0
= r
->num
;
87 NDR_PULL_ALLOC_N(ndr
, r
->messages
, size_messages_0
);
88 _mem_save_messages_0
= NDR_PULL_GET_MEM_CTX(ndr
);
89 NDR_PULL_SET_MEM_CTX(ndr
, r
->messages
, 0);
91 struct ndr_pull
*_ndr_messages
;
92 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_messages
, 4, r
->length
));
93 for (cntr_messages_0
= 0; cntr_messages_0
< (size_messages_0
); cntr_messages_0
++) {
94 NDR_CHECK(ndr_pull_set_switch_value(_ndr_messages
, &r
->messages
[cntr_messages_0
], r
->type
));
95 NDR_CHECK(ndr_pull_witness_notifyResponse_message(_ndr_messages
, NDR_SCALARS
, &r
->messages
[cntr_messages_0
]));
97 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_messages
, 4, r
->length
));
99 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_messages_0
, 0);
101 ndr
->flags
= _flags_save_witness_notifyResponse_message
;
103 NDR_CHECK(ndr_pull_trailer_align(ndr
, 4));
105 if (ndr_flags
& NDR_BUFFERS
) {
107 ndr
->flags
= _flags_save_STRUCT
;
109 return NDR_ERR_SUCCESS
;