configure: Fix bug 9546, aio_suspend detection on FreeBSD
[Samba.git] / librpc / ndr / ndr_drsuapi.c
blob86ecdcb86161ae5bfb8186c1e23b9e16f6b6194b
1 /*
2 Unix SMB/CIFS implementation.
4 routines for printing some linked list structs in DRSUAPI
6 Copyright (C) Stefan (metze) Metzmacher 2005
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 "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
31 void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name,
32 const struct drsuapi_DsReplicaObjectListItem *r)
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);
44 void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItemEx *r)
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);
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);
62 ndr->depth--;
63 ndr->depth--;
64 if (r->next_object) {
65 ndr_print_drsuapi_DsReplicaObjectListItemEx(ndr, "next_object", r->next_object);
69 _PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
71 ndr_print_struct(ndr, name, "drsuapi_DsReplicaOID");
72 ndr->depth++;
73 ndr_print_uint32(ndr, "length", r->length);
74 ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
75 if (r->binary_oid) {
76 char *partial_oid = NULL;
77 DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
78 char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
79 ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
80 ndr->depth++;
81 ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
82 ndr->depth--;
83 talloc_free(hex_str);
84 talloc_free(partial_oid);
86 ndr->depth--;
89 static void _print_drsuapi_DsAttributeValue_attid(struct ndr_print *ndr, const char *name,
90 const struct drsuapi_DsAttributeValue *r)
92 uint32_t v;
94 ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue");
95 ndr->depth++;
96 v = IVAL(r->blob->data, 0);
97 ndr_print_uint32(ndr, "attid", v);
98 ndr->depth--;
101 static void _print_drsuapi_DsAttributeValue_str(struct ndr_print *ndr, const char *name,
102 const struct drsuapi_DsAttributeValue *r)
104 char *str;
106 ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue");
107 ndr->depth++;
108 if (!convert_string_talloc(ndr,
109 CH_UTF16, CH_UNIX,
110 r->blob->data,
111 r->blob->length,
112 (void **)&str, NULL, false)) {
113 ndr_print_string(ndr, "string", "INVALID CONVERSION");
114 } else {
115 ndr_print_string(ndr, "string", str);
116 talloc_free(str);
118 ndr->depth--;
121 static void _print_drsuapi_DsAttributeValueCtr(struct ndr_print *ndr,
122 const char *name,
123 const struct drsuapi_DsAttributeValueCtr *r,
124 void (*print_val_fn)(struct ndr_print *ndr, const char *name, const struct drsuapi_DsAttributeValue *r))
126 uint32_t cntr_values_1;
127 ndr_print_struct(ndr, name, "drsuapi_DsAttributeValueCtr");
128 ndr->depth++;
129 ndr_print_uint32(ndr, "num_values", r->num_values);
130 ndr_print_ptr(ndr, "values", r->values);
131 ndr->depth++;
132 if (r->values) {
133 ndr->print(ndr, "%s: ARRAY(%d)", "values", (int)r->num_values);
134 ndr->depth++;
135 for (cntr_values_1=0;cntr_values_1<r->num_values;cntr_values_1++) {
136 char *idx_1=NULL;
137 if (asprintf(&idx_1, "[%d]", cntr_values_1) != -1) {
138 //ndr_print_drsuapi_DsAttributeValue(ndr, "values", &r->values[cntr_values_1]);
139 print_val_fn(ndr, "values", &r->values[cntr_values_1]);
140 free(idx_1);
143 ndr->depth--;
145 ndr->depth--;
146 ndr->depth--;
149 _PUBLIC_ void ndr_print_drsuapi_DsReplicaAttribute(struct ndr_print *ndr,
150 const char *name,
151 const struct drsuapi_DsReplicaAttribute *r)
153 ndr_print_struct(ndr, name, "drsuapi_DsReplicaAttribute");
154 ndr->depth++;
155 ndr_print_drsuapi_DsAttributeId(ndr, "attid", r->attid);
156 switch (r->attid) {
157 case DRSUAPI_ATTID_objectClass:
158 case DRSUAPI_ATTID_possSuperiors:
159 case DRSUAPI_ATTID_subClassOf:
160 case DRSUAPI_ATTID_governsID:
161 case DRSUAPI_ATTID_mustContain:
162 case DRSUAPI_ATTID_mayContain:
163 case DRSUAPI_ATTID_rDNAttId:
164 case DRSUAPI_ATTID_attributeID:
165 case DRSUAPI_ATTID_attributeSyntax:
166 case DRSUAPI_ATTID_auxiliaryClass:
167 case DRSUAPI_ATTID_systemPossSuperiors:
168 case DRSUAPI_ATTID_systemMayContain:
169 case DRSUAPI_ATTID_systemMustContain:
170 case DRSUAPI_ATTID_systemAuxiliaryClass:
171 case DRSUAPI_ATTID_transportAddressAttribute:
172 /* ATTIDs for classSchema and attributeSchema */
173 _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
174 _print_drsuapi_DsAttributeValue_attid);
175 break;
176 case DRSUAPI_ATTID_cn:
177 case DRSUAPI_ATTID_ou:
178 case DRSUAPI_ATTID_description:
179 case DRSUAPI_ATTID_displayName:
180 case DRSUAPI_ATTID_dMDLocation:
181 case DRSUAPI_ATTID_adminDisplayName:
182 case DRSUAPI_ATTID_adminDescription:
183 case DRSUAPI_ATTID_lDAPDisplayName:
184 case DRSUAPI_ATTID_name:
185 _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
186 _print_drsuapi_DsAttributeValue_str);
187 break;
188 default:
189 _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
190 ndr_print_drsuapi_DsAttributeValue);
191 break;
193 ndr->depth--;
196 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r)
198 if (ndr_flags & NDR_SCALARS) {
199 uint32_t decompressed_length = 0;
200 uint32_t compressed_length = 0;
201 if (r->ts) {
203 struct ndr_push *_ndr_ts;
204 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
206 struct ndr_push *_ndr_ts_compressed;
207 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
208 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
209 decompressed_length = _ndr_ts_compressed->offset;
210 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
212 compressed_length = _ndr_ts->offset;
213 talloc_free(_ndr_ts);
216 NDR_CHECK(ndr_push_align(ndr, 4));
217 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
218 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
219 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
221 if (ndr_flags & NDR_BUFFERS) {
222 if (r->ts) {
224 struct ndr_push *_ndr_ts;
225 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
227 struct ndr_push *_ndr_ts_compressed;
228 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
229 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
230 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
232 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
236 return NDR_ERR_SUCCESS;
239 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r)
241 if (ndr_flags & NDR_SCALARS) {
242 uint32_t decompressed_length = 0;
243 uint32_t compressed_length = 0;
244 if (r->ts) {
246 struct ndr_push *_ndr_ts;
247 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
249 struct ndr_push *_ndr_ts_compressed;
250 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
251 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
252 decompressed_length = _ndr_ts_compressed->offset;
253 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
255 compressed_length = _ndr_ts->offset;
256 talloc_free(_ndr_ts);
259 NDR_CHECK(ndr_push_align(ndr, 4));
260 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
261 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
262 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
264 if (ndr_flags & NDR_BUFFERS) {
265 if (r->ts) {
267 struct ndr_push *_ndr_ts;
268 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
270 struct ndr_push *_ndr_ts_compressed;
271 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
272 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
273 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
275 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
279 return NDR_ERR_SUCCESS;
282 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r)
284 if (ndr_flags & NDR_SCALARS) {
285 uint32_t decompressed_length = 0;
286 uint32_t compressed_length = 0;
287 if (r->ts) {
289 struct ndr_push *_ndr_ts;
290 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
292 struct ndr_push *_ndr_ts_compressed;
293 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
294 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
295 decompressed_length = _ndr_ts_compressed->offset;
296 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
298 compressed_length = _ndr_ts->offset;
299 talloc_free(_ndr_ts);
302 NDR_CHECK(ndr_push_align(ndr, 4));
303 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
304 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
305 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
307 if (ndr_flags & NDR_BUFFERS) {
308 if (r->ts) {
310 struct ndr_push *_ndr_ts;
311 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
313 struct ndr_push *_ndr_ts_compressed;
314 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
315 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
316 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
318 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
322 return NDR_ERR_SUCCESS;
325 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r)
327 if (ndr_flags & NDR_SCALARS) {
328 uint32_t decompressed_length = 0;
329 uint32_t compressed_length = 0;
330 if (r->ts) {
332 struct ndr_push *_ndr_ts;
333 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
335 struct ndr_push *_ndr_ts_compressed;
336 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
337 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
338 decompressed_length = _ndr_ts_compressed->offset;
339 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
341 compressed_length = _ndr_ts->offset;
342 talloc_free(_ndr_ts);
345 NDR_CHECK(ndr_push_align(ndr, 4));
346 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
347 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
348 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
350 if (ndr_flags & NDR_BUFFERS) {
351 if (r->ts) {
353 struct ndr_push *_ndr_ts;
354 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
356 struct ndr_push *_ndr_ts_compressed;
357 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
358 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
359 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
361 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
365 return NDR_ERR_SUCCESS;
368 _PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, int flags)
370 return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3);
373 _PUBLIC_ void ndr_print_drsuapi_SecBufferType(struct ndr_print *ndr, const char *name, enum drsuapi_SecBufferType r)
375 const char *val = NULL;
377 switch (r & 0x00000007) {
378 case DRSUAPI_SECBUFFER_EMPTY: val = "DRSUAPI_SECBUFFER_EMPTY"; break;
379 case DRSUAPI_SECBUFFER_DATA: val = "DRSUAPI_SECBUFFER_DATA"; break;
380 case DRSUAPI_SECBUFFER_TOKEN: val = "DRSUAPI_SECBUFFER_TOKEN"; break;
381 case DRSUAPI_SECBUFFER_PKG_PARAMS: val = "DRSUAPI_SECBUFFER_PKG_PARAMS"; break;
382 case DRSUAPI_SECBUFFER_MISSING: val = "DRSUAPI_SECBUFFER_MISSING"; break;
383 case DRSUAPI_SECBUFFER_EXTRA: val = "DRSUAPI_SECBUFFER_EXTRA"; break;
384 case DRSUAPI_SECBUFFER_STREAM_TRAILER: val = "DRSUAPI_SECBUFFER_STREAM_TRAILER"; break;
385 case DRSUAPI_SECBUFFER_STREAM_HEADER: val = "DRSUAPI_SECBUFFER_STREAM_HEADER"; break;
388 if (r & DRSUAPI_SECBUFFER_READONLY) {
389 char *v = talloc_asprintf(ndr, "DRSUAPI_SECBUFFER_READONLY | %s", val);
390 ndr_print_enum(ndr, name, "ENUM", v, r);
391 } else {
392 ndr_print_enum(ndr, name, "ENUM", val, r);
396 _PUBLIC_ void ndr_print_drsuapi_DsAddEntry_AttrErrListItem_V1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsAddEntry_AttrErrListItem_V1 *r)
398 ndr_print_struct(ndr, name, "drsuapi_DsAddEntry_AttrErrListItem_V1");
399 ndr->depth++;
400 ndr_print_ptr(ndr, "next", r->next);
401 ndr_print_drsuapi_DsAddEntry_AttrErr_V1(ndr, "err_data", &r->err_data);
402 ndr->depth--;
403 if (r->next) {
404 ndr_print_drsuapi_DsAddEntry_AttrErrListItem_V1(ndr, "next", r->next);