2 OpenChange implementation.
6 Copyright (C) Julien Kerihuel 2005-2009
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 <libmapi/libmapi.h>
24 #include <gen_ndr/ndr_exchange.h>
27 static void obfuscate_data(uint8_t *data
, uint32_t size
, uint8_t salt
)
31 for (i
=0; i
<size
; i
++) {
36 ssize_t
lzxpress_decompress(const uint8_t *input
,
39 uint32_t max_output_size
);
41 static enum ndr_err_code
ndr_pull_lxpress_chunk(struct ndr_pull
*ndrpull
,
42 struct ndr_push
*ndrpush
,
43 ssize_t decompressed_len
)
46 DATA_BLOB plain_chunk
;
49 /* Step 1. Retrieve the compressed buf */
50 comp_chunk
.length
= ndrpull
->data_size
;
51 comp_chunk
.data
= ndrpull
->data
;
53 plain_chunk
.length
= decompressed_len
;
54 plain_chunk
.data
= ndrpush
->data
;
56 ret
= lzxpress_decompress(comp_chunk
.data
,
61 return ndr_pull_error(ndrpull
, NDR_ERR_COMPRESSION
,
62 "XPRESS lzxpress_decompress() returned %d\n",
65 plain_chunk
.length
= ret
;
66 ndrpush
->offset
= ret
;
68 return NDR_ERR_SUCCESS
;
71 static enum ndr_err_code
ndr_pull_lzxpress_decompress(struct ndr_pull
*subndr
,
72 struct ndr_pull
**_comndr
,
73 ssize_t decompressed_len
)
75 struct ndr_push
*ndrpush
;
76 struct ndr_pull
*comndr
;
77 DATA_BLOB uncompressed
;
79 ndrpush
= ndr_push_init_ctx(subndr
, subndr
->iconv_convenience
);
80 NDR_ERR_HAVE_NO_MEMORY(ndrpush
);
82 NDR_CHECK(ndr_pull_lxpress_chunk(subndr
, ndrpush
, decompressed_len
));
84 uncompressed
= ndr_push_blob(ndrpush
);
85 if (uncompressed
.length
!= decompressed_len
) {
86 return ndr_pull_error(subndr
, NDR_ERR_COMPRESSION
,
87 "Bad uncompressed_len [%u] != [%u](0x%08X) (PULL)",
88 (int)uncompressed
.length
,
89 (int)decompressed_len
,
90 (int)decompressed_len
);
93 comndr
= talloc_zero(subndr
, struct ndr_pull
);
94 NDR_ERR_HAVE_NO_MEMORY(comndr
);
95 comndr
->flags
= subndr
->flags
;
96 comndr
->current_mem_ctx
= subndr
->current_mem_ctx
;
97 comndr
->data
= uncompressed
.data
;
98 comndr
->data_size
= uncompressed
.length
;
101 comndr
->iconv_convenience
= talloc_reference(comndr
, subndr
->iconv_convenience
);
103 return NDR_ERR_SUCCESS
;
107 _PUBLIC_
enum ndr_err_code
ndr_pull_mapi2k7_request(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi2k7_request
*r
)
109 if (ndr_flags
& NDR_SCALARS
) {
110 NDR_CHECK(ndr_pull_align(ndr
, 4));
111 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr
, NDR_SCALARS
, &r
->header
));
113 uint32_t _flags_save_mapi_request
= ndr
->flags
;
114 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
|LIBNDR_FLAG_NOALIGN
);
116 struct ndr_pull
*_ndr_buffer
;
118 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
119 NDR_PULL_ALLOC(ndr
, r
->mapi_request
);
122 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_buffer
, 0, -1));
124 if (r
->header
.Flags
& RHEF_Compressed
) {
125 struct ndr_pull
*_ndr_data_compressed
= NULL
;
127 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer
, &_ndr_data_compressed
, r
->header
.SizeActual
));
128 NDR_CHECK(ndr_pull_mapi_request(_ndr_data_compressed
, NDR_SCALARS
|NDR_BUFFERS
, r
->mapi_request
));
129 } else if (r
->header
.Flags
& RHEF_XorMagic
) {
130 obfuscate_data(_ndr_buffer
->data
, _ndr_buffer
->data_size
, 0xA5);
131 NDR_CHECK(ndr_pull_mapi_request(_ndr_buffer
, NDR_SCALARS
|NDR_BUFFERS
, r
->mapi_request
));
134 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_buffer
, 0, -1));
136 ndr
->flags
= _flags_save_mapi_request
;
140 return NDR_ERR_SUCCESS
;
144 _PUBLIC_
enum ndr_err_code
ndr_pull_mapi2k7_response(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi2k7_response
*r
)
146 if (ndr_flags
& NDR_SCALARS
) {
147 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr
, NDR_SCALARS
, &r
->header
));
149 uint32_t _flags_save_mapi_response
= ndr
->flags
;
150 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
|LIBNDR_FLAG_REMAINING
);
152 struct ndr_pull
*_ndr_buffer
;
154 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
155 NDR_PULL_ALLOC(ndr
, r
->mapi_response
);
158 NDR_CHECK((ndr_pull_subcontext_start(ndr
, &_ndr_buffer
, 0, -1)));
160 if (r
->header
.Flags
& RHEF_Compressed
) {
161 struct ndr_pull
*_ndr_data_compressed
= NULL
;
163 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer
, &_ndr_data_compressed
, r
->header
.SizeActual
));
164 NDR_CHECK(ndr_pull_mapi_response(_ndr_data_compressed
, NDR_SCALARS
|NDR_BUFFERS
, r
->mapi_response
));
165 } else if (r
->header
.Flags
& RHEF_XorMagic
) {
166 obfuscate_data(_ndr_buffer
->data
, _ndr_buffer
->data_size
, 0xA5);
167 NDR_CHECK(ndr_pull_mapi_response(_ndr_buffer
, NDR_SCALARS
|NDR_BUFFERS
, r
->mapi_response
));
170 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_buffer
, 0, -1));
172 ndr
->flags
= _flags_save_mapi_response
;
176 return NDR_ERR_SUCCESS
;
180 _PUBLIC_
void ndr_print_AUX_HEADER(struct ndr_print
*ndr
, const char *name
, const struct AUX_HEADER
*r
)
182 ndr_print_struct(ndr
, name
, "AUX_HEADER");
184 uint32_t _flags_save_STRUCT
= ndr
->flags
;
185 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
187 ndr_print_uint16(ndr
, "Size", r
->Size
);
188 ndr_print_AUX_VERSION(ndr
, "Version", r
->Version
);
190 switch (r
->Version
) {
192 ndr_print_AUX_HEADER_TYPE_1(ndr
, "Type", (enum AUX_HEADER_TYPE_1
) r
->Type
);
193 ndr_print_set_switch_value(ndr
, &r
->Payload_1
, r
->Type
);
194 ndr_print_AUX_HEADER_TYPE_UNION_1(ndr
, "Payload", &r
->Payload_1
);
197 ndr_print_AUX_HEADER_TYPE_2(ndr
, "Type", (enum AUX_HEADER_TYPE_2
) r
->Type
);
198 ndr_print_set_switch_value(ndr
, &r
->Payload_2
, r
->Type
);
199 ndr_print_AUX_HEADER_TYPE_UNION_2(ndr
, "Payload", &r
->Payload_2
);
202 ndr
->flags
= _flags_save_STRUCT
;
207 _PUBLIC_
enum ndr_err_code
ndr_pull_AUX_HEADER(struct ndr_pull
*ndr
, int ndr_flags
, struct AUX_HEADER
*r
)
210 uint32_t _flags_save_STRUCT
= ndr
->flags
;
211 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
212 if (ndr_flags
& NDR_SCALARS
) {
213 NDR_CHECK(ndr_pull_align(ndr
, 4));
214 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, &r
->Size
));
215 NDR_CHECK(ndr_pull_AUX_VERSION(ndr
, NDR_SCALARS
, &r
->Version
));
216 NDR_CHECK(ndr_pull_uint8(ndr
, NDR_SCALARS
, &r
->Type
));
217 switch (r
->Version
) {
219 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->Payload_1
, r
->Type
));
220 NDR_CHECK(ndr_pull_AUX_HEADER_TYPE_UNION_1(ndr
, NDR_SCALARS
, &r
->Payload_1
));
223 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->Payload_2
, r
->Type
));
224 NDR_CHECK(ndr_pull_AUX_HEADER_TYPE_UNION_2(ndr
, NDR_SCALARS
, &r
->Payload_2
));
228 if (ndr_flags
& NDR_BUFFERS
) {
230 ndr
->flags
= _flags_save_STRUCT
;
232 return NDR_ERR_SUCCESS
;
236 _PUBLIC_
void ndr_print_mapi2k7_AuxInfo(struct ndr_print
*ndr
, const char *name
, const struct mapi2k7_AuxInfo
*r
)
240 if (r
&& r
->AUX_HEADER
) {
241 ndr_print_struct(ndr
, name
, "mapi2k7_AuxInfo");
243 ndr_print_RPC_HEADER_EXT(ndr
, "RPC_HEADER_EXT", &r
->RPC_HEADER_EXT
);
244 for (i
= 0; r
->AUX_HEADER
[i
].Size
; i
++) {
245 ndr_print_AUX_HEADER(ndr
, "AUX_HEADER", &r
->AUX_HEADER
[i
]);
249 ndr_print_pointer(ndr
, "mapi2k7_AuxInfo", NULL
);
254 _PUBLIC_
enum ndr_err_code
ndr_pull_mapi2k7_AuxInfo(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi2k7_AuxInfo
*r
)
256 if (ndr_flags
& NDR_SCALARS
) {
259 if (!ndr
->data_size
) {
260 r
->AUX_HEADER
= NULL
;
261 return NDR_ERR_SUCCESS
;
264 NDR_CHECK(ndr_pull_align(ndr
, 4));
265 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr
, NDR_SCALARS
, &r
->RPC_HEADER_EXT
));
267 uint32_t _flags_save_DATA_BLOB
= ndr
->flags
;
268 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
|LIBNDR_FLAG_REMAINING
);
269 if (r
->RPC_HEADER_EXT
.Size
) {
270 struct ndr_pull
*_ndr_buffer
;
271 TALLOC_CTX
*_mem_save_AUX_HEADER_0
;
272 uint32_t cntr_AUX_HEADER_0
= 0;
274 _mem_save_AUX_HEADER_0
= NDR_PULL_GET_MEM_CTX(ndr
);
276 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_buffer
, 0, r
->RPC_HEADER_EXT
.Size
));
278 r
->AUX_HEADER
= talloc_array(_mem_save_AUX_HEADER_0
, struct AUX_HEADER
, 2);
280 if (r
->RPC_HEADER_EXT
.Flags
& RHEF_Compressed
) {
281 struct ndr_pull
*_ndr_data_compressed
= NULL
;
283 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
284 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer
, &_ndr_data_compressed
, r
->RPC_HEADER_EXT
.SizeActual
));
286 for (cntr_AUX_HEADER_0
= 0; _ndr_data_compressed
->offset
< _ndr_data_compressed
->data_size
; cntr_AUX_HEADER_0
++) {
287 NDR_CHECK(ndr_pull_AUX_HEADER(_ndr_data_compressed
, NDR_SCALARS
, &r
->AUX_HEADER
[cntr_AUX_HEADER_0
]));
288 r
->AUX_HEADER
= talloc_realloc(_mem_save_AUX_HEADER_0
, r
->AUX_HEADER
, struct AUX_HEADER
, cntr_AUX_HEADER_0
+ 2);
290 r
->AUX_HEADER
= talloc_realloc(_mem_save_AUX_HEADER_0
, r
->AUX_HEADER
, struct AUX_HEADER
, cntr_AUX_HEADER_0
+ 2);
291 r
->AUX_HEADER
[cntr_AUX_HEADER_0
].Size
= 0;
293 } else if (r
->RPC_HEADER_EXT
.Flags
& RHEF_XorMagic
) {
294 obfuscate_data(_ndr_buffer
->data
, _ndr_buffer
->data_size
, 0xA5);
296 for (cntr_AUX_HEADER_0
= 0; _ndr_buffer
->offset
< _ndr_buffer
->data_size
; cntr_AUX_HEADER_0
++) {
297 NDR_CHECK(ndr_pull_AUX_HEADER(_ndr_buffer
, NDR_SCALARS
, &r
->AUX_HEADER
[cntr_AUX_HEADER_0
]));
298 r
->AUX_HEADER
= talloc_realloc(_mem_save_AUX_HEADER_0
, r
->AUX_HEADER
, struct AUX_HEADER
, cntr_AUX_HEADER_0
+ 2);
300 r
->AUX_HEADER
= talloc_realloc(_mem_save_AUX_HEADER_0
, r
->AUX_HEADER
, struct AUX_HEADER
, cntr_AUX_HEADER_0
+ 2);
301 r
->AUX_HEADER
[cntr_AUX_HEADER_0
].Size
= 0;
304 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_buffer
, 0, -1));
306 ndr
->flags
= _flags_save_DATA_BLOB
;
309 if (ndr_flags
& NDR_BUFFERS
) {
311 return NDR_ERR_SUCCESS
;
315 print mapi_request / mapi_response structures
318 void ndr_print_mapi_request(struct ndr_print
*ndr
, const char *name
, const struct mapi_request
*r
)
322 rlength
= r
->mapi_len
- r
->length
;
324 ndr_print_uint32(ndr
, "mapi_len", r
->mapi_len
);
325 if (r
->length
&& r
->length
> sizeof(uint16_t)) {
326 uint32_t cntr_mapi_req_0
;
328 ndr_print_uint16(ndr
, "length", r
->length
);
330 for (cntr_mapi_req_0
=0; r
->mapi_req
[cntr_mapi_req_0
].opnum
; cntr_mapi_req_0
++) {
334 ret
= asprintf(&idx_0
, "[%u]", cntr_mapi_req_0
);
335 if (ret
!= -1 && idx_0
) {
336 ndr_print_EcDoRpc_MAPI_REQ(ndr
, "mapi_request", &r
->mapi_req
[cntr_mapi_req_0
]);
347 ndr
->print(ndr
, "%-25s: (handles) number=%u", name
, rlength
/ 4);
349 for (i
= 0; i
< (rlength
/ 4); i
++) {
350 ndr_print_uint32(ndr
, "handle", r
->handles
[i
]);
356 void ndr_print_mapi_response(struct ndr_print
*ndr
, const char *name
, const struct mapi_response
*r
)
360 rlength
= r
->mapi_len
- r
->length
;
362 ndr
->print(ndr
, "%-25s: length=%u", name
, r
->length
);
363 if (r
->length
&& r
->length
> sizeof(uint16_t)) {
364 uint32_t cntr_mapi_repl_0
;
366 ndr
->print(ndr
, "%s: ARRAY(%d)", name
, r
->length
- 2);
368 for (cntr_mapi_repl_0
=0; r
->mapi_repl
[cntr_mapi_repl_0
].opnum
; cntr_mapi_repl_0
++) {
369 ndr_print_EcDoRpc_MAPI_REPL(ndr
, "mapi_repl", &r
->mapi_repl
[cntr_mapi_repl_0
]);
374 ndr
->print(ndr
, "%-25s: (handles) number=%u", name
, rlength
/ 4);
381 for (i
= 0; i
< (rlength
/ 4); i
++) {
382 ndr_print_uint32(ndr
, "handle id", r
->handles
[i
]);
390 push mapi_request / mapi_response onto the wire.
392 MAPI length field includes length bytes.
393 But these bytes do not belong to the mapi content in the user
394 context. We have to add them when pushing mapi content length
395 (uint16_t) and next substract when pushing the content blob
398 enum ndr_err_code
ndr_push_mapi_request(struct ndr_push
*ndr
, int ndr_flags
, const struct mapi_request
*r
)
400 uint32_t cntr_mapi_req_0
;
403 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
404 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, r
->length
));
406 for (count
= 0; ndr
->offset
< r
->length
- 2; count
++) {
407 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REQ(ndr
, NDR_SCALARS
, &r
->mapi_req
[count
]));
410 count
= (r
->mapi_len
- r
->length
) / sizeof(uint32_t);
411 for (cntr_mapi_req_0
=0; cntr_mapi_req_0
< count
; cntr_mapi_req_0
++) {
412 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->handles
[cntr_mapi_req_0
]));
415 return NDR_ERR_SUCCESS
;
418 enum ndr_err_code
ndr_push_mapi_response(struct ndr_push
*ndr
, int ndr_flags
, const struct mapi_response
*r
)
420 uint32_t cntr_mapi_repl_0
;
423 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
);
424 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, r
->length
));
426 if (r
->length
> sizeof (uint16_t)) {
427 for (count
= 0; ndr
->offset
< r
->length
- 2; count
++) {
428 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL(ndr
, NDR_SCALARS
, &r
->mapi_repl
[count
]));
432 count
= (r
->mapi_len
- r
->length
) / sizeof (uint32_t);
433 for (cntr_mapi_repl_0
= 0; cntr_mapi_repl_0
<count
; cntr_mapi_repl_0
++) {
434 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->handles
[cntr_mapi_repl_0
]));
437 return NDR_ERR_SUCCESS
;
441 pull mapi_request / mapi_response from the wire
444 enum ndr_err_code
ndr_pull_mapi_request(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi_request
*r
)
446 uint32_t length
,count
;
447 uint32_t cntr_mapi_req_0
;
448 TALLOC_CTX
*_mem_save_mapi_req_0
;
449 TALLOC_CTX
*_mem_save_handles_0
;
450 struct ndr_pull
*_ndr_mapi_req
;
452 if (ndr
->flags
& LIBNDR_FLAG_REMAINING
) {
453 length
= ndr
->data_size
- ndr
->offset
;
455 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &length
));
457 r
->mapi_len
= length
;
459 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, &r
->length
));
461 /* If length equals length field then skipping subcontext */
462 if (r
->length
> sizeof (uint16_t)) {
463 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_mapi_req
, 0, r
->length
- 2));
464 _mem_save_mapi_req_0
= NDR_PULL_GET_MEM_CTX(_ndr_mapi_req
);
465 r
->mapi_req
= talloc_zero(_mem_save_mapi_req_0
, struct EcDoRpc_MAPI_REQ
);
466 for (cntr_mapi_req_0
= 0; _ndr_mapi_req
->offset
< _ndr_mapi_req
->data_size
- 2; cntr_mapi_req_0
++) {
467 NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REQ(_ndr_mapi_req
, NDR_SCALARS
, &r
->mapi_req
[cntr_mapi_req_0
]));
468 r
->mapi_req
= talloc_realloc(_mem_save_mapi_req_0
, r
->mapi_req
, struct EcDoRpc_MAPI_REQ
, cntr_mapi_req_0
+ 2);
470 r
->mapi_req
= talloc_realloc(_mem_save_mapi_req_0
, r
->mapi_req
, struct EcDoRpc_MAPI_REQ
, cntr_mapi_req_0
+ 2);
471 r
->mapi_req
[cntr_mapi_req_0
].opnum
= 0;
473 if (_ndr_mapi_req
->offset
!= r
->length
- 2) {
474 return NDR_ERR_BUFSIZE
;
476 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_mapi_req
, 4, -1));
478 _mem_save_handles_0
= NDR_PULL_GET_MEM_CTX(ndr
);
479 count
= (r
->mapi_len
- r
->length
) / sizeof(uint32_t);
480 r
->handles
= talloc_array(_mem_save_handles_0
, uint32_t, count
+ 1);
481 for (cntr_mapi_req_0
=0; cntr_mapi_req_0
< count
; cntr_mapi_req_0
++) {
482 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->handles
[cntr_mapi_req_0
]));
488 return NDR_ERR_SUCCESS
;
491 enum ndr_err_code
ndr_pull_mapi_response(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi_response
*r
)
493 uint32_t length
,count
;
494 uint32_t cntr_mapi_repl_0
;
495 TALLOC_CTX
*_mem_save_mapi_repl_0
;
496 TALLOC_CTX
*_mem_save_handles_0
;
497 struct ndr_pull
*_ndr_mapi_repl
;
499 if (ndr
->flags
& LIBNDR_FLAG_REMAINING
) {
500 length
= ndr
->data_size
- ndr
->offset
;
502 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &length
));
504 r
->mapi_len
= length
;
506 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, &r
->length
));
508 /* If length equals length field then skipping subcontext */
509 if (r
->length
> sizeof (uint16_t)) {
510 _mem_save_mapi_repl_0
= NDR_PULL_GET_MEM_CTX(ndr
);
511 r
->mapi_repl
= talloc_array(_mem_save_mapi_repl_0
, struct EcDoRpc_MAPI_REPL
, 2);
512 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_mapi_repl
, 0, r
->length
- 2));
513 for (cntr_mapi_repl_0
= 0; _ndr_mapi_repl
->offset
< _ndr_mapi_repl
->data_size
- 2; cntr_mapi_repl_0
++) {
514 NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL(_ndr_mapi_repl
, NDR_SCALARS
, &r
->mapi_repl
[cntr_mapi_repl_0
]));
515 r
->mapi_repl
= talloc_realloc(_ndr_mapi_repl
, r
->mapi_repl
, struct EcDoRpc_MAPI_REPL
, cntr_mapi_repl_0
+ 2);
517 r
->mapi_repl
[cntr_mapi_repl_0
].opnum
= 0;
518 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_mapi_repl
, 4, -1));
519 talloc_free(_ndr_mapi_repl
);
522 _mem_save_handles_0
= NDR_PULL_GET_MEM_CTX(ndr
);
523 count
= (r
->mapi_len
- r
->length
) / sizeof(uint32_t);
524 NDR_PULL_ALLOC_N(ndr
, r
->handles
, count
+ 1);
526 for (cntr_mapi_repl_0
=0; cntr_mapi_repl_0
< count
; cntr_mapi_repl_0
++) {
527 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->handles
[cntr_mapi_repl_0
]));
529 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_handles_0
, LIBNDR_FLAG_REF_ALLOC
);
531 return NDR_ERR_SUCCESS
;
535 We stop processing the IDL if MAPISTATUS is different from MAPI_E_SUCCESS
538 _PUBLIC_
enum ndr_err_code
ndr_push_EcDoRpc_MAPI_REPL(struct ndr_push
*ndr
, int ndr_flags
, const struct EcDoRpc_MAPI_REPL
*r
)
540 if (r
->opnum
!= op_MAPI_Release
)
542 uint32_t _flags_save_STRUCT
= ndr
->flags
;
543 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
544 if (ndr_flags
& NDR_SCALARS
) {
545 NDR_CHECK(ndr_push_align(ndr
, 8));
546 NDR_CHECK(ndr_push_uint8(ndr
, NDR_SCALARS
, r
->opnum
));
547 if ((r
->opnum
== op_MAPI_Notify
) || (r
->opnum
== op_MAPI_Pending
)) {
548 NDR_CHECK(ndr_push_set_switch_value(ndr
, &r
->u
, r
->opnum
));
549 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr
, NDR_SCALARS
, &r
->u
));
551 NDR_CHECK(ndr_push_uint8(ndr
, NDR_SCALARS
, r
->handle_idx
));
552 NDR_CHECK(ndr_push_MAPISTATUS(ndr
, NDR_SCALARS
, r
->error_code
));
553 if (r
->error_code
== MAPI_E_SUCCESS
) {
554 NDR_CHECK(ndr_push_set_switch_value(ndr
, &r
->u
, r
->opnum
));
555 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr
, NDR_SCALARS
, &r
->u
));
558 case op_MAPI_Logon
: {
559 if (r
->error_code
== ecWrongServer
) {
560 NDR_CHECK(ndr_push_Logon_redirect(ndr
, NDR_SCALARS
, &(r
->us
.mapi_Logon
)));
569 if (ndr_flags
& NDR_BUFFERS
) {
570 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr
, NDR_BUFFERS
, &r
->u
));
572 ndr
->flags
= _flags_save_STRUCT
;
574 return NDR_ERR_SUCCESS
;
577 enum ndr_err_code
ndr_pull_EcDoRpc_MAPI_REPL(struct ndr_pull
*ndr
, int ndr_flags
, struct EcDoRpc_MAPI_REPL
*r
)
580 uint32_t _flags_save_STRUCT
= ndr
->flags
;
581 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
582 if (ndr_flags
& NDR_SCALARS
) {
583 NDR_CHECK(ndr_pull_align(ndr
, 8));
584 NDR_CHECK(ndr_pull_uint8(ndr
, NDR_SCALARS
, &r
->opnum
));
585 if ((r
->opnum
== op_MAPI_Notify
) || (r
->opnum
== op_MAPI_Pending
)) {
586 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->u
, r
->opnum
));
587 NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL_UNION(ndr
, NDR_SCALARS
, &r
->u
));
589 NDR_CHECK(ndr_pull_uint8(ndr
, NDR_SCALARS
, &r
->handle_idx
));
590 NDR_CHECK(ndr_pull_MAPISTATUS(ndr
, NDR_SCALARS
, &r
->error_code
));
591 if ( r
->error_code
== MAPI_E_SUCCESS
) {
592 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->u
, r
->opnum
));
593 NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL_UNION(ndr
, NDR_SCALARS
, &r
->u
));
596 case op_MAPI_Logon
: {
597 if (r
->error_code
== ecWrongServer
) {
598 NDR_CHECK(ndr_pull_Logon_redirect(ndr
, NDR_SCALARS
, &(r
->us
.mapi_Logon
)));
607 if (ndr_flags
& NDR_BUFFERS
) {
608 ndr
->flags
= _flags_save_STRUCT
;
611 return NDR_ERR_SUCCESS
;
614 void ndr_print_EcDoRpc_MAPI_REPL(struct ndr_print
*ndr
, const char *name
, const struct EcDoRpc_MAPI_REPL
*r
)
616 ndr_print_struct(ndr
, name
, "EcDoRpc_MAPI_REPL");
618 uint32_t _flags_save_STRUCT
= ndr
->flags
;
619 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
621 ndr_print_uint8(ndr
, "opnum", r
->opnum
);
622 if ((r
->opnum
!= op_MAPI_Notify
) && (r
->opnum
!= op_MAPI_Pending
)) {
623 ndr_print_uint8(ndr
, "handle_idx", r
->handle_idx
);
624 ndr_print_MAPISTATUS(ndr
, "error_code", r
->error_code
);
625 if (r
->error_code
== MAPI_E_SUCCESS
) {
626 ndr_print_set_switch_value(ndr
, &r
->u
, r
->opnum
);
627 ndr_print_EcDoRpc_MAPI_REPL_UNION(ndr
, "u", &r
->u
);
630 case op_MAPI_Logon
: {
631 if (r
->error_code
== ecWrongServer
) {
632 ndr_print_set_switch_value(ndr
, &r
->us
, r
->opnum
);
633 ndr_print_EcDoRpc_MAPI_REPL_UNION_SPECIAL(ndr
, "us", &r
->us
);
641 ndr_print_set_switch_value(ndr
, &r
->u
, r
->opnum
);
642 ndr_print_EcDoRpc_MAPI_REPL_UNION(ndr
, "u", &r
->u
);
645 ndr
->flags
= _flags_save_STRUCT
;
650 _PUBLIC_
enum ndr_err_code
ndr_pull_EcDoRpc(struct ndr_pull
*ndr
, int flags
, struct EcDoRpc
*r
)
652 TALLOC_CTX
*_mem_save_handle_0
;
653 TALLOC_CTX
*_mem_save_mapi_request_0
;
654 TALLOC_CTX
*_mem_save_mapi_response_0
;
655 TALLOC_CTX
*_mem_save_length_0
;
657 if (flags
& NDR_IN
) {
660 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
661 NDR_PULL_ALLOC(ndr
, r
->in
.handle
);
663 _mem_save_handle_0
= NDR_PULL_GET_MEM_CTX(ndr
);
664 NDR_PULL_SET_MEM_CTX(ndr
, r
->in
.handle
, LIBNDR_FLAG_REF_ALLOC
);
665 NDR_CHECK(ndr_pull_policy_handle(ndr
, NDR_SCALARS
|NDR_BUFFERS
, r
->in
.handle
));
666 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_handle_0
, LIBNDR_FLAG_REF_ALLOC
);
667 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->in
.size
));
668 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->in
.offset
));
670 uint32_t _flags_save_mapi_request
= ndr
->flags
;
671 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
|LIBNDR_FLAG_NOALIGN
);
672 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
673 NDR_PULL_ALLOC(ndr
, r
->in
.mapi_request
);
675 _mem_save_mapi_request_0
= NDR_PULL_GET_MEM_CTX(ndr
);
676 NDR_PULL_SET_MEM_CTX(ndr
, r
->in
.mapi_request
, LIBNDR_FLAG_REF_ALLOC
);
678 struct ndr_pull
*_ndr_mapi_request
;
679 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_mapi_request
, 4, -1));
680 obfuscate_data(_ndr_mapi_request
->data
, _ndr_mapi_request
->data_size
, 0xA5);
681 NDR_CHECK(ndr_pull_mapi_request(_ndr_mapi_request
, NDR_SCALARS
|NDR_BUFFERS
, r
->in
.mapi_request
));
682 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_mapi_request
, 4, -1));
684 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_mapi_request_0
, LIBNDR_FLAG_REF_ALLOC
);
685 ndr
->flags
= _flags_save_mapi_request
;
687 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
688 NDR_PULL_ALLOC(ndr
, r
->in
.length
);
690 _mem_save_length_0
= NDR_PULL_GET_MEM_CTX(ndr
);
691 NDR_PULL_SET_MEM_CTX(ndr
, r
->in
.length
, LIBNDR_FLAG_REF_ALLOC
);
692 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, r
->in
.length
));
693 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_length_0
, LIBNDR_FLAG_REF_ALLOC
);
694 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, &r
->in
.max_data
));
695 NDR_PULL_ALLOC(ndr
, r
->out
.handle
);
696 *r
->out
.handle
= *r
->in
.handle
;
697 NDR_PULL_ALLOC(ndr
, r
->out
.mapi_response
);
698 ZERO_STRUCTP(r
->out
.mapi_response
);
699 NDR_PULL_ALLOC(ndr
, r
->out
.length
);
700 *r
->out
.length
= *r
->in
.length
;
702 if (flags
& NDR_OUT
) {
703 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
704 NDR_PULL_ALLOC(ndr
, r
->out
.handle
);
706 _mem_save_handle_0
= NDR_PULL_GET_MEM_CTX(ndr
);
707 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.handle
, LIBNDR_FLAG_REF_ALLOC
);
708 NDR_CHECK(ndr_pull_policy_handle(ndr
, NDR_SCALARS
|NDR_BUFFERS
, r
->out
.handle
));
709 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_handle_0
, LIBNDR_FLAG_REF_ALLOC
);
710 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->out
.size
));
711 NDR_CHECK(ndr_pull_uint32(ndr
, NDR_SCALARS
, &r
->out
.offset
));
713 uint32_t _flags_save_mapi_response
= ndr
->flags
;
714 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
|LIBNDR_FLAG_NOALIGN
);
715 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
716 NDR_PULL_ALLOC(ndr
, r
->out
.mapi_response
);
718 _mem_save_mapi_response_0
= NDR_PULL_GET_MEM_CTX(ndr
);
719 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.mapi_response
, LIBNDR_FLAG_REF_ALLOC
);
721 struct ndr_pull
*_ndr_mapi_response
;
722 NDR_CHECK(ndr_pull_subcontext_start(ndr
, &_ndr_mapi_response
, 4, -1));
723 obfuscate_data(_ndr_mapi_response
->data
, _ndr_mapi_response
->data_size
, 0xA5);
724 NDR_CHECK(ndr_pull_mapi_response(_ndr_mapi_response
, NDR_SCALARS
|NDR_BUFFERS
, r
->out
.mapi_response
));
725 NDR_CHECK(ndr_pull_subcontext_end(ndr
, _ndr_mapi_response
, 4, -1));
727 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_mapi_response_0
, LIBNDR_FLAG_REF_ALLOC
);
728 ndr
->flags
= _flags_save_mapi_response
;
730 if (ndr
->flags
& LIBNDR_FLAG_REF_ALLOC
) {
731 NDR_PULL_ALLOC(ndr
, r
->out
.length
);
733 _mem_save_length_0
= NDR_PULL_GET_MEM_CTX(ndr
);
734 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.length
, LIBNDR_FLAG_REF_ALLOC
);
735 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, r
->out
.length
));
736 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_length_0
, LIBNDR_FLAG_REF_ALLOC
);
737 NDR_CHECK(ndr_pull_MAPISTATUS(ndr
, NDR_SCALARS
, &r
->out
.result
));
739 return NDR_ERR_SUCCESS
;
743 _PUBLIC_
enum ndr_err_code
ndr_push_EcDoRpc(struct ndr_push
*ndr
, int flags
, const struct EcDoRpc
*r
)
745 if (flags
& NDR_IN
) {
746 if (r
->in
.handle
== NULL
) {
747 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
749 NDR_CHECK(ndr_push_policy_handle(ndr
, NDR_SCALARS
|NDR_BUFFERS
, r
->in
.handle
));
750 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->in
.size
));
751 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->in
.offset
));
753 uint32_t _flags_save_mapi_request
= ndr
->flags
;
754 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
|LIBNDR_FLAG_NOALIGN
);
755 if (r
->in
.mapi_request
== NULL
) {
756 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
759 struct ndr_push
*_ndr_mapi_request
;
760 NDR_CHECK(ndr_push_subcontext_start(ndr
, &_ndr_mapi_request
, 4, -1));
761 NDR_CHECK(ndr_push_mapi_request(_ndr_mapi_request
, NDR_SCALARS
|NDR_BUFFERS
, r
->in
.mapi_request
));
762 obfuscate_data(_ndr_mapi_request
->data
, _ndr_mapi_request
->offset
, 0xA5);
763 NDR_CHECK(ndr_push_subcontext_end(ndr
, _ndr_mapi_request
, 4, -1));
765 ndr
->flags
= _flags_save_mapi_request
;
767 if (r
->in
.length
== NULL
) {
768 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
770 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, *r
->in
.length
));
771 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, r
->in
.max_data
));
773 if (flags
& NDR_OUT
) {
774 if (r
->out
.handle
== NULL
) {
775 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
777 NDR_CHECK(ndr_push_policy_handle(ndr
, NDR_SCALARS
|NDR_BUFFERS
, r
->out
.handle
));
778 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->out
.size
));
779 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, r
->out
.offset
));
781 uint32_t _flags_save_mapi_response
= ndr
->flags
;
782 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
|LIBNDR_FLAG_NOALIGN
);
783 if (r
->out
.mapi_response
== NULL
) {
784 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
787 struct ndr_push
*_ndr_mapi_response
;
788 NDR_CHECK(ndr_push_subcontext_start(ndr
, &_ndr_mapi_response
, 4, -1));
789 NDR_CHECK(ndr_push_mapi_response(_ndr_mapi_response
, NDR_SCALARS
|NDR_BUFFERS
, r
->out
.mapi_response
));
790 obfuscate_data(_ndr_mapi_response
->data
, _ndr_mapi_response
->alloc_size
, 0xA5);
791 NDR_CHECK(ndr_push_subcontext_end(ndr
, _ndr_mapi_response
, 4, -1));
793 ndr
->flags
= _flags_save_mapi_response
;
795 if (r
->out
.length
== NULL
) {
796 return ndr_push_error(ndr
, NDR_ERR_INVALID_POINTER
, "NULL [ref] pointer");
798 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, *r
->out
.length
));
799 NDR_CHECK(ndr_push_MAPISTATUS(ndr
, NDR_SCALARS
, r
->out
.result
));
801 return NDR_ERR_SUCCESS
;
807 We need to pull QueryRows replies on our own:
808 If we have no results, do not push/pull the DATA_BLOB
811 enum ndr_err_code
ndr_push_QueryRows_repl(struct ndr_push
*ndr
, int ndr_flags
, const struct QueryRows_repl
*r
)
814 uint32_t _flags_save_STRUCT
= ndr
->flags
;
815 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
816 if (ndr_flags
& NDR_SCALARS
) {
817 NDR_CHECK(ndr_push_align(ndr
, 4));
818 NDR_CHECK(ndr_push_uint8(ndr
, NDR_SCALARS
, r
->Origin
));
819 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, r
->RowCount
));
822 uint32_t _flags_save_DATA_BLOB
= ndr
->flags
;
823 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
);
824 NDR_CHECK(ndr_push_DATA_BLOB(ndr
, NDR_SCALARS
, r
->RowData
));
825 ndr
->flags
= _flags_save_DATA_BLOB
;
828 if (ndr_flags
& NDR_BUFFERS
) {
830 ndr
->flags
= _flags_save_STRUCT
;
832 return NDR_ERR_SUCCESS
;
835 enum ndr_err_code
ndr_pull_QueryRows_repl(struct ndr_pull
*ndr
, int ndr_flags
, struct QueryRows_repl
*r
)
838 uint32_t _flags_save_STRUCT
= ndr
->flags
;
839 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
840 if (ndr_flags
& NDR_SCALARS
) {
841 NDR_CHECK(ndr_pull_align(ndr
, 4));
842 NDR_CHECK(ndr_pull_uint8(ndr
, NDR_SCALARS
, &r
->Origin
));
843 NDR_CHECK(ndr_pull_uint16(ndr
, NDR_SCALARS
, &r
->RowCount
));
847 uint32_t _flags_save_DATA_BLOB
= ndr
->flags
;
849 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_REMAINING
);
850 NDR_CHECK(ndr_pull_DATA_BLOB(ndr
, NDR_SCALARS
, &r
->RowData
));
851 ndr
->flags
= _flags_save_DATA_BLOB
;
853 r
->RowData
.length
= 0;
854 r
->RowData
.data
= NULL
;
857 if (ndr_flags
& NDR_BUFFERS
) {
859 ndr
->flags
= _flags_save_STRUCT
;
861 return NDR_ERR_SUCCESS
;
865 enum ndr_err_code
ndr_push_Logon_req(struct ndr_push
*ndr
, int ndr_flags
, const struct Logon_req
*r
)
868 uint32_t _flags_save_STRUCT
= ndr
->flags
;
869 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
870 if (ndr_flags
& NDR_SCALARS
) {
871 NDR_CHECK(ndr_push_align(ndr
, 4));
872 NDR_CHECK(ndr_push_LogonFlags(ndr
, NDR_SCALARS
, r
->LogonFlags
));
873 NDR_CHECK(ndr_push_OpenFlags(ndr
, NDR_SCALARS
, r
->OpenFlags
));
874 NDR_CHECK(ndr_push_StoreState(ndr
, NDR_SCALARS
, r
->StoreState
));
875 if (r
->EssDN
&& r
->EssDN
[0] != '\0') {
876 uint32_t _flags_save_string
= ndr
->flags
;
877 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_STR_ASCII
|LIBNDR_FLAG_STR_SIZE2
);
878 NDR_CHECK(ndr_push_string(ndr
, NDR_SCALARS
, r
->EssDN
));
879 ndr
->flags
= _flags_save_string
;
881 NDR_CHECK(ndr_push_uint16(ndr
, NDR_SCALARS
, 0));
884 if (ndr_flags
& NDR_BUFFERS
) {
886 ndr
->flags
= _flags_save_STRUCT
;
888 return NDR_ERR_SUCCESS
;
892 _PUBLIC_
void ndr_print_SBinary_short(struct ndr_print
*ndr
, const char *name
, const struct SBinary_short
*r
)
894 ndr
->print(ndr
, "%-25s: SBinary_short cb=%u", name
, (unsigned)r
->cb
);
896 uint32_t _flags_save_STRUCT
= ndr
->flags
;
897 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
899 dump_data(0, r
->lpb
, r
->cb
);
901 ndr
->flags
= _flags_save_STRUCT
;
906 _PUBLIC_
void ndr_print_fuzzyLevel(struct ndr_print
*ndr
, const char *name
, uint32_t r
)
908 ndr_print_uint32(ndr
, name
, r
);
910 switch ((r
& 0x0000FFFF)) {
912 ndr
->print(ndr
, "%-25s: FL_FULLSTRING", "lower 16 bits");
915 ndr
->print(ndr
, "%-25s: FL_SUBSTRING", "lower 16 bits");
918 ndr
->print(ndr
, "%-25s: FL_PREFIX", "lower 16 bits");
921 ndr
->print(ndr
, "%-25s", "higher 16 bits");
922 ndr_print_bitmap_flag(ndr
, sizeof(uint32_t), "FL_IGNORECASE", FL_IGNORECASE
, r
);
923 ndr_print_bitmap_flag(ndr
, sizeof(uint32_t), "FL_IGNORENONSPACE", FL_IGNORENONSPACE
, r
);
924 ndr_print_bitmap_flag(ndr
, sizeof(uint32_t), "FL_LOOSE", FL_LOOSE
, r
);
929 * Fake wrapper over mapi_SRestriction. Workaround the no-pointer deep
930 * recursion problem in pidl
932 enum ndr_err_code
ndr_push_mapi_SRestriction_wrap(struct ndr_push
*ndr
, int ndr_flags
, const struct mapi_SRestriction_wrap
*r
)
934 return ndr_push_mapi_SRestriction(ndr
, NDR_SCALARS
, (const struct mapi_SRestriction
*)r
);
938 enum ndr_err_code
ndr_pull_mapi_SRestriction_wrap(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi_SRestriction_wrap
*r
)
940 return ndr_pull_mapi_SRestriction(ndr
, NDR_SCALARS
|NDR_BUFFERS
, (struct mapi_SRestriction
*)r
);
943 void ndr_print_mapi_SRestriction_wrap(struct ndr_print
*ndr
, const char *name
, const struct mapi_SRestriction_wrap
*r
)
945 ndr_print_mapi_SRestriction(ndr
, name
, (const struct mapi_SRestriction
*)r
);
949 * Fake wrapper over mapi_SPropValue. Workaround the no-pointer deep
950 * recursion problem in pidl
952 enum ndr_err_code
ndr_push_mapi_SPropValue_wrap(struct ndr_push
*ndr
, int ndr_flags
, const struct mapi_SPropValue_wrap
*r
)
954 NDR_CHECK(ndr_push_align(ndr
, 8));
955 return ndr_push_mapi_SPropValue(ndr
, NDR_SCALARS
, (const struct mapi_SPropValue
*)r
);
958 enum ndr_err_code
ndr_pull_mapi_SPropValue_wrap(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi_SPropValue_wrap
*r
)
960 return ndr_pull_mapi_SPropValue(ndr
, NDR_SCALARS
, (struct mapi_SPropValue
*)r
);
963 void ndr_print_mapi_SPropValue_wrap(struct ndr_print
*ndr
, const char *name
, const struct mapi_SPropValue_wrap
*r
)
965 ndr_print_mapi_SPropValue(ndr
, name
, (const struct mapi_SPropValue
*)r
);
970 * Fake wrapper over mapi_SPropValue_array. Workaround the no-pointer deep
971 * recursion problem in pidl
973 enum ndr_err_code
ndr_push_mapi_SPropValue_array_wrap(struct ndr_push
*ndr
, int ndr_flags
, const struct mapi_SPropValue_array_wrap
*r
)
975 NDR_CHECK(ndr_push_align(ndr
, 8));
976 return ndr_push_mapi_SPropValue_array(ndr
, NDR_SCALARS
, (const struct mapi_SPropValue_array
*)r
);
979 enum ndr_err_code
ndr_pull_mapi_SPropValue_array_wrap(struct ndr_pull
*ndr
, int ndr_flags
, struct mapi_SPropValue_array_wrap
*r
)
981 return ndr_pull_mapi_SPropValue_array(ndr
, NDR_SCALARS
, (struct mapi_SPropValue_array
*)r
);
984 void ndr_print_mapi_SPropValue_array_wrap(struct ndr_print
*ndr
, const char *name
, const struct mapi_SPropValue_array_wrap
*r
)
986 ndr_print_mapi_SPropValue_array(ndr
, name
, (const struct mapi_SPropValue_array
*)r
);
989 enum ndr_err_code
ndr_push_RestrictionVariable(struct ndr_push
*ndr
, int ndr_flags
, const union RestrictionVariable
*r
)
992 uint32_t _flags_save_STRUCT
= ndr
->flags
;
993 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
994 if (ndr_flags
& NDR_SCALARS
) {
995 int level
= ndr_push_get_switch_value(ndr
, r
);
1001 NDR_CHECK(ndr_push_mapi_SRestriction_comment(ndr
, NDR_SCALARS
, &r
->res
[0]));
1005 return ndr_push_error(ndr
, NDR_ERR_BAD_SWITCH
, "Bad switch value %u", level
);
1008 if (ndr_flags
& NDR_BUFFERS
) {
1009 int level
= ndr_push_get_switch_value(ndr
, r
);
1016 NDR_CHECK(ndr_push_mapi_SRestriction_comment(ndr
, NDR_BUFFERS
, &r
->res
[0]));
1021 return ndr_push_error(ndr
, NDR_ERR_BAD_SWITCH
, "Bad switch value %u", level
);
1024 ndr
->flags
= _flags_save_STRUCT
;
1026 return NDR_ERR_SUCCESS
;
1029 enum ndr_err_code
ndr_pull_RestrictionVariable(struct ndr_pull
*ndr
, int ndr_flags
, union RestrictionVariable
*r
)
1032 TALLOC_CTX
*_mem_save_res_0
;
1033 level
= ndr_pull_get_switch_value(ndr
, r
);
1035 uint32_t _flags_save_STRUCT
= ndr
->flags
;
1036 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
1038 if (ndr_flags
& NDR_SCALARS
) {
1044 NDR_CHECK(ndr_pull_align(ndr
, 4));
1045 NDR_PULL_ALLOC_N(ndr
, r
->res
, 1);
1046 _mem_save_res_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1047 NDR_PULL_SET_MEM_CTX(ndr
, r
->res
, 0);
1048 NDR_CHECK(ndr_pull_mapi_SRestriction_comment(ndr
, NDR_SCALARS
, &r
->res
[0]));
1049 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_res_0
, 0);
1053 return ndr_pull_error(ndr
, NDR_ERR_BAD_SWITCH
, "Bad switch value %u", level
);
1056 if (ndr_flags
& NDR_BUFFERS
) {
1063 _mem_save_res_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1064 NDR_PULL_SET_MEM_CTX(ndr
, r
->res
, 0);
1065 NDR_CHECK(ndr_pull_mapi_SRestriction_comment(ndr
, NDR_BUFFERS
, &r
->res
[0]));
1066 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_res_0
, 0);
1070 return ndr_pull_error(ndr
, NDR_ERR_BAD_SWITCH
, "Bad switch value %u", level
);
1073 ndr
->flags
= _flags_save_STRUCT
;
1075 return NDR_ERR_SUCCESS
;
1079 _PUBLIC_
void ndr_print_RestrictionVariable(struct ndr_print
*ndr
, const char *name
, const union RestrictionVariable
*r
)
1082 level
= ndr_print_get_switch_value(ndr
, r
);
1083 ndr_print_union(ndr
, name
, level
, "RestrictionVariable");
1089 ndr_print_ptr(ndr
, "res", r
->res
);
1092 ndr_set_flags(&ndr
->flags
, LIBNDR_FLAG_NOALIGN
);
1093 ndr_print_mapi_SRestriction_comment(ndr
, "res", &r
->res
[0]);
1100 enum ndr_err_code
ndr_push_Release_req(struct ndr_push
*ndr
, int ndr_flags
, const struct Release_req
*r
)
1102 return NDR_ERR_SUCCESS
;
1105 enum ndr_err_code
ndr_pull_Release_req(struct ndr_pull
*ndr
, int ndr_flags
, struct Release_req
*r
)
1107 return NDR_ERR_SUCCESS
;
1110 enum ndr_err_code
ndr_push_Release_repl(struct ndr_push
*ndr
, int ndr_flags
, const struct Release_repl
*r
)
1112 return NDR_ERR_SUCCESS
;
1115 enum ndr_err_code
ndr_pull_Release_repl(struct ndr_pull
*ndr
, int ndr_flags
, struct Release_repl
*r
)
1117 return NDR_ERR_SUCCESS
;