Changeset 740 for vendor/current/librpc/tools/ndrdump.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/librpc/tools/ndrdump.c
r414 r740 128 128 } 129 129 130 static void printf_cb(const char *buf, void *private_data) 131 { 132 printf("%s", buf); 133 } 134 130 135 static void ndrdump_data(uint8_t *d, uint32_t l, bool force) 131 136 { 132 if (force) { 133 dump_data(0, d, l); 134 } else { 135 dump_data_skip_zeros(0, d, l); 136 } 137 dump_data_cb(d, l, !force, printf_cb, NULL); 138 } 139 140 static NTSTATUS ndrdump_pull_and_print_pipes(const char *function, 141 struct ndr_pull *ndr_pull, 142 struct ndr_print *ndr_print, 143 const struct ndr_interface_call_pipes *pipes) 144 { 145 NTSTATUS status; 146 enum ndr_err_code ndr_err; 147 uint32_t i; 148 149 for (i=0; i < pipes->num_pipes; i++) { 150 uint64_t idx = 0; 151 while (true) { 152 uint32_t *count; 153 void *c; 154 char *n; 155 156 c = talloc_zero_size(ndr_pull, pipes->pipes[i].chunk_struct_size); 157 talloc_set_name(c, "struct %s", pipes->pipes[i].name); 158 /* 159 * Note: the first struct member is always 160 * 'uint32_t count;' 161 */ 162 count = (uint32_t *)c; 163 164 n = talloc_asprintf(c, "%s: %s[%llu]", 165 function, pipes->pipes[i].name, 166 (unsigned long long)idx); 167 168 ndr_err = pipes->pipes[i].ndr_pull(ndr_pull, NDR_SCALARS, c); 169 status = ndr_map_error2ntstatus(ndr_err); 170 171 printf("pull returned %s\n", nt_errstr(status)); 172 if (!NT_STATUS_IS_OK(status)) { 173 return status; 174 } 175 pipes->pipes[i].ndr_print(ndr_print, n, c); 176 177 if (*count == 0) { 178 break; 179 } 180 idx++; 181 } 182 } 183 184 return NT_STATUS_OK; 137 185 } 138 186 … … 172 220 { NULL } 173 221 }; 174 175 if (DEBUGLEVEL < 1) { 176 DEBUGLEVEL = 1; 177 } 222 struct ndr_interface_call_pipes *in_pipes = NULL; 223 struct ndr_interface_call_pipes *out_pipes = NULL; 178 224 179 225 ndr_table_init(); … … 184 230 setlinebuf(stdout); 185 231 186 dbf = x_stderr; 187 188 setup_logging_stdout(); 232 setup_logging("ndrdump", DEBUG_STDOUT); 189 233 190 234 pc = poptGetContext("ndrdump", argc, argv, long_options, 0); … … 253 297 } 254 298 299 f = find_function(p, function); 300 255 301 if (strcmp(inout, "in") == 0 || 256 302 strcmp(inout, "request") == 0) { 257 303 flags = NDR_IN; 304 in_pipes = &f->in_pipes; 258 305 } else if (strcmp(inout, "out") == 0 || 259 306 strcmp(inout, "response") == 0) { 260 307 flags = NDR_OUT; 308 out_pipes = &f->out_pipes; 261 309 } else { 262 310 printf("Bad inout value '%s'\n", inout); 263 311 exit(1); 264 312 } 265 266 f = find_function(p, function);267 313 268 314 mem_ctx = talloc_init("ndrdump"); … … 295 341 blob.length = size; 296 342 297 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx , lp_iconv_convenience(cmdline_lp_ctx));343 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); 298 344 ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 299 345 if (assume_ndr64) { … … 331 377 blob.length = size; 332 378 333 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx , lp_iconv_convenience(cmdline_lp_ctx));379 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); 334 380 ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 335 381 if (assume_ndr64) { 336 382 ndr_pull->flags |= LIBNDR_FLAG_NDR64; 383 } 384 385 ndr_print = talloc_zero(mem_ctx, struct ndr_print); 386 ndr_print->print = ndr_print_printf_helper; 387 ndr_print->depth = 1; 388 389 if (out_pipes) { 390 status = ndrdump_pull_and_print_pipes(function, ndr_pull, ndr_print, out_pipes); 391 if (!NT_STATUS_IS_OK(status)) { 392 printf("dump FAILED\n"); 393 exit(1); 394 } 337 395 } 338 396 … … 354 412 } 355 413 356 ndr_print = talloc_zero(mem_ctx, struct ndr_print);357 ndr_print->print = ndr_print_debug_helper;358 ndr_print->depth = 1;359 414 f->ndr_print(ndr_print, function, flags, st); 360 415 … … 362 417 printf("dump FAILED\n"); 363 418 exit(1); 419 } 420 421 if (in_pipes) { 422 status = ndrdump_pull_and_print_pipes(function, ndr_pull, ndr_print, in_pipes); 423 if (!NT_STATUS_IS_OK(status)) { 424 printf("dump FAILED\n"); 425 exit(1); 426 } 364 427 } 365 428 … … 373 436 bool differ; 374 437 375 ndr_v_push = ndr_push_init_ctx(mem_ctx , lp_iconv_convenience(cmdline_lp_ctx));438 ndr_v_push = ndr_push_init_ctx(mem_ctx); 376 439 377 440 ndr_err = f->ndr_push(ndr_v_push, flags, st); … … 390 453 } 391 454 392 ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx , lp_iconv_convenience(cmdline_lp_ctx));455 ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); 393 456 ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 394 457
Note:
See TracChangeset
for help on using the changeset viewer.