s4/drsblobs: Custom ndr_print_ implementation for drsuapi_MSPrefixMap_Entry
[Samba/fernandojvsilva.git] / librpc / ndr / ndr_drsblobs.c
blob741bf71191ed132e4a64379981dc4fbb726f53ea
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(ndr, r->current));
101 NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
103 if (r->previous) {
104 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous));
105 NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
108 return NDR_ERR_SUCCESS;
111 _PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r)
113 uint32_t _ptr_current;
114 TALLOC_CTX *_mem_save_current_0;
115 uint32_t _ptr_previous;
116 TALLOC_CTX *_mem_save_previous_0;
117 if (ndr_flags & NDR_SCALARS) {
118 NDR_CHECK(ndr_pull_align(ndr, 4));
119 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
120 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_current));
121 if (_ptr_current) {
122 NDR_PULL_ALLOC(ndr, r->current);
123 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->current, _ptr_current));
124 } else {
125 r->current = NULL;
127 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous));
128 if (_ptr_previous) {
129 NDR_PULL_ALLOC(ndr, r->previous);
130 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous, _ptr_previous));
131 } else {
132 r->previous = NULL;
135 if (ndr_flags & NDR_BUFFERS) {
136 if (r->current) {
137 uint32_t _relative_save_offset;
138 _relative_save_offset = ndr->offset;
139 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->current));
140 _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr);
141 NDR_PULL_SET_MEM_CTX(ndr, r->current, 0);
142 NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
143 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0);
144 ndr->offset = _relative_save_offset;
146 if (r->previous) {
147 uint32_t _relative_save_offset;
148 _relative_save_offset = ndr->offset;
149 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous));
150 _mem_save_previous_0 = NDR_PULL_GET_MEM_CTX(ndr);
151 NDR_PULL_SET_MEM_CTX(ndr, r->previous, 0);
152 NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
153 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_0, 0);
154 ndr->offset = _relative_save_offset;
157 return NDR_ERR_SUCCESS;
160 _PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r)
162 ndr_print_struct(ndr, name, "trustAuthInOutBlob");
163 ndr->depth++;
164 ndr_print_uint32(ndr, "count", r->count);
165 ndr_print_ptr(ndr, "current", r->current);
166 ndr->depth++;
167 if (r->current) {
168 ndr_print_AuthenticationInformationArray_with_count(ndr, "current", r->count, r->current);
170 ndr->depth--;
171 ndr_print_ptr(ndr, "previous", r->previous);
172 ndr->depth++;
173 if (r->previous) {
174 ndr_print_AuthenticationInformationArray_with_count(ndr, "previous", r->count, r->previous);
176 ndr->depth--;
177 ndr->depth--;
180 _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r)
182 if (ndr_flags & NDR_SCALARS) {
183 uint32_t offset;
184 NDR_PULL_ALIGN(ndr, 4);
185 NDR_PULL_NEED_BYTES(ndr, 8);
187 offset = ndr->offset;
188 ndr->offset = ndr->data_size - 8;
190 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
191 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
193 ndr->offset = offset;
194 NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512));
196 struct ndr_pull *_ndr_outgoing;
197 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
198 NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
199 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
202 struct ndr_pull *_ndr_incoming;
203 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
204 NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
205 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
207 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size));
208 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size));
210 if (ndr_flags & NDR_BUFFERS) {
212 return NDR_ERR_SUCCESS;
215 _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
217 ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
219 uint32_t _flags_save_STRUCT = ndr->flags;
220 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
221 ndr->depth++;
222 ndr_print_uint16(ndr, "entryID", r->entryID);
223 ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
224 if (r->binary_oid) {
225 char *partial_oid = NULL;
226 DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
227 char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
228 ber_read_partial_OID_String(ndr, oid_blob, (const char **)&partial_oid);
229 ndr->depth++;
230 ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
231 ndr->depth--;
232 talloc_free(hex_str);
233 talloc_free(partial_oid);
235 ndr->depth--;
236 ndr->flags = _flags_save_STRUCT;