forked from openchange/openchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathndr_fasttransfer.c
698 lines (627 loc) · 22.3 KB
/
ndr_fasttransfer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
/*
OpenChange implementation.
libndr mapi support
Copyright (C) Julien Kerihuel 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libmapi/libmapi.h"
#include "libmapi/libmapi_private.h"
#include <ndr.h>
#include "gen_ndr/ndr_exchange.h"
#include "gen_ndr/ndr_property.h"
#include "gen_ndr/ndr_exchange_debug.h"
#if (!defined(NDR_COLOR))
#define NDR_COLOR
#define COLOR_BLACK
#define COLOR_RED
#define COLOR_GREEN
#define COLOR_YELLOW
#define COLOR_BLUE
#define COLOR_MAGENTA
#define COLOR_CYAN
#define COLOR_WHITE
#define COLOR_BOLD
#define COLOR_INVERSE
#define COLOR_BOLD_OFF
#define COLOR_END
#else
#define COLOR_BLACK "\x1b[30m"
#define COLOR_RED "\x1b[31m"
#define COLOR_GREEN "\x1b[32m"
#define COLOR_YELLOW "\x1b[33m"
#define COLOR_BLUE "\x1b[34m"
#define COLOR_MAGENTA "\x1b[35m"
#define COLOR_CYAN "\x1b[36m"
#define COLOR_WHITE "\x1b[37m"
#define COLOR_BOLD "\x1b[1m"
#define COLOR_INVERSE "\x1b[7m"
#define COLOR_BOLD_OFF "\x1b[22m"
#define COLOR_END "\x1b[0m"
#endif
#define NDR_RED(s) COLOR_RED #s COLOR_END
#define NDR_GREEN(s) COLOR_GREEN #s COLOR_END
#define NDR_YELLOW(s) COLOR_YELLOW #s COLOR_END
#define NDR_BLUE(s) COLOR_BLUE #s COLOR_END
#define NDR_MAGENTA(s) COLOR_MAGENTA #s COLOR_END
#define NDR_CYAN(s) COLOR_CYAN #s COLOR_END
#define NDR_WHITE(s) COLOR_WHITE #s COLOR_END
/* Make error checking from libndr calls compliant with FastTransfer
* buffer API calls which expects error to have a retval < 0. Set
* errno to libndr retval if needed afterwards */
#define NDR_CHECK_FT(call) do { \
enum ndr_err_code _status; \
_status = call; \
if (unlikely(!NDR_ERR_CODE_IS_SUCCESS(_status))) { \
errno = _status; \
return -1; \
} \
} while (0)
/**
*/
static int ndr_print_marker(struct ndr_print *ndr, uint32_t marker)
{
const char *val = NULL;
static bool noend = false;
static uint32_t _saved_depth = 0;
if (_saved_depth == 0) {
_saved_depth = ndr->depth;
}
ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX);
/* Adjust ndr depth */
switch (marker) {
case EndFolder:
case EndMessage:
case EndEmbed:
case EndToRecip:
case EndAttach:
case IncrSyncStateEnd:
if (_saved_depth != ndr->depth) {
ndr->depth--;
}
break;
case IncrSyncChg:
case IncrSyncChgPartial:
case IncrSyncStateBegin:
if (noend == true) ndr->depth--;
break;
}
switch (marker) {
/* Folders */
case StartTopFld: val = NDR_YELLOW("StartTopFld"); break;
case StartSubFld: val = NDR_YELLOW("StartSubFld"); break;
case EndFolder: val = NDR_YELLOW("EndFolder"); break;
/* Messages and their parts */
case StartMessage: val = NDR_YELLOW("StartMessage"); break;
case StartFAIMsg: val = NDR_YELLOW("StartFAIMsg"); break;
case EndMessage: val = NDR_YELLOW("EndMessage"); break;
case StartEmbed: val = NDR_YELLOW("StartEmbed"); break;
case EndEmbed: val = NDR_YELLOW("EndEmbed"); break;
case StartRecip: val = NDR_YELLOW("StartRecip"); break;
case EndToRecip: val = NDR_YELLOW("EndToRecip"); break;
case NewAttach: val = NDR_YELLOW("NewAttach"); break;
case EndAttach: val = NDR_YELLOW("EndAttach"); break;
/* Synchronization download */
case IncrSyncChg: val = NDR_YELLOW("IncrSyncChg"); noend = true; break;
case IncrSyncChgPartial: val = NDR_YELLOW("IncrSyncChgPartial"); noend = true; break;
case IncrSyncDel: val = NDR_YELLOW("IncrSyncDel"); break;
case IncrSyncEnd: val = NDR_YELLOW("IncrSyncEnd"); break;
case IncrSyncRead: val = NDR_YELLOW("IncrSyncRead"); break;
case IncrSyncStateBegin: val = NDR_YELLOW("IncrSyncStateBegin"); noend = true; break;
case IncrSyncStateEnd: val = NDR_YELLOW("IncrSyncStateEnd"); break;
case IncrSyncProgressMode: val = NDR_YELLOW("IncrSyncProgressMode"); break;
case IncrSyncProgressPerMsg: val = NDR_YELLOW("IncrSyncProgressPerMsg"); break;
case IncrSyncMessage: val = NDR_YELLOW("IncrSyncMessage"); break;
case IncrSyncGroupInfo: val = NDR_YELLOW("IncrSyncGroupInfo"); break;
/* Special */
case FXErrorInfo: val = "FXErrorInfo"; break;
}
if (val == NULL) {
return -1;
}
ndr_print_enum(ndr, NDR_YELLOW(Marker), "ENUM", val, marker);
/* Adjust ndr depth */
switch (marker) {
case EndFolder:
case EndMessage:
case EndEmbed:
case EndToRecip:
case EndAttach:
case IncrSyncStateEnd:
if (_saved_depth != ndr->depth) {
ndr->depth--;
}
break;
default:
ndr->depth++;
}
return 0;
}
static void ndr_print_IDSET(struct ndr_print *ndr, const struct idset *idset,
const char *label)
{
struct globset_range *range;
uint32_t i;
char *guid_str;
ndr->print(ndr, "%s:", label);
ndr->depth++;
while (idset) {
if (idset->idbased) {
ndr->print(ndr, COLOR_CYAN "%.4x (%d elements):" COLOR_END, idset->repl.id, idset->range_count);
}
else {
guid_str = GUID_string(NULL, &idset->repl.guid);
ndr->print(ndr, COLOR_CYAN "{%s} (%d elements):" COLOR_END, guid_str, idset->range_count);
talloc_free(guid_str);
}
ndr->depth++;
range = idset->ranges;
for (i = 0; i < idset->range_count; i++) {
if (exchange_globcnt(range->low) > exchange_globcnt(range->high)) {
ndr->print(ndr, COLOR_BOLD COLOR_RED "Incorrect GLOBCNT range as high value is larger than low value" COLOR_END COLOR_END);
}
ndr->print(ndr, COLOR_CYAN "0x%.12" PRIx64 ":0x%.12" PRIx64 COLOR_END, range->low, range->high);
range = range->next;
}
ndr->depth--;
idset = idset->next;
}
ndr->depth--;
}
/**
\details Enhanced display of the PidTagAdditionalRenEntryIds
property content as described in [MS-OXOSFLD] section 2.2.4
This PT_MV_BINARY property is an array of SBinary values (bin.cb on
4 bytes) while MAPI properties generally use an array of
SBinary_short (bin.cb on 2 bytes)
\param ndr pointer to the ndr print structure
\param r pointer to the mapi_SBinaryArray_32 pulled structure
\param label the name of the property
\return void
*/
static void ndr_print_PidTagAdditionalRenEntryIds(struct ndr_print *ndr, const struct mapi_SBinaryArray_32 *r, const char *label)
{
uint32_t i;
const char *folders[] = { COLOR_MAGENTA "Conflicts" COLOR_END,
COLOR_MAGENTA "Sync Issues" COLOR_END,
COLOR_MAGENTA "Local Failures" COLOR_END,
COLOR_MAGENTA "Server Failures" COLOR_END,
COLOR_MAGENTA "Junk E-mail" COLOR_END,
COLOR_BOLD COLOR_RED "Suspicious ID" COLOR_END COLOR_END,
NULL };
uint32_t max = 5;
if (r == NULL) { ndr_print_null(ndr); return; }
ndr->print(ndr, "%s: ARRAY(%d)", label, (int)r->cValues);
ndr->depth++;
for (i = 0; i < r->cValues; i++) {
if (i < max) {
ndr_print_SBinary(ndr, folders[i], &r->bin[i]);
} else {
ndr_print_SBinary(ndr, folders[max], &r->bin[i]);
}
}
ndr->depth--;
}
/**
\details Enhanced display of the PidTagFreeBusyEntryIds
property content as described in [MS-OXOSFLD] Section 2.2.6
This PT_MV_BINARY property is an array of SBinary values (bin.cb on
4 bytes) while MAPI properties generally use an array of
SBinary_short (bin.cb on 2 bytes)
\param ndr pointer to the ndr print structure
\param r pointer to the mapi_SBinaryArray_32 pulled structure
\param label the name of the property
\return void
*/
static void ndr_print_PidTagFreeBusyEntryIds(struct ndr_print *ndr, const struct mapi_SBinaryArray_32 *r, const char *label)
{
uint32_t i;
const char *entries[] = { COLOR_MAGENTA "Null" COLOR_END,
COLOR_MAGENTA "Delegate Information Object EntryID" COLOR_END,
COLOR_MAGENTA "Free/Busy Message EntryID" COLOR_END,
COLOR_MAGENTA "Freebusy Data EntryID" COLOR_END,
COLOR_BOLD COLOR_RED "Suspicious entry" COLOR_END COLOR_END,
NULL };
uint32_t max = 4;
if (r == NULL) { ndr_print_null(ndr); return; }
ndr->print(ndr, "%s: ARRAY(%d)", label, (int)r->cValues);
ndr->depth++;
for (i = 0; i < r->cValues; i++) {
if (i < max) {
ndr_print_SBinary(ndr, entries[i], &r->bin[i]);
} else {
ndr_print_SBinary(ndr, entries[max], &r->bin[i]);
}
}
ndr->depth--;
}
static int ndr_parse_ics_state(TALLOC_CTX *mem_ctx, struct ndr_print *ndr,
struct ndr_pull *ndr_pull, uint32_t element)
{
bool idbased;
struct idset *idset;
struct SBinary PtypBinary;
DATA_BLOB buffer;
const char *name = NULL;
switch (element) {
case MetaTagIdsetGiven: name = COLOR_BOLD NDR_CYAN(MetaTagIdsetGiven) COLOR_BOLD_OFF; break;
case MetaTagCnsetSeen: name = COLOR_BOLD NDR_CYAN(MetaTagCnsetSeen) COLOR_BOLD_OFF; break;
case MetaTagCnsetSeenFAI: name = COLOR_BOLD NDR_CYAN(MetaTagCnsetSeenFAI) COLOR_BOLD_OFF; break;
case MetaTagCnsetRead: name = COLOR_BOLD NDR_CYAN(MetaTagCnsetRead) COLOR_BOLD_OFF; break;
case MetaTagIdsetDeleted: name = COLOR_BOLD NDR_CYAN(MetaTagIdsetDeleted) COLOR_BOLD_OFF; break;
}
switch (element) {
case MetaTagIdsetGiven:
case MetaTagCnsetSeen:
case MetaTagCnsetSeenFAI:
case MetaTagCnsetRead:
case MetaTagIdsetDeleted:
NDR_CHECK_FT(ndr_pull_SBinary(ndr_pull, NDR_SCALARS, &PtypBinary));
buffer.length = PtypBinary.cb;
buffer.data = PtypBinary.lpb;
idbased = (element == MetaTagIdsetDeleted) ? true : false;
idset = IDSET_parse(mem_ctx, buffer, idbased);
ndr_print_IDSET(ndr, idset, name);
return 0;
default:
return -1;
}
return -1;
}
static int ndr_parse_property(TALLOC_CTX *mem_ctx, struct ndr_print *ndr,
struct ndr_pull *ndr_pull, uint32_t element)
{
struct XID xid;
struct SizedXid SizedXid;
struct ndr_pull *_ndr_buffer;
struct mapi_SBinaryArray_32 binarray_32;
uint32_t len;
char *propValue;
switch (element) {
case PidTagChangeKey:
case PidTagSourceKey:
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(%s) COLOR_BOLD_OFF, get_proptag_name(element));
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &len));
NDR_CHECK_FT((ndr_pull_subcontext_start(ndr_pull, &_ndr_buffer, 0, len)));
NDR_CHECK_FT(ndr_pull_XID(_ndr_buffer, NDR_SCALARS, &xid));
ndr_print_XID(ndr, propValue, &xid);
NDR_CHECK_FT(ndr_pull_subcontext_end(ndr_pull, _ndr_buffer, 4, -1));
return 0;
case PidTagPredecessorChangeList:
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(%s) COLOR_BOLD_OFF, get_proptag_name(element));
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &len));
NDR_CHECK_FT((ndr_pull_subcontext_start(ndr_pull, &_ndr_buffer, 0, len)));
ndr->print(ndr, "%s:", propValue);
ndr->depth++;
while (_ndr_buffer->offset < _ndr_buffer->data_size) {
NDR_CHECK_FT(ndr_pull_SizedXid(_ndr_buffer, NDR_SCALARS, &SizedXid));
ndr_print_XID(ndr, NULL, &SizedXid.XID);
}
ndr->depth--;
NDR_CHECK_FT(ndr_pull_subcontext_end(ndr_pull, _ndr_buffer, 4, -1));
return 0;
case PidTagAdditionalRenEntryIds:
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(%s) COLOR_BOLD_OFF, get_proptag_name(element));
NDR_CHECK_FT(ndr_pull_mapi_SBinaryArray_32(ndr_pull, NDR_SCALARS, &binarray_32));
ndr_print_PidTagAdditionalRenEntryIds(ndr, &binarray_32, propValue);
return 0;
case PidTagFreeBusyEntryIds:
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(%s) COLOR_BOLD_OFF, get_proptag_name(element));
NDR_CHECK_FT(ndr_pull_mapi_SBinaryArray_32(ndr_pull, NDR_SCALARS, &binarray_32));
ndr_print_PidTagFreeBusyEntryIds(ndr, &binarray_32, propValue);
return 0;
default:
return -1;
}
return -1;
}
/* Parse namedPropInfo element which includes:
PytpGuid ((%x00 PytpInteger32) | (%x01 PtypString))
to set the name and kind of the parsed named property
*/
static int ndr_parse_namedproperty(TALLOC_CTX *mem_ctx, struct ndr_print *ndr,
struct ndr_pull *ndr_pull, uint32_t element,
char **named_prop)
{
const char *name;
struct GUID PytpGuid;
uint8_t ul_kind;
uint32_t dispid;
if (!named_prop) {
return -1;
}
NDR_CHECK_FT(ndr_pull_GUID(ndr_pull, NDR_SCALARS, &PytpGuid));
NDR_CHECK_FT(ndr_pull_uint8(ndr_pull, NDR_SCALARS, &ul_kind));
if (ul_kind == MNID_ID) {
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &dispid));
*named_prop = talloc_asprintf(mem_ctx, "(LID 0x%08x)", dispid);
if (!*named_prop) {
return -1;
}
} else if (ul_kind == MNID_STRING) {
uint32_t _flags_save_string = ndr_pull->flags;
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_STR_NULLTERM);
NDR_CHECK_FT(ndr_pull_string(ndr_pull, NDR_SCALARS, &name));
ndr_pull->flags = _flags_save_string;
*named_prop = talloc_asprintf(mem_ctx, "(Name \"%s\")", name);
if (!*named_prop) {
return -1;
}
} else {
/* Incorrect named property type */
return -1;
}
return 0;
}
static int ndr_parse_propValue(TALLOC_CTX *mem_ctx, struct ndr_print *ndr,
struct ndr_pull *ndr_pull, uint32_t element)
{
uint16_t PtypInteger16;
uint32_t PtypInteger32;
double PtypFloating64;
uint16_t PtypBoolean;
int64_t PtypInteger64;
struct FILETIME PtypTime;
struct GUID PtypGuid;
const char *PtypString;
const char *PtypString8;
struct Binary_r PtypServerId;
struct SBinary PtypBinary;
struct mapi_SLPSTRArrayW PtypMvUnicode;
const char *_propValue;
char *propValue, *named_prop;
int i, ret;
DATA_BLOB datablob;
_propValue = get_proptag_name(element);
if (_propValue == NULL) {
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(0x%X) COLOR_BOLD_OFF, element);
if (!propValue) {
return -1;
}
} else {
propValue = talloc_asprintf(mem_ctx, COLOR_BOLD NDR_MAGENTA(%s) COLOR_BOLD_OFF, _propValue);
if (!propValue) {
return -1;
}
}
/* named property with propid > 0x8000 or known property */
if ((element >> 16) & 0x8000) {
ret = ndr_parse_namedproperty(mem_ctx, ndr, ndr_pull, element, &named_prop);
if (ret != 0) {
return ret;
}
propValue = talloc_asprintf_append(propValue, " %s", named_prop);
}
switch (element & 0xFFFF) {
/* fixedSizeValue */
case PT_SHORT:
NDR_CHECK_FT(ndr_pull_uint16(ndr_pull, NDR_SCALARS, &PtypInteger16));
ndr_print_uint16(ndr, propValue, PtypInteger16);
break;
case PT_LONG:
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &PtypInteger32));
ndr_print_uint32(ndr, propValue, PtypInteger32);
break;
/* no support for PtypFloating32 0x0004 PT_FLOAT */
case PT_DOUBLE:
NDR_CHECK_FT(ndr_pull_double(ndr_pull, NDR_SCALARS, &PtypFloating64));
ndr_print_double(ndr, propValue, PtypFloating64);
break;
/* no support for PtypCurrency, 0x0006 PT_CURRENCY */
/* no support for PtypFloatingTime, 0x0007 PT_APPTIME */
case PT_BOOLEAN:
NDR_CHECK_FT(ndr_pull_uint16(ndr_pull, NDR_SCALARS, &PtypBoolean));
ndr_print_string(ndr, propValue, (const char *)((PtypBoolean == true) ? "True" : "False"));
//ndr_print_uint16(ndr, propValue, PtypBoolean);
break;
case PT_I8:
NDR_CHECK_FT(ndr_pull_dlong(ndr_pull, NDR_SCALARS, &PtypInteger64));
ndr_print_dlong(ndr, propValue, PtypInteger64);
break;
case PT_SYSTIME:
NDR_CHECK_FT(ndr_pull_FILETIME(ndr_pull, NDR_SCALARS, &PtypTime));
ndr_print_FILETIME(ndr, propValue, &PtypTime);
break;
case PT_CLSID:
NDR_CHECK_FT(ndr_pull_GUID(ndr_pull, NDR_SCALARS, &PtypGuid));
ndr_print_GUID(ndr, propValue, &PtypGuid);
break;
/* varSizeValue */
case PT_UNICODE:
{
uint32_t _flags_save_string = ndr_pull->flags;
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &PtypInteger32));
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_STR_NULLTERM);
NDR_CHECK_FT(ndr_pull_string(ndr_pull, NDR_SCALARS, &PtypString));
ndr_pull->flags = _flags_save_string;
ndr_print_string(ndr, propValue, PtypString);
}
break;
case PT_STRING8:
{
/* FIXME: probably need to pull uint32_t first */
uint32_t _flags_save_string = ndr_pull->flags;
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_STR_RAW8|LIBNDR_FLAG_STR_NULLTERM|LIBNDR_FLAG_STR_SIZE4);
NDR_CHECK_FT(ndr_pull_string(ndr_pull, NDR_SCALARS, &PtypString8));
ndr_pull->flags = _flags_save_string;
ndr_print_string(ndr, propValue, PtypString8);
}
break;
case PT_SVREID:
NDR_CHECK_FT(ndr_pull_Binary_r(ndr_pull, NDR_SCALARS, &PtypServerId));
ndr_print_Binary_r(ndr, propValue, &PtypServerId);
break;
case PT_BINARY:
NDR_CHECK_FT(ndr_pull_SBinary(ndr_pull, NDR_SCALARS, &PtypBinary));
ndr_print_SBinary(ndr, propValue, &PtypBinary);
break;
case PT_MV_UNICODE:
NDR_CHECK(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &PtypMvUnicode.cValues));
PtypMvUnicode.strings = talloc_zero_array(ndr_pull, struct mapi_LPWSTR, PtypMvUnicode.cValues);
if (!PtypMvUnicode.strings) {
return -1;
}
for (i = 0; i < PtypMvUnicode.cValues; i++) {
uint32_t _flags_save_string = ndr_pull->flags;
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &PtypInteger32));
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_STR_NULLTERM);
NDR_CHECK_FT(ndr_pull_string(ndr_pull, NDR_SCALARS, &PtypString));
ndr_pull->flags = _flags_save_string;
PtypMvUnicode.strings[i].lppszW = talloc_strdup(ndr, PtypString);
if (!PtypMvUnicode.strings[i].lppszW) {
return -1;
}
}
ndr_print_mapi_SLPSTRArrayW(ndr, propValue, &PtypMvUnicode);
break;
default:
{
uint32_t _flags_save_default = ndr_pull->flags;
ndr->print(ndr, COLOR_RED "Not supported: %s" COLOR_END, propValue);
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_REMAINING);
NDR_CHECK_FT(ndr_pull_DATA_BLOB(ndr_pull, NDR_SCALARS, &datablob));
ndr_pull->flags = _flags_save_default;
ndr_dump_data(ndr, datablob.data, datablob.length);
}
}
talloc_free(propValue);
return 0;
}
/**
\details Parse and Display Fast Transfer element. An element is either
a marker or a propvalue.
\param mem_ctx pointer to the memory context
\param ndr pointer to the ndr_print structure
\param ndr_pull pointer to the ndr_pull structure representing the fxbuffer
\return value >= 0 on success, otherwise -1
*/
static int ndr_parse_FastTransferElement(TALLOC_CTX *mem_ctx, struct ndr_print *ndr, struct ndr_pull *ndr_pull)
{
uint32_t element;
int ret;
NDR_CHECK_FT(ndr_pull_uint32(ndr_pull, NDR_SCALARS, &element));
ret = ndr_print_marker(ndr, element);
if (ret == 0) return 0;
ret = ndr_parse_ics_state(mem_ctx, ndr, ndr_pull, element);
if (ret == 0) return 0;
ret = ndr_parse_property(mem_ctx, ndr, ndr_pull, element);
if (ret == 0) return 0;
ret = ndr_parse_propValue(mem_ctx, ndr, ndr_pull, element);
return ret;
}
/**
\details Parse and display Fast Transfer Stream
\param ndr pointer to the ndr_print structure
\param buf the FastTransfer Stream buffer to parse
\return 0 on success, otherwise -1
*/
static int ndr_parse_FastTransferStream(struct ndr_print *ndr, DATA_BLOB buf)
{
TALLOC_CTX *mem_ctx;
struct ndr_pull *ndr_pull;
int ret = 0;
int offset;
mem_ctx = talloc_named(NULL, 0, "FastTransferStream");
if (!mem_ctx) return -1;
if (buf.length == 0) return 0;
/* Map DATA_BLOB to ndr pull context */
ndr_pull = talloc_zero(mem_ctx, struct ndr_pull);
if (!ndr_pull) return -1;
ndr_pull->flags |= LIBNDR_FLAG_NOALIGN;
ndr_pull->current_mem_ctx = mem_ctx;
ndr_pull->data = buf.data;
ndr_pull->data_size = buf.length;
ndr_pull->offset = 0;
ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_NOALIGN);
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
while (ndr_pull->offset < ndr_pull->data_size -1) {
offset = ndr_parse_FastTransferElement(mem_ctx, ndr, ndr_pull);
if (offset < 0) {
ret = -1;
goto end;
}
}
end:
talloc_free(mem_ctx);
return ret;
}
_PUBLIC_ void ndr_print_FastTransferSourceGetBuffer_repl(struct ndr_print *ndr, const char *name, const struct FastTransferSourceGetBuffer_repl *r)
{
int res;
ndr_print_struct(ndr, name, "FastTransferSourceGetBuffer_repl");
if (r == NULL) { ndr_print_null(ndr); return; }
{
uint32_t _flags_save_STRUCT = ndr->flags;
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
ndr->depth++;
ndr_print_TransferStatus(ndr, "TransferStatus", r->TransferStatus);
ndr_print_uint16(ndr, "InProgressCount", r->InProgressCount);
ndr_print_uint16(ndr, "TotalStepCount", r->TotalStepCount);
ndr_print_uint8(ndr, "Reserved", r->Reserved);
ndr_print_uint16(ndr, "TransferBufferSize", r->TransferBufferSize);
ndr_print_DATA_BLOB(ndr, "TransferBuffer", r->TransferBuffer);
res = ndr_parse_FastTransferStream(ndr, r->TransferBuffer);
if (res != 0) {
ndr_print_DATA_BLOB(ndr, "TransferBuffer", r->TransferBuffer);
}
ndr->depth--;
ndr->flags = _flags_save_STRUCT;
}
}
_PUBLIC_ void ndr_print_SyncUploadStateStreamContinue_req(struct ndr_print *ndr, const char *name, const struct SyncUploadStateStreamContinue_req *r)
{
ndr_print_struct(ndr, name, "SyncUploadStateStreamContinue_req");
if (r == NULL) { ndr_print_null(ndr); return; }
{
uint32_t _flags_save_STRUCT = ndr->flags;
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
ndr->depth++;
{
TALLOC_CTX *mem_ctx;
struct idset *idset;
DATA_BLOB buffer;
mem_ctx = talloc_named(NULL, 0, "SyncUploadStateStreamContinue");
if (!mem_ctx) return;
buffer.length = r->StreamDataSize;
buffer.data = r->StreamData;
idset = IDSET_parse(mem_ctx, buffer, false);
ndr_print_IDSET(ndr, idset, name);
talloc_free(mem_ctx);
}
ndr->depth--;
ndr->flags = _flags_save_STRUCT;
}
}
/* Debug interface */
_PUBLIC_ void ndr_print_FastTransferSourceGetBuffer(struct ndr_print *ndr, const char *name, int flags, const struct FastTransferSourceGetBuffer *r)
{
ndr_print_struct(ndr, name, "FastTransferSourceGetBuffer");
if (r == NULL) { ndr_print_null(ndr); return; }
ndr->depth++;
if (flags & NDR_SET_VALUES) {
ndr->flags |= LIBNDR_PRINT_SET_VALUES;
}
if (flags & NDR_IN) {
ndr_print_struct(ndr, "in", "FastTransferSourceGetBuffer");
ndr->depth++;
ndr_print_DATA_BLOB(ndr, "data", r->in.data);
ndr_parse_FastTransferStream(ndr, r->in.data);
ndr->depth--;
}
if (flags & NDR_OUT) {
ndr_print_struct(ndr, "out", "FastTransferSourceGetBuffer");
ndr->depth++;
ndr_print_DATA_BLOB(ndr, "data", r->out.data);
ndr_parse_FastTransferStream(ndr, r->out.data);
ndr->depth--;
}
ndr->depth--;
}