s3:auth: Fix typo in debug message.
[Samba/gebeck_regimport.git] / librpc / ndr / ndr_drsuapi.c
blob17f2b7e2ed2b9f7f3a4929ee476f22db00a788bc
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 #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)
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)
85 _PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
87 ndr_print_struct(ndr, name, "drsuapi_DsReplicaOID");
88 ndr->depth++;
89 ndr_print_uint32(ndr, "length", r->length);
90 ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
91 if (r->binary_oid) {
92 char *partial_oid = NULL;
93 DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
94 char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
95 ber_read_partial_OID_String(ndr, oid_blob, (const char **)&partial_oid);
96 ndr->depth++;
97 ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
98 ndr->depth--;
99 talloc_free(hex_str);
100 talloc_free(partial_oid);
102 ndr->depth--;
105 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r)
107 if (ndr_flags & NDR_SCALARS) {
108 uint32_t decompressed_length = 0;
109 uint32_t compressed_length = 0;
110 if (r->ts) {
112 struct ndr_push *_ndr_ts;
113 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
115 struct ndr_push *_ndr_ts_compressed;
116 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
117 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
118 decompressed_length = _ndr_ts_compressed->offset;
119 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
121 compressed_length = _ndr_ts->offset;
122 talloc_free(_ndr_ts);
125 NDR_CHECK(ndr_push_align(ndr, 4));
126 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
127 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
128 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
130 if (ndr_flags & NDR_BUFFERS) {
131 if (r->ts) {
133 struct ndr_push *_ndr_ts;
134 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
136 struct ndr_push *_ndr_ts_compressed;
137 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
138 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
139 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
141 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
145 return NDR_ERR_SUCCESS;
148 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r)
150 if (ndr_flags & NDR_SCALARS) {
151 uint32_t decompressed_length = 0;
152 uint32_t compressed_length = 0;
153 if (r->ts) {
155 struct ndr_push *_ndr_ts;
156 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
158 struct ndr_push *_ndr_ts_compressed;
159 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
160 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
161 decompressed_length = _ndr_ts_compressed->offset;
162 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
164 compressed_length = _ndr_ts->offset;
165 talloc_free(_ndr_ts);
168 NDR_CHECK(ndr_push_align(ndr, 4));
169 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
170 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
171 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
173 if (ndr_flags & NDR_BUFFERS) {
174 if (r->ts) {
176 struct ndr_push *_ndr_ts;
177 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
179 struct ndr_push *_ndr_ts_compressed;
180 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
181 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
182 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
184 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
188 return NDR_ERR_SUCCESS;
191 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r)
193 if (ndr_flags & NDR_SCALARS) {
194 uint32_t decompressed_length = 0;
195 uint32_t compressed_length = 0;
196 if (r->ts) {
198 struct ndr_push *_ndr_ts;
199 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
201 struct ndr_push *_ndr_ts_compressed;
202 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
203 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
204 decompressed_length = _ndr_ts_compressed->offset;
205 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
207 compressed_length = _ndr_ts->offset;
208 talloc_free(_ndr_ts);
211 NDR_CHECK(ndr_push_align(ndr, 4));
212 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
213 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
214 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
216 if (ndr_flags & NDR_BUFFERS) {
217 if (r->ts) {
219 struct ndr_push *_ndr_ts;
220 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
222 struct ndr_push *_ndr_ts_compressed;
223 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
224 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
225 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
227 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
231 return NDR_ERR_SUCCESS;
234 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r)
236 if (ndr_flags & NDR_SCALARS) {
237 uint32_t decompressed_length = 0;
238 uint32_t compressed_length = 0;
239 if (r->ts) {
241 struct ndr_push *_ndr_ts;
242 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
244 struct ndr_push *_ndr_ts_compressed;
245 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
246 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
247 decompressed_length = _ndr_ts_compressed->offset;
248 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
250 compressed_length = _ndr_ts->offset;
251 talloc_free(_ndr_ts);
254 NDR_CHECK(ndr_push_align(ndr, 4));
255 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
256 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
257 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
259 if (ndr_flags & NDR_BUFFERS) {
260 if (r->ts) {
262 struct ndr_push *_ndr_ts;
263 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
265 struct ndr_push *_ndr_ts_compressed;
266 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
267 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
268 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
270 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
274 return NDR_ERR_SUCCESS;
277 _PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags)
279 return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3, ic);