1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | routines for printing some linked list structs in DRSUAPI
|
---|
5 |
|
---|
6 | Copyright (C) Stefan (metze) Metzmacher 2005
|
---|
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 |
|
---|
23 | #include "includes.h"
|
---|
24 | #include "librpc/gen_ndr/ndr_drsuapi.h"
|
---|
25 | #include "librpc/gen_ndr/ndr_misc.h"
|
---|
26 | #include "../lib/util/asn1.h"
|
---|
27 | #include "librpc/ndr/ndr_compression.h"
|
---|
28 | /* We don't need multibyte if we're just comparing to 'ff' */
|
---|
29 | #undef strncasecmp
|
---|
30 |
|
---|
31 | void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name,
|
---|
32 | const struct drsuapi_DsReplicaObjectListItem *r)
|
---|
33 | {
|
---|
34 | ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItem");
|
---|
35 | ndr->depth++;
|
---|
36 | ndr_print_ptr(ndr, "next_object", r->next_object);
|
---|
37 | ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object);
|
---|
38 | ndr->depth--;
|
---|
39 | if (r->next_object) {
|
---|
40 | ndr_print_drsuapi_DsReplicaObjectListItem(ndr, "next_object", r->next_object);
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItemEx *r)
|
---|
45 | {
|
---|
46 | ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItemEx");
|
---|
47 | ndr->depth++;
|
---|
48 | ndr_print_ptr(ndr, "next_object", r->next_object);
|
---|
49 | ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object);
|
---|
50 | ndr_print_uint32(ndr, "is_nc_prefix", r->is_nc_prefix);
|
---|
51 | ndr_print_ptr(ndr, "parent_object_guid", r->parent_object_guid);
|
---|
52 | ndr->depth++;
|
---|
53 | if (r->parent_object_guid) {
|
---|
54 | ndr_print_GUID(ndr, "parent_object_guid", r->parent_object_guid);
|
---|
55 | }
|
---|
56 | ndr->depth--;
|
---|
57 | ndr_print_ptr(ndr, "meta_data_ctr", r->meta_data_ctr);
|
---|
58 | ndr->depth++;
|
---|
59 | if (r->meta_data_ctr) {
|
---|
60 | ndr_print_drsuapi_DsReplicaMetaDataCtr(ndr, "meta_data_ctr", r->meta_data_ctr);
|
---|
61 | }
|
---|
62 | ndr->depth--;
|
---|
63 | ndr->depth--;
|
---|
64 | if (r->next_object) {
|
---|
65 | ndr_print_drsuapi_DsReplicaObjectListItemEx(ndr, "next_object", r->next_object);
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | #define _OID_PUSH_CHECK(call) do { \
|
---|
70 | bool _status; \
|
---|
71 | _status = call; \
|
---|
72 | if (_status != true) { \
|
---|
73 | return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
|
---|
74 | } \
|
---|
75 | } while (0)
|
---|
76 |
|
---|
77 | #define _OID_PULL_CHECK(call) do { \
|
---|
78 | bool _status; \
|
---|
79 | _status = call; \
|
---|
80 | if (_status != true) { \
|
---|
81 | return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
|
---|
82 | } \
|
---|
83 | } while (0)
|
---|
84 |
|
---|
85 | enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r)
|
---|
86 | {
|
---|
87 | if (ndr_flags & NDR_SCALARS) {
|
---|
88 | NDR_CHECK(ndr_push_align(ndr, 4));
|
---|
89 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0)));
|
---|
90 | NDR_CHECK(ndr_push_unique_ptr(ndr, r->oid));
|
---|
91 | }
|
---|
92 | if (ndr_flags & NDR_BUFFERS) {
|
---|
93 | if (r->oid) {
|
---|
94 | DATA_BLOB blob;
|
---|
95 |
|
---|
96 | if (strncasecmp("ff", r->oid, 2) == 0) {
|
---|
97 | blob = strhex_to_data_blob(ndr, r->oid);
|
---|
98 | if (!blob.data) {
|
---|
99 | return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT,
|
---|
100 | "HEX String Conversion Error: %s\n",
|
---|
101 | __location__);
|
---|
102 | }
|
---|
103 | } else {
|
---|
104 | _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid));
|
---|
105 | talloc_steal(ndr, blob.data);
|
---|
106 | }
|
---|
107 |
|
---|
108 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length));
|
---|
109 | NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length));
|
---|
110 | }
|
---|
111 | }
|
---|
112 | return NDR_ERR_SUCCESS;
|
---|
113 | }
|
---|
114 |
|
---|
115 | enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r)
|
---|
116 | {
|
---|
117 | uint32_t _ptr_oid;
|
---|
118 | TALLOC_CTX *_mem_save_oid_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->__ndr_size));
|
---|
122 | if (r->__ndr_size < 0 || r->__ndr_size > 10000) {
|
---|
123 | return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
|
---|
124 | }
|
---|
125 | NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_oid));
|
---|
126 | if (_ptr_oid) {
|
---|
127 | NDR_PULL_ALLOC(ndr, r->oid);
|
---|
128 | } else {
|
---|
129 | r->oid = NULL;
|
---|
130 | }
|
---|
131 | }
|
---|
132 | if (ndr_flags & NDR_BUFFERS) {
|
---|
133 | if (r->oid) {
|
---|
134 | DATA_BLOB _oid_array;
|
---|
135 | const char *_oid;
|
---|
136 |
|
---|
137 | _mem_save_oid_0 = NDR_PULL_GET_MEM_CTX(ndr);
|
---|
138 | NDR_PULL_SET_MEM_CTX(ndr, ndr, 0);
|
---|
139 | NDR_CHECK(ndr_pull_array_size(ndr, &r->oid));
|
---|
140 | _oid_array.length = ndr_get_array_size(ndr, &r->oid);
|
---|
141 | NDR_PULL_ALLOC_N(ndr, _oid_array.data, _oid_array.length);
|
---|
142 | NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, _oid_array.data, _oid_array.length));
|
---|
143 | NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oid_0, 0);
|
---|
144 |
|
---|
145 | if (_oid_array.length && _oid_array.data[0] == 0xFF) {
|
---|
146 | _oid = data_blob_hex_string(ndr, &_oid_array);
|
---|
147 | NDR_ERR_HAVE_NO_MEMORY(_oid);
|
---|
148 | } else {
|
---|
149 | _OID_PULL_CHECK(ber_read_OID_String(ndr, _oid_array, &_oid));
|
---|
150 | }
|
---|
151 | data_blob_free(&_oid_array);
|
---|
152 | talloc_steal(r->oid, _oid);
|
---|
153 | r->oid = _oid;
|
---|
154 | }
|
---|
155 | if (r->oid) {
|
---|
156 | NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->oid, r->__ndr_size));
|
---|
157 | }
|
---|
158 | }
|
---|
159 | return NDR_ERR_SUCCESS;
|
---|
160 | }
|
---|
161 |
|
---|
162 | size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags)
|
---|
163 | {
|
---|
164 | DATA_BLOB _blob;
|
---|
165 | size_t ret = 0;
|
---|
166 |
|
---|
167 | if (!oid) return 0;
|
---|
168 |
|
---|
169 | if (strncasecmp("ff", oid, 2) == 0) {
|
---|
170 | _blob = strhex_to_data_blob(NULL, oid);
|
---|
171 | if (_blob.data) {
|
---|
172 | ret = _blob.length;
|
---|
173 | }
|
---|
174 | } else {
|
---|
175 | if (ber_write_OID_String(&_blob, oid)) {
|
---|
176 | ret = _blob.length;
|
---|
177 | }
|
---|
178 | }
|
---|
179 | data_blob_free(&_blob);
|
---|
180 | return ret;
|
---|
181 | }
|
---|
182 |
|
---|
183 | enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r)
|
---|
184 | {
|
---|
185 | if (ndr_flags & NDR_SCALARS) {
|
---|
186 | uint32_t decompressed_length = 0;
|
---|
187 | uint32_t compressed_length = 0;
|
---|
188 | if (r->ts) {
|
---|
189 | {
|
---|
190 | struct ndr_push *_ndr_ts;
|
---|
191 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
192 | {
|
---|
193 | struct ndr_push *_ndr_ts_compressed;
|
---|
194 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
195 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
196 | decompressed_length = _ndr_ts_compressed->offset;
|
---|
197 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
198 | }
|
---|
199 | compressed_length = _ndr_ts->offset;
|
---|
200 | talloc_free(_ndr_ts);
|
---|
201 | }
|
---|
202 | }
|
---|
203 | NDR_CHECK(ndr_push_align(ndr, 4));
|
---|
204 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
|
---|
205 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
|
---|
206 | NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
|
---|
207 | }
|
---|
208 | if (ndr_flags & NDR_BUFFERS) {
|
---|
209 | if (r->ts) {
|
---|
210 | {
|
---|
211 | struct ndr_push *_ndr_ts;
|
---|
212 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
213 | {
|
---|
214 | struct ndr_push *_ndr_ts_compressed;
|
---|
215 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
216 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
217 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
218 | }
|
---|
219 | NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
|
---|
220 | }
|
---|
221 | }
|
---|
222 | }
|
---|
223 | return NDR_ERR_SUCCESS;
|
---|
224 | }
|
---|
225 |
|
---|
226 | enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r)
|
---|
227 | {
|
---|
228 | if (ndr_flags & NDR_SCALARS) {
|
---|
229 | uint32_t decompressed_length = 0;
|
---|
230 | uint32_t compressed_length = 0;
|
---|
231 | if (r->ts) {
|
---|
232 | {
|
---|
233 | struct ndr_push *_ndr_ts;
|
---|
234 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
235 | {
|
---|
236 | struct ndr_push *_ndr_ts_compressed;
|
---|
237 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
238 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
239 | decompressed_length = _ndr_ts_compressed->offset;
|
---|
240 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
241 | }
|
---|
242 | compressed_length = _ndr_ts->offset;
|
---|
243 | talloc_free(_ndr_ts);
|
---|
244 | }
|
---|
245 | }
|
---|
246 | NDR_CHECK(ndr_push_align(ndr, 4));
|
---|
247 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
|
---|
248 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
|
---|
249 | NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
|
---|
250 | }
|
---|
251 | if (ndr_flags & NDR_BUFFERS) {
|
---|
252 | if (r->ts) {
|
---|
253 | {
|
---|
254 | struct ndr_push *_ndr_ts;
|
---|
255 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
256 | {
|
---|
257 | struct ndr_push *_ndr_ts_compressed;
|
---|
258 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
259 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
260 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
|
---|
261 | }
|
---|
262 | NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
|
---|
263 | }
|
---|
264 | }
|
---|
265 | }
|
---|
266 | return NDR_ERR_SUCCESS;
|
---|
267 | }
|
---|
268 |
|
---|
269 | enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r)
|
---|
270 | {
|
---|
271 | if (ndr_flags & NDR_SCALARS) {
|
---|
272 | uint32_t decompressed_length = 0;
|
---|
273 | uint32_t compressed_length = 0;
|
---|
274 | if (r->ts) {
|
---|
275 | {
|
---|
276 | struct ndr_push *_ndr_ts;
|
---|
277 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
278 | {
|
---|
279 | struct ndr_push *_ndr_ts_compressed;
|
---|
280 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
281 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
282 | decompressed_length = _ndr_ts_compressed->offset;
|
---|
283 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
284 | }
|
---|
285 | compressed_length = _ndr_ts->offset;
|
---|
286 | talloc_free(_ndr_ts);
|
---|
287 | }
|
---|
288 | }
|
---|
289 | NDR_CHECK(ndr_push_align(ndr, 4));
|
---|
290 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
|
---|
291 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
|
---|
292 | NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
|
---|
293 | }
|
---|
294 | if (ndr_flags & NDR_BUFFERS) {
|
---|
295 | if (r->ts) {
|
---|
296 | {
|
---|
297 | struct ndr_push *_ndr_ts;
|
---|
298 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
299 | {
|
---|
300 | struct ndr_push *_ndr_ts_compressed;
|
---|
301 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
302 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
303 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
304 | }
|
---|
305 | NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
|
---|
306 | }
|
---|
307 | }
|
---|
308 | }
|
---|
309 | return NDR_ERR_SUCCESS;
|
---|
310 | }
|
---|
311 |
|
---|
312 | enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r)
|
---|
313 | {
|
---|
314 | if (ndr_flags & NDR_SCALARS) {
|
---|
315 | uint32_t decompressed_length = 0;
|
---|
316 | uint32_t compressed_length = 0;
|
---|
317 | if (r->ts) {
|
---|
318 | {
|
---|
319 | struct ndr_push *_ndr_ts;
|
---|
320 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
321 | {
|
---|
322 | struct ndr_push *_ndr_ts_compressed;
|
---|
323 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
324 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
325 | decompressed_length = _ndr_ts_compressed->offset;
|
---|
326 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
327 | }
|
---|
328 | compressed_length = _ndr_ts->offset;
|
---|
329 | talloc_free(_ndr_ts);
|
---|
330 | }
|
---|
331 | }
|
---|
332 | NDR_CHECK(ndr_push_align(ndr, 4));
|
---|
333 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
|
---|
334 | NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
|
---|
335 | NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
|
---|
336 | }
|
---|
337 | if (ndr_flags & NDR_BUFFERS) {
|
---|
338 | if (r->ts) {
|
---|
339 | {
|
---|
340 | struct ndr_push *_ndr_ts;
|
---|
341 | NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
|
---|
342 | {
|
---|
343 | struct ndr_push *_ndr_ts_compressed;
|
---|
344 | NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
345 | NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
|
---|
346 | NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
|
---|
347 | }
|
---|
348 | NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
|
---|
349 | }
|
---|
350 | }
|
---|
351 | }
|
---|
352 | return NDR_ERR_SUCCESS;
|
---|
353 | }
|
---|
354 |
|
---|
355 | _PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags)
|
---|
356 | {
|
---|
357 | return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3, ic);
|
---|
358 | }
|
---|
359 |
|
---|