Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/librpc/tools/ndrdump.c

    r414 r740  
    128128}
    129129
     130static void printf_cb(const char *buf, void *private_data)
     131{
     132        printf("%s", buf);
     133}
     134
    130135static void ndrdump_data(uint8_t *d, uint32_t l, bool force)
    131136{
    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
     140static 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;
    137185}
    138186
     
    172220                { NULL }
    173221        };
    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;
    178224
    179225        ndr_table_init();
     
    184230        setlinebuf(stdout);
    185231
    186         dbf = x_stderr;
    187 
    188         setup_logging_stdout();
     232        setup_logging("ndrdump", DEBUG_STDOUT);
    189233
    190234        pc = poptGetContext("ndrdump", argc, argv, long_options, 0);
     
    253297        }
    254298
     299        f = find_function(p, function);
     300
    255301        if (strcmp(inout, "in") == 0 ||
    256302            strcmp(inout, "request") == 0) {
    257303                flags = NDR_IN;
     304                in_pipes = &f->in_pipes;
    258305        } else if (strcmp(inout, "out") == 0 ||
    259306                   strcmp(inout, "response") == 0) {
    260307                flags = NDR_OUT;
     308                out_pipes = &f->out_pipes;
    261309        } else {
    262310                printf("Bad inout value '%s'\n", inout);
    263311                exit(1);
    264312        }
    265 
    266         f = find_function(p, function);
    267313
    268314        mem_ctx = talloc_init("ndrdump");
     
    295341                blob.length = size;
    296342
    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);
    298344                ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    299345                if (assume_ndr64) {
     
    331377        blob.length = size;
    332378
    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);
    334380        ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    335381        if (assume_ndr64) {
    336382                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                }
    337395        }
    338396
     
    354412        }
    355413
    356         ndr_print = talloc_zero(mem_ctx, struct ndr_print);
    357         ndr_print->print = ndr_print_debug_helper;
    358         ndr_print->depth = 1;
    359414        f->ndr_print(ndr_print, function, flags, st);
    360415
     
    362417                printf("dump FAILED\n");
    363418                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                }
    364427        }
    365428
     
    373436                bool differ;
    374437
    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);
    376439               
    377440                ndr_err = f->ndr_push(ndr_v_push, flags, st);
     
    390453                }
    391454
    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);
    393456                ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    394457
Note: See TracChangeset for help on using the changeset viewer.