diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/repl/drepl_out_helpers.c | 20 | ||||
-rw-r--r-- | source4/kdc/pac-glue.c | 24 | ||||
-rw-r--r-- | source4/libnet/libnet_become_dc.c | 19 | ||||
-rw-r--r-- | source4/librpc/idl/drsuapi.idl | 16 | ||||
-rw-r--r-- | source4/librpc/idl/krb5pac.idl | 6 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 115 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_compression.c | 176 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 75 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 506 | ||||
-rwxr-xr-x | source4/pidl/tests/samba-ndr.pl | 13 | ||||
-rw-r--r-- | source4/torture/rpc/dssync.c | 15 |
11 files changed, 528 insertions, 457 deletions
diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c index 3629a3b92b..80b398ef5c 100644 --- a/source4/dsdb/repl/drepl_out_helpers.c +++ b/source4/dsdb/repl/drepl_out_helpers.c @@ -314,27 +314,35 @@ static void dreplsrv_op_pull_source_get_changes_recv(struct rpc_request *req) if (*r->out.level == 1) { ctr_level = 1; ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2) { + } else if (*r->out.level == 2 && + r->out.ctr.ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = r->out.ctr.ctr2.mszip1.ctr1; + ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; } else if (*r->out.level == 6) { ctr_level = 6; ctr6 = &r->out.ctr.ctr6; } else if (*r->out.level == 7 && r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { + r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr.ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = r->out.ctr.ctr7.ctr.mszip6.ctr6; + ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; } else if (*r->out.level == 7 && r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS) { + r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr.ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = r->out.ctr.ctr7.ctr.xpress6.ctr6; + ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; } else { composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP)); return; } + if (!ctr1 && !ctr6) { + composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP)); + return; + } + if (ctr_level == 6) { if (!W_ERROR_IS_OK(ctr6->drs_error)) { composite_error(c, werror_to_ntstatus(ctr6->drs_error)); diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index cab1446ff3..bee271eaa9 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -51,7 +51,7 @@ static krb5_error_code make_pac(krb5_context context, struct auth_serversupplied_info *server_info, krb5_pac *pac) { - struct PAC_LOGON_INFO_CTR logon_info; + union PAC_INFO info; struct netr_SamInfo3 *info3; krb5_data pac_data; NTSTATUS nt_status; @@ -59,7 +59,7 @@ static krb5_error_code make_pac(krb5_context context, DATA_BLOB pac_out; krb5_error_code ret; - ZERO_STRUCT(logon_info); + ZERO_STRUCT(info); nt_status = auth_convert_server_info_saminfo3(mem_ctx, server_info, &info3); if (!NT_STATUS_IS_OK(nt_status)) { @@ -67,15 +67,16 @@ static krb5_error_code make_pac(krb5_context context, return EINVAL; } - logon_info.info = talloc_zero(mem_ctx, struct PAC_LOGON_INFO); + info.logon_info.info = talloc_zero(mem_ctx, struct PAC_LOGON_INFO); if (!mem_ctx) { return ENOMEM; } - logon_info.info->info3 = *info3; + info.logon_info.info->info3 = *info3; - ndr_err = ndr_push_struct_blob(&pac_out, mem_ctx, iconv_convenience, &logon_info, - (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO_CTR); + ndr_err = ndr_push_union_blob(&pac_out, mem_ctx, iconv_convenience, &info, + PAC_TYPE_LOGON_INFO, + (ndr_push_flags_fn_t)ndr_push_PAC_INFO); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { nt_status = ndr_map_error2ntstatus(ndr_err); DEBUG(1, ("PAC (presig) push failed: %s\n", nt_errstr(nt_status))); @@ -162,7 +163,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, krb5_data k5pac_in; DATA_BLOB pac_in; - struct PAC_LOGON_INFO_CTR logon_info; + union PAC_INFO info; union netr_Validation validation; struct auth_serversupplied_info *server_info_out; @@ -191,9 +192,10 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, return ENOMEM; } - ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, private->iconv_convenience, &logon_info, - (ndr_pull_flags_fn_t)ndr_pull_PAC_LOGON_INFO_CTR); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || !logon_info.info) { + ndr_err = ndr_pull_union_blob(&pac_in, mem_ctx, private->iconv_convenience, &info, + PAC_TYPE_LOGON_INFO, + (ndr_pull_flags_fn_t)ndr_pull_PAC_INFO); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || !info.logon_info.info) { nt_status = ndr_map_error2ntstatus(ndr_err); DEBUG(0,("can't parse the PAC LOGON_INFO: %s\n", nt_errstr(nt_status))); talloc_free(mem_ctx); @@ -201,7 +203,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, } /* Pull this right into the normal auth sysstem structures */ - validation.sam3 = &logon_info.info->info3; + validation.sam3 = &info.logon_info.info->info3; nt_status = make_server_info_netlogon_validation(mem_ctx, "", 3, &validation, diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 19391e7983..332b041e36 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -2465,26 +2465,33 @@ static WERROR becomeDC_drsuapi_pull_partition_recv(struct libnet_BecomeDC_state if (*r->out.level == 1) { ctr_level = 1; ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2) { + } else if (*r->out.level == 2 && + r->out.ctr.ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = r->out.ctr.ctr2.mszip1.ctr1; + ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; } else if (*r->out.level == 6) { ctr_level = 6; ctr6 = &r->out.ctr.ctr6; } else if (*r->out.level == 7 && r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { + r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr.ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = r->out.ctr.ctr7.ctr.mszip6.ctr6; + ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; } else if (*r->out.level == 7 && r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS) { + r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr.ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = r->out.ctr.ctr7.ctr.xpress6.ctr6; + ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; } else { return WERR_BAD_NET_RESP; } + if (!ctr1 && ! ctr6) { + return WERR_BAD_NET_RESP; + } + if (ctr_level == 6) { if (!W_ERROR_IS_OK(ctr6->drs_error)) { return ctr6->drs_error; diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl index 88d2126d0b..b929bb0d58 100644 --- a/source4/librpc/idl/drsuapi.idl +++ b/source4/librpc/idl/drsuapi.idl @@ -618,11 +618,19 @@ interface drsuapi } drsuapi_DsGetNCChangesCtr6; typedef struct { + [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr1 ctr1; + } drsuapi_DsGetNCChangesCtr1TS; + + typedef struct { + [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr6 ctr6; + } drsuapi_DsGetNCChangesCtr6TS; + + typedef struct { uint32 decompressed_length; uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1 *ctr1; + drsuapi_DsGetNCChangesCtr1TS *ts; } drsuapi_DsGetNCChangesMSZIPCtr1; typedef struct { @@ -630,7 +638,7 @@ interface drsuapi uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6 *ctr6; + drsuapi_DsGetNCChangesCtr6TS *ts; } drsuapi_DsGetNCChangesMSZIPCtr6; typedef struct { @@ -638,7 +646,7 @@ interface drsuapi uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1 *ctr1; + drsuapi_DsGetNCChangesCtr1TS *ts; } drsuapi_DsGetNCChangesXPRESSCtr1; typedef struct { @@ -646,7 +654,7 @@ interface drsuapi uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6 *ctr6; + drsuapi_DsGetNCChangesCtr6TS *ts; } drsuapi_DsGetNCChangesXPRESSCtr6; typedef [enum16bit] enum { diff --git a/source4/librpc/idl/krb5pac.idl b/source4/librpc/idl/krb5pac.idl index b450908915..ca0efaed3e 100644 --- a/source4/librpc/idl/krb5pac.idl +++ b/source4/librpc/idl/krb5pac.idl @@ -45,10 +45,6 @@ interface krb5pac } PAC_UNKNOWN_12; typedef [public] struct { - [value(0x00081001)] uint32 unknown1; - [value(0xCCCCCCCC)] uint32 unknown2; - [value(NDR_ROUND(ndr_size_PAC_LOGON_INFO(info, ndr->flags)+4,8))] uint32 _ndr_size; - [value(0x00000000)] uint32 unknown3; PAC_LOGON_INFO *info; } PAC_LOGON_INFO_CTR; @@ -66,7 +62,7 @@ interface krb5pac } DATA_BLOB_REM; typedef [public,nodiscriminant,gensize] union { - [case(PAC_TYPE_LOGON_INFO)] PAC_LOGON_INFO_CTR logon_info; + [case(PAC_TYPE_LOGON_INFO)][subcontext(0xFFFFFC01)] PAC_LOGON_INFO_CTR logon_info; [case(PAC_TYPE_SRV_CHECKSUM)] PAC_SIGNATURE_DATA srv_cksum; [case(PAC_TYPE_KDC_CHECKSUM)] PAC_SIGNATURE_DATA kdc_cksum; [case(PAC_TYPE_LOGON_NAME)] PAC_LOGON_NAME logon_name; diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 40852456bc..c5e4c44794 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -394,6 +394,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, { struct ndr_pull *subndr; uint32_t r_content_size; + bool force_le = false; + bool force_be = false; switch (header_size) { case 0: { @@ -426,6 +428,74 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, r_content_size = content_size; break; } + case 0xFFFFFC01: { + /* + * Common Type Header for the Serialization Stream + * See [MS-RPCE] 2.2.6 Type Serialization Version 1 + */ + uint8_t version; + uint8_t drep; + uint16_t hdrlen; + uint32_t filler; + uint32_t content_size; + uint32_t reserved; + + /* version */ + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &version)); + + if (version != 1) { + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, + "Bad subcontext (PULL) Common Type Header version %d != 1", + (int)version); + } + + /* + * 0x10 little endian + * 0x00 big endian + */ + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &drep)); + if (drep == 0x10) { + force_le = true; + } else if (drep == 0x00) { + force_be = true; + } else { + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, + "Bad subcontext (PULL) Common Type Header invalid drep 0x%02X", + (unsigned int)drep); + } + + /* length of the "Private Header for Constructed Type" */ + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &hdrlen)); + if (hdrlen != 8) { + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, + "Bad subcontext (PULL) Common Type Header length %d != 8", + (int)hdrlen); + } + + /* filler should be ignored */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &filler)); + + /* + * Private Header for Constructed Type + */ + /* length - will be updated latter */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &content_size)); + if (size_is >= 0 && size_is != content_size) { + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", + (int)size_is, (int)content_size); + } + /* the content size must be a multiple of 8 */ + if ((content_size % 8) != 0) { + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, + "Bad subcontext (PULL) size_is(%d) not padded to 8 content_size %d", + (int)size_is, (int)content_size); + } + r_content_size = content_size; + + /* reserved */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &reserved)); + break; + } default: return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) header_size %d", (int)header_size); @@ -443,6 +513,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, subndr->data_size = r_content_size; subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience); + if (force_le) { + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); + } else if (force_be) { + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); + } + *_subndr = subndr; return NDR_ERR_SUCCESS; } @@ -487,8 +563,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_end(struct ndr_push *ndr, size_t header_size, ssize_t size_is) { + ssize_t padding_len; + if (size_is >= 0) { - ssize_t padding_len = size_is - subndr->offset; + padding_len = size_is - subndr->offset; if (padding_len > 0) { NDR_CHECK(ndr_push_zero(subndr, padding_len)); } else if (padding_len < 0) { @@ -509,6 +587,41 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_end(struct ndr_push *ndr, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, subndr->offset)); break; + case 0xFFFFFC01: + /* + * Common Type Header for the Serialization Stream + * See [MS-RPCE] 2.2.6 Type Serialization Version 1 + */ + padding_len = NDR_ROUND(subndr->offset, 8) - subndr->offset; + if (padding_len > 0) { + NDR_CHECK(ndr_push_zero(subndr, padding_len)); + } + + /* version */ + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, 1)); + + /* + * 0x10 little endian + * 0x00 big endian + */ + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, NDR_BE(ndr)?0x00:0x10)); + + /* length of the "Private Header for Constructed Type" */ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 8)); + + /* filler */ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xCCCCCCCC)); + + /* + * Private Header for Constructed Type + */ + /* length - will be updated latter */ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, subndr->offset)); + + /* reserved */ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + break; + default: return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext header size %d", (int)header_size); diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index 7c2aca72e9..f6de0a1319 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -145,80 +145,6 @@ static enum ndr_err_code ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpu return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_compression_mszip(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - ssize_t decompressed_len) -{ - struct ndr_push *ndrpush; - struct ndr_pull *comndr; - DATA_BLOB uncompressed; - uint32_t payload_header[4]; - uint32_t payload_size; - uint32_t payload_offset; - uint8_t *payload; - z_stream z; - bool last = false; - - ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(ndrpush); - - ZERO_STRUCT(z); - - while (!last) { - NDR_CHECK(ndr_pull_compression_mszip_chunk(subndr, ndrpush, &z, &last)); - } - - uncompressed = ndr_push_blob(ndrpush); - - if (uncompressed.length != decompressed_len) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP uncompressed_len [%u] != [%d] (PULL)", - (int)uncompressed.length, (int)decompressed_len); - } - - comndr = talloc_zero(subndr, struct ndr_pull); - NDR_ERR_HAVE_NO_MEMORY(comndr); - comndr->flags = subndr->flags; - comndr->current_mem_ctx = subndr->current_mem_ctx; - - comndr->data = uncompressed.data; - comndr->data_size = uncompressed.length; - comndr->offset = 0; - - comndr->iconv_convenience = talloc_reference(comndr, subndr->iconv_convenience); - - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[0])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[1])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[2])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[3])); - - if (payload_header[0] != 0x00081001) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[0] [0x%08X] != [0x00081001] (PULL)", - payload_header[0]); - } - if (payload_header[1] != 0xCCCCCCCC) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[1] [0x%08X] != [0xCCCCCCCC] (PULL)", - payload_header[1]); - } - - payload_size = payload_header[2]; - - if (payload_header[3] != 0x00000000) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[3] [0x%08X] != [0x00000000] (PULL)", - payload_header[3]); - } - - payload_offset = comndr->offset; - NDR_CHECK(ndr_pull_advance(comndr, payload_size)); - payload = comndr->data + payload_offset; - - comndr->data = payload; - comndr->data_size = payload_size; - comndr->offset = 0; - - *_comndr = comndr; - return NDR_ERR_SUCCESS; -} - static enum ndr_err_code ndr_push_compression_mszip(struct ndr_push *subndr, struct ndr_push *comndr) { @@ -268,30 +194,53 @@ static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrp return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_compression_xpress(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - ssize_t decompressed_len) +static enum ndr_err_code ndr_push_compression_xpress(struct ndr_push *subndr, + struct ndr_push *comndr) +{ + return ndr_push_error(subndr, NDR_ERR_COMPRESSION, "XPRESS compression is not supported yet (PUSH)"); +} + +/* + handle compressed subcontext buffers, which in midl land are user-marshalled, but + we use magic in pidl to make them easier to cope with +*/ +enum ndr_err_code ndr_pull_compression_start(struct ndr_pull *subndr, + struct ndr_pull **_comndr, + enum ndr_compression_alg compression_alg, + ssize_t decompressed_len) { struct ndr_push *ndrpush; struct ndr_pull *comndr; DATA_BLOB uncompressed; - uint32_t payload_header[4]; - uint32_t payload_size; - uint32_t payload_offset; - uint8_t *payload; bool last = false; + z_stream z; ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(ndrpush); - while (!last) { - NDR_CHECK(ndr_pull_compression_xpress_chunk(subndr, ndrpush, &last)); + switch (compression_alg) { + case NDR_COMPRESSION_MSZIP: + ZERO_STRUCT(z); + while (!last) { + NDR_CHECK(ndr_pull_compression_mszip_chunk(subndr, ndrpush, &z, &last)); + } + break; + + case NDR_COMPRESSION_XPRESS: + while (!last) { + NDR_CHECK(ndr_pull_compression_xpress_chunk(subndr, ndrpush, &last)); + } + break; + + default: + return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad compression algorithm %d (PULL)", + compression_alg); } uncompressed = ndr_push_blob(ndrpush); if (uncompressed.length != decompressed_len) { return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, - "Bad XPRESS uncompressed_len [%u] != [%u](0x%08X) (PULL)", + "Bad uncompressed_len [%u] != [%u](0x%08X) (PULL)", (int)uncompressed.length, (int)decompressed_len, (int)decompressed_len); @@ -308,69 +257,10 @@ static enum ndr_err_code ndr_pull_compression_xpress(struct ndr_pull *subndr, comndr->iconv_convenience = talloc_reference(comndr, subndr->iconv_convenience); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[0])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[1])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[2])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[3])); - - if (payload_header[0] != 0x00081001) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, - "Bad XPRESS payload_header[0] [0x%08X] != [0x00081001] (PULL)", - payload_header[0]); - } - if (payload_header[1] != 0xCCCCCCCC) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, - "Bad XPRESS payload_header[1] [0x%08X] != [0xCCCCCCCC] (PULL)", - payload_header[1]); - } - - payload_size = payload_header[2]; - - if (payload_header[3] != 0x00000000) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, - "Bad XPRESS payload_header[3] [0x%08X] != [0x00000000] (PULL)", - payload_header[3]); - } - - payload_offset = comndr->offset; - NDR_CHECK(ndr_pull_advance(comndr, payload_size)); - payload = comndr->data + payload_offset; - - comndr->data = payload; - comndr->data_size = payload_size; - comndr->offset = 0; - *_comndr = comndr; return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_push_compression_xpress(struct ndr_push *subndr, - struct ndr_push *comndr) -{ - return ndr_push_error(subndr, NDR_ERR_COMPRESSION, "XPRESS compression is not supported yet (PUSH)"); -} - -/* - handle compressed subcontext buffers, which in midl land are user-marshalled, but - we use magic in pidl to make them easier to cope with -*/ -enum ndr_err_code ndr_pull_compression_start(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - enum ndr_compression_alg compression_alg, - ssize_t decompressed_len) -{ - switch (compression_alg) { - case NDR_COMPRESSION_MSZIP: - return ndr_pull_compression_mszip(subndr, _comndr, decompressed_len); - case NDR_COMPRESSION_XPRESS: - return ndr_pull_compression_xpress(subndr, _comndr, decompressed_len); - default: - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad compression algorithm %d (PULL)", - compression_alg); - } - return NDR_ERR_SUCCESS; -} - enum ndr_err_code ndr_pull_compression_end(struct ndr_pull *subndr, struct ndr_pull *comndr, enum ndr_compression_alg compression_alg, diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 1e4504764a..10bd29715b 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -287,6 +287,22 @@ sub GetElementLevelTable($$) return $order; } +sub GetTypedefLevelTable($$$) +{ + my ($e, $data, $pointer_default) = @_; + + my $order = []; + + push (@$order, { + TYPE => "TYPEDEF" + }); + + my $i = 0; + foreach (@$order) { $_->{LEVEL_INDEX} = $i; $i+=1; } + + return $order; +} + ##################################################################### # see if a type contains any deferred data sub can_contain_deferred($) @@ -575,6 +591,7 @@ sub ParseTypedef($$) NAME => $d->{NAME}, TYPE => $d->{TYPE}, PROPERTIES => $d->{PROPERTIES}, + LEVELS => GetTypedefLevelTable($d, $data, $pointer_default), DATA => $data, ORIGINAL => $d }; @@ -795,20 +812,21 @@ sub ContainsDeferred($$) sub el_name($) { my $e = shift; + my $name = "<ANONYMOUS>"; - if ($e->{PARENT} && $e->{PARENT}->{NAME}) { - return "$e->{PARENT}->{NAME}.$e->{NAME}"; - } + $name = $e->{NAME} if defined($e->{NAME}); - if ($e->{PARENT} && $e->{PARENT}->{PARENT}->{NAME}) { - return "$e->{PARENT}->{PARENT}->{NAME}.$e->{NAME}"; + if (defined($e->{PARENT}) and defined($e->{PARENT}->{NAME})) { + return "$e->{PARENT}->{NAME}.$name"; } - if ($e->{PARENT}) { - return "$e->{PARENT}->{NAME}.$e->{NAME}"; + if (defined($e->{PARENT}) and + defined($e->{PARENT}->{PARENT}) and + defined($e->{PARENT}->{PARENT}->{NAME})) { + return "$e->{PARENT}->{PARENT}->{NAME}.$name"; } - return $e->{NAME}; + return $name; } ################################### @@ -858,25 +876,25 @@ my %property_list = ( "unique" => ["ELEMENT"], "ignore" => ["ELEMENT"], "relative" => ["ELEMENT"], - "relative_base" => ["TYPEDEF"], + "relative_base" => ["TYPEDEF", "STRUCT", "UNION"], - "gensize" => ["TYPEDEF"], + "gensize" => ["TYPEDEF", "STRUCT", "UNION"], "value" => ["ELEMENT"], - "flag" => ["ELEMENT", "TYPEDEF"], + "flag" => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], # generic - "public" => ["FUNCTION", "TYPEDEF"], - "nopush" => ["FUNCTION", "TYPEDEF"], - "nopull" => ["FUNCTION", "TYPEDEF"], - "nosize" => ["FUNCTION", "TYPEDEF"], - "noprint" => ["FUNCTION", "TYPEDEF"], - "noejs" => ["FUNCTION", "TYPEDEF"], + "public" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], + "nopush" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], + "nopull" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], + "nosize" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], + "noprint" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT"], + "noejs" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], "todo" => ["FUNCTION"], # union "switch_is" => ["ELEMENT"], - "switch_type" => ["ELEMENT", "TYPEDEF"], - "nodiscriminant" => ["TYPEDEF"], + "switch_type" => ["ELEMENT", "UNION"], + "nodiscriminant" => ["UNION"], "case" => ["ELEMENT"], "default" => ["ELEMENT"], @@ -889,15 +907,15 @@ my %property_list = ( "compression" => ["ELEMENT"], # enum - "enum8bit" => ["TYPEDEF"], - "enum16bit" => ["TYPEDEF"], - "v1_enum" => ["TYPEDEF"], + "enum8bit" => ["ENUM"], + "enum16bit" => ["ENUM"], + "v1_enum" => ["ENUM"], # bitmap - "bitmap8bit" => ["TYPEDEF"], - "bitmap16bit" => ["TYPEDEF"], - "bitmap32bit" => ["TYPEDEF"], - "bitmap64bit" => ["TYPEDEF"], + "bitmap8bit" => ["BITMAP"], + "bitmap16bit" => ["BITMAP"], + "bitmap32bit" => ["BITMAP"], + "bitmap64bit" => ["BITMAP"], # array "range" => ["ELEMENT"], @@ -921,7 +939,7 @@ sub ValidProperties($$) unless defined($property_list{$key}); fatal($e, el_name($e) . ": property '$key' not allowed on '$t'") - unless grep($t, @{$property_list{$key}}); + unless grep(/^$t$/, @{$property_list{$key}}); } } @@ -1101,6 +1119,9 @@ sub ValidTypedef($) $data->{PARENT} = $typedef; + $data->{FILE} = $typedef->{FILE} unless defined($data->{FILE}); + $data->{LINE} = $typedef->{LINE} unless defined($data->{LINE}); + ValidType($data) if (ref($data) eq "HASH"); } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index a0de1f127a..745777d012 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -158,26 +158,26 @@ sub fn_declare($$$$) ################################################################### # setup any special flags for an element or structure -sub start_flags($$) +sub start_flags($$$) { - my ($self, $e) = @_; + my ($self, $e, $ndr) = @_; my $flags = has_property($e, "flag"); if (defined $flags) { $self->pidl("{"); $self->indent; - $self->pidl("uint32_t _flags_save_$e->{TYPE} = ndr->flags;"); - $self->pidl("ndr_set_flags(&ndr->flags, $flags);"); + $self->pidl("uint32_t _flags_save_$e->{TYPE} = $ndr->flags;"); + $self->pidl("ndr_set_flags(&$ndr->flags, $flags);"); } } ################################################################### # end any special flags for an element or structure -sub end_flags($$) +sub end_flags($$$) { - my ($self, $e) = @_; + my ($self, $e, $ndr) = @_; my $flags = has_property($e, "flag"); if (defined $flags) { - $self->pidl("ndr->flags = _flags_save_$e->{TYPE};"); + $self->pidl("$ndr->flags = _flags_save_$e->{TYPE};"); $self->deindent; $self->pidl("}"); } @@ -331,12 +331,12 @@ sub ParseArrayPullHeader($$$$$$) } else { $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, - "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), + "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), check_fully_dereferenced($e, $env)); } if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) { - $self->pidl("NDR_CHECK(ndr_pull_array_size(ndr, " . get_pointer_to($var_name) . "));"); + $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));"); } if ($l->{IS_VARYING}) { @@ -357,9 +357,9 @@ sub ParseArrayPullHeader($$$$$$) $self->defer_indent; my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->defer(shift); }, - "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), + "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), check_fully_dereferenced($e, $env)); - $self->defer("NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));"); + $self->defer("NDR_CHECK(ndr_check_array_size($ndr, (void*)" . get_pointer_to($var_name) . ", $size));"); $self->defer_deindent; $self->defer("}"); } @@ -369,9 +369,9 @@ sub ParseArrayPullHeader($$$$$$) $self->defer_indent; my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->defer(shift); }, - "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"), + "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"), check_fully_dereferenced($e, $env)); - $self->defer("NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));"); + $self->defer("NDR_CHECK(ndr_check_array_length($ndr, (void*)" . get_pointer_to($var_name) . ", $length));"); $self->defer_deindent; $self->defer("}"); } @@ -543,7 +543,7 @@ sub ParseElementPushLevel $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $subndr, $var_name, $env, 1, 1); $self->ParseSubcontextPushEnd($e, $l, $ndr, $env); } elsif ($l->{TYPE} eq "POINTER") { - $self->ParsePtrPush($e, $l, $var_name); + $self->ParsePtrPush($e, $l, $ndr, $var_name); } elsif ($l->{TYPE} eq "ARRAY") { my $length = $self->ParseArrayPushHeader($e, $l, $ndr, $var_name, $env); @@ -561,6 +561,8 @@ sub ParseElementPushLevel $self->ParseSwitchPush($e, $l, $ndr, $var_name, $env); } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPush($e, $l, $ndr, $var_name, $primitives, $deferred); + } elsif ($l->{TYPE} eq "TYPEDEF") { + $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name); } } @@ -569,7 +571,7 @@ sub ParseElementPushLevel $self->pidl("if ($var_name) {"); $self->indent; if ($l->{POINTER_TYPE} eq "relative") { - $self->pidl("NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_name));"); + $self->pidl("NDR_CHECK(ndr_push_relative_ptr2($ndr, $var_name));"); } } $var_name = get_value_of($var_name); @@ -629,7 +631,7 @@ sub ParseElementPush($$$$$$) $var_name = append_prefix($e, $var_name); - $self->start_flags($e); + $self->start_flags($e, $ndr); if (defined(my $value = has_property($e, "value"))) { $var_name = ParseExpr($value, $env, $e->{ORIGINAL}); @@ -637,7 +639,7 @@ sub ParseElementPush($$$$$$) $self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred); - $self->end_flags($e); + $self->end_flags($e, $ndr); if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) { $self->deindent; @@ -647,25 +649,25 @@ sub ParseElementPush($$$$$$) ##################################################################### # parse a pointer in a struct element or function -sub ParsePtrPush($$$$) +sub ParsePtrPush($$$$$) { - my ($self,$e,$l,$var_name) = @_; + my ($self,$e,$l,$ndr,$var_name) = @_; if ($l->{POINTER_TYPE} eq "ref") { $self->pidl("if ($var_name == NULL) {"); $self->indent; - $self->pidl("return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");"); + $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");"); $self->deindent; $self->pidl("}"); if ($l->{LEVEL} eq "EMBEDDED") { $self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr));"); } } elsif ($l->{POINTER_TYPE} eq "relative") { - $self->pidl("NDR_CHECK(ndr_push_relative_ptr1(ndr, $var_name));"); + $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));"); } elsif ($l->{POINTER_TYPE} eq "unique") { - $self->pidl("NDR_CHECK(ndr_push_unique_ptr(ndr, $var_name));"); + $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));"); } elsif ($l->{POINTER_TYPE} eq "full") { - $self->pidl("NDR_CHECK(ndr_push_full_ptr(ndr, $var_name));"); + $self->pidl("NDR_CHECK(ndr_push_full_ptr($ndr, $var_name));"); } else { die("Unhandled pointer type $l->{POINTER_TYPE}"); } @@ -702,45 +704,45 @@ sub need_pointer_to($$$) return 0; } -sub ParseDataPrint($$$$) +sub ParseDataPrint($$$$$) { - my ($self, $e, $l, $var_name) = @_; - + my ($self, $e, $l, $ndr, $var_name) = @_; + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);"); + $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."($ndr, \"$e->{NAME}\", $var_name);"); } else { - $self->ParseTypePrint($l->{DATA_TYPE}, $var_name); + $self->ParseTypePrint($l->{DATA_TYPE}, $ndr, $var_name); } } ##################################################################### # print scalars in a structure element -sub ParseElementPrint($$$$) +sub ParseElementPrint($$$$$) { - my($self, $e, $var_name, $env) = @_; + my($self, $e, $ndr, $var_name, $env) = @_; return if (has_property($e, "noprint")); if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) { - $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}(ndr, \"$e->{NAME}\", $var_name);"); + $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}($ndr, \"$e->{NAME}\", $var_name);"); return; } $var_name = append_prefix($e, $var_name); if (defined(my $value = has_property($e, "value"))) { - $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name"; + $var_name = "($ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name"; } foreach my $l (@{$e->{LEVELS}}) { if ($l->{TYPE} eq "POINTER") { - $self->pidl("ndr_print_ptr(ndr, \"$e->{NAME}\", $var_name);"); - $self->pidl("ndr->depth++;"); + $self->pidl("ndr_print_ptr($ndr, \"$e->{NAME}\", $var_name);"); + $self->pidl("$ndr->depth++;"); if ($l->{POINTER_TYPE} ne "ref") { $self->pidl("if ($var_name) {"); $self->indent; @@ -761,17 +763,17 @@ sub ParseElementPrint($$$$) } if (is_charset_array($e,$l)) { - $self->pidl("ndr_print_string(ndr, \"$e->{NAME}\", $var_name);"); + $self->pidl("ndr_print_string($ndr, \"$e->{NAME}\", $var_name);"); last; } elsif (has_fast_array($e, $l)) { my $nl = GetNextLevel($e, $l); - $self->pidl("ndr_print_array_$nl->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name, $length);"); + $self->pidl("ndr_print_array_$nl->{DATA_TYPE}($ndr, \"$e->{NAME}\", $var_name, $length);"); last; } else { my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; - $self->pidl("ndr->print(ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);"); - $self->pidl("ndr->depth++;"); + $self->pidl("$ndr->print($ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);"); + $self->pidl("$ndr->depth++;"); $self->pidl("for ($counter=0;$counter<$length;$counter++) {"); $self->indent; $self->pidl("char *idx_$l->{LEVEL_INDEX}=NULL;"); @@ -781,11 +783,11 @@ sub ParseElementPrint($$$$) $var_name = get_array_element($var_name, $counter); } } elsif ($l->{TYPE} eq "DATA") { - $self->ParseDataPrint($e, $l, $var_name); + $self->ParseDataPrint($e, $l, $ndr, $var_name); } elsif ($l->{TYPE} eq "SWITCH") { my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env)); - $self->pidl("ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);"); + $self->pidl("ndr_print_set_switch_value($ndr, " . get_pointer_to($var_name) . ", $switch_var);"); } } @@ -795,7 +797,7 @@ sub ParseElementPrint($$$$) $self->deindent; $self->pidl("}"); } - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); } elsif (($l->{TYPE} eq "ARRAY") and not is_charset_array($e,$l) and not has_fast_array($e,$l)) { @@ -804,7 +806,7 @@ sub ParseElementPrint($$$$) $self->pidl("}"); $self->deindent; $self->pidl("}"); - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); } } } @@ -816,7 +818,7 @@ sub ParseSwitchPull($$$$$$) my($self,$e,$l,$ndr,$var_name,$env) = @_; my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, - "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), + "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), check_fully_dereferenced($e, $env)); $var_name = get_pointer_to($var_name); @@ -830,7 +832,7 @@ sub ParseSwitchPush($$$$$$) my($self,$e,$l,$ndr,$var_name,$env) = @_; my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, - "return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), + "return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), check_fully_dereferenced($e, $env)); $var_name = get_pointer_to($var_name); @@ -861,7 +863,7 @@ sub ParseDataPull($$$$$$$) $self->pidl("}"); } } else { - $self->ParseTypePull($l->{DATA_TYPE}, $var_name, $primitives, $deferred); + $self->ParseTypePull($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred); } } @@ -880,7 +882,7 @@ sub ParseDataPush($$$$$$$) $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); } else { - $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred); + $self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred); } } @@ -936,9 +938,9 @@ sub ParseMemCtxPullFlags($$$$) return $mem_flags; } -sub ParseMemCtxPullStart($$$$) +sub ParseMemCtxPullStart($$$$$) { - my ($self, $e, $l, $ptr_name) = @_; + my ($self, $e, $l, $ndr, $ptr_name) = @_; my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}"; my $mem_c_ctx = $ptr_name; @@ -946,20 +948,20 @@ sub ParseMemCtxPullStart($$$$) return unless defined($mem_c_flags); - $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX(ndr);"); - $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_c_ctx, $mem_c_flags);"); + $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX($ndr);"); + $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_c_ctx, $mem_c_flags);"); } -sub ParseMemCtxPullEnd($$$) +sub ParseMemCtxPullEnd($$$$) { - my ($self, $e, $l) = @_; + my ($self, $e, $l, $ndr) = @_; my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}"; my $mem_r_flags = $self->ParseMemCtxPullFlags($e, $l); return unless defined($mem_r_flags); - $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_r_ctx, $mem_r_flags);"); + $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_r_ctx, $mem_r_flags);"); } sub CheckStringTerminator($$$$$) @@ -1011,6 +1013,8 @@ sub ParseElementPullLevel $self->ParseSwitchPull($e, $l, $ndr, $var_name, $env); } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPull($e, $l, $ndr, $var_name, $primitives, $deferred); + } elsif ($l->{TYPE} eq "TYPEDEF") { + $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name); } } @@ -1022,21 +1026,21 @@ sub ParseElementPullLevel if ($l->{POINTER_TYPE} eq "relative") { $self->pidl("uint32_t _relative_save_offset;"); - $self->pidl("_relative_save_offset = ndr->offset;"); - $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2(ndr, $var_name));"); + $self->pidl("_relative_save_offset = $ndr->offset;"); + $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2($ndr, $var_name));"); } } - $self->ParseMemCtxPullStart($e, $l, $var_name); + $self->ParseMemCtxPullStart($e, $l, $ndr, $var_name); $var_name = get_value_of($var_name); $self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, 1, 1); - $self->ParseMemCtxPullEnd($e,$l); + $self->ParseMemCtxPullEnd($e, $l, $ndr); if ($l->{POINTER_TYPE} ne "ref") { if ($l->{POINTER_TYPE} eq "relative") { - $self->pidl("ndr->offset = _relative_save_offset;"); + $self->pidl("$ndr->offset = _relative_save_offset;"); } $self->deindent; $self->pidl("}"); @@ -1049,7 +1053,7 @@ sub ParseElementPullLevel $var_name = get_array_element($var_name, $counter); - $self->ParseMemCtxPullStart($e, $l, $array_name); + $self->ParseMemCtxPullStart($e, $l, $ndr, $array_name); if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { my $nl = GetNextLevel($e,$l); @@ -1073,7 +1077,7 @@ sub ParseElementPullLevel $self->pidl("}"); } - $self->ParseMemCtxPullEnd($e, $l); + $self->ParseMemCtxPullEnd($e, $l, $ndr); } elsif ($l->{TYPE} eq "SWITCH") { $self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, $primitives, $deferred); @@ -1103,11 +1107,11 @@ sub ParseElementPull($$$$$$) $var_name = append_prefix($e, $var_name); - $self->start_flags($e); + $self->start_flags($e, $ndr); $self->ParseElementPullLevel($e,$e->{LEVELS}[0],$ndr,$var_name,$env,$primitives,$deferred); - $self->end_flags($e); + $self->end_flags($e, $ndr); # Representation type is different from transmit_as if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) { @@ -1131,7 +1135,7 @@ sub ParsePtrPull($$$$$) if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") { if (!$next_is_array and !$next_is_string) { - $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); + $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); $self->pidl("\tNDR_PULL_ALLOC($ndr, $var_name);"); $self->pidl("}"); } @@ -1172,9 +1176,9 @@ sub ParsePtrPull($$$$$) $self->pidl("}"); } -sub ParseStructPushPrimitives($$$$) +sub ParseStructPushPrimitives($$$$$) { - my ($self, $struct, $varname, $env) = @_; + my ($self, $struct, $ndr, $varname, $env) = @_; # see if the structure contains a conformant array. If it # does, then it must be the last element of the structure, and @@ -1198,39 +1202,39 @@ sub ParseStructPushPrimitives($$$$) $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL}); } - $self->pidl("NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));"); + $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $size));"); } else { - $self->pidl("NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, $varname->$e->{NAME})));"); + $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, ndr_string_array_size($ndr, $varname->$e->{NAME})));"); } } - $self->pidl("NDR_CHECK(ndr_push_align(ndr, $struct->{ALIGN}));"); + $self->pidl("NDR_CHECK(ndr_push_align($ndr, $struct->{ALIGN}));"); if (defined($struct->{PROPERTIES}{relative_base})) { # set the current offset as base for relative pointers # and store it based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, $varname, ndr->offset));"); + $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));"); } - $self->ParseElementPush($_, "ndr", $env, 1, 0) foreach (@{$struct->{ELEMENTS}}); + $self->ParseElementPush($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}}); } -sub ParseStructPushDeferred($$$) +sub ParseStructPushDeferred($$$$) { - my ($self, $struct, $varname, $env) = @_; + my ($self, $struct, $ndr, $varname, $env) = @_; if (defined($struct->{PROPERTIES}{relative_base})) { # retrieve the current offset as base for relative pointers # based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, $varname));"); + $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));"); } - $self->ParseElementPush($_, "ndr", $env, 0, 1) foreach (@{$struct->{ELEMENTS}}); + $self->ParseElementPush($_, $ndr, $env, 0, 1) foreach (@{$struct->{ELEMENTS}}); } ##################################################################### # parse a struct -sub ParseStructPush($$$) +sub ParseStructPush($$$$) { - my ($self, $struct, $varname) = @_; + my ($self, $struct, $ndr, $varname) = @_; return unless defined($struct->{ELEMENTS}); @@ -1240,61 +1244,61 @@ sub ParseStructPush($$$) $self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}}); - $self->start_flags($struct); + $self->start_flags($struct, $ndr); $self->pidl("if (ndr_flags & NDR_SCALARS) {"); $self->indent; - $self->ParseStructPushPrimitives($struct, $varname, $env); + $self->ParseStructPushPrimitives($struct, $ndr, $varname, $env); $self->deindent; $self->pidl("}"); $self->pidl("if (ndr_flags & NDR_BUFFERS) {"); $self->indent; - $self->ParseStructPushDeferred($struct, $varname, $env); + $self->ParseStructPushDeferred($struct, $ndr, $varname, $env); $self->deindent; $self->pidl("}"); - $self->end_flags($struct); + $self->end_flags($struct, $ndr); } ##################################################################### # generate a push function for an enum -sub ParseEnumPush($$$) +sub ParseEnumPush($$$$) { - my($self,$enum,$varname) = @_; + my($self,$enum,$ndr,$varname) = @_; my($type_fn) = $enum->{BASE_TYPE}; - $self->start_flags($enum); - $self->pidl("NDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, $varname));"); - $self->end_flags($enum); + $self->start_flags($enum, $ndr); + $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));"); + $self->end_flags($enum, $ndr); } ##################################################################### # generate a pull function for an enum -sub ParseEnumPull($$$) +sub ParseEnumPull($$$$) { - my($self,$enum,$varname) = @_; + my($self,$enum,$ndr,$varname) = @_; my($type_fn) = $enum->{BASE_TYPE}; my($type_v_decl) = mapTypeName($type_fn); $self->pidl("$type_v_decl v;"); - $self->start_flags($enum); - $self->pidl("NDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));"); + $self->start_flags($enum, $ndr); + $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));"); $self->pidl("*$varname = v;"); - $self->end_flags($enum); + $self->end_flags($enum, $ndr); } ##################################################################### # generate a print function for an enum -sub ParseEnumPrint($$$$) +sub ParseEnumPrint($$$$$) { - my($self,$enum,$name,$varname) = @_; + my($self,$enum,$ndr,$name,$varname) = @_; $self->pidl("const char *val = NULL;"); $self->pidl(""); - $self->start_flags($enum); + $self->start_flags($enum, $ndr); $self->pidl("switch ($varname) {"); $self->indent; @@ -1311,9 +1315,9 @@ sub ParseEnumPrint($$$$) $self->deindent; $self->pidl("}"); - $self->pidl("ndr_print_enum(ndr, name, \"$enum->{TYPE}\", val, $varname);"); + $self->pidl("ndr_print_enum($ndr, name, \"$enum->{TYPE}\", val, $varname);"); - $self->end_flags($enum); + $self->end_flags($enum, $ndr); } sub DeclEnum($$$$) @@ -1332,39 +1336,39 @@ $typefamily{ENUM} = { ##################################################################### # generate a push function for a bitmap -sub ParseBitmapPush($$$) +sub ParseBitmapPush($$$$) { - my($self,$bitmap,$varname) = @_; + my($self,$bitmap,$ndr,$varname) = @_; my($type_fn) = $bitmap->{BASE_TYPE}; - $self->start_flags($bitmap); + $self->start_flags($bitmap, $ndr); - $self->pidl("NDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, $varname));"); + $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));"); - $self->end_flags($bitmap); + $self->end_flags($bitmap, $ndr); } ##################################################################### # generate a pull function for an bitmap -sub ParseBitmapPull($$$) +sub ParseBitmapPull($$$$) { - my($self,$bitmap,$varname) = @_; + my($self,$bitmap,$ndr,$varname) = @_; my $type_fn = $bitmap->{BASE_TYPE}; my($type_decl) = mapTypeName($bitmap->{BASE_TYPE}); $self->pidl("$type_decl v;"); - $self->start_flags($bitmap); - $self->pidl("NDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));"); + $self->start_flags($bitmap, $ndr); + $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));"); $self->pidl("*$varname = v;"); - $self->end_flags($bitmap); + $self->end_flags($bitmap, $ndr); } ##################################################################### # generate a print function for an bitmap -sub ParseBitmapPrintElement($$$$$) +sub ParseBitmapPrintElement($$$$$$) { - my($self,$e,$bitmap,$name,$varname) = @_; + my($self,$e,$bitmap,$ndr,$name,$varname) = @_; my($type_decl) = mapTypeName($bitmap->{BASE_TYPE}); my($type_fn) = $bitmap->{BASE_TYPE}; my($flag); @@ -1375,28 +1379,28 @@ sub ParseBitmapPrintElement($$$$$) die "Bitmap: \"$name\" invalid Flag: \"$e\""; } - $self->pidl("ndr_print_bitmap_flag(ndr, sizeof($type_decl), \"$flag\", $flag, $varname);"); + $self->pidl("ndr_print_bitmap_flag($ndr, sizeof($type_decl), \"$flag\", $flag, $varname);"); } ##################################################################### # generate a print function for an bitmap -sub ParseBitmapPrint($$$$) +sub ParseBitmapPrint($$$$$) { - my($self,$bitmap,$name,$varname) = @_; + my($self,$bitmap,$ndr,$name,$varname) = @_; my($type_decl) = mapTypeName($bitmap->{TYPE}); my($type_fn) = $bitmap->{BASE_TYPE}; - $self->start_flags($bitmap); + $self->start_flags($bitmap, $ndr); - $self->pidl("ndr_print_$type_fn(ndr, name, $varname);"); + $self->pidl("ndr_print_$type_fn($ndr, name, $varname);"); - $self->pidl("ndr->depth++;"); + $self->pidl("$ndr->depth++;"); foreach my $e (@{$bitmap->{ELEMENTS}}) { - $self->ParseBitmapPrintElement($e, $bitmap, $name, $varname); + $self->ParseBitmapPrintElement($e, $bitmap, $ndr, $name, $varname); } - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); - $self->end_flags($bitmap); + $self->end_flags($bitmap, $ndr); } sub DeclBitmap($$$$) @@ -1415,9 +1419,9 @@ $typefamily{BITMAP} = { ##################################################################### # generate a struct print function -sub ParseStructPrint($$$$) +sub ParseStructPrint($$$$$) { - my($self,$struct,$name,$varname) = @_; + my($self,$struct,$ndr,$name,$varname) = @_; return unless defined $struct->{ELEMENTS}; @@ -1425,17 +1429,17 @@ sub ParseStructPrint($$$$) $self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}}); - $self->pidl("ndr_print_struct(ndr, name, \"$name\");"); + $self->pidl("ndr_print_struct($ndr, name, \"$name\");"); - $self->start_flags($struct); + $self->start_flags($struct, $ndr); - $self->pidl("ndr->depth++;"); + $self->pidl("$ndr->depth++;"); - $self->ParseElementPrint($_, $env->{$_->{NAME}}, $env) + $self->ParseElementPrint($_, $ndr, $env->{$_->{NAME}}, $env) foreach (@{$struct->{ELEMENTS}}); - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); - $self->end_flags($struct); + $self->end_flags($struct, $ndr); } sub DeclarePtrVariables($$) @@ -1474,38 +1478,38 @@ sub DeclareMemCtxVariables($$) } } -sub ParseStructPullPrimitives($$$$) +sub ParseStructPullPrimitives($$$$$) { - my($self,$struct,$varname,$env) = @_; + my($self,$struct,$ndr,$varname,$env) = @_; if (defined $struct->{SURROUNDING_ELEMENT}) { - $self->pidl("NDR_CHECK(ndr_pull_array_size(ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));"); + $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));"); } - $self->pidl("NDR_CHECK(ndr_pull_align(ndr, $struct->{ALIGN}));"); + $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $struct->{ALIGN}));"); if (defined($struct->{PROPERTIES}{relative_base})) { # set the current offset as base for relative pointers # and store it based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, $varname, ndr->offset));"); + $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));"); } - $self->ParseElementPull($_, "ndr", $env, 1, 0) foreach (@{$struct->{ELEMENTS}}); + $self->ParseElementPull($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}}); $self->add_deferred(); } -sub ParseStructPullDeferred($$$$) +sub ParseStructPullDeferred($$$$$) { - my ($self,$struct,$varname,$env) = @_; + my ($self,$struct,$ndr,$varname,$env) = @_; if (defined($struct->{PROPERTIES}{relative_base})) { # retrieve the current offset as base for relative pointers # based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, $varname));"); + $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));"); } foreach my $e (@{$struct->{ELEMENTS}}) { - $self->ParseElementPull($e, "ndr", $env, 0, 1); + $self->ParseElementPull($e, $ndr, $env, 0, 1); } $self->add_deferred(); @@ -1513,9 +1517,9 @@ sub ParseStructPullDeferred($$$$) ##################################################################### # parse a struct - pull side -sub ParseStructPull($$$) +sub ParseStructPull($$$$) { - my($self,$struct,$varname) = @_; + my($self,$struct,$ndr,$varname) = @_; return unless defined $struct->{ELEMENTS}; @@ -1526,22 +1530,22 @@ sub ParseStructPull($$$) $self->DeclareMemCtxVariables($e); } - $self->start_flags($struct); + $self->start_flags($struct, $ndr); my $env = GenerateStructEnv($struct, $varname); $self->pidl("if (ndr_flags & NDR_SCALARS) {"); $self->indent; - $self->ParseStructPullPrimitives($struct,$varname,$env); + $self->ParseStructPullPrimitives($struct,$ndr,$varname,$env); $self->deindent; $self->pidl("}"); $self->pidl("if (ndr_flags & NDR_BUFFERS) {"); $self->indent; - $self->ParseStructPullDeferred($struct,$varname,$env); + $self->ParseStructPullDeferred($struct,$ndr,$varname,$env); $self->deindent; $self->pidl("}"); - $self->end_flags($struct); + $self->end_flags($struct, $ndr); } ##################################################################### @@ -1592,16 +1596,16 @@ sub ParseUnionNdrSize($$$) $self->pidl("return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);"); } -sub ParseUnionPushPrimitives($$$) +sub ParseUnionPushPrimitives($$$$) { - my ($self, $e, $varname) = @_; + my ($self, $e, $ndr ,$varname) = @_; my $have_default = 0; - $self->pidl("int level = ndr_push_get_switch_value(ndr, $varname);"); + $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);"); if (defined($e->{SWITCH_TYPE})) { - $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}(ndr, NDR_SCALARS, level));"); + $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));"); } $self->pidl("switch (level) {"); @@ -1615,13 +1619,13 @@ sub ParseUnionPushPrimitives($$$) if ($el->{TYPE} ne "EMPTY") { $self->indent; if (defined($e->{PROPERTIES}{relative_base})) { - $self->pidl("NDR_CHECK(ndr_push_align(ndr, $el->{ALIGN}));"); + $self->pidl("NDR_CHECK(ndr_push_align($ndr, $el->{ALIGN}));"); # set the current offset as base for relative pointers # and store it based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, $varname, ndr->offset));"); + $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));"); } $self->DeclareArrayVariables($el); - $self->ParseElementPush($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0); + $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0); $self->deindent; } $self->pidl("break; }"); @@ -1629,23 +1633,23 @@ sub ParseUnionPushPrimitives($$$) } if (! $have_default) { $self->pidl("default:"); - $self->pidl("\treturn ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); + $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); } $self->deindent; $self->pidl("}"); } -sub ParseUnionPushDeferred($$$) +sub ParseUnionPushDeferred($$$$) { - my ($self,$e,$varname) = @_; + my ($self,$e,$ndr,$varname) = @_; my $have_default = 0; - $self->pidl("int level = ndr_push_get_switch_value(ndr, $varname);"); + $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);"); if (defined($e->{PROPERTIES}{relative_base})) { # retrieve the current offset as base for relative pointers # based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, $varname));"); + $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));"); } $self->pidl("switch (level) {"); $self->indent; @@ -1657,7 +1661,7 @@ sub ParseUnionPushDeferred($$$) $self->pidl("$el->{CASE}:"); if ($el->{TYPE} ne "EMPTY") { $self->indent; - $self->ParseElementPush($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1); + $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1); $self->deindent; } $self->pidl("break;"); @@ -1665,7 +1669,7 @@ sub ParseUnionPushDeferred($$$) } if (! $have_default) { $self->pidl("default:"); - $self->pidl("\treturn ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); + $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); } $self->deindent; $self->pidl("}"); @@ -1673,31 +1677,31 @@ sub ParseUnionPushDeferred($$$) ##################################################################### # parse a union - push side -sub ParseUnionPush($$$) +sub ParseUnionPush($$$$) { - my ($self,$e,$varname) = @_; + my ($self,$e,$ndr,$varname) = @_; my $have_default = 0; - $self->start_flags($e); + $self->start_flags($e, $ndr); $self->pidl("if (ndr_flags & NDR_SCALARS) {"); $self->indent; - $self->ParseUnionPushPrimitives($e, $varname); + $self->ParseUnionPushPrimitives($e, $ndr, $varname); $self->deindent; $self->pidl("}"); $self->pidl("if (ndr_flags & NDR_BUFFERS) {"); $self->indent; - $self->ParseUnionPushDeferred($e, $varname); + $self->ParseUnionPushDeferred($e, $ndr, $varname); $self->deindent; $self->pidl("}"); - $self->end_flags($e); + $self->end_flags($e, $ndr); } ##################################################################### # print a union -sub ParseUnionPrint($$$$) +sub ParseUnionPrint($$$$$) { - my ($self,$e,$name,$varname) = @_; + my ($self,$e,$ndr,$name,$varname) = @_; my $have_default = 0; $self->pidl("int level;"); @@ -1705,11 +1709,11 @@ sub ParseUnionPrint($$$$) $self->DeclareArrayVariables($el); } - $self->start_flags($e); + $self->start_flags($e, $ndr); - $self->pidl("level = ndr_print_get_switch_value(ndr, $varname);"); + $self->pidl("level = ndr_print_get_switch_value($ndr, $varname);"); - $self->pidl("ndr_print_union(ndr, name, level, \"$name\");"); + $self->pidl("ndr_print_union($ndr, name, level, \"$name\");"); $self->pidl("switch (level) {"); $self->indent; @@ -1720,7 +1724,7 @@ sub ParseUnionPrint($$$$) $self->pidl("$el->{CASE}:"); if ($el->{TYPE} ne "EMPTY") { $self->indent; - $self->ParseElementPrint($el, "$varname->$el->{NAME}", {}); + $self->ParseElementPrint($el, $ndr, "$varname->$el->{NAME}", {}); $self->deindent; } $self->pidl("break;"); @@ -1728,23 +1732,23 @@ sub ParseUnionPrint($$$$) } if (! $have_default) { $self->pidl("default:"); - $self->pidl("\tndr_print_bad_level(ndr, name, level);"); + $self->pidl("\tndr_print_bad_level($ndr, name, level);"); } $self->deindent; $self->pidl("}"); - $self->end_flags($e); + $self->end_flags($e, $ndr); } -sub ParseUnionPullPrimitives($$$$) +sub ParseUnionPullPrimitives($$$$$) { - my ($self,$e,$varname,$switch_type) = @_; + my ($self,$e,$ndr,$varname,$switch_type) = @_; my $have_default = 0; if (defined($switch_type)) { - $self->pidl("NDR_CHECK(ndr_pull_$switch_type(ndr, NDR_SCALARS, &_level));"); + $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));"); $self->pidl("if (_level != level) {"); - $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);"); + $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);"); $self->pidl("}"); } @@ -1761,12 +1765,12 @@ sub ParseUnionPullPrimitives($$$$) $self->DeclarePtrVariables($el); $self->DeclareArrayVariables($el); if (defined($e->{PROPERTIES}{relative_base})) { - $self->pidl("NDR_CHECK(ndr_pull_align(ndr, $el->{ALIGN}));"); + $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $el->{ALIGN}));"); # set the current offset as base for relative pointers # and store it based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, $varname, ndr->offset));"); + $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));"); } - $self->ParseElementPull($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0); + $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0); $self->deindent; } $self->pidl("break; }"); @@ -1774,21 +1778,21 @@ sub ParseUnionPullPrimitives($$$$) } if (! $have_default) { $self->pidl("default:"); - $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); + $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); } $self->deindent; $self->pidl("}"); } -sub ParseUnionPullDeferred($$$) +sub ParseUnionPullDeferred($$$$) { - my ($self,$e,$varname) = @_; + my ($self,$e,$ndr,$varname) = @_; my $have_default = 0; if (defined($e->{PROPERTIES}{relative_base})) { # retrieve the current offset as base for relative pointers # based on the toplevel struct/union - $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, $varname));"); + $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));"); } $self->pidl("switch (level) {"); $self->indent; @@ -1800,7 +1804,7 @@ sub ParseUnionPullDeferred($$$) $self->pidl("$el->{CASE}:"); if ($el->{TYPE} ne "EMPTY") { $self->indent; - $self->ParseElementPull($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1); + $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1); $self->deindent; } $self->pidl("break;"); @@ -1808,7 +1812,7 @@ sub ParseUnionPullDeferred($$$) } if (! $have_default) { $self->pidl("default:"); - $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); + $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);"); } $self->deindent; $self->pidl("}"); @@ -1818,9 +1822,9 @@ sub ParseUnionPullDeferred($$$) ##################################################################### # parse a union - pull side -sub ParseUnionPull($$$) +sub ParseUnionPull($$$$) { - my ($self,$e,$varname) = @_; + my ($self,$e,$ndr,$varname) = @_; my $switch_type = $e->{SWITCH_TYPE}; $self->pidl("int level;"); @@ -1839,25 +1843,25 @@ sub ParseUnionPull($$$) $double_cases{"$el->{NAME}"} = 1; } - $self->start_flags($e); + $self->start_flags($e, $ndr); - $self->pidl("level = ndr_pull_get_switch_value(ndr, $varname);"); + $self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);"); $self->pidl("if (ndr_flags & NDR_SCALARS) {"); $self->indent; - $self->ParseUnionPullPrimitives($e,$varname,$switch_type); + $self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type); $self->deindent; $self->pidl("}"); $self->pidl("if (ndr_flags & NDR_BUFFERS) {"); $self->indent; - $self->ParseUnionPullDeferred($e,$varname); + $self->ParseUnionPullDeferred($e,$ndr,$varname); $self->deindent; $self->pidl("}"); $self->add_deferred(); - $self->end_flags($e); + $self->end_flags($e, $ndr); } sub DeclUnion($$$$) @@ -1883,29 +1887,37 @@ $typefamily{UNION} = { ##################################################################### # parse a typedef - push side -sub ParseTypedefPush($$$) +sub ParseTypedefPush($$$$) { - my($self,$e,$varname) = @_; + my($self,$e,$ndr,$varname) = @_; + + my $env; + + $env->{$e->{NAME}} = $varname; - $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($self, $e->{DATA}, $varname); + $self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1); } ##################################################################### # parse a typedef - pull side -sub ParseTypedefPull($$$) +sub ParseTypedefPull($$$$) { - my($self,$e,$varname) = @_; + my($self,$e,$ndr,$varname) = @_; - $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($self, $e->{DATA}, $varname); + my $env; + + $env->{$e->{NAME}} = $varname; + + $self->ParseElementPullLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1); } ##################################################################### # parse a typedef - print side -sub ParseTypedefPrint($$$$) +sub ParseTypedefPrint($$$$$) { - my($self,$e,$name,$varname) = @_; + my($self,$e,$ndr,$name,$varname) = @_; - $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($self, $e->{DATA}, $name, $varname); + $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($self, $e->{DATA}, $ndr, $name, $varname); } ##################################################################### @@ -1944,12 +1956,13 @@ $typefamily{TYPEDEF} = { sub ParseFunctionPrint($$) { my($self, $fn) = @_; + my $ndr = "ndr"; - $self->pidl_hdr("void ndr_print_$fn->{NAME}(struct ndr_print *ndr, const char *name, int flags, const struct $fn->{NAME} *r);"); + $self->pidl_hdr("void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r);"); return if has_property($fn, "noprint"); - $self->pidl("_PUBLIC_ void ndr_print_$fn->{NAME}(struct ndr_print *ndr, const char *name, int flags, const struct $fn->{NAME} *r)"); + $self->pidl("_PUBLIC_ void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r)"); $self->pidl("{"); $self->indent; @@ -1957,48 +1970,48 @@ sub ParseFunctionPrint($$) $self->DeclareArrayVariables($e); } - $self->pidl("ndr_print_struct(ndr, name, \"$fn->{NAME}\");"); - $self->pidl("ndr->depth++;"); + $self->pidl("ndr_print_struct($ndr, name, \"$fn->{NAME}\");"); + $self->pidl("$ndr->depth++;"); $self->pidl("if (flags & NDR_SET_VALUES) {"); - $self->pidl("\tndr->flags |= LIBNDR_PRINT_SET_VALUES;"); + $self->pidl("\t$ndr->flags |= LIBNDR_PRINT_SET_VALUES;"); $self->pidl("}"); $self->pidl("if (flags & NDR_IN) {"); $self->indent; - $self->pidl("ndr_print_struct(ndr, \"in\", \"$fn->{NAME}\");"); - $self->pidl("ndr->depth++;"); + $self->pidl("ndr_print_struct($ndr, \"in\", \"$fn->{NAME}\");"); + $self->pidl("$ndr->depth++;"); my $env = GenerateFunctionInEnv($fn); foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/in/,@{$e->{DIRECTION}})) { - $self->ParseElementPrint($e, $env->{$e->{NAME}}, $env); + $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env); } } - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); $self->pidl("if (flags & NDR_OUT) {"); $self->indent; - $self->pidl("ndr_print_struct(ndr, \"out\", \"$fn->{NAME}\");"); - $self->pidl("ndr->depth++;"); + $self->pidl("ndr_print_struct($ndr, \"out\", \"$fn->{NAME}\");"); + $self->pidl("$ndr->depth++;"); $env = GenerateFunctionOutEnv($fn); foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/out/,@{$e->{DIRECTION}})) { - $self->ParseElementPrint($e, $env->{$e->{NAME}}, $env); + $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env); } } if ($fn->{RETURN_TYPE}) { - $self->pidl("ndr_print_$fn->{RETURN_TYPE}(ndr, \"result\", r->out.result);"); + $self->pidl("ndr_print_$fn->{RETURN_TYPE}($ndr, \"result\", r->out.result);"); } - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); - $self->pidl("ndr->depth--;"); + $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); $self->pidl(""); @@ -2009,8 +2022,9 @@ sub ParseFunctionPrint($$) sub ParseFunctionPush($$) { my($self, $fn) = @_; + my $ndr = "ndr"; - $self->fn_declare("push", $fn, "enum ndr_err_code ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, const struct $fn->{NAME} *r)") or return; + $self->fn_declare("push", $fn, "enum ndr_err_code ndr_push_$fn->{NAME}(struct ndr_push *$ndr, int flags, const struct $fn->{NAME} *r)") or return; return if has_property($fn, "nopush"); @@ -2030,7 +2044,7 @@ sub ParseFunctionPush($$) foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/in/,@{$e->{DIRECTION}})) { - $self->ParseElementPush($e, "ndr", $env, 1, 1); + $self->ParseElementPush($e, $ndr, $env, 1, 1); } } @@ -2043,12 +2057,12 @@ sub ParseFunctionPush($$) $env = GenerateFunctionOutEnv($fn); foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/out/,@{$e->{DIRECTION}})) { - $self->ParseElementPush($e, "ndr", $env, 1, 1); + $self->ParseElementPush($e, $ndr, $env, 1, 1); } } if ($fn->{RETURN_TYPE}) { - $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, r->out.result));"); + $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, r->out.result));"); } $self->deindent; @@ -2068,7 +2082,7 @@ sub AllocateArrayLevel($$$$$$) $pl->{TYPE} eq "POINTER" and $pl->{POINTER_TYPE} eq "ref" and not $l->{IS_ZERO_TERMINATED}) { - $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); + $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); $self->pidl("\tNDR_PULL_ALLOC_N($ndr, $var, $size);"); $self->pidl("}"); if (grep(/in/,@{$e->{DIRECTION}}) and @@ -2086,9 +2100,10 @@ sub AllocateArrayLevel($$$$$$) sub ParseFunctionPull($$) { my($self,$fn) = @_; + my $ndr = "ndr"; # pull function args - $self->fn_declare("pull", $fn, "enum ndr_err_code ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)") or return; + $self->fn_declare("pull", $fn, "enum ndr_err_code ndr_pull_$fn->{NAME}(struct ndr_pull *$ndr, int flags, struct $fn->{NAME} *r)") or return; $self->pidl("{"); $self->indent; @@ -2125,7 +2140,7 @@ sub ParseFunctionPull($$) foreach my $e (@{$fn->{ELEMENTS}}) { next unless (grep(/in/, @{$e->{DIRECTION}})); - $self->ParseElementPull($e, "ndr", $env, 1, 1); + $self->ParseElementPull($e, $ndr, $env, 1, 1); } # allocate the "simple" out ref variables. FIXME: Shouldn't this have it's @@ -2143,9 +2158,9 @@ sub ParseFunctionPull($$) if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") { my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, - "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), + "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"), check_fully_dereferenced($e, $env)); - $self->pidl("NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);"); + $self->pidl("NDR_PULL_ALLOC_N($ndr, r->out.$e->{NAME}, $size);"); if (grep(/in/, @{$e->{DIRECTION}})) { $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, ($size) * sizeof(*r->in.$e->{NAME}));"); @@ -2153,7 +2168,7 @@ sub ParseFunctionPull($$) $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));"); } } else { - $self->pidl("NDR_PULL_ALLOC(ndr, r->out.$e->{NAME});"); + $self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});"); if (grep(/in/, @{$e->{DIRECTION}})) { $self->pidl("*r->out.$e->{NAME} = *r->in.$e->{NAME};"); @@ -2173,11 +2188,11 @@ sub ParseFunctionPull($$) $env = GenerateFunctionOutEnv($fn); foreach my $e (@{$fn->{ELEMENTS}}) { next unless grep(/out/, @{$e->{DIRECTION}}); - $self->ParseElementPull($e, "ndr", $env, 1, 1); + $self->ParseElementPull($e, $ndr, $env, 1, 1); } if ($fn->{RETURN_TYPE}) { - $self->pidl("NDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, &r->out.result));"); + $self->pidl("NDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, &r->out.result));"); } $self->add_deferred(); @@ -2364,81 +2379,86 @@ sub HeaderInterface($$$) } -sub ParseTypePush($$$$$) +sub ParseTypePush($$$$$$) { - my ($self,$e,$varname, $primitives, $deferred) = @_; + my ($self,$e, $ndr, $varname, $primitives, $deferred) = @_; # save the old relative_base_offset - $self->pidl("uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);") if defined(has_property($e, "relative_base")); - $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($self, $e, $varname); + $self->pidl("uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base")); + $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($self, $e, $ndr, $varname); # restore the old relative_base_offset - $self->pidl("ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base")); + $self->pidl("ndr_push_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base")); } sub ParseTypePushFunction($$$) { my ($self, $e, $varname) = @_; + my $ndr = "ndr"; my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "push", $e->{NAME}, $varname); - $self->fn_declare("push", $e, "enum ndr_err_code ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *ndr, int ndr_flags, $args)") or return; + + $self->fn_declare("push", $e, "enum ndr_err_code ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *$ndr, int ndr_flags, $args)") or return; $self->pidl("{"); $self->indent; - $self->ParseTypePush($e, $varname, 1, 1); + $self->ParseTypePush($e, $ndr, $varname, 1, 1); $self->pidl("return NDR_ERR_SUCCESS;"); $self->deindent; $self->pidl("}"); $self->pidl("");; } -sub ParseTypePull($$$$$) +sub ParseTypePull($$$$$$) { - my ($self, $e, $varname, $primitives, $deferred) = @_; + my ($self, $e, $ndr, $varname, $primitives, $deferred) = @_; # save the old relative_base_offset - $self->pidl("uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr);") if defined(has_property($e, "relative_base")); - $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($self, $e, $varname); + $self->pidl("uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base")); + $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($self, $e, $ndr, $varname); # restore the old relative_base_offset - $self->pidl("ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base")); + $self->pidl("ndr_pull_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base")); } sub ParseTypePullFunction($$) { my ($self, $e, $varname) = @_; + my $ndr = "ndr"; my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "pull", $e->{NAME}, $varname); - $self->fn_declare("pull", $e, "enum ndr_err_code ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *ndr, int ndr_flags, $args)") or return; + $self->fn_declare("pull", $e, "enum ndr_err_code ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *$ndr, int ndr_flags, $args)") or return; $self->pidl("{"); $self->indent; - $self->ParseTypePull($e, $varname, 1, 1); + $self->ParseTypePull($e, $ndr, $varname, 1, 1); $self->pidl("return NDR_ERR_SUCCESS;"); $self->deindent; $self->pidl("}"); $self->pidl(""); } -sub ParseTypePrint($$$) +sub ParseTypePrint($$$$) { - my ($self, $e, $varname) = @_; + my ($self, $e, $ndr, $varname) = @_; - $typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($self, $e, $e->{NAME}, $varname); + $typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($self, $e, $ndr, $e->{NAME}, $varname); } sub ParseTypePrintFunction($$$) { my ($self, $e, $varname) = @_; + my $ndr = "ndr"; + my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "print", $e->{NAME}, $varname); $self->pidl_hdr("void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args);"); return if (has_property($e, "noprint")); - $self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args)"); + $self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *$ndr, const char *name, $args)"); $self->pidl("{"); $self->indent; - $self->ParseTypePrint($e, $varname); + $self->ParseTypePrint($e, $ndr, $varname); $self->deindent; $self->pidl("}"); $self->pidl(""); diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 114ca01cfa..cdfe0514f1 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -220,7 +220,7 @@ $generator->ParseStructPush({ TYPE => "STRUCT", PROPERTIES => {}, ALIGN => 4, - ELEMENTS => [ ]}, "x"); + ELEMENTS => [ ]}, "ndr", "x"); is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); } @@ -243,7 +243,7 @@ $generator->ParseStructPush({ PROPERTIES => {}, ALIGN => 4, SURROUNDING_ELEMENT => $e, - ELEMENTS => [ $e ]}, "x"); + ELEMENTS => [ $e ]}, "ndr", "x"); is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); NDR_CHECK(ndr_push_align(ndr, 4)); @@ -262,20 +262,23 @@ is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_ST $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => { noprint => 1}, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, ""); $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => {}, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, "ndr_print_rt(ndr, \"x\", &var);\n"); # make sure that a print function for an element with value() set works $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32", PROPERTIES => { value => "23" }, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); $generator = new Parse::Pidl::Samba4::NDR::Parser(); diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 2739081246..e9346f9605 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -747,9 +747,10 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) if (ret == true && *r.out.level == 1) { out_level = 1; ctr1 = &r.out.ctr.ctr1; - } else if (ret == true && *r.out.level == 2) { + } else if (ret == true && *r.out.level == 2 && + r.out.ctr.ctr2.mszip1.ts) { out_level = 1; - ctr1 = r.out.ctr.ctr2.mszip1.ctr1; + ctr1 = &r.out.ctr.ctr2.mszip1.ts->ctr1; } if (out_level == 1) { @@ -770,14 +771,16 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) ctr6 = &r.out.ctr.ctr6; } else if (ret == true && *r.out.level == 7 && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { + && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP + && r.out.ctr.ctr7.ctr.mszip6.ts) { out_level = 6; - ctr6 = r.out.ctr.ctr7.ctr.mszip6.ctr6; + ctr6 = &r.out.ctr.ctr7.ctr.mszip6.ts->ctr6; } else if (ret == true && *r.out.level == 7 && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS) { + && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS + && r.out.ctr.ctr7.ctr.xpress6.ts) { out_level = 6; - ctr6 = r.out.ctr.ctr7.ctr.xpress6.ctr6; + ctr6 = &r.out.ctr.ctr7.ctr.xpress6.ts->ctr6; } if (out_level == 6) { |