build: waf update to fix macos build error
[Samba/gebeck_regimport.git] / librpc / ndr / ndr_drsblobs.c
blob9b55c5d5e1ebe871461f6d11f7d9b0bbdd906ae4
1 /*
2 Unix SMB/CIFS implementation.
4 Manually parsed structures found in the DRS protocol
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
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 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_drsblobs.h"
24 #include "../lib/util/asn1.h"
26 /* parser auto-generated by pidl, then hand-modified by abartlet */
28 /* Modified to have 'count' specified */
29 static enum ndr_err_code ndr_push_AuthenticationInformationArray_with_count(struct ndr_push *ndr, int ndr_flags, int count,
30 const struct AuthenticationInformationArray *r)
32 uint32_t cntr_array_0;
33 if (ndr_flags & NDR_SCALARS) {
34 NDR_CHECK(ndr_push_align(ndr, 4));
35 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
36 NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
39 if (ndr_flags & NDR_BUFFERS) {
40 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
41 NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0]));
44 return NDR_ERR_SUCCESS;
47 /* Modified to have 'count' specified, and to allocate the array */
48 static enum ndr_err_code ndr_pull_AuthenticationInformationArray_with_count(struct ndr_pull *ndr, int ndr_flags, int count, struct AuthenticationInformationArray *r)
50 uint32_t cntr_array_0;
51 TALLOC_CTX *_mem_save_array_0;
52 if (ndr_flags & NDR_SCALARS) {
53 NDR_CHECK(ndr_pull_align(ndr, 4));
54 NDR_PULL_ALLOC_N(ndr, r->array, count);
55 _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr);
56 NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
57 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
58 NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
60 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);
62 if (ndr_flags & NDR_BUFFERS) {
63 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
64 NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0]));
67 return NDR_ERR_SUCCESS;
70 /* Modified to have 'count' specified */
71 _PUBLIC_ void ndr_print_AuthenticationInformationArray_with_count(struct ndr_print *ndr, const char *name, int count, const struct AuthenticationInformationArray *r)
73 uint32_t cntr_array_0;
74 ndr_print_struct(ndr, name, "AuthenticationInformationArray");
75 ndr->depth++;
76 ndr->print(ndr, "%s: ARRAY(%d)", "array", (int)1);
77 ndr->depth++;
78 for (cntr_array_0=0;cntr_array_0<count;cntr_array_0++) {
79 char *idx_0=NULL;
80 if (asprintf(&idx_0, "[%d]", cntr_array_0) != -1) {
81 ndr_print_AuthenticationInformation(ndr, "array", &r->array[cntr_array_0]);
82 free(idx_0);
85 ndr->depth--;
86 ndr->depth--;
89 /* Modified to call AuthenticationInformationArray with 'count' specified */
90 _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r)
92 if (ndr_flags & NDR_SCALARS) {
93 NDR_CHECK(ndr_push_align(ndr, 4));
94 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
95 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->current));
96 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous));
98 if (ndr_flags & NDR_BUFFERS) {
99 if (r->current) {
100 NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->current));
101 NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
102 NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->current));
104 if (r->previous) {
105 NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->previous));
106 NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
107 NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->previous));
110 return NDR_ERR_SUCCESS;
113 _PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r)
115 uint32_t _ptr_current;
116 TALLOC_CTX *_mem_save_current_0;
117 uint32_t _ptr_previous;
118 TALLOC_CTX *_mem_save_previous_0;
119 if (ndr_flags & NDR_SCALARS) {
120 NDR_CHECK(ndr_pull_align(ndr, 4));
121 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
122 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_current));
123 if (_ptr_current) {
124 NDR_PULL_ALLOC(ndr, r->current);
125 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->current, _ptr_current));
126 } else {
127 r->current = NULL;
129 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous));
130 if (_ptr_previous) {
131 NDR_PULL_ALLOC(ndr, r->previous);
132 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous, _ptr_previous));
133 } else {
134 r->previous = NULL;
137 if (ndr_flags & NDR_BUFFERS) {
138 if (r->current) {
139 uint32_t _relative_save_offset;
140 _relative_save_offset = ndr->offset;
141 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->current));
142 _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr);
143 NDR_PULL_SET_MEM_CTX(ndr, r->current, 0);
144 NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
145 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0);
146 ndr->offset = _relative_save_offset;
148 if (r->previous) {
149 uint32_t _relative_save_offset;
150 _relative_save_offset = ndr->offset;
151 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous));
152 _mem_save_previous_0 = NDR_PULL_GET_MEM_CTX(ndr);
153 NDR_PULL_SET_MEM_CTX(ndr, r->previous, 0);
154 NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
155 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_0, 0);
156 ndr->offset = _relative_save_offset;
159 return NDR_ERR_SUCCESS;
162 _PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r)
164 ndr_print_struct(ndr, name, "trustAuthInOutBlob");
165 ndr->depth++;
166 ndr_print_uint32(ndr, "count", r->count);
167 ndr_print_ptr(ndr, "current", r->current);
168 ndr->depth++;
169 if (r->current) {
170 ndr_print_AuthenticationInformationArray_with_count(ndr, "current", r->count, r->current);
172 ndr->depth--;
173 ndr_print_ptr(ndr, "previous", r->previous);
174 ndr->depth++;
175 if (r->previous) {
176 ndr_print_AuthenticationInformationArray_with_count(ndr, "previous", r->count, r->previous);
178 ndr->depth--;
179 ndr->depth--;
182 _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r)
184 if (ndr_flags & NDR_SCALARS) {
185 uint32_t offset;
186 NDR_PULL_ALIGN(ndr, 4);
187 NDR_PULL_NEED_BYTES(ndr, 8);
189 offset = ndr->offset;
190 ndr->offset = ndr->data_size - 8;
192 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
193 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
195 ndr->offset = offset;
196 NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512));
198 struct ndr_pull *_ndr_outgoing;
199 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
200 NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
201 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
204 struct ndr_pull *_ndr_incoming;
205 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
206 NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
207 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
209 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
210 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
212 if (ndr_flags & NDR_BUFFERS) {
214 return NDR_ERR_SUCCESS;
217 _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
219 ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
221 uint32_t _flags_save_STRUCT = ndr->flags;
222 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
223 ndr->depth++;
224 ndr_print_uint16(ndr, "entryID", r->entryID);
225 ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
226 if (r->binary_oid) {
227 char *partial_oid = NULL;
228 DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
229 char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
230 ber_read_partial_OID_String(ndr, oid_blob, (const char **)&partial_oid);
231 ndr->depth++;
232 ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
233 ndr->depth--;
234 talloc_free(hex_str);
235 talloc_free(partial_oid);
237 ndr->depth--;
238 ndr->flags = _flags_save_STRUCT;