Changeset 745 for trunk/server/librpc/ndr
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 1 deleted
- 22 edited
- 13 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/librpc/ndr/libndr.h
r590 r745 61 61 uint32_t offset; 62 62 63 struct smb_iconv_convenience *iconv_convenience; 64 63 uint32_t relative_highest_offset; 65 64 uint32_t relative_base_offset; 65 uint32_t relative_rap_convert; 66 66 struct ndr_token_list *relative_base_list; 67 67 … … 93 93 struct ndr_token_list *relative_begin_list; 94 94 struct ndr_token_list *nbt_string_list; 95 struct ndr_token_list *dns_string_list; 95 96 struct ndr_token_list *full_ptr_list; 96 97 97 98 /* this is used to ensure we generate unique reference IDs */ 98 99 uint32_t ptr_count; 99 100 struct smb_iconv_convenience *iconv_convenience;101 100 }; 102 101 … … 106 105 uint32_t depth; 107 106 struct ndr_token_list *switch_list; 108 struct smb_iconv_convenience *iconv_convenience;109 107 void (*print)(struct ndr_print *, const char *, ...) PRINTF_ATTRIBUTE(2,3); 110 108 void *private_data; 109 bool no_newline; 111 110 }; 112 111 … … 192 191 NDR_ERR_TOKEN, 193 192 NDR_ERR_IPV4ADDRESS, 193 NDR_ERR_IPV6ADDRESS, 194 194 NDR_ERR_INVALID_POINTER, 195 195 NDR_ERR_UNREAD_BYTES, … … 329 329 extern const struct ndr_syntax_id ndr_transfer_syntax; 330 330 extern const struct ndr_syntax_id ndr64_transfer_syntax; 331 extern const struct ndr_syntax_id null_ndr_syntax_id; 332 333 struct 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 342 struct ndr_interface_call_pipes { 343 uint32_t num_pipes; 344 const struct ndr_interface_call_pipe *pipes; 345 }; 331 346 332 347 struct ndr_interface_call { … … 336 351 ndr_pull_flags_fn_t ndr_pull; 337 352 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; 339 355 }; 340 356 … … 364 380 NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err); 365 381 const char *ndr_map_error2string(enum ndr_err_code ndr_err); 382 #define ndr_errstr ndr_map_error2string 366 383 367 384 /* FIXME: Use represent_as instead */ … … 378 395 void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid); 379 396 size_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);381 397 void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); 382 398 bool 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 *);399 enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn); 400 enum 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); 401 size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push); 402 size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push); 387 403 uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr); 388 404 void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset); … … 390 406 enum ndr_err_code ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p); 391 407 enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p); 408 enum ndr_err_code ndr_push_short_relative_ptr1(struct ndr_push *ndr, const void *p); 392 409 enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, const void *p); 393 410 enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, const void *p); 411 enum ndr_err_code ndr_push_short_relative_ptr2(struct ndr_push *ndr, const void *p); 394 412 uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr); 395 413 void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset); … … 398 416 enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset); 399 417 enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p); 418 enum ndr_err_code ndr_pull_relative_ptr_short(struct ndr_pull *ndr, uint16_t *v); 400 419 size_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);420 struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx); 402 421 enum 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);422 struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx); 404 423 DATA_BLOB ndr_push_blob(struct ndr_push *ndr); 405 424 enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size); 406 425 void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 426 void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 407 427 void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 408 428 void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr); … … 441 461 const void *key, 442 462 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);463 enum 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); 444 464 enum ndr_err_code ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v); 445 465 uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key); … … 450 470 uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p); 451 471 enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length); 472 enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count); 473 enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count); 452 474 enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val); 453 475 enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val); … … 456 478 uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p); 457 479 uint32_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);480 enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn); 481 enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn); 482 enum 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); 483 enum 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); 462 484 463 485 /* from libndr_basic.h */ … … 487 509 NDR_SCALAR_PROTO(pointer, void *) 488 510 NDR_SCALAR_PROTO(time_t, time_t) 511 NDR_SCALAR_PROTO(uid_t, uid_t) 512 NDR_SCALAR_PROTO(gid_t, gid_t) 489 513 NDR_SCALAR_PROTO(NTSTATUS, NTSTATUS) 490 514 NDR_SCALAR_PROTO(WERROR, WERROR) … … 494 518 NDR_SCALAR_PROTO(DATA_BLOB, DATA_BLOB) 495 519 NDR_SCALAR_PROTO(ipv4address, const char *) 520 NDR_SCALAR_PROTO(ipv6address, const char *) 496 521 NDR_SCALAR_PROTO(string, const char *) 497 522 NDR_SCALAR_PROTO(double, double) … … 500 525 enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r); 501 526 void 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); 527 bool policy_handle_empty(const struct policy_handle *h); 528 bool is_valid_policy_hnd(const struct policy_handle *hnd); 529 bool policy_handle_equal(const struct policy_handle *hnd1, 530 const struct policy_handle *hnd2); 503 531 504 532 void ndr_check_padding(struct ndr_pull *ndr, size_t n); … … 520 548 enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr); 521 549 void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type); 550 void ndr_print_null(struct ndr_print *ndr); 522 551 void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, const char *val, uint32_t value); 523 552 void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value); … … 544 573 /* GUIDs */ 545 574 bool GUID_equal(const struct GUID *u1, const struct GUID *u2); 575 NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b); 546 576 NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid); 547 577 NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid); … … 566 596 _PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v); 567 597 598 _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b); 599 568 600 #endif /* __LIBNDR_H__ */ -
trunk/server/librpc/ndr/ndr.c
r596 r745 47 47 }; 48 48 49 const struct ndr_syntax_id null_ndr_syntax_id = { 50 { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, 51 0 52 }; 53 49 54 /* 50 55 work out the number of bytes needed to align on a n byte boundary … … 59 64 initialise a ndr parse structure from a data blob 60 65 */ 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) 62 67 { 63 68 struct ndr_pull *ndr; … … 69 74 ndr->data = blob->data; 70 75 ndr->data_size = blob->length; 71 ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);72 76 73 77 return ndr; … … 103 107 104 108 /* 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) 106 110 { 107 111 struct ndr_push *ndr; … … 118 122 return NULL; 119 123 } 120 ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);121 124 122 125 return ndr; … … 169 172 va_list ap; 170 173 char *s = NULL; 171 int i, ret; 174 uint32_t i; 175 int ret; 172 176 173 177 va_start(ap, format); … … 179 183 } 180 184 185 if (ndr->no_newline) { 186 DEBUGADD(1,("%s", s)); 187 free(s); 188 return; 189 } 190 181 191 for (i=0;i<ndr->depth;i++) { 182 192 DEBUGADD(1,(" ")); … … 187 197 } 188 198 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 189 218 _PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) 190 219 { 191 220 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 } 197 228 } 198 229 … … 201 232 format, ap); 202 233 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 } 205 238 } 206 239 … … 257 290 ndr->flags = 0; 258 291 259 /* this is a s4 hack until we build up the courage to pass260 * this all the way down261 */262 #if _SAMBA_BUILD_ == 4263 ndr->iconv_convenience = smb_iconv_convenience_init(talloc_autofree_context(), "ASCII", "UTF-8", true);264 #endif265 266 292 fn(ndr, name, flags, ptr); 267 293 talloc_free(ndr); … … 285 311 ndr->depth = 1; 286 312 ndr->flags = 0; 287 288 /* this is a s4 hack until we build up the courage to pass289 * this all the way down290 */291 #if _SAMBA_BUILD_ == 4292 ndr->iconv_convenience = smb_iconv_convenience_init(talloc_autofree_context(), "ASCII", "UTF-8", true);293 #endif294 313 295 314 fn(ndr, name, ptr); … … 554 573 subndr->offset = 0; 555 574 subndr->data_size = r_content_size; 556 subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience);557 575 558 576 if (force_le) { … … 590 608 struct ndr_push *subndr; 591 609 592 subndr = ndr_push_init_ctx(ndr , ndr->iconv_convenience);610 subndr = ndr_push_init_ctx(ndr); 593 611 NDR_ERR_HAVE_NO_MEMORY(subndr); 594 612 subndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64; … … 812 830 } 813 831 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 814 866 /* 815 867 store a switch value … … 851 903 pull a struct from a blob using NDR 852 904 */ 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, 854 906 ndr_pull_flags_fn_t fn) 855 907 { 856 908 struct ndr_pull *ndr; 857 ndr = ndr_pull_init_blob(blob, mem_ctx , iconv_convenience);909 ndr = ndr_pull_init_blob(blob, mem_ctx); 858 910 NDR_ERR_HAVE_NO_MEMORY(ndr); 859 911 NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); … … 866 918 */ 867 919 _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,869 920 void *p, ndr_pull_flags_fn_t fn) 870 921 { 871 922 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); 873 925 NDR_ERR_HAVE_NO_MEMORY(ndr); 874 926 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; 879 939 } 880 940 talloc_free(ndr); … … 886 946 */ 887 947 _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, 889 949 uint32_t level, ndr_pull_flags_fn_t fn) 890 950 { 891 951 struct ndr_pull *ndr; 892 ndr = ndr_pull_init_blob(blob, mem_ctx , iconv_convenience);952 ndr = ndr_pull_init_blob(blob, mem_ctx); 893 953 NDR_ERR_HAVE_NO_MEMORY(ndr); 894 954 NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level)); … … 903 963 */ 904 964 _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, 906 966 uint32_t level, ndr_pull_flags_fn_t fn) 907 967 { 908 968 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); 910 971 NDR_ERR_HAVE_NO_MEMORY(ndr); 911 972 NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level)); 912 973 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) { 914 980 enum ndr_err_code ret; 915 981 ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, 916 982 "not all bytes consumed ofs[%u] size[%u]", 917 ndr->offset, ndr->data_size);983 highest_ofs, ndr->data_size); 918 984 talloc_free(ndr); 919 985 return ret; … … 926 992 push a struct to a blob using NDR 927 993 */ 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) 929 995 { 930 996 struct ndr_push *ndr; 931 ndr = ndr_push_init_ctx(mem_ctx , iconv_convenience);997 ndr = ndr_push_init_ctx(mem_ctx); 932 998 NDR_ERR_HAVE_NO_MEMORY(ndr); 933 999 … … 944 1010 push a union to a blob using NDR 945 1011 */ 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, 947 1013 uint32_t level, ndr_push_flags_fn_t fn) 948 1014 { 949 1015 struct ndr_push *ndr; 950 ndr = ndr_push_init_ctx(mem_ctx , iconv_convenience);1016 ndr = ndr_push_init_ctx(mem_ctx); 951 1017 NDR_ERR_HAVE_NO_MEMORY(ndr); 952 1018 … … 964 1030 generic ndr_size_*() handler for structures 965 1031 */ 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) 967 1033 { 968 1034 struct ndr_push *ndr; … … 973 1039 if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; 974 1040 975 ndr = ndr_push_init_ctx(NULL , iconv_convenience);1041 ndr = ndr_push_init_ctx(NULL); 976 1042 if (!ndr) return 0; 977 1043 ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; … … 989 1055 generic ndr_size_*() handler for unions 990 1056 */ 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) 992 1058 { 993 1059 struct ndr_push *ndr; … … 998 1064 if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; 999 1065 1000 ndr = ndr_push_init_ctx(NULL , iconv_convenience);1066 ndr = ndr_push_init_ctx(NULL); 1001 1067 if (!ndr) return 0; 1002 1068 ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; … … 1067 1133 } 1068 1134 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 } 1069 1149 /* 1070 1150 push a relative object - stage2 … … 1092 1172 } 1093 1173 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)); 1094 1202 ndr->offset = save_offset; 1095 1203 return NDR_ERR_SUCCESS; -
trunk/server/librpc/ndr/ndr_basic.c
r596 r745 23 23 #include "system/network.h" 24 24 #include "librpc/ndr/libndr.h" 25 #include "lib/util/util_net.h" 25 26 26 27 #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) … … 177 178 178 179 /* 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 /* 179 193 parse a pointer referent identifier 180 194 */ … … 239 253 { 240 254 NDR_PULL_ALIGN(ndr, 8); 255 if (NDR_BE(ndr)) { 256 return ndr_pull_udlongr(ndr, ndr_flags, v); 257 } 241 258 return ndr_pull_udlong(ndr, ndr_flags, v); 242 259 } … … 536 553 { 537 554 NDR_PUSH_ALIGN(ndr, 8); 555 if (NDR_BE(ndr)) { 556 return ndr_push_udlongr(ndr, NDR_SCALARS, v); 557 } 538 558 return ndr_push_udlong(ndr, NDR_SCALARS, v); 539 559 } … … 791 811 792 812 /* 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 /* 793 863 pull a ipv4address 794 864 */ … … 812 882 if (!is_ipaddress(address)) { 813 883 return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS, 814 "Invalid IPv4 address: '%s'", 884 "Invalid IPv4 address: '%s'", 815 885 address); 816 886 } … … 823 893 print a ipv4address 824 894 */ 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, 826 896 const char *address) 827 897 { … … 829 899 } 830 900 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 831 960 832 961 _PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) 833 962 { 834 963 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"); 835 969 } 836 970 … … 891 1025 } 892 1026 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 893 1037 _PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) 894 1038 { … … 957 1101 } 958 1102 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 959 1113 _PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) 960 1114 { … … 975 1129 { 976 1130 int i; 1131 1132 if (data == NULL) { 1133 ndr->print(ndr, "%s: ARRAY(%d) : NULL", name, count); 1134 return; 1135 } 977 1136 978 1137 if (count <= 600 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { … … 998 1157 } 999 1158 1159 static 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 */ 1169 static 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 1000 1206 _PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) 1001 1207 { 1002 1208 ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, (unsigned)r.length); 1003 1209 if (r.length) { 1004 dump_data(10, r.data, r.length);1210 ndr_dump_data(ndr, r.data, r.length); 1005 1211 } 1006 1212 } … … 1069 1275 return ret + data->length; 1070 1276 } 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 392 392 z_stream z; 393 393 394 ndrpush = ndr_push_init_ctx(subndr , subndr->iconv_convenience);394 ndrpush = ndr_push_init_ctx(subndr); 395 395 NDR_ERR_HAVE_NO_MEMORY(ndrpush); 396 396 … … 431 431 comndr->data_size = uncompressed.length; 432 432 comndr->offset = 0; 433 434 comndr->iconv_convenience = talloc_reference(comndr, subndr->iconv_convenience);435 433 436 434 *_comndr = comndr; … … 466 464 } 467 465 468 uncomndr = ndr_push_init_ctx(subndr , subndr->iconv_convenience);466 uncomndr = ndr_push_init_ctx(subndr); 469 467 NDR_ERR_HAVE_NO_MEMORY(uncomndr); 470 468 uncomndr->flags = subndr->flags; … … 493 491 ndrpull->offset = 0; 494 492 495 ndrpull->iconv_convenience = talloc_reference(ndrpull, subndr->iconv_convenience);496 497 493 switch (compression_alg) { 498 494 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 1 23 #ifndef __LIBRPC_NDR_NDR_COMPRESSION_H__ 2 24 #define __LIBRPC_NDR_NDR_COMPRESSION_H__ -
trunk/server/librpc/ndr/ndr_drsblobs.c
r414 r745 5 5 6 6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 7 Copyright (C) Guenther Deschner <gd@samba.org> 2010 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 22 23 #include "includes.h" 23 24 #include "librpc/gen_ndr/ndr_drsblobs.h" 25 #include "../lib/util/asn1.h" 24 26 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) 30 28 { 31 29 uint32_t cntr_array_0; 32 30 if (ndr_flags & NDR_SCALARS) { 33 31 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++) { 35 33 NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0])); 36 34 } 35 NDR_CHECK(ndr_push_trailer_align(ndr, 4)); 37 36 } 38 37 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 }42 38 } 43 39 return NDR_ERR_SUCCESS; 44 40 } 45 41 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) 48 43 { 49 uint32_t cntr_array_0;50 TALLOC_CTX *_mem_save_array_0;51 44 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++; 58 53 } 59 NDR_ PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);54 NDR_CHECK(ndr_pull_trailer_align(ndr, 4)); 60 55 } 61 56 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 }65 57 } 66 58 return NDR_ERR_SUCCESS; 67 59 } 68 60 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 */89 61 _PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r) 90 62 { … … 92 64 NDR_CHECK(ndr_push_align(ndr, 4)); 93 65 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)); 96 86 } 97 87 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 }108 88 } 109 89 return NDR_ERR_SUCCESS; 110 90 } 111 91 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 }180 92 181 93 _PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r) … … 197 109 struct ndr_pull *_ndr_outgoing; 198 110 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size)); 199 NDR_CHECK(ndr_pull_trust CurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing));111 NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing)); 200 112 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size)); 201 113 } … … 203 115 struct ndr_pull *_ndr_incoming; 204 116 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size)); 205 NDR_CHECK(ndr_pull_trust CurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming));117 NDR_CHECK(ndr_pull_trustAuthInOutBlob(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming)); 206 118 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size)); 207 119 } … … 214 126 } 215 127 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 20 20 */ 21 21 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);26 22 _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 67 67 } 68 68 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 89 static 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 101 static 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"); 174 114 } 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 121 static 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--; 181 194 } 182 195 … … 353 366 } 354 367 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 29 29 const struct drsuapi_DsReplicaObjectListItemEx *r); 30 30 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); 31 size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, int flags); 34 32 35 size_t ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(const struct drsuapi_DsReplicaObjectIdentifier3Binary *r, struct smb_iconv_convenience *ic, int flags);36 33 37 34 #endif /* _LIBRPC_NDR_NDR_DRSUAPI_H */ -
trunk/server/librpc/ndr/ndr_frsrpc.c
r414 r745 85 85 86 86 size_t ndr_size_frsrpc_CommPktChunkCtr(const struct frsrpc_CommPktChunkCtr *r, 87 struct smb_iconv_convenience *ic,88 87 int flags) 89 88 { 90 89 flags |= LIBNDR_FLAG_NOALIGN; 91 90 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); 94 92 } -
trunk/server/librpc/ndr/ndr_frsrpc.h
r414 r745 30 30 struct frsrpc_CommPktChunkCtr *r); 31 31 size_t ndr_size_frsrpc_CommPktChunkCtr(const struct frsrpc_CommPktChunkCtr *r, 32 struct smb_iconv_convenience *ic,33 32 int flags); 34 33 -
trunk/server/librpc/ndr/ndr_krb5pac.c
r414 r745 24 24 #include "librpc/gen_ndr/ndr_krb5pac.h" 25 25 26 static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic,int flags)26 static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) 27 27 { 28 size_t s = ndr_size_PAC_INFO(r, level, ic,flags);28 size_t s = ndr_size_PAC_INFO(r, level, flags); 29 29 switch (level) { 30 30 case PAC_TYPE_LOGON_INFO: … … 35 35 } 36 36 37 static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic,int flags)37 static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) 38 38 { 39 size_t s = ndr_size_PAC_INFO(r, level, ic,flags);39 size_t s = ndr_size_PAC_INFO(r, level, flags); 40 40 return NDR_ROUND(s,8); 41 41 } … … 46 46 NDR_CHECK(ndr_push_align(ndr, 4)); 47 47 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))); 49 49 { 50 50 uint32_t _flags_save_PAC_INFO = ndr->flags; … … 63 63 { 64 64 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))); 66 66 NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type)); 67 67 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))); 69 69 } 70 70 NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->info)); … … 129 129 ndr->depth++; 130 130 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); 132 132 ndr_print_ptr(ndr, "info", r->info); 133 133 ndr->depth++; -
trunk/server/librpc/ndr/ndr_ntlmssp.c
r414 r745 109 109 110 110 _PUBLIC_ void ndr_print_ntlmssp_nt_response(TALLOC_CTX *mem_ctx, 111 struct smb_iconv_convenience *ic,112 111 const DATA_BLOB *nt_response, 113 112 bool ntlmv2) … … 118 117 struct NTLMv2_RESPONSE nt; 119 118 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, 121 120 (ndr_pull_flags_fn_t)ndr_pull_NTLMv2_RESPONSE); 122 121 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 127 126 struct NTLM_RESPONSE nt; 128 127 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, 130 129 (ndr_pull_flags_fn_t)ndr_pull_NTLM_RESPONSE); 131 130 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 137 136 138 137 _PUBLIC_ void ndr_print_ntlmssp_lm_response(TALLOC_CTX *mem_ctx, 139 struct smb_iconv_convenience *ic,140 138 const DATA_BLOB *lm_response, 141 139 bool ntlmv2) … … 146 144 struct LMv2_RESPONSE lm; 147 145 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, 149 147 (ndr_pull_flags_fn_t)ndr_pull_LMv2_RESPONSE); 150 148 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 155 153 struct LM_RESPONSE lm; 156 154 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, 158 156 (ndr_pull_flags_fn_t)ndr_pull_LM_RESPONSE); 159 157 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 170 168 switch (level) { 171 169 case NTLMSSP_NEGOTIATE_VERSION: 172 ndr_print_ VERSION(ndr, name, &r->version);170 ndr_print_ntlmssp_VERSION(ndr, name, &r->version); 173 171 break; 174 172 -
trunk/server/librpc/ndr/ndr_ntlmssp.h
r414 r745 25 25 _PUBLIC_ enum ndr_err_code ndr_pull_AV_PAIR_LIST(struct ndr_pull *ndr, int ndr_flags, struct AV_PAIR_LIST *r); 26 26 _PUBLIC_ void ndr_print_ntlmssp_nt_response(TALLOC_CTX *mem_ctx, 27 struct smb_iconv_convenience *ic,28 27 const DATA_BLOB *nt_response, 29 28 bool ntlmv2); 30 29 _PUBLIC_ void ndr_print_ntlmssp_lm_response(TALLOC_CTX *mem_ctx, 31 struct smb_iconv_convenience *ic,32 30 const DATA_BLOB *lm_response, 33 31 bool ntlmv2); -
trunk/server/librpc/ndr/ndr_schannel.c
r414 r745 86 86 case NL_SIGN_HMAC_MD5: { 87 87 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, 89 89 (ndr_pull_flags_fn_t)ndr_pull_NL_AUTH_SIGNATURE); 90 90 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 95 95 case NL_SIGN_HMAC_SHA256: { 96 96 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, 98 98 (ndr_pull_flags_fn_t)ndr_pull_NL_AUTH_SHA2_SIGNATURE); 99 99 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -
trunk/server/librpc/ndr/ndr_sec_helper.c
r414 r745 24 24 #include "includes.h" 25 25 #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" 29 27 30 28 /* 31 29 return the wire size of a security_ace 32 30 */ 33 size_t ndr_size_security_ace(const struct security_ace *ace, struct smb_iconv_convenience *ic,int flags)31 size_t ndr_size_security_ace(const struct security_ace *ace, int flags) 34 32 { 35 33 size_t ret; … … 37 35 if (!ace) return 0; 38 36 39 ret = 8 + ndr_size_dom_sid(&ace->trustee, ic,flags);37 ret = 8 + ndr_size_dom_sid(&ace->trustee, flags); 40 38 41 39 switch (ace->type) { … … 92 90 return the wire size of a security_acl 93 91 */ 94 size_t ndr_size_security_acl(const struct security_acl *theacl, struct smb_iconv_convenience *ic,int flags)92 size_t ndr_size_security_acl(const struct security_acl *theacl, int flags) 95 93 { 96 94 size_t ret; … … 99 97 ret = 8; 100 98 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); 102 100 } 103 101 return ret; … … 107 105 return the wire size of a security descriptor 108 106 */ 109 size_t ndr_size_security_descriptor(const struct security_descriptor *sd, struct smb_iconv_convenience *ic,int flags)107 size_t ndr_size_security_descriptor(const struct security_descriptor *sd, int flags) 110 108 { 111 109 size_t ret; … … 113 111 114 112 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); 119 117 return ret; 120 118 } … … 123 121 return the wire size of a dom_sid 124 122 */ 125 size_t ndr_size_dom_sid(const struct dom_sid *sid, struct smb_iconv_convenience *ic,int flags)123 size_t ndr_size_dom_sid(const struct dom_sid *sid, int flags) 126 124 { 127 125 if (!sid) return 0; -
trunk/server/librpc/ndr/ndr_spoolss_buf.c
r596 r745 61 61 if (r->in.buffer) {\ 62 62 DATA_BLOB _data_blob_info;\ 63 _ndr_info = ndr_push_init_ctx(ndr , ndr->iconv_convenience);\63 _ndr_info = ndr_push_init_ctx(ndr);\ 64 64 NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ 65 65 _ndr_info->flags= ndr->flags;\ … … 138 138 struct ndr_pull *_ndr_info;\ 139 139 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);\ 141 141 NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ 142 142 _ndr_info->flags= ndr->flags;\ … … 182 182 struct __##fn __r;\ 183 183 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);\ 185 185 if (!_ndr_info) return 0;\ 186 186 _ndr_info->flags|=LIBNDR_FLAG_NO_NDR_SIZE;\ … … 197 197 struct __##fn __r;\ 198 198 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);\ 200 200 if (!_ndr_info) return 0;\ 201 201 _ndr_info->flags|=LIBNDR_FLAG_NO_NDR_SIZE;\ … … 235 235 } 236 236 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)237 uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info) 238 238 { 239 239 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinters); … … 271 271 } 272 272 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)273 uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_JobInfo *info) 274 274 { 275 275 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumJobs); … … 303 303 } 304 304 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)305 uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_DriverInfo *info) 306 306 { 307 307 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinterDrivers); … … 331 331 } 332 332 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)333 uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_FormInfo *info) 334 334 { 335 335 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumForms); … … 359 359 } 360 360 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)361 uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PortInfo *info) 362 362 { 363 363 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPorts); … … 387 387 } 388 388 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)389 uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info) 390 390 { 391 391 NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumMonitors); … … 419 419 } 420 420 421 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,421 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, 422 422 uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info) 423 423 { … … 452 452 } 453 453 454 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,454 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, 455 455 uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info) 456 456 { … … 481 481 _r.out.info = data_blob(NULL, 0); 482 482 if (r->in.offered >= *r->out.needed) { 483 struct ndr_push *_subndr_info; 483 484 struct __spoolss_EnumPrinterDataEx __r; 484 _ndr_info = ndr_push_init_ctx(ndr , ndr->iconv_convenience);485 _ndr_info = ndr_push_init_ctx(ndr); 485 486 NDR_ERR_HAVE_NO_MEMORY(_ndr_info); 486 487 _ndr_info->flags= ndr->flags; 487 488 __r.in.count = *r->out.count; 488 489 __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)); 490 493 if (r->in.offered > _ndr_info->offset) { 491 494 uint32_t _padding_len = r->in.offered - _ndr_info->offset; … … 532 535 struct ndr_pull *_ndr_info; 533 536 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); 535 538 NDR_ERR_HAVE_NO_MEMORY(_ndr_info); 536 539 _ndr_info->flags= ndr->flags; … … 552 555 } 553 556 554 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,557 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, 555 558 uint32_t count, struct spoolss_PrinterEnumValues *info) 556 559 { … … 558 561 } 559 562 560 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic,uint32_t flags)563 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, uint32_t flags) 561 564 { 562 565 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) 567 570 { 568 571 if (!r) { … … 570 573 } 571 574 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); 573 576 } 574 577 … … 640 643 ndr->flags = _flags_save_string; 641 644 } 645 NDR_CHECK(ndr_push_trailer_align(ndr, 8)); 642 646 } 643 647 if (ndr_flags & NDR_BUFFERS) { … … 665 669 NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->file_info)); 666 670 #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)); 668 672 #endif 669 673 for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) { … … 894 898 ndr->flags = _flags_save_string; 895 899 } 900 NDR_CHECK(ndr_pull_trailer_align(ndr, 8)); 896 901 } 897 902 if (ndr_flags & NDR_BUFFERS) { … … 907 912 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); 908 913 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 } 909 917 ndr->offset = _relative_save_offset; 910 918 } … … 922 930 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); 923 931 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 } 924 935 ndr->offset = _relative_save_offset; 925 936 } … … 948 959 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_1, 0); 949 960 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 } 950 964 ndr->offset = _relative_save_offset; 951 965 } … … 961 975 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); 962 976 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 } 963 980 ndr->offset = _relative_save_offset; 964 981 } … … 976 993 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype)); 977 994 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 } 978 998 ndr->offset = _relative_save_offset; 979 999 } … … 991 1011 NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names)); 992 1012 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 } 993 1016 ndr->offset = _relative_save_offset; 994 1017 } … … 1006 1029 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_name)); 1007 1030 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 } 1008 1034 ndr->offset = _relative_save_offset; 1009 1035 } … … 1021 1047 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_url)); 1022 1048 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 } 1023 1052 ndr->offset = _relative_save_offset; 1024 1053 } … … 1036 1065 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->hardware_id)); 1037 1066 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 } 1038 1070 ndr->offset = _relative_save_offset; 1039 1071 } … … 1051 1083 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->provider)); 1052 1084 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 } 1053 1088 ndr->offset = _relative_save_offset; 1054 1089 } … … 1083 1118 } 1084 1119 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) 1086 1121 { 1087 1122 if (!r) { 1088 1123 return 0; 1089 1124 } 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); 1091 1126 } 1092 1127 -
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 1 24 #ifndef ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__ 2 25 #define ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__ … … 15 38 enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r); 16 39 enum 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);40 uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info); 18 41 enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r); 19 42 enum 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);43 uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_JobInfo *info); 21 44 enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r); 22 45 enum 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);46 uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_DriverInfo *info); 24 47 enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r); 25 48 enum 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);49 uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_FormInfo *info); 27 50 enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r); 28 51 enum 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);52 uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_PortInfo *info); 30 53 enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r); 31 54 enum 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);55 uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info); 33 56 enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r); 34 57 enum 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,58 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, 36 59 uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info); 37 60 enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r); 38 61 enum 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,62 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, 40 63 uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info); 41 64 enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r); 42 65 enum 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,66 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, 44 67 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);68 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, uint32_t flags); 69 size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, int flags); 47 70 _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r); 48 71 _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r); 49 72 void 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);73 size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, int flags); 51 74 void ndr_print_spoolss_security_descriptor(struct ndr_print *ndr, const char *name, const struct security_descriptor *r); 52 75 enum 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 1 23 #ifndef _NDR_TABLE_PROTO_H_ 2 24 #define _NDR_TABLE_PROTO_H_ -
trunk/server/librpc/ndr/ndr_wmi.c
r414 r745 24 24 #include "librpc/gen_ndr/ndr_dcom.h" 25 25 #include "librpc/gen_ndr/ndr_wmi.h" 26 #include "librpc/ndr/ndr_wmi.h"27 26 28 27 // Just for debugging … … 36 35 enum ndr_err_code status; 37 36 len = strlen(r->data); 38 39 40 41 42 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)); 43 42 flags = ndr->flags; 44 43 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM | LIBNDR_FLAG_STR_SIZE4); … … 46 45 ndr->flags = flags; 47 46 return status; 48 49 47 } 48 return NDR_ERR_SUCCESS; 50 49 } 51 50 -
trunk/server/librpc/ndr/uuid.c
r590 r745 26 26 #include "librpc/gen_ndr/ndr_misc.h" 27 27 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 28 39 29 40 /** … … 38 49 NT_STATUS_HAVE_NO_MEMORY(mem_ctx); 39 50 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, 41 52 (ndr_pull_flags_fn_t)ndr_pull_GUID); 42 53 talloc_free(mem_ctx); … … 64 75 } 65 76 66 if (s->length == 36) { 77 switch(s->length) { 78 case 36: 79 { 67 80 TALLOC_CTX *mem_ctx; 68 81 const char *string; … … 80 93 } 81 94 talloc_free(mem_ctx); 82 83 } else if (s->length == 38) { 95 break; 96 } 97 case 38: 98 { 84 99 TALLOC_CTX *mem_ctx; 85 100 const char *string; … … 97 112 } 98 113 talloc_free(mem_ctx); 99 100 } else if (s->length == 32) { 114 break; 115 } 116 case 32: 117 { 101 118 size_t rlen = strhex_to_str((char *)blob16.data, blob16.length, 102 119 (const char *)s->data, s->length); … … 108 125 return GUID_from_ndr_blob(s, guid); 109 126 } 110 111 if (s->length == 16) { 127 case 16: 112 128 return GUID_from_ndr_blob(s, guid); 129 default: 130 status = NT_STATUS_INVALID_PARAMETER; 131 break; 113 132 } 114 133 … … 136 155 DATA_BLOB blob = data_blob_string_const(s); 137 156 return GUID_from_data_blob(&blob, guid); 138 return NT_STATUS_OK;139 157 } 140 158 … … 233 251 { 234 252 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; 236 254 } 237 255 238 256 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; 240 258 } 241 259 242 260 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; 244 262 } 245 263 246 264 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; 248 266 } 249 267 250 268 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; 252 270 } 253 271 … … 283 301 char *ret; 284 302 DATA_BLOB guid_blob; 285 enum ndr_err_code ndr_err;286 303 TALLOC_CTX *tmp_mem; 304 NTSTATUS status; 287 305 288 306 tmp_mem = talloc_new(mem_ctx); … … 290 308 return NULL; 291 309 } 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)) { 297 312 talloc_free(tmp_mem); 298 313 return NULL; 299 314 } 300 315 301 ret = data_blob_hex_string (mem_ctx, &guid_blob);316 ret = data_blob_hex_string_upper(mem_ctx, &guid_blob); 302 317 talloc_free(tmp_mem); 303 318 return ret; … … 317 332 } 318 333 319 _PUBLIC_ bool policy_handle_empty( struct policy_handle *h)334 _PUBLIC_ bool policy_handle_empty(const struct policy_handle *h) 320 335 { 321 336 return (h->handle_type == 0 && GUID_all_zero(&h->uuid)); 322 337 } 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.