s4:objectclass LDB module - change counter variabls to "unsigned" where appropriate
[Samba/cd1.git] / librpc / ndr / ndr_drsuapi.c
blobb91d5f7def59451753b9bfe969e1bbf5d1cbf9f5
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, (const char **)&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 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r)
91 if (ndr_flags & NDR_SCALARS) {
92 uint32_t decompressed_length = 0;
93 uint32_t compressed_length = 0;
94 if (r->ts) {
96 struct ndr_push *_ndr_ts;
97 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
99 struct ndr_push *_ndr_ts_compressed;
100 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
101 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
102 decompressed_length = _ndr_ts_compressed->offset;
103 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
105 compressed_length = _ndr_ts->offset;
106 talloc_free(_ndr_ts);
109 NDR_CHECK(ndr_push_align(ndr, 4));
110 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
111 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
112 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
114 if (ndr_flags & NDR_BUFFERS) {
115 if (r->ts) {
117 struct ndr_push *_ndr_ts;
118 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
120 struct ndr_push *_ndr_ts_compressed;
121 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
122 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
123 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
125 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
129 return NDR_ERR_SUCCESS;
132 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r)
134 if (ndr_flags & NDR_SCALARS) {
135 uint32_t decompressed_length = 0;
136 uint32_t compressed_length = 0;
137 if (r->ts) {
139 struct ndr_push *_ndr_ts;
140 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
142 struct ndr_push *_ndr_ts_compressed;
143 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
144 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
145 decompressed_length = _ndr_ts_compressed->offset;
146 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
148 compressed_length = _ndr_ts->offset;
149 talloc_free(_ndr_ts);
152 NDR_CHECK(ndr_push_align(ndr, 4));
153 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
154 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
155 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
157 if (ndr_flags & NDR_BUFFERS) {
158 if (r->ts) {
160 struct ndr_push *_ndr_ts;
161 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
163 struct ndr_push *_ndr_ts_compressed;
164 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
165 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
166 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1));
168 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
172 return NDR_ERR_SUCCESS;
175 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r)
177 if (ndr_flags & NDR_SCALARS) {
178 uint32_t decompressed_length = 0;
179 uint32_t compressed_length = 0;
180 if (r->ts) {
182 struct ndr_push *_ndr_ts;
183 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
185 struct ndr_push *_ndr_ts_compressed;
186 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
187 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
188 decompressed_length = _ndr_ts_compressed->offset;
189 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
191 compressed_length = _ndr_ts->offset;
192 talloc_free(_ndr_ts);
195 NDR_CHECK(ndr_push_align(ndr, 4));
196 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
197 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
198 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
200 if (ndr_flags & NDR_BUFFERS) {
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_XPRESS, -1));
208 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
209 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
211 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
215 return NDR_ERR_SUCCESS;
218 enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r)
220 if (ndr_flags & NDR_SCALARS) {
221 uint32_t decompressed_length = 0;
222 uint32_t compressed_length = 0;
223 if (r->ts) {
225 struct ndr_push *_ndr_ts;
226 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1));
228 struct ndr_push *_ndr_ts_compressed;
229 NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
230 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
231 decompressed_length = _ndr_ts_compressed->offset;
232 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
234 compressed_length = _ndr_ts->offset;
235 talloc_free(_ndr_ts);
238 NDR_CHECK(ndr_push_align(ndr, 4));
239 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length));
240 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length));
241 NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts));
243 if (ndr_flags & NDR_BUFFERS) {
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_XPRESS, -1));
251 NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts));
252 NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1));
254 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1));
258 return NDR_ERR_SUCCESS;
261 _PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags)
263 return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3, ic);