Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
1 deleted
22 edited
13 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/librpc/ndr/libndr.h

    r590 r745  
    6161        uint32_t offset;
    6262
    63         struct smb_iconv_convenience *iconv_convenience;
    64 
     63        uint32_t relative_highest_offset;
    6564        uint32_t relative_base_offset;
     65        uint32_t relative_rap_convert;
    6666        struct ndr_token_list *relative_base_list;
    6767
     
    9393        struct ndr_token_list *relative_begin_list;
    9494        struct ndr_token_list *nbt_string_list;
     95        struct ndr_token_list *dns_string_list;
    9596        struct ndr_token_list *full_ptr_list;
    9697
    9798        /* this is used to ensure we generate unique reference IDs */
    9899        uint32_t ptr_count;
    99 
    100         struct smb_iconv_convenience *iconv_convenience;
    101100};
    102101
     
    106105        uint32_t depth;
    107106        struct ndr_token_list *switch_list;
    108         struct smb_iconv_convenience *iconv_convenience;
    109107        void (*print)(struct ndr_print *, const char *, ...) PRINTF_ATTRIBUTE(2,3);
    110108        void *private_data;
     109        bool no_newline;
    111110};
    112111
     
    192191        NDR_ERR_TOKEN,
    193192        NDR_ERR_IPV4ADDRESS,
     193        NDR_ERR_IPV6ADDRESS,
    194194        NDR_ERR_INVALID_POINTER,
    195195        NDR_ERR_UNREAD_BYTES,
     
    329329extern const struct ndr_syntax_id ndr_transfer_syntax;
    330330extern const struct ndr_syntax_id ndr64_transfer_syntax;
     331extern const struct ndr_syntax_id null_ndr_syntax_id;
     332
     333struct ndr_interface_call_pipe {
     334        const char *name;
     335        const char *chunk_struct_name;
     336        size_t chunk_struct_size;
     337        ndr_push_flags_fn_t ndr_push;
     338        ndr_pull_flags_fn_t ndr_pull;
     339        ndr_print_fn_t ndr_print;
     340};
     341
     342struct ndr_interface_call_pipes {
     343        uint32_t num_pipes;
     344        const struct ndr_interface_call_pipe *pipes;
     345};
    331346
    332347struct ndr_interface_call {
     
    336351        ndr_pull_flags_fn_t ndr_pull;
    337352        ndr_print_function_t ndr_print;
    338         bool async;
     353        struct ndr_interface_call_pipes in_pipes;
     354        struct ndr_interface_call_pipes out_pipes;
    339355};
    340356
     
    364380NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err);
    365381const char *ndr_map_error2string(enum ndr_err_code ndr_err);
     382#define ndr_errstr ndr_map_error2string
    366383
    367384/* FIXME: Use represent_as instead */
     
    378395void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
    379396size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
    380 void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip);
    381397void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
    382398bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2);
    383 enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
    384 enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, uint32_t level, ndr_push_flags_fn_t fn);
    385 size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push, struct smb_iconv_convenience *);
    386 size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push, struct smb_iconv_convenience *);
     399enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn);
     400enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_push_flags_fn_t fn);
     401size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push);
     402size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push);
    387403uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr);
    388404void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset);
     
    390406enum ndr_err_code ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p);
    391407enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p);
     408enum ndr_err_code ndr_push_short_relative_ptr1(struct ndr_push *ndr, const void *p);
    392409enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, const void *p);
    393410enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, const void *p);
     411enum ndr_err_code ndr_push_short_relative_ptr2(struct ndr_push *ndr, const void *p);
    394412uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr);
    395413void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset);
     
    398416enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset);
    399417enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p);
     418enum ndr_err_code ndr_pull_relative_ptr_short(struct ndr_pull *ndr, uint16_t *v);
    400419size_t ndr_align_size(uint32_t offset, size_t n);
    401 struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience);
     420struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
    402421enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size);
    403 struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience);
     422struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx);
    404423DATA_BLOB ndr_push_blob(struct ndr_push *ndr);
    405424enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size);
    406425void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
     426void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    407427void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    408428void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr);
     
    441461                         const void *key,
    442462                         uint32_t value);
    443 enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, comparison_fn_t _cmp_fn, bool _remove_tok);
     463enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, int(*_cmp_fn)(const void*,const void*), bool _remove_tok);
    444464enum ndr_err_code ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v);
    445465uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key);
     
    450470uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p);
    451471enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length);
     472enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count);
     473enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count);
    452474enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val);
    453475enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val);
     
    456478uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p);
    457479uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p);
    458 enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, ndr_pull_flags_fn_t fn);
    459 enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, ndr_pull_flags_fn_t fn);
    460 enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
    461 enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
     480enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
     481enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
     482enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
     483enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
    462484
    463485/* from libndr_basic.h */
     
    487509NDR_SCALAR_PROTO(pointer, void *)
    488510NDR_SCALAR_PROTO(time_t, time_t)
     511NDR_SCALAR_PROTO(uid_t, uid_t)
     512NDR_SCALAR_PROTO(gid_t, gid_t)
    489513NDR_SCALAR_PROTO(NTSTATUS, NTSTATUS)
    490514NDR_SCALAR_PROTO(WERROR, WERROR)
     
    494518NDR_SCALAR_PROTO(DATA_BLOB, DATA_BLOB)
    495519NDR_SCALAR_PROTO(ipv4address, const char *)
     520NDR_SCALAR_PROTO(ipv6address, const char *)
    496521NDR_SCALAR_PROTO(string, const char *)
    497522NDR_SCALAR_PROTO(double, double)
     
    500525enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r);
    501526void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, const struct policy_handle *r);
    502 bool policy_handle_empty(struct policy_handle *h);
     527bool policy_handle_empty(const struct policy_handle *h);
     528bool is_valid_policy_hnd(const struct policy_handle *hnd);
     529bool policy_handle_equal(const struct policy_handle *hnd1,
     530                         const struct policy_handle *hnd2);
    503531
    504532void ndr_check_padding(struct ndr_pull *ndr, size_t n);
     
    520548enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr);
    521549void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type);
     550void ndr_print_null(struct ndr_print *ndr);
    522551void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, const char *val, uint32_t value);
    523552void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value);
     
    544573/* GUIDs */
    545574bool GUID_equal(const struct GUID *u1, const struct GUID *u2);
     575NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b);
    546576NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid);
    547577NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid);
     
    566596_PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v);
    567597
     598_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
     599
    568600#endif /* __LIBNDR_H__ */
  • trunk/server/librpc/ndr/ndr.c

    r596 r745  
    4747};
    4848
     49const struct ndr_syntax_id null_ndr_syntax_id = {
     50  { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
     51  0
     52};
     53
    4954/*
    5055  work out the number of bytes needed to align on a n byte boundary
     
    5964  initialise a ndr parse structure from a data blob
    6065*/
    61 _PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience)
     66_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
    6267{
    6368        struct ndr_pull *ndr;
     
    6974        ndr->data = blob->data;
    7075        ndr->data_size = blob->length;
    71         ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);
    7276
    7377        return ndr;
     
    103107
    104108/* create a ndr_push structure, ready for some marshalling */
    105 _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience)
     109_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
    106110{
    107111        struct ndr_push *ndr;
     
    118122                return NULL;
    119123        }
    120         ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);
    121124
    122125        return ndr;
     
    169172        va_list ap;
    170173        char *s = NULL;
    171         int i, ret;
     174        uint32_t i;
     175        int ret;
    172176
    173177        va_start(ap, format);
     
    179183        }
    180184
     185        if (ndr->no_newline) {
     186                DEBUGADD(1,("%s", s));
     187                free(s);
     188                return;
     189        }
     190
    181191        for (i=0;i<ndr->depth;i++) {
    182192                DEBUGADD(1,("    "));
     
    187197}
    188198
     199_PUBLIC_ void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...)
     200{
     201        va_list ap;
     202        uint32_t i;
     203
     204        if (!ndr->no_newline) {
     205                for (i=0;i<ndr->depth;i++) {
     206                        printf("    ");
     207                }
     208        }
     209
     210        va_start(ap, format);
     211        vprintf(format, ap);
     212        va_end(ap);
     213        if (!ndr->no_newline) {
     214                printf("\n");
     215        }
     216}
     217
    189218_PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...)
    190219{
    191220        va_list ap;
    192         int i;
    193 
    194         for (i=0;i<ndr->depth;i++) {
    195                 ndr->private_data = talloc_asprintf_append_buffer(
    196                                         (char *)ndr->private_data, "    ");
     221        uint32_t i;
     222
     223        if (!ndr->no_newline) {
     224                for (i=0;i<ndr->depth;i++) {
     225                        ndr->private_data = talloc_asprintf_append_buffer(
     226                                (char *)ndr->private_data, "    ");
     227                }
    197228        }
    198229
     
    201232                                                    format, ap);
    202233        va_end(ap);
    203         ndr->private_data = talloc_asprintf_append_buffer((char *)ndr->private_data,
    204                                                    "\n");
     234        if (!ndr->no_newline) {
     235                ndr->private_data = talloc_asprintf_append_buffer((char *)ndr->private_data,
     236                                                                  "\n");
     237        }
    205238}
    206239
     
    257290        ndr->flags = 0;
    258291
    259         /* this is a s4 hack until we build up the courage to pass
    260          * this all the way down
    261          */
    262 #if _SAMBA_BUILD_ == 4
    263         ndr->iconv_convenience = smb_iconv_convenience_init(talloc_autofree_context(), "ASCII", "UTF-8", true);
    264 #endif
    265 
    266292        fn(ndr, name, flags, ptr);
    267293        talloc_free(ndr);
     
    285311        ndr->depth = 1;
    286312        ndr->flags = 0;
    287 
    288         /* this is a s4 hack until we build up the courage to pass
    289          * this all the way down
    290          */
    291 #if _SAMBA_BUILD_ == 4
    292         ndr->iconv_convenience = smb_iconv_convenience_init(talloc_autofree_context(), "ASCII", "UTF-8", true);
    293 #endif
    294313
    295314        fn(ndr, name, ptr);
     
    554573        subndr->offset = 0;
    555574        subndr->data_size = r_content_size;
    556         subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience);
    557575
    558576        if (force_le) {
     
    590608        struct ndr_push *subndr;
    591609
    592         subndr = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
     610        subndr = ndr_push_init_ctx(ndr);
    593611        NDR_ERR_HAVE_NO_MEMORY(subndr);
    594612        subndr->flags   = ndr->flags & ~LIBNDR_FLAG_NDR64;
     
    812830}
    813831
     832_PUBLIC_ enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count)
     833{
     834        if (ndr->flags & LIBNDR_FLAG_NDR64) {
     835                int64_t tmp = 0 - (int64_t)count;
     836                uint64_t ncount = tmp;
     837
     838                NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, ncount));
     839        }
     840
     841        return NDR_ERR_SUCCESS;
     842}
     843
     844_PUBLIC_ enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count)
     845{
     846        if (ndr->flags & LIBNDR_FLAG_NDR64) {
     847                int64_t tmp = 0 - (int64_t)count;
     848                uint64_t ncount1 = tmp;
     849                uint64_t ncount2;
     850
     851                NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &ncount2));
     852                if (ncount1 == ncount2) {
     853                        return NDR_ERR_SUCCESS;
     854                }
     855
     856                return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE,
     857                        "Bad pipe trailer[%lld should be %lld] size was %lu\"",
     858                        (unsigned long long)ncount2,
     859                        (unsigned long long)ncount1,
     860                        (unsigned long)count);
     861        }
     862
     863        return NDR_ERR_SUCCESS;
     864}
     865
    814866/*
    815867  store a switch value
     
    851903  pull a struct from a blob using NDR
    852904*/
    853 _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p,
     905_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
    854906                              ndr_pull_flags_fn_t fn)
    855907{
    856908        struct ndr_pull *ndr;
    857         ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
     909        ndr = ndr_pull_init_blob(blob, mem_ctx);
    858910        NDR_ERR_HAVE_NO_MEMORY(ndr);
    859911        NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
     
    866918*/
    867919_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
    868                                                     struct smb_iconv_convenience *iconv_convenience,
    869920                                                    void *p, ndr_pull_flags_fn_t fn)
    870921{
    871922        struct ndr_pull *ndr;
    872         ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
     923        uint32_t highest_ofs;
     924        ndr = ndr_pull_init_blob(blob, mem_ctx);
    873925        NDR_ERR_HAVE_NO_MEMORY(ndr);
    874926        NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
    875         if (ndr->offset < ndr->data_size) {
    876                 return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
    877                                       "not all bytes consumed ofs[%u] size[%u]",
    878                                       ndr->offset, ndr->data_size);
     927        if (ndr->offset > ndr->relative_highest_offset) {
     928                highest_ofs = ndr->offset;
     929        } else {
     930                highest_ofs = ndr->relative_highest_offset;
     931        }
     932        if (highest_ofs < ndr->data_size) {
     933                enum ndr_err_code ret;
     934                ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
     935                                     "not all bytes consumed ofs[%u] size[%u]",
     936                                     highest_ofs, ndr->data_size);
     937                talloc_free(ndr);
     938                return ret;
    879939        }
    880940        talloc_free(ndr);
     
    886946*/
    887947_PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
    888                                                struct smb_iconv_convenience *iconv_convenience, void *p,
     948                                               void *p,
    889949                             uint32_t level, ndr_pull_flags_fn_t fn)
    890950{
    891951        struct ndr_pull *ndr;
    892         ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
     952        ndr = ndr_pull_init_blob(blob, mem_ctx);
    893953        NDR_ERR_HAVE_NO_MEMORY(ndr);
    894954        NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
     
    903963*/
    904964_PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
    905                                                    struct smb_iconv_convenience *iconv_convenience, void *p,
     965                                                   void *p,
    906966                             uint32_t level, ndr_pull_flags_fn_t fn)
    907967{
    908968        struct ndr_pull *ndr;
    909         ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
     969        uint32_t highest_ofs;
     970        ndr = ndr_pull_init_blob(blob, mem_ctx);
    910971        NDR_ERR_HAVE_NO_MEMORY(ndr);
    911972        NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
    912973        NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
    913         if (ndr->offset < ndr->data_size) {
     974        if (ndr->offset > ndr->relative_highest_offset) {
     975                highest_ofs = ndr->offset;
     976        } else {
     977                highest_ofs = ndr->relative_highest_offset;
     978        }
     979        if (highest_ofs < ndr->data_size) {
    914980                enum ndr_err_code ret;
    915981                ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
    916982                                     "not all bytes consumed ofs[%u] size[%u]",
    917                                      ndr->offset, ndr->data_size);
     983                                     highest_ofs, ndr->data_size);
    918984                talloc_free(ndr);
    919985                return ret;
     
    926992  push a struct to a blob using NDR
    927993*/
    928 _PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn)
     994_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn)
    929995{
    930996        struct ndr_push *ndr;
    931         ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience);
     997        ndr = ndr_push_init_ctx(mem_ctx);
    932998        NDR_ERR_HAVE_NO_MEMORY(ndr);
    933999
     
    9441010  push a union to a blob using NDR
    9451011*/
    946 _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p,
     1012_PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
    9471013                             uint32_t level, ndr_push_flags_fn_t fn)
    9481014{
    9491015        struct ndr_push *ndr;
    950         ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience);
     1016        ndr = ndr_push_init_ctx(mem_ctx);
    9511017        NDR_ERR_HAVE_NO_MEMORY(ndr);
    9521018
     
    9641030  generic ndr_size_*() handler for structures
    9651031*/
    966 _PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push, struct smb_iconv_convenience *iconv_convenience)
     1032_PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
    9671033{
    9681034        struct ndr_push *ndr;
     
    9731039        if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0;
    9741040
    975         ndr = ndr_push_init_ctx(NULL, iconv_convenience);
     1041        ndr = ndr_push_init_ctx(NULL);
    9761042        if (!ndr) return 0;
    9771043        ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
     
    9891055  generic ndr_size_*() handler for unions
    9901056*/
    991 _PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push, struct smb_iconv_convenience *iconv_convenience)
     1057_PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push)
    9921058{
    9931059        struct ndr_push *ndr;
     
    9981064        if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0;
    9991065
    1000         ndr = ndr_push_init_ctx(NULL, iconv_convenience);
     1066        ndr = ndr_push_init_ctx(NULL);
    10011067        if (!ndr) return 0;
    10021068        ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
     
    10671133}
    10681134
     1135/*
     1136  push a short relative object - stage1
     1137  this is called during SCALARS processing
     1138*/
     1139_PUBLIC_ enum ndr_err_code ndr_push_short_relative_ptr1(struct ndr_push *ndr, const void *p)
     1140{
     1141        if (p == NULL) {
     1142                NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 0));
     1143                return NDR_ERR_SUCCESS;
     1144        }
     1145        NDR_CHECK(ndr_push_align(ndr, 2));
     1146        NDR_CHECK(ndr_token_store(ndr, &ndr->relative_list, p, ndr->offset));
     1147        return ndr_push_uint16(ndr, NDR_SCALARS, 0xFFFF);
     1148}
    10691149/*
    10701150  push a relative object - stage2
     
    10921172        }       
    10931173        NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, save_offset - ndr->relative_base_offset));
     1174        ndr->offset = save_offset;
     1175        return NDR_ERR_SUCCESS;
     1176}
     1177/*
     1178  push a short relative object - stage2
     1179  this is called during buffers processing
     1180*/
     1181_PUBLIC_ enum ndr_err_code ndr_push_short_relative_ptr2(struct ndr_push *ndr, const void *p)
     1182{
     1183        uint32_t save_offset;
     1184        uint32_t ptr_offset = 0xFFFF;
     1185        if (p == NULL) {
     1186                return NDR_ERR_SUCCESS;
     1187        }
     1188        save_offset = ndr->offset;
     1189        NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &ptr_offset));
     1190        if (ptr_offset > ndr->offset) {
     1191                return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
     1192                                      "ndr_push_short_relative_ptr2 ptr_offset(%u) > ndr->offset(%u)",
     1193                                      ptr_offset, ndr->offset);
     1194        }
     1195        ndr->offset = ptr_offset;
     1196        if (save_offset < ndr->relative_base_offset) {
     1197                return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
     1198                                      "ndr_push_relative_ptr2 save_offset(%u) < ndr->relative_base_offset(%u)",
     1199                                      save_offset, ndr->relative_base_offset);
     1200        }
     1201        NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, save_offset - ndr->relative_base_offset));
    10941202        ndr->offset = save_offset;
    10951203        return NDR_ERR_SUCCESS;
  • trunk/server/librpc/ndr/ndr_basic.c

    r596 r745  
    2323#include "system/network.h"
    2424#include "librpc/ndr/libndr.h"
     25#include "lib/util/util_net.h"
    2526
    2627#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs))
     
    177178
    178179/*
     180  parse a pointer referent identifier stored in 2 bytes
     181*/
     182_PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr_short(struct ndr_pull *ndr, uint16_t *v)
     183{
     184        NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, v));
     185        if (*v != 0) {
     186                ndr->ptr_count++;
     187        }
     188        *(v) -= ndr->relative_rap_convert;
     189        return NDR_ERR_SUCCESS;
     190}
     191
     192/*
    179193  parse a pointer referent identifier
    180194*/
     
    239253{
    240254        NDR_PULL_ALIGN(ndr, 8);
     255        if (NDR_BE(ndr)) {
     256                return ndr_pull_udlongr(ndr, ndr_flags, v);
     257        }
    241258        return ndr_pull_udlong(ndr, ndr_flags, v);
    242259}
     
    536553{
    537554        NDR_PUSH_ALIGN(ndr, 8);
     555        if (NDR_BE(ndr)) {
     556                return ndr_push_udlongr(ndr, NDR_SCALARS, v);
     557        }
    538558        return ndr_push_udlong(ndr, NDR_SCALARS, v);
    539559}
     
    791811
    792812/*
     813  push a uid_t
     814*/
     815_PUBLIC_ enum ndr_err_code ndr_push_uid_t(struct ndr_push *ndr, int ndr_flags, uid_t u)
     816{
     817        return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)u);
     818}
     819
     820/*
     821  pull a uid_t
     822*/
     823_PUBLIC_ enum ndr_err_code ndr_pull_uid_t(struct ndr_pull *ndr, int ndr_flags, uid_t *u)
     824{
     825        uint64_t uu;
     826        NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &uu));
     827        *u = (uid_t)uu;
     828        if (unlikely(uu != *u)) {
     829                DEBUG(0,(__location__ ": uid_t pull doesn't fit 0x%016llx\n",
     830                         (unsigned long long)uu));
     831                return NDR_ERR_NDR64;
     832        }
     833        return NDR_ERR_SUCCESS;
     834}
     835
     836
     837/*
     838  push a gid_t
     839*/
     840_PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t g)
     841{
     842        return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)g);
     843}
     844
     845/*
     846  pull a gid_t
     847*/
     848_PUBLIC_ enum ndr_err_code ndr_pull_gid_t(struct ndr_pull *ndr, int ndr_flags, gid_t *g)
     849{
     850        uint64_t gg;
     851        NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &gg));
     852        *g = (gid_t)gg;
     853        if (unlikely(gg != *g)) {
     854                DEBUG(0,(__location__ ": gid_t pull doesn't fit 0x%016llx\n",
     855                         (unsigned long long)gg));
     856                return NDR_ERR_NDR64;
     857        }
     858        return NDR_ERR_SUCCESS;
     859}
     860
     861
     862/*
    793863  pull a ipv4address
    794864*/
     
    812882        if (!is_ipaddress(address)) {
    813883                return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
    814                                       "Invalid IPv4 address: '%s'", 
     884                                      "Invalid IPv4 address: '%s'",
    815885                                      address);
    816886        }
     
    823893  print a ipv4address
    824894*/
    825 _PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, 
     895_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
    826896                           const char *address)
    827897{
     
    829899}
    830900
     901/*
     902  pull a ipv6address
     903*/
     904#define IPV6_BYTES 16
     905#define IPV6_ADDR_STR_LEN 39
     906_PUBLIC_ enum ndr_err_code ndr_pull_ipv6address(struct ndr_pull *ndr, int ndr_flags, const char **address)
     907{
     908        uint8_t addr[IPV6_BYTES];
     909        char *addr_str = talloc_strdup(ndr->current_mem_ctx, "");
     910        int i;
     911        NDR_CHECK(ndr_pull_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES));
     912        for (i = 0; i < IPV6_BYTES; ++i) {
     913                addr_str = talloc_asprintf_append(addr_str, "%02x", addr[i]);
     914                /* We need a ':' every second byte but the last one */
     915                if (i%2 == 1 && i != (IPV6_BYTES - 1)) {
     916                        addr_str = talloc_strdup_append(addr_str, ":");
     917                }
     918        }
     919        *address = addr_str;
     920        NDR_ERR_HAVE_NO_MEMORY(*address);
     921        return NDR_ERR_SUCCESS;
     922}
     923
     924/*
     925  push a ipv6address
     926*/
     927_PUBLIC_ enum ndr_err_code ndr_push_ipv6address(struct ndr_push *ndr, int ndr_flags, const char *address)
     928{
     929#ifdef AF_INET6
     930        uint8_t addr[IPV6_BYTES];
     931        int ret;
     932
     933        if (!is_ipaddress(address)) {
     934                return ndr_push_error(ndr, NDR_ERR_IPV6ADDRESS,
     935                                      "Invalid IPv6 address: '%s'",
     936                                      address);
     937        }
     938        ret = inet_pton(AF_INET6, address, addr);
     939        if (ret <= 0) {
     940                return NDR_ERR_IPV6ADDRESS;
     941        }
     942
     943        NDR_CHECK(ndr_push_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES));
     944
     945        return NDR_ERR_SUCCESS;
     946#else
     947        return NDR_ERR_IPV6ADDRESS;
     948#endif
     949}
     950
     951/*
     952  print a ipv6address
     953*/
     954_PUBLIC_ void ndr_print_ipv6address(struct ndr_print *ndr, const char *name,
     955                           const char *address)
     956{
     957        ndr->print(ndr, "%-25s: %s", name, address);
     958}
     959#undef IPV6_BYTES
    831960
    832961_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
    833962{
    834963        ndr->print(ndr, "%s: struct %s", name, type);
     964}
     965
     966_PUBLIC_ void ndr_print_null(struct ndr_print *ndr)
     967{
     968        ndr->print(ndr, "UNEXPECTED NULL POINTER");
    835969}
    836970
     
    8911025}
    8921026
     1027_PUBLIC_ void ndr_print_int3264(struct ndr_print *ndr, const char *name, int32_t v)
     1028{
     1029        ndr->print(ndr, "%-25s: %d", name, v);
     1030}
     1031
     1032_PUBLIC_ void ndr_print_uint3264(struct ndr_print *ndr, const char *name, uint32_t v)
     1033{
     1034        ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
     1035}
     1036
    8931037_PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v)
    8941038{
     
    9571101}
    9581102
     1103_PUBLIC_ void ndr_print_uid_t(struct ndr_print *ndr, const char *name, uid_t u)
     1104{
     1105        ndr_print_dlong(ndr, name, u);
     1106}
     1107
     1108_PUBLIC_ void ndr_print_gid_t(struct ndr_print *ndr, const char *name, gid_t g)
     1109{
     1110        ndr_print_dlong(ndr, name, g);
     1111}
     1112
    9591113_PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type)
    9601114{
     
    9751129{
    9761130        int i;
     1131
     1132        if (data == NULL) {
     1133                ndr->print(ndr, "%s: ARRAY(%d) : NULL", name, count);
     1134                return;
     1135        }
    9771136
    9781137        if (count <= 600 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {
     
    9981157}
    9991158
     1159static void ndr_print_asc(struct ndr_print *ndr, const uint8_t *buf, int len)
     1160{
     1161        int i;
     1162        for (i=0;i<len;i++)
     1163                ndr->print(ndr, "%c", isprint(buf[i])?buf[i]:'.');
     1164}
     1165
     1166/*
     1167  ndr_print version of dump_data()
     1168 */
     1169static void ndr_dump_data(struct ndr_print *ndr, const uint8_t *buf, int len)
     1170{
     1171        int i=0;
     1172
     1173        ndr->no_newline = true;
     1174
     1175        for (i=0;i<len;) {
     1176                if (i%16 == 0 && i<len) {
     1177                        ndr->print(ndr, "[%04X] ",i);
     1178                }
     1179
     1180                ndr->print(ndr, "%02X ",(int)buf[i]);
     1181                i++;
     1182                if (i%8 == 0) ndr->print(ndr,"  ");
     1183                if (i%16 == 0) {
     1184                        ndr_print_asc(ndr,&buf[i-16],8); ndr->print(ndr," ");
     1185                        ndr_print_asc(ndr,&buf[i-8],8); ndr->print(ndr, "\n");
     1186                }
     1187        }
     1188
     1189        if (i%16) {
     1190                int n;
     1191                n = 16 - (i%16);
     1192                ndr->print(ndr, " ");
     1193                if (n>8) ndr->print(ndr," ");
     1194                while (n--) ndr->print(ndr,"   ");
     1195                n = MIN(8,i%16);
     1196                ndr_print_asc(ndr,&buf[i-(i%16)],n); ndr->print(ndr, " ");
     1197                n = (i%16) - n;
     1198                if (n>0) ndr_print_asc(ndr,&buf[i-n],n);
     1199                ndr->print(ndr,"\n");
     1200        }
     1201
     1202        ndr->no_newline = false;
     1203}
     1204
     1205
    10001206_PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r)
    10011207{
    10021208        ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, (unsigned)r.length);
    10031209        if (r.length) {
    1004                 dump_data(10, r.data, r.length);
     1210                ndr_dump_data(ndr, r.data, r.length);
    10051211        }
    10061212}
     
    10691275        return ret + data->length;
    10701276}
     1277
     1278_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b)
     1279{
     1280        ndr->print(ndr, "%-25s: %s", name, b?"true":"false");
     1281}
     1282
     1283_PUBLIC_ NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err)
     1284{
     1285        switch (ndr_err) {
     1286        case NDR_ERR_SUCCESS:
     1287                return NT_STATUS_OK;
     1288        case NDR_ERR_BUFSIZE:
     1289                return NT_STATUS_BUFFER_TOO_SMALL;
     1290        case NDR_ERR_TOKEN:
     1291                return NT_STATUS_INTERNAL_ERROR;
     1292        case NDR_ERR_ALLOC:
     1293                return NT_STATUS_NO_MEMORY;
     1294        case NDR_ERR_ARRAY_SIZE:
     1295                return NT_STATUS_ARRAY_BOUNDS_EXCEEDED;
     1296        case NDR_ERR_INVALID_POINTER:
     1297                return NT_STATUS_INVALID_PARAMETER_MIX;
     1298        case NDR_ERR_UNREAD_BYTES:
     1299                return NT_STATUS_PORT_MESSAGE_TOO_LONG;
     1300        default:
     1301                break;
     1302        }
     1303
     1304        /* we should map all error codes to different status codes */
     1305        return NT_STATUS_INVALID_PARAMETER;
     1306}
  • trunk/server/librpc/ndr/ndr_compression.c

    r414 r745  
    392392        z_stream z;
    393393
    394         ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience);
     394        ndrpush = ndr_push_init_ctx(subndr);
    395395        NDR_ERR_HAVE_NO_MEMORY(ndrpush);
    396396
     
    431431        comndr->data_size       = uncompressed.length;
    432432        comndr->offset          = 0;
    433 
    434         comndr->iconv_convenience = talloc_reference(comndr, subndr->iconv_convenience);
    435433
    436434        *_comndr = comndr;
     
    466464        }
    467465
    468         uncomndr = ndr_push_init_ctx(subndr, subndr->iconv_convenience);
     466        uncomndr = ndr_push_init_ctx(subndr);
    469467        NDR_ERR_HAVE_NO_MEMORY(uncomndr);
    470468        uncomndr->flags = subndr->flags;
     
    493491        ndrpull->offset         = 0;
    494492
    495         ndrpull->iconv_convenience = talloc_reference(ndrpull, subndr->iconv_convenience);
    496 
    497493        switch (compression_alg) {
    498494        case NDR_COMPRESSION_MSZIP:
  • trunk/server/librpc/ndr/ndr_compression.h

    r414 r745  
     1/*
     2   Unix SMB/CIFS implementation.
     3
     4   libndr compression support
     5
     6   Copyright (C) Stefan Metzmacher 2005
     7   Copyright (C) Matthieu Suiche 2008
     8
     9   This program is free software; you can redistribute it and/or modify
     10   it under the terms of the GNU General Public License as published by
     11   the Free Software Foundation; either version 3 of the License, or
     12   (at your option) any later version.
     13
     14   This program is distributed in the hope that it will be useful,
     15   but WITHOUT ANY WARRANTY; without even the implied warranty of
     16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17   GNU General Public License for more details.
     18
     19   You should have received a copy of the GNU General Public License
     20   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     21*/
     22
    123#ifndef __LIBRPC_NDR_NDR_COMPRESSION_H__
    224#define __LIBRPC_NDR_NDR_COMPRESSION_H__
  • trunk/server/librpc/ndr/ndr_drsblobs.c

    r414 r745  
    55
    66   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
     7   Copyright (C) Guenther Deschner <gd@samba.org> 2010
    78   
    89   This program is free software; you can redistribute it and/or modify
     
    2223#include "includes.h"
    2324#include "librpc/gen_ndr/ndr_drsblobs.h"
     25#include "../lib/util/asn1.h"
    2426
    25 /* parser auto-generated by pidl, then hand-modified by abartlet */
    26 
    27 /* Modified to have 'count' specified */
    28 static enum ndr_err_code ndr_push_AuthenticationInformationArray_with_count(struct ndr_push *ndr, int ndr_flags, int count,
    29                                                                  const struct AuthenticationInformationArray *r)
     27_PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, int ndr_flags, const struct AuthenticationInformationArray *r)
    3028{
    3129        uint32_t cntr_array_0;
    3230        if (ndr_flags & NDR_SCALARS) {
    3331                NDR_CHECK(ndr_push_align(ndr, 4));
    34                 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
     32                for (cntr_array_0 = 0; cntr_array_0 < r->count; cntr_array_0++) {
    3533                        NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
    3634                }
     35                NDR_CHECK(ndr_push_trailer_align(ndr, 4));
    3736        }
    3837        if (ndr_flags & NDR_BUFFERS) {
    39                 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
    40                         NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0]));
    41                 }
    4238        }
    4339        return NDR_ERR_SUCCESS;
    4440}
    4541
    46 /* Modified to have 'count' specified, and to allocate the array */
    47 static enum ndr_err_code ndr_pull_AuthenticationInformationArray_with_count(struct ndr_pull *ndr, int ndr_flags, int count, struct AuthenticationInformationArray *r)
     42_PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, int ndr_flags, struct AuthenticationInformationArray *r)
    4843{
    49         uint32_t cntr_array_0;
    50         TALLOC_CTX *_mem_save_array_0;
    5144        if (ndr_flags & NDR_SCALARS) {
    52                 NDR_CHECK(ndr_pull_align(ndr, 4));
    53                 NDR_PULL_ALLOC_N(ndr, r->array, count);
    54                 _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr);
    55                 NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
    56                 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
    57                         NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0]));
     45                r->count = 0;
     46                NDR_PULL_ALLOC_N(ndr, r->array, r->count);
     47                /* entry is at least 16 bytes large */
     48                while (ndr->offset + 16 <= ndr->data_size) {
     49                        r->array = talloc_realloc(ndr, r->array, struct AuthenticationInformation, r->count + 1);
     50                        NDR_ERR_HAVE_NO_MEMORY(r->array);
     51                        NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[r->count]));
     52                        r->count++;
    5853                }
    59                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);
     54                NDR_CHECK(ndr_pull_trailer_align(ndr, 4));
    6055        }
    6156        if (ndr_flags & NDR_BUFFERS) {
    62                 for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) {
    63                         NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0]));
    64                 }
    6557        }
    6658        return NDR_ERR_SUCCESS;
    6759}
    6860
    69 /* Modified to have 'count' specified */
    70 _PUBLIC_ void ndr_print_AuthenticationInformationArray_with_count(struct ndr_print *ndr, const char *name, int count, const struct AuthenticationInformationArray *r)
    71 {
    72         uint32_t cntr_array_0;
    73         ndr_print_struct(ndr, name, "AuthenticationInformationArray");
    74         ndr->depth++;
    75         ndr->print(ndr, "%s: ARRAY(%d)", "array", (int)1);
    76         ndr->depth++;
    77         for (cntr_array_0=0;cntr_array_0<count;cntr_array_0++) {
    78                 char *idx_0=NULL;
    79                 if (asprintf(&idx_0, "[%d]", cntr_array_0) != -1) {
    80                         ndr_print_AuthenticationInformation(ndr, "array", &r->array[cntr_array_0]);
    81                         free(idx_0);
    82                 }
    83         }
    84         ndr->depth--;
    85         ndr->depth--;
    86 }
    87 
    88 /* Modified to call AuthenticationInformationArray with 'count' specified */
    8961_PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r)
    9062{
     
    9264                NDR_CHECK(ndr_push_align(ndr, 4));
    9365                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
    94                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->current));
    95                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous));
     66                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0));
     67                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0));
     68                {
     69                        struct ndr_push *_ndr_current;
     70                        NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0) - ((r->count > 0)?12:0)));
     71                        NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current));
     72                        NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0) - ((r->count > 0)?12:0)));
     73                }
     74                {
     75                        uint32_t _flags_save_AuthenticationInformationArray = ndr->flags;
     76                        ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
     77                        {
     78                                struct ndr_push *_ndr_previous;
     79                                NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_previous, 0, -1));
     80                                NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_previous, NDR_SCALARS, &r->previous));
     81                                NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_previous, 0, -1));
     82                        }
     83                        ndr->flags = _flags_save_AuthenticationInformationArray;
     84                }
     85                NDR_CHECK(ndr_push_trailer_align(ndr, 4));
    9686        }
    9787        if (ndr_flags & NDR_BUFFERS) {
    98                 if (r->current) {
    99                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->current));
    100                         NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
    101                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->current));
    102                 }
    103                 if (r->previous) {
    104                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->previous));
    105                         NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
    106                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->previous));
    107                 }
    10888        }
    10989        return NDR_ERR_SUCCESS;
    11090}
    11191
    112 _PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r)
    113 {
    114         uint32_t _ptr_current;
    115         TALLOC_CTX *_mem_save_current_0;
    116         uint32_t _ptr_previous;
    117         TALLOC_CTX *_mem_save_previous_0;
    118         if (ndr_flags & NDR_SCALARS) {
    119                 NDR_CHECK(ndr_pull_align(ndr, 4));
    120                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
    121                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_current));
    122                 if (_ptr_current) {
    123                         NDR_PULL_ALLOC(ndr, r->current);
    124                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->current, _ptr_current));
    125                 } else {
    126                         r->current = NULL;
    127                 }
    128                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous));
    129                 if (_ptr_previous) {
    130                         NDR_PULL_ALLOC(ndr, r->previous);
    131                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous, _ptr_previous));
    132                 } else {
    133                         r->previous = NULL;
    134                 }
    135         }
    136         if (ndr_flags & NDR_BUFFERS) {
    137                 if (r->current) {
    138                         uint32_t _relative_save_offset;
    139                         _relative_save_offset = ndr->offset;
    140                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->current));
    141                         _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr);
    142                         NDR_PULL_SET_MEM_CTX(ndr, r->current, 0);
    143                         NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current));
    144                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0);
    145                         ndr->offset = _relative_save_offset;
    146                 }
    147                 if (r->previous) {
    148                         uint32_t _relative_save_offset;
    149                         _relative_save_offset = ndr->offset;
    150                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous));
    151                         _mem_save_previous_0 = NDR_PULL_GET_MEM_CTX(ndr);
    152                         NDR_PULL_SET_MEM_CTX(ndr, r->previous, 0);
    153                         NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous));
    154                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_0, 0);
    155                         ndr->offset = _relative_save_offset;
    156                 }
    157         }
    158         return NDR_ERR_SUCCESS;
    159 }
    160 
    161 _PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r)
    162 {
    163         ndr_print_struct(ndr, name, "trustAuthInOutBlob");
    164         ndr->depth++;
    165         ndr_print_uint32(ndr, "count", r->count);
    166         ndr_print_ptr(ndr, "current", r->current);
    167         ndr->depth++;
    168         if (r->current) {
    169                 ndr_print_AuthenticationInformationArray_with_count(ndr, "current", r->count, r->current);
    170         }
    171         ndr->depth--;
    172         ndr_print_ptr(ndr, "previous", r->previous);
    173         ndr->depth++;
    174         if (r->previous) {
    175                 ndr_print_AuthenticationInformationArray_with_count(ndr, "previous", r->count, r->previous);
    176         }
    177         ndr->depth--;
    178         ndr->depth--;
    179 }
    18092
    18193_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r)
     
    197109                        struct ndr_pull *_ndr_outgoing;
    198110                        NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size));
    199                         NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
     111                        NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));
    200112                        NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size));
    201113                }
     
    203115                        struct ndr_pull *_ndr_incoming;
    204116                        NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size));
    205                         NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
     117                        NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));
    206118                        NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size));
    207119                }
     
    214126}
    215127
     128_PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r)
     129{
     130        ndr_print_struct(ndr, name, "drsuapi_MSPrefixMap_Entry");
     131        {
     132                uint32_t _flags_save_STRUCT = ndr->flags;
     133                ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
     134                ndr->depth++;
     135                ndr_print_uint16(ndr, "entryID", r->entryID);
     136                ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
     137                if (r->binary_oid) {
     138                        char *partial_oid = NULL;
     139                        DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
     140                        char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
     141                        ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
     142                        ndr->depth++;
     143                        ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
     144                        ndr->depth--;
     145                        talloc_free(hex_str);
     146                        talloc_free(partial_oid);
     147                }
     148                ndr->depth--;
     149                ndr->flags = _flags_save_STRUCT;
     150        }
     151}
  • trunk/server/librpc/ndr/ndr_drsblobs.h

    r414 r745  
    2020*/
    2121
    22 _PUBLIC_ void ndr_print_AuthenticationInformationArray_with_count(struct ndr_print *ndr, const char *name, int count, const struct AuthenticationInformationArray *r);
    23 _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r);
    24 _PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r);
    25 _PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r);
    2622_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r);
    27 
     23_PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const char *name, const struct drsuapi_MSPrefixMap_Entry *r);
  • trunk/server/librpc/ndr/ndr_drsuapi.c

    r414 r745  
    6767}
    6868
    69 #define _OID_PUSH_CHECK(call) do { \
    70         bool _status; \
    71         _status = call; \
    72         if (_status != true) { \
    73                 return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
    74         } \
    75 } while (0)
    76 
    77 #define _OID_PULL_CHECK(call) do { \
    78         bool _status; \
    79         _status = call; \
    80         if (_status != true) { \
    81                 return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
    82         } \
    83 } while (0)
    84 
    85 enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r)
    86 {
    87         if (ndr_flags & NDR_SCALARS) {
    88                 NDR_CHECK(ndr_push_align(ndr, 4));
    89                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0)));
    90                 NDR_CHECK(ndr_push_unique_ptr(ndr, r->oid));
    91         }
    92         if (ndr_flags & NDR_BUFFERS) {
    93                 if (r->oid) {
    94                         DATA_BLOB blob;
    95 
    96                         if (strncasecmp("ff", r->oid, 2) == 0) {
    97                                 blob = strhex_to_data_blob(ndr, r->oid);
    98                                 if (!blob.data) {
    99                                         return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT,
    100                                                               "HEX String Conversion Error: %s\n",
    101                                                               __location__);
    102                                 }
    103                         } else {
    104                                 _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid));
    105                                 talloc_steal(ndr, blob.data);
    106                         }
    107 
    108                         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length));
    109                         NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length));
    110                 }
    111         }
    112         return NDR_ERR_SUCCESS;
    113 }
    114 
    115 enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r)
    116 {
    117         uint32_t _ptr_oid;
    118         TALLOC_CTX *_mem_save_oid_0;
    119         if (ndr_flags & NDR_SCALARS) {
    120                 NDR_CHECK(ndr_pull_align(ndr, 4));
    121                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__ndr_size));
    122                 if (r->__ndr_size < 0 || r->__ndr_size > 10000) {
    123                         return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
    124                 }
    125                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_oid));
    126                 if (_ptr_oid) {
    127                         NDR_PULL_ALLOC(ndr, r->oid);
    128                 } else {
    129                         r->oid = NULL;
    130                 }
    131         }
    132         if (ndr_flags & NDR_BUFFERS) {
    133                 if (r->oid) {
    134                         DATA_BLOB _oid_array;
    135                         const char *_oid;
    136 
    137                         _mem_save_oid_0 = NDR_PULL_GET_MEM_CTX(ndr);
    138                         NDR_PULL_SET_MEM_CTX(ndr, ndr, 0);
    139                         NDR_CHECK(ndr_pull_array_size(ndr, &r->oid));
    140                         _oid_array.length = ndr_get_array_size(ndr, &r->oid);
    141                         NDR_PULL_ALLOC_N(ndr, _oid_array.data, _oid_array.length);
    142                         NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, _oid_array.data, _oid_array.length));
    143                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oid_0, 0);
    144 
    145                         if (_oid_array.length && _oid_array.data[0] == 0xFF) {
    146                                 _oid = data_blob_hex_string(ndr, &_oid_array);
    147                                 NDR_ERR_HAVE_NO_MEMORY(_oid);
    148                         } else {
    149                                 _OID_PULL_CHECK(ber_read_OID_String(ndr, _oid_array, &_oid));
    150                         }
    151                         data_blob_free(&_oid_array);
    152                         talloc_steal(r->oid, _oid);
    153                         r->oid = _oid;
    154                 }
    155                 if (r->oid) {
    156                         NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->oid, r->__ndr_size));
    157                 }
    158         }
    159         return NDR_ERR_SUCCESS;
    160 }
    161 
    162 size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags)
    163 {
    164         DATA_BLOB _blob;
    165         size_t ret = 0;
    166 
    167         if (!oid) return 0;
    168 
    169         if (strncasecmp("ff", oid, 2) == 0) {
    170                 _blob = strhex_to_data_blob(NULL, oid);
    171                 if (_blob.data) {
    172                         ret = _blob.length;
    173                 }
     69_PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
     70{
     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, &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);
     85        }
     86        ndr->depth--;
     87}
     88
     89static void _print_drsuapi_DsAttributeValue_attid(struct ndr_print *ndr, const char *name,
     90                                                  const struct drsuapi_DsAttributeValue *r)
     91{
     92        uint32_t v;
     93
     94        ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue");
     95        ndr->depth++;
     96        v = IVAL(r->blob->data, 0);
     97        ndr_print_uint32(ndr, "attid", v);
     98        ndr->depth--;
     99}
     100
     101static void _print_drsuapi_DsAttributeValue_str(struct ndr_print *ndr, const char *name,
     102                                                const struct drsuapi_DsAttributeValue *r)
     103{
     104        char *str;
     105
     106        ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue");
     107        ndr->depth++;
     108        if (!convert_string_talloc(ndr,
     109                                   CH_UTF16, CH_UNIX,
     110                                   r->blob->data,
     111                                   r->blob->length,
     112                                   (void **)&str, NULL, false)) {
     113                ndr_print_string(ndr, "string", "INVALID CONVERSION");
    174114        } else {
    175                 if (ber_write_OID_String(&_blob, oid)) {
    176                         ret = _blob.length;
    177                 }
    178         }
    179         data_blob_free(&_blob);
    180         return ret;
     115                ndr_print_string(ndr, "string", str);
     116                talloc_free(str);
     117        }
     118        ndr->depth--;
     119}
     120
     121static void _print_drsuapi_DsAttributeValueCtr(struct ndr_print *ndr,
     122                                               const char *name,
     123                                               const struct drsuapi_DsAttributeValueCtr *r,
     124                                               void (*print_val_fn)(struct ndr_print *ndr, const char *name, const struct drsuapi_DsAttributeValue *r))
     125{
     126        uint32_t cntr_values_1;
     127        ndr_print_struct(ndr, name, "drsuapi_DsAttributeValueCtr");
     128        ndr->depth++;
     129        ndr_print_uint32(ndr, "num_values", r->num_values);
     130        ndr_print_ptr(ndr, "values", r->values);
     131        ndr->depth++;
     132        if (r->values) {
     133                ndr->print(ndr, "%s: ARRAY(%d)", "values", (int)r->num_values);
     134                ndr->depth++;
     135                for (cntr_values_1=0;cntr_values_1<r->num_values;cntr_values_1++) {
     136                        char *idx_1=NULL;
     137                        if (asprintf(&idx_1, "[%d]", cntr_values_1) != -1) {
     138                                //ndr_print_drsuapi_DsAttributeValue(ndr, "values", &r->values[cntr_values_1]);
     139                                print_val_fn(ndr, "values", &r->values[cntr_values_1]);
     140                                free(idx_1);
     141                        }
     142                }
     143                ndr->depth--;
     144        }
     145        ndr->depth--;
     146        ndr->depth--;
     147}
     148
     149_PUBLIC_ void ndr_print_drsuapi_DsReplicaAttribute(struct ndr_print *ndr,
     150                                                   const char *name,
     151                                                   const struct drsuapi_DsReplicaAttribute *r)
     152{
     153        ndr_print_struct(ndr, name, "drsuapi_DsReplicaAttribute");
     154        ndr->depth++;
     155        ndr_print_drsuapi_DsAttributeId(ndr, "attid", r->attid);
     156        switch (r->attid) {
     157        case DRSUAPI_ATTID_objectClass:
     158        case DRSUAPI_ATTID_possSuperiors:
     159        case DRSUAPI_ATTID_subClassOf:
     160        case DRSUAPI_ATTID_governsID:
     161        case DRSUAPI_ATTID_mustContain:
     162        case DRSUAPI_ATTID_mayContain:
     163        case DRSUAPI_ATTID_rDNAttId:
     164        case DRSUAPI_ATTID_attributeID:
     165        case DRSUAPI_ATTID_attributeSyntax:
     166        case DRSUAPI_ATTID_auxiliaryClass:
     167        case DRSUAPI_ATTID_systemPossSuperiors:
     168        case DRSUAPI_ATTID_systemMayContain:
     169        case DRSUAPI_ATTID_systemMustContain:
     170        case DRSUAPI_ATTID_systemAuxiliaryClass:
     171        case DRSUAPI_ATTID_transportAddressAttribute:
     172                /* ATTIDs for classSchema and attributeSchema */
     173                _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
     174                                                   _print_drsuapi_DsAttributeValue_attid);
     175                break;
     176        case DRSUAPI_ATTID_cn:
     177        case DRSUAPI_ATTID_ou:
     178        case DRSUAPI_ATTID_description:
     179        case DRSUAPI_ATTID_displayName:
     180        case DRSUAPI_ATTID_dMDLocation:
     181        case DRSUAPI_ATTID_adminDisplayName:
     182        case DRSUAPI_ATTID_adminDescription:
     183        case DRSUAPI_ATTID_lDAPDisplayName:
     184        case DRSUAPI_ATTID_name:
     185                _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
     186                                                   _print_drsuapi_DsAttributeValue_str);
     187                break;
     188        default:
     189                _print_drsuapi_DsAttributeValueCtr(ndr, "value_ctr", &r->value_ctr,
     190                                                   ndr_print_drsuapi_DsAttributeValue);
     191                break;
     192        }
     193        ndr->depth--;
    181194}
    182195
     
    353366}
    354367
    355 _PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags)
    356 {
    357         return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3, ic);
    358 }
    359 
     368_PUBLIC_ size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, int flags)
     369{
     370        return ndr_size_struct((const struct drsuapi_DsReplicaObjectIdentifier3 *)r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3);
     371}
     372
     373_PUBLIC_ void ndr_print_drsuapi_SecBufferType(struct ndr_print *ndr, const char *name, enum drsuapi_SecBufferType r)
     374{
     375        const char *val = NULL;
     376
     377        switch (r & 0x00000007) {
     378                case DRSUAPI_SECBUFFER_EMPTY: val = "DRSUAPI_SECBUFFER_EMPTY"; break;
     379                case DRSUAPI_SECBUFFER_DATA: val = "DRSUAPI_SECBUFFER_DATA"; break;
     380                case DRSUAPI_SECBUFFER_TOKEN: val = "DRSUAPI_SECBUFFER_TOKEN"; break;
     381                case DRSUAPI_SECBUFFER_PKG_PARAMS: val = "DRSUAPI_SECBUFFER_PKG_PARAMS"; break;
     382                case DRSUAPI_SECBUFFER_MISSING: val = "DRSUAPI_SECBUFFER_MISSING"; break;
     383                case DRSUAPI_SECBUFFER_EXTRA: val = "DRSUAPI_SECBUFFER_EXTRA"; break;
     384                case DRSUAPI_SECBUFFER_STREAM_TRAILER: val = "DRSUAPI_SECBUFFER_STREAM_TRAILER"; break;
     385                case DRSUAPI_SECBUFFER_STREAM_HEADER: val = "DRSUAPI_SECBUFFER_STREAM_HEADER"; break;
     386        }
     387
     388        if (r & DRSUAPI_SECBUFFER_READONLY) {
     389                char *v = talloc_asprintf(ndr, "DRSUAPI_SECBUFFER_READONLY | %s", val);
     390                ndr_print_enum(ndr, name, "ENUM", v, r);
     391        } else {
     392                ndr_print_enum(ndr, name, "ENUM", val, r);
     393        }
     394}
     395
     396_PUBLIC_ void ndr_print_drsuapi_DsAddEntry_AttrErrListItem_V1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsAddEntry_AttrErrListItem_V1 *r)
     397{
     398        ndr_print_struct(ndr, name, "drsuapi_DsAddEntry_AttrErrListItem_V1");
     399        ndr->depth++;
     400        ndr_print_ptr(ndr, "next", r->next);
     401        ndr_print_drsuapi_DsAddEntry_AttrErr_V1(ndr, "err_data", &r->err_data);
     402        ndr->depth--;
     403        if (r->next) {
     404                ndr_print_drsuapi_DsAddEntry_AttrErrListItem_V1(ndr, "next", r->next);
     405        }
     406}
  • trunk/server/librpc/ndr/ndr_drsuapi.h

    r414 r745  
    2929                                                 const struct drsuapi_DsReplicaObjectListItemEx *r);
    3030
    31 enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r);
    32 enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r);
    33 size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags);
     31size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, int flags);
    3432
    35 size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags);
    3633
    3734#endif /* _LIBRPC_NDR_NDR_DRSUAPI_H */
  • trunk/server/librpc/ndr/ndr_frsrpc.c

    r414 r745  
    8585
    8686size_t ndr_size_frsrpc_CommPktChunkCtr(const struct frsrpc_CommPktChunkCtr *r,
    87                                        struct smb_iconv_convenience *ic,
    8887                                       int flags)
    8988{
    9089        flags |= LIBNDR_FLAG_NOALIGN;
    9190        return ndr_size_struct(r, flags,
    92                         (ndr_push_flags_fn_t)ndr_push_frsrpc_CommPktChunkCtr,
    93                         ic);
     91                        (ndr_push_flags_fn_t)ndr_push_frsrpc_CommPktChunkCtr);
    9492}
  • trunk/server/librpc/ndr/ndr_frsrpc.h

    r414 r745  
    3030                                        struct frsrpc_CommPktChunkCtr *r);
    3131size_t ndr_size_frsrpc_CommPktChunkCtr(const struct frsrpc_CommPktChunkCtr *r,
    32                                        struct smb_iconv_convenience *ic,
    3332                                       int flags);
    3433
  • trunk/server/librpc/ndr/ndr_krb5pac.c

    r414 r745  
    2424#include "librpc/gen_ndr/ndr_krb5pac.h"
    2525
    26 static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
     26static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags)
    2727{
    28         size_t s = ndr_size_PAC_INFO(r, level, ic, flags);
     28        size_t s = ndr_size_PAC_INFO(r, level, flags);
    2929        switch (level) {
    3030                case PAC_TYPE_LOGON_INFO:
     
    3535}
    3636
    37 static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
     37static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags)
    3838{
    39         size_t s = ndr_size_PAC_INFO(r, level, ic, flags);
     39        size_t s = ndr_size_PAC_INFO(r, level, flags);
    4040        return NDR_ROUND(s,8);
    4141}
     
    4646                NDR_CHECK(ndr_push_align(ndr, 4));
    4747                NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
    48                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,ndr->iconv_convenience,0)));
     48                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0)));
    4949                {
    5050                        uint32_t _flags_save_PAC_INFO = ndr->flags;
     
    6363                                {
    6464                                        struct ndr_push *_ndr_info;
    65                                         NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,ndr->iconv_convenience, 0)));
     65                                        NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0)));
    6666                                        NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
    6767                                        NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
    68                                         NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,ndr->iconv_convenience,0)));
     68                                        NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0)));
    6969                                }
    7070                                NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->info));
     
    129129        ndr->depth++;
    130130        ndr_print_PAC_TYPE(ndr, "type", r->type);
    131         ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,ndr->iconv_convenience,0):r->_ndr_size);
     131        ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,0):r->_ndr_size);
    132132        ndr_print_ptr(ndr, "info", r->info);
    133133        ndr->depth++;
  • trunk/server/librpc/ndr/ndr_ntlmssp.c

    r414 r745  
    109109
    110110_PUBLIC_ void ndr_print_ntlmssp_nt_response(TALLOC_CTX *mem_ctx,
    111                                             struct smb_iconv_convenience *ic,
    112111                                            const DATA_BLOB *nt_response,
    113112                                            bool ntlmv2)
     
    118117                struct NTLMv2_RESPONSE nt;
    119118                if (nt_response->length > 24) {
    120                         ndr_err = ndr_pull_struct_blob(nt_response, mem_ctx, ic, &nt,
     119                        ndr_err = ndr_pull_struct_blob(nt_response, mem_ctx, &nt,
    121120                                        (ndr_pull_flags_fn_t)ndr_pull_NTLMv2_RESPONSE);
    122121                        if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    127126                struct NTLM_RESPONSE nt;
    128127                if (nt_response->length == 24) {
    129                         ndr_err = ndr_pull_struct_blob(nt_response, mem_ctx, ic, &nt,
     128                        ndr_err = ndr_pull_struct_blob(nt_response, mem_ctx, &nt,
    130129                                        (ndr_pull_flags_fn_t)ndr_pull_NTLM_RESPONSE);
    131130                        if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    137136
    138137_PUBLIC_ void ndr_print_ntlmssp_lm_response(TALLOC_CTX *mem_ctx,
    139                                             struct smb_iconv_convenience *ic,
    140138                                            const DATA_BLOB *lm_response,
    141139                                            bool ntlmv2)
     
    146144                struct LMv2_RESPONSE lm;
    147145                if (lm_response->length == 24) {
    148                         ndr_err = ndr_pull_struct_blob(lm_response, mem_ctx, ic, &lm,
     146                        ndr_err = ndr_pull_struct_blob(lm_response, mem_ctx, &lm,
    149147                                        (ndr_pull_flags_fn_t)ndr_pull_LMv2_RESPONSE);
    150148                        if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    155153                struct LM_RESPONSE lm;
    156154                if (lm_response->length == 24) {
    157                         ndr_err = ndr_pull_struct_blob(lm_response, mem_ctx, ic, &lm,
     155                        ndr_err = ndr_pull_struct_blob(lm_response, mem_ctx, &lm,
    158156                                        (ndr_pull_flags_fn_t)ndr_pull_LM_RESPONSE);
    159157                        if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    170168        switch (level) {
    171169                case NTLMSSP_NEGOTIATE_VERSION:
    172                         ndr_print_VERSION(ndr, name, &r->version);
     170                        ndr_print_ntlmssp_VERSION(ndr, name, &r->version);
    173171                break;
    174172
  • trunk/server/librpc/ndr/ndr_ntlmssp.h

    r414 r745  
    2525_PUBLIC_ enum ndr_err_code ndr_pull_AV_PAIR_LIST(struct ndr_pull *ndr, int ndr_flags, struct AV_PAIR_LIST *r);
    2626_PUBLIC_ void ndr_print_ntlmssp_nt_response(TALLOC_CTX *mem_ctx,
    27                                             struct smb_iconv_convenience *ic,
    2827                                            const DATA_BLOB *nt_response,
    2928                                            bool ntlmv2);
    3029_PUBLIC_ void ndr_print_ntlmssp_lm_response(TALLOC_CTX *mem_ctx,
    31                                             struct smb_iconv_convenience *ic,
    3230                                            const DATA_BLOB *lm_response,
    3331                                            bool ntlmv2);
  • trunk/server/librpc/ndr/ndr_schannel.c

    r414 r745  
    8686        case NL_SIGN_HMAC_MD5: {
    8787                struct NL_AUTH_SIGNATURE r;
    88                 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL, &r,
     88                ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &r,
    8989                       (ndr_pull_flags_fn_t)ndr_pull_NL_AUTH_SIGNATURE);
    9090                if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    9595        case NL_SIGN_HMAC_SHA256: {
    9696                struct NL_AUTH_SHA2_SIGNATURE r;
    97                 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL, &r,
     97                ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &r,
    9898                       (ndr_pull_flags_fn_t)ndr_pull_NL_AUTH_SHA2_SIGNATURE);
    9999                if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
  • trunk/server/librpc/ndr/ndr_sec_helper.c

    r414 r745  
    2424#include "includes.h"
    2525#include "librpc/gen_ndr/ndr_security.h"
    26 #if _SAMBA_BUILD_ == 4
    27 #include "libcli/security/security.h"
    28 #endif
     26#include "../libcli/security/security.h"
    2927
    3028/*
    3129  return the wire size of a security_ace
    3230*/
    33 size_t ndr_size_security_ace(const struct security_ace *ace, struct smb_iconv_convenience *ic, int flags)
     31size_t ndr_size_security_ace(const struct security_ace *ace, int flags)
    3432{
    3533        size_t ret;
     
    3735        if (!ace) return 0;
    3836
    39         ret = 8 + ndr_size_dom_sid(&ace->trustee, ic, flags);
     37        ret = 8 + ndr_size_dom_sid(&ace->trustee, flags);
    4038
    4139        switch (ace->type) {
     
    9290  return the wire size of a security_acl
    9391*/
    94 size_t ndr_size_security_acl(const struct security_acl *theacl, struct smb_iconv_convenience *ic, int flags)
     92size_t ndr_size_security_acl(const struct security_acl *theacl, int flags)
    9593{
    9694        size_t ret;
     
    9997        ret = 8;
    10098        for (i=0;i<theacl->num_aces;i++) {
    101                 ret += ndr_size_security_ace(&theacl->aces[i], ic, flags);
     99                ret += ndr_size_security_ace(&theacl->aces[i], flags);
    102100        }
    103101        return ret;
     
    107105  return the wire size of a security descriptor
    108106*/
    109 size_t ndr_size_security_descriptor(const struct security_descriptor *sd, struct smb_iconv_convenience *ic, int flags)
     107size_t ndr_size_security_descriptor(const struct security_descriptor *sd, int flags)
    110108{
    111109        size_t ret;
     
    113111       
    114112        ret = 20;
    115         ret += ndr_size_dom_sid(sd->owner_sid, ic, flags);
    116         ret += ndr_size_dom_sid(sd->group_sid, ic, flags);
    117         ret += ndr_size_security_acl(sd->dacl, ic, flags);
    118         ret += ndr_size_security_acl(sd->sacl, ic, flags);
     113        ret += ndr_size_dom_sid(sd->owner_sid, flags);
     114        ret += ndr_size_dom_sid(sd->group_sid, flags);
     115        ret += ndr_size_security_acl(sd->dacl, flags);
     116        ret += ndr_size_security_acl(sd->sacl, flags);
    119117        return ret;
    120118}
     
    123121  return the wire size of a dom_sid
    124122*/
    125 size_t ndr_size_dom_sid(const struct dom_sid *sid, struct smb_iconv_convenience *ic, int flags)
     123size_t ndr_size_dom_sid(const struct dom_sid *sid, int flags)
    126124{
    127125        if (!sid) return 0;
  • trunk/server/librpc/ndr/ndr_spoolss_buf.c

    r596 r745  
    6161        if (r->in.buffer) {\
    6262                DATA_BLOB _data_blob_info;\
    63                 _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\
     63                _ndr_info = ndr_push_init_ctx(ndr);\
    6464                NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
    6565                _ndr_info->flags= ndr->flags;\
     
    138138                struct ndr_pull *_ndr_info;\
    139139                NDR_PULL_ALLOC(ndr, *r->out.info);\
    140                 _ndr_info = ndr_pull_init_blob(_r.out.info, *r->out.info, ndr->iconv_convenience);\
     140                _ndr_info = ndr_pull_init_blob(_r.out.info, *r->out.info);\
    141141                NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
    142142                _ndr_info->flags= ndr->flags;\
     
    182182        struct __##fn __r;\
    183183        DATA_BLOB _data_blob_info;\
    184         struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
     184        struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx);\
    185185        if (!_ndr_info) return 0;\
    186186        _ndr_info->flags|=LIBNDR_FLAG_NO_NDR_SIZE;\
     
    197197        struct __##fn __r;\
    198198        DATA_BLOB _data_blob_info;\
    199         struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
     199        struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx);\
    200200        if (!_ndr_info) return 0;\
    201201        _ndr_info->flags|=LIBNDR_FLAG_NO_NDR_SIZE;\
     
    235235}
    236236
    237 uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info)
     237uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info)
    238238{
    239239        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinters);
     
    271271}
    272272
    273 uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info)
     273uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_JobInfo *info)
    274274{
    275275        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumJobs);
     
    303303}
    304304
    305 uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_DriverInfo *info)
     305uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_DriverInfo *info)
    306306{
    307307        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinterDrivers);
     
    331331}
    332332
    333 uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_FormInfo *info)
     333uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_FormInfo *info)
    334334{
    335335        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumForms);
     
    359359}
    360360
    361 uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PortInfo *info)
     361uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PortInfo *info)
    362362{
    363363        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPorts);
     
    387387}
    388388
    389 uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info)
     389uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info)
    390390{
    391391        NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumMonitors);
     
    419419}
    420420
    421 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     421uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx,
    422422                                                   uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info)
    423423{
     
    452452}
    453453
    454 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     454uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx,
    455455                                                      uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info)
    456456{
     
    481481                _r.out.info     = data_blob(NULL, 0);
    482482                if (r->in.offered >= *r->out.needed) {
     483                        struct ndr_push *_subndr_info;
    483484                        struct __spoolss_EnumPrinterDataEx __r;
    484                         _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
     485                        _ndr_info = ndr_push_init_ctx(ndr);
    485486                        NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
    486487                        _ndr_info->flags= ndr->flags;
    487488                        __r.in.count    = *r->out.count;
    488489                        __r.out.info    = *r->out.info;
    489                         NDR_CHECK(ndr_push___spoolss_EnumPrinterDataEx(_ndr_info, flags, &__r));
     490                        NDR_CHECK(ndr_push_subcontext_start(_ndr_info, &_subndr_info, 0, r->in.offered));
     491                        NDR_CHECK(ndr_push___spoolss_EnumPrinterDataEx(_subndr_info, flags, &__r));
     492                        NDR_CHECK(ndr_push_subcontext_end(_ndr_info, _subndr_info, 0, r->in.offered));
    490493                        if (r->in.offered > _ndr_info->offset) {
    491494                                uint32_t _padding_len = r->in.offered - _ndr_info->offset;
     
    532535                        struct ndr_pull *_ndr_info;
    533536                        NDR_PULL_ALLOC(ndr, *r->out.info);
    534                         _ndr_info = ndr_pull_init_blob(&_r.out.info, *r->out.info, ndr->iconv_convenience);
     537                        _ndr_info = ndr_pull_init_blob(&_r.out.info, *r->out.info);
    535538                        NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
    536539                        _ndr_info->flags= ndr->flags;
     
    552555}
    553556
    554 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     557uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx,
    555558                                                 uint32_t count, struct spoolss_PrinterEnumValues *info)
    556559{
     
    558561}
    559562
    560 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags)
     563uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, uint32_t flags)
    561564{
    562565        if (!devmode) return 0;
    563         return ndr_size_spoolss_DeviceMode(devmode,ic,flags);
    564 }
    565 
    566 _PUBLIC_ size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags)
     566        return ndr_size_spoolss_DeviceMode(devmode, flags);
     567}
     568
     569_PUBLIC_ size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, int flags)
    567570{
    568571        if (!r) {
     
    570573        }
    571574
    572         return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_StringArray, ic);
     575        return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_StringArray);
    573576}
    574577
     
    640643                        ndr->flags = _flags_save_string;
    641644                }
     645                NDR_CHECK(ndr_push_trailer_align(ndr, 8));
    642646        }
    643647        if (ndr_flags & NDR_BUFFERS) {
     
    665669                        NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->file_info));
    666670#if 0
    667                         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_count));
     671                        NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->file_count));
    668672#endif
    669673                        for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
     
    894898                        ndr->flags = _flags_save_string;
    895899                }
     900                NDR_CHECK(ndr_pull_trailer_align(ndr, 8));
    896901        }
    897902        if (ndr_flags & NDR_BUFFERS) {
     
    907912                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name));
    908913                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0);
     914                                if (ndr->offset > ndr->relative_highest_offset) {
     915                                        ndr->relative_highest_offset = ndr->offset;
     916                                }
    909917                                ndr->offset = _relative_save_offset;
    910918                        }
     
    922930                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture));
    923931                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_0, 0);
     932                                if (ndr->offset > ndr->relative_highest_offset) {
     933                                        ndr->relative_highest_offset = ndr->offset;
     934                                }
    924935                                ndr->offset = _relative_save_offset;
    925936                        }
     
    948959                        NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_1, 0);
    949960                        NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_0, 0);
     961                        if (ndr->offset > ndr->relative_highest_offset) {
     962                                ndr->relative_highest_offset = ndr->offset;
     963                        }
    950964                        ndr->offset = _relative_save_offset;
    951965                }
     
    961975                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name));
    962976                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_name_0, 0);
     977                                if (ndr->offset > ndr->relative_highest_offset) {
     978                                        ndr->relative_highest_offset = ndr->offset;
     979                                }
    963980                                ndr->offset = _relative_save_offset;
    964981                        }
     
    976993                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype));
    977994                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0);
     995                                if (ndr->offset > ndr->relative_highest_offset) {
     996                                        ndr->relative_highest_offset = ndr->offset;
     997                                }
    978998                                ndr->offset = _relative_save_offset;
    979999                        }
     
    9911011                                NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names));
    9921012                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_names_0, 0);
     1013                                if (ndr->offset > ndr->relative_highest_offset) {
     1014                                        ndr->relative_highest_offset = ndr->offset;
     1015                                }
    9931016                                ndr->offset = _relative_save_offset;
    9941017                        }
     
    10061029                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_name));
    10071030                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_name_0, 0);
     1031                                if (ndr->offset > ndr->relative_highest_offset) {
     1032                                        ndr->relative_highest_offset = ndr->offset;
     1033                                }
    10081034                                ndr->offset = _relative_save_offset;
    10091035                        }
     
    10211047                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_url));
    10221048                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_url_0, 0);
     1049                                if (ndr->offset > ndr->relative_highest_offset) {
     1050                                        ndr->relative_highest_offset = ndr->offset;
     1051                                }
    10231052                                ndr->offset = _relative_save_offset;
    10241053                        }
     
    10361065                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->hardware_id));
    10371066                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hardware_id_0, 0);
     1067                                if (ndr->offset > ndr->relative_highest_offset) {
     1068                                        ndr->relative_highest_offset = ndr->offset;
     1069                                }
    10381070                                ndr->offset = _relative_save_offset;
    10391071                        }
     
    10511083                                NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->provider));
    10521084                                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_provider_0, 0);
     1085                                if (ndr->offset > ndr->relative_highest_offset) {
     1086                                        ndr->relative_highest_offset = ndr->offset;
     1087                                }
    10531088                                ndr->offset = _relative_save_offset;
    10541089                        }
     
    10831118}
    10841119
    1085 _PUBLIC_ size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
     1120_PUBLIC_ size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, int flags)
    10861121{
    10871122        if (!r) {
    10881123                return 0;
    10891124        }
    1090         return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData, ic);
     1125        return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData);
    10911126}
    10921127
  • trunk/server/librpc/ndr/ndr_spoolss_buf.h

    r596 r745  
     1/*
     2   Unix SMB/CIFS implementation.
     3
     4   routines for marshalling/unmarshalling spoolss subcontext buffer structures
     5
     6   Copyright (C) Andrew Tridgell 2003
     7   Copyright (C) Tim Potter 2003
     8   Copyright (C) Guenther Deschner 2009
     9
     10   This program is free software; you can redistribute it and/or modify
     11   it under the terms of the GNU General Public License as published by
     12   the Free Software Foundation; either version 3 of the License, or
     13   (at your option) any later version.
     14
     15   This program is distributed in the hope that it will be useful,
     16   but WITHOUT ANY WARRANTY; without even the implied warranty of
     17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18   GNU General Public License for more details.
     19
     20   You should have received a copy of the GNU General Public License
     21   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     22*/
     23
    124#ifndef ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__
    225#define ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__
     
    1538enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r);
    1639enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r);
    17 uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info);
     40uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info);
    1841enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r);
    1942enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r);
    20 uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info);
     43uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_JobInfo *info);
    2144enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r);
    2245enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r);
    23 uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_DriverInfo *info);
     46uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_DriverInfo *info);
    2447enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r);
    2548enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r);
    26 uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_FormInfo *info);
     49uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_FormInfo *info);
    2750enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r);
    2851enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r);
    29 uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PortInfo *info);
     52uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PortInfo *info);
    3053enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r);
    3154enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r);
    32 uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info);
     55uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info);
    3356enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r);
    3457enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r);
    35 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     58uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx,
    3659                                                   uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info);
    3760enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r);
    3861enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r);
    39 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     62uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx,
    4063                                                      uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info);
    4164enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r);
    4265enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r);
    43 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
     66uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx,
    4467                                                 uint32_t count, struct spoolss_PrinterEnumValues *info);
    45 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags);
    46 size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags);
     68uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, uint32_t flags);
     69size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, int flags);
    4770_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r);
    4871_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r);
    4972void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r);
    50 size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, struct smb_iconv_convenience *ic, int flags);
     73size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, int flags);
    5174void ndr_print_spoolss_security_descriptor(struct ndr_print *ndr, const char *name, const struct security_descriptor *r);
    5275enum ndr_err_code ndr_pull_spoolss_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r);
  • trunk/server/librpc/ndr/ndr_table.h

    r414 r745  
     1/*
     2   Unix SMB/CIFS implementation.
     3
     4   dcerpc utility functions
     5
     6   Copyright (C) Andrew Tridgell 2003
     7   Copyright (C) Jelmer Vernooij 2004
     8
     9   This program is free software; you can redistribute it and/or modify
     10   it under the terms of the GNU General Public License as published by
     11   the Free Software Foundation; either version 3 of the License, or
     12   (at your option) any later version.
     13
     14   This program is distributed in the hope that it will be useful,
     15   but WITHOUT ANY WARRANTY; without even the implied warranty of
     16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17   GNU General Public License for more details.
     18
     19   You should have received a copy of the GNU General Public License
     20   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     21*/
     22
    123#ifndef _NDR_TABLE_PROTO_H_
    224#define _NDR_TABLE_PROTO_H_
  • trunk/server/librpc/ndr/ndr_wmi.c

    r414 r745  
    2424#include "librpc/gen_ndr/ndr_dcom.h"
    2525#include "librpc/gen_ndr/ndr_wmi.h"
    26 #include "librpc/ndr/ndr_wmi.h"
    2726
    2827// Just for debugging
     
    3635        enum ndr_err_code status;
    3736        len = strlen(r->data);
    38         if (ndr_flags & NDR_SCALARS) {
    39                 NDR_CHECK(ndr_push_align(ndr, 4));
    40                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x72657355));
    41                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, len));
    42                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2*len));
     37        if (ndr_flags & NDR_SCALARS) {
     38                NDR_CHECK(ndr_push_align(ndr, 4));
     39                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x72657355));
     40                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, len));
     41                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2*len));
    4342                flags = ndr->flags;
    4443                ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM | LIBNDR_FLAG_STR_SIZE4);
     
    4645                ndr->flags = flags;
    4746                return status;
    48         }
    49         return NDR_ERR_SUCCESS;
     47        }
     48        return NDR_ERR_SUCCESS;
    5049}
    5150
  • trunk/server/librpc/ndr/uuid.c

    r590 r745  
    2626#include "librpc/gen_ndr/ndr_misc.h"
    2727
     28/**
     29  build a NDR blob from a GUID
     30*/
     31_PUBLIC_ NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b)
     32{
     33        enum ndr_err_code ndr_err;
     34        ndr_err = ndr_push_struct_blob(b, mem_ctx, guid,
     35                                       (ndr_push_flags_fn_t)ndr_push_GUID);
     36        return ndr_map_error2ntstatus(ndr_err);
     37}
     38
    2839
    2940/**
     
    3849        NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
    3950
    40         ndr_err = ndr_pull_struct_blob_all(b, mem_ctx, NULL, guid,
     51        ndr_err = ndr_pull_struct_blob_all(b, mem_ctx, guid,
    4152                                           (ndr_pull_flags_fn_t)ndr_pull_GUID);
    4253        talloc_free(mem_ctx);
     
    6475        }
    6576
    66         if (s->length == 36) {
     77        switch(s->length) {
     78        case 36:
     79        {
    6780                TALLOC_CTX *mem_ctx;
    6881                const char *string;
     
    8093                }
    8194                talloc_free(mem_ctx);
    82 
    83         } else if (s->length == 38) {
     95                break;
     96        }
     97        case 38:
     98        {
    8499                TALLOC_CTX *mem_ctx;
    85100                const char *string;
     
    97112                }
    98113                talloc_free(mem_ctx);
    99 
    100         } else if (s->length == 32) {
     114                break;
     115        }
     116        case 32:
     117        {
    101118                size_t rlen = strhex_to_str((char *)blob16.data, blob16.length,
    102119                                            (const char *)s->data, s->length);
     
    108125                return GUID_from_ndr_blob(s, guid);
    109126        }
    110 
    111         if (s->length == 16) {
     127        case 16:
    112128                return GUID_from_ndr_blob(s, guid);
     129        default:
     130                status = NT_STATUS_INVALID_PARAMETER;
     131                break;
    113132        }
    114133
     
    136155        DATA_BLOB blob = data_blob_string_const(s);
    137156        return GUID_from_data_blob(&blob, guid);
    138         return NT_STATUS_OK;
    139157}
    140158
     
    233251{
    234252        if (u1->time_low != u2->time_low) {
    235                 return u1->time_low - u2->time_low;
     253                return u1->time_low > u2->time_low ? 1 : -1;
    236254        }
    237255
    238256        if (u1->time_mid != u2->time_mid) {
    239                 return u1->time_mid - u2->time_mid;
     257                return u1->time_mid > u2->time_mid ? 1 : -1;
    240258        }
    241259
    242260        if (u1->time_hi_and_version != u2->time_hi_and_version) {
    243                 return u1->time_hi_and_version - u2->time_hi_and_version;
     261                return u1->time_hi_and_version > u2->time_hi_and_version ? 1 : -1;
    244262        }
    245263
    246264        if (u1->clock_seq[0] != u2->clock_seq[0]) {
    247                 return u1->clock_seq[0] - u2->clock_seq[0];
     265                return u1->clock_seq[0] > u2->clock_seq[0] ? 1 : -1;
    248266        }
    249267
    250268        if (u1->clock_seq[1] != u2->clock_seq[1]) {
    251                 return u1->clock_seq[1] - u2->clock_seq[1];
     269                return u1->clock_seq[1] > u2->clock_seq[1] ? 1 : -1;
    252270        }
    253271
     
    283301        char *ret;
    284302        DATA_BLOB guid_blob;
    285         enum ndr_err_code ndr_err;
    286303        TALLOC_CTX *tmp_mem;
     304        NTSTATUS status;
    287305
    288306        tmp_mem = talloc_new(mem_ctx);
     
    290308                return NULL;
    291309        }
    292         ndr_err = ndr_push_struct_blob(&guid_blob, tmp_mem,
    293                                        NULL,
    294                                        guid,
    295                                        (ndr_push_flags_fn_t)ndr_push_GUID);
    296         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     310        status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
     311        if (!NT_STATUS_IS_OK(status)) {
    297312                talloc_free(tmp_mem);
    298313                return NULL;
    299314        }
    300315
    301         ret = data_blob_hex_string(mem_ctx, &guid_blob);
     316        ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
    302317        talloc_free(tmp_mem);
    303318        return ret;
     
    317332}
    318333
    319 _PUBLIC_ bool policy_handle_empty(struct policy_handle *h)
     334_PUBLIC_ bool policy_handle_empty(const struct policy_handle *h)
    320335{
    321336        return (h->handle_type == 0 && GUID_all_zero(&h->uuid));
    322337}
     338
     339_PUBLIC_ bool is_valid_policy_hnd(const struct policy_handle *hnd)
     340{
     341        return !policy_handle_empty(hnd);
     342}
     343
     344_PUBLIC_ bool policy_handle_equal(const struct policy_handle *hnd1,
     345                                  const struct policy_handle *hnd2)
     346{
     347        if (!hnd1 || !hnd2) {
     348                return false;
     349        }
     350
     351        return (memcmp(hnd1, hnd2, sizeof(*hnd1)) == 0);
     352}
Note: See TracChangeset for help on using the changeset viewer.