示例#1
0
static enum ndr_err_code ndr_push_frsapi_ForceReplication(struct ndr_push *ndr, int flags, const struct frsapi_ForceReplication *r)
{
	if (flags & NDR_IN) {
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.replica_set_guid));
		if (r->in.replica_set_guid) {
			NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.replica_set_guid));
		}
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.connection_guid));
		if (r->in.connection_guid) {
			NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.connection_guid));
		}
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.replica_set_name));
		if (r->in.replica_set_name) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.replica_set_name, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.replica_set_name, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.replica_set_name, ndr_charset_length(r->in.replica_set_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.partner_dns_name));
		if (r->in.partner_dns_name) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.partner_dns_name, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.partner_dns_name, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.partner_dns_name, ndr_charset_length(r->in.partner_dns_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
	}
	if (flags & NDR_OUT) {
		NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));
	}
	return NDR_ERR_SUCCESS;
}
示例#2
0
static enum ndr_err_code ndr_push_security_ace_object_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_type *r)
{
	if (ndr_flags & NDR_SCALARS) {
		int level = ndr_push_get_switch_value(ndr, r);
		NDR_CHECK(ndr_push_union_align(ndr, 4));
		switch (level) {
			case SEC_ACE_OBJECT_TYPE_PRESENT: {
				NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->type));
			break; }

			default: {
			break; }

		}
	}
	if (ndr_flags & NDR_BUFFERS) {
		int level = ndr_push_get_switch_value(ndr, r);
		switch (level) {
			case SEC_ACE_OBJECT_TYPE_PRESENT:
			break;

			default:
			break;

		}
	}
	return NDR_ERR_SUCCESS;
}
示例#3
0
static enum ndr_err_code ndr_push_frsapi_IsPathReplicated(struct ndr_push *ndr, int flags, const struct frsapi_IsPathReplicated *r)
{
	if (flags & NDR_IN) {
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.path));
		if (r->in.path) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.path, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.path, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.path, ndr_charset_length(r->in.path, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
		NDR_CHECK(ndr_push_frsapi_ReplicaSetType(ndr, NDR_SCALARS, r->in.replica_set_type));
	}
	if (flags & NDR_OUT) {
		if (r->out.replicated == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.replicated));
		if (r->out.primary == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.primary));
		if (r->out.root == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.root));
		if (r->out.replica_set_guid == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->out.replica_set_guid));
		NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));
	}
	return NDR_ERR_SUCCESS;
}
static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
{
	DATA_BLOB blob;
	enum ndr_err_code ndr_err;
	struct ndr_push *ndr;

	ndr = ndr_push_init_ctx(mem_ctx);
	if (ndr == NULL) {
		return data_blob_null;
	}

	ndr->flags |= LIBNDR_FLAG_NOALIGN;

	ndr_err = ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
		return data_blob_null;
	}
	ndr_err = ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);
	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
		return data_blob_null;
	}

	blob = ndr_push_blob(ndr);
	talloc_steal(mem_ctx, blob.data);
	talloc_free(ndr);
	return blob;
}
示例#5
0
static enum ndr_err_code ndr_push_frsapi_Info(struct ndr_push *ndr, int ndr_flags, const struct frsapi_Info *r)
{
	if (ndr_flags & NDR_SCALARS) {
		NDR_CHECK(ndr_push_align(ndr, 4));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length));
		NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->guid));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length2));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1));
		NDR_CHECK(ndr_push_frsapi_InfoEnum(ndr, NDR_SCALARS, r->level));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->query_counter));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->offset));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->blob_len));
		{
			uint32_t _flags_save_DATA_BLOB = ndr->flags;
			ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
			{
				struct ndr_push *_ndr_blob;
				NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_blob, 0, r->length - r->offset));
				NDR_CHECK(ndr_push_DATA_BLOB(_ndr_blob, NDR_SCALARS, r->blob));
				NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_blob, 0, r->length - r->offset));
			}
			ndr->flags = _flags_save_DATA_BLOB;
		}
		NDR_CHECK(ndr_push_trailer_align(ndr, 4));
	}
	if (ndr_flags & NDR_BUFFERS) {
	}
	return NDR_ERR_SUCCESS;
}
示例#6
0
static enum ndr_err_code ndr_push_dssetup_DsRolePrimaryDomInfoBasic(struct ndr_push *ndr, int ndr_flags, const struct dssetup_DsRolePrimaryDomInfoBasic *r)
{
	if (ndr_flags & NDR_SCALARS) {
		NDR_CHECK(ndr_push_align(ndr, 5));
		NDR_CHECK(ndr_push_dssetup_DsRole(ndr, NDR_SCALARS, r->role));
		NDR_CHECK(ndr_push_dssetup_DsRoleFlags(ndr, NDR_SCALARS, r->flags));
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->domain));
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->dns_domain));
		NDR_CHECK(ndr_push_unique_ptr(ndr, r->forest));
		NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_guid));
		NDR_CHECK(ndr_push_trailer_align(ndr, 5));
	}
	if (ndr_flags & NDR_BUFFERS) {
		if (r->domain) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->domain, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->domain, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->domain, ndr_charset_length(r->domain, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
		if (r->dns_domain) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->dns_domain, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->dns_domain, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->dns_domain, ndr_charset_length(r->dns_domain, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
		if (r->forest) {
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->forest, CH_UTF16)));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
			NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->forest, CH_UTF16)));
			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->forest, ndr_charset_length(r->forest, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		}
	}
	return NDR_ERR_SUCCESS;
}
示例#7
0
static NTSTATUS ndr_push_security_ace_object_inherited_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_inherited_type *r)
{
    int level;
    level = ndr_push_get_switch_value(ndr, r);
    if (ndr_flags & NDR_SCALARS) {
        switch (level) {
        case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
            NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->inherited_type));
            break;

        default:
            break;

        }
    }
    if (ndr_flags & NDR_BUFFERS) {
        switch (level) {
        case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
            break;

        default:
            break;

        }
    }
    return NT_STATUS_OK;
}
示例#8
0
/* Manually modified to only push some parts of the structure if certain flags are set */
enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r)
{
    {
        uint32_t _flags_save_STRUCT = ndr->flags;
        ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
        if (ndr_flags & NDR_SCALARS) {
            NDR_CHECK(ndr_push_align(ndr, 4));
            NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command));
            NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz));
            NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
            NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain_name));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
            NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
            if (r->nt_version & NETLOGON_NT_VERSION_5EX_WITH_IP) {
                NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
                {
                    struct ndr_push *_ndr_sockaddr;
                    NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
                    NDR_CHECK(ndr_push_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr));
                    NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
                }
            }
            if (r->nt_version & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) {
                NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site));
            }
            NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version));
            NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
            NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
        }
        if (ndr_flags & NDR_BUFFERS) {
            NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_uuid));
        }
        ndr->flags = _flags_save_STRUCT;
    }
    return NDR_ERR_SUCCESS;
}
示例#9
0
static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct dcerpc_syntax_id *syntax)
{
	struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx);

	ndr->flags |= LIBNDR_FLAG_NOALIGN;

	ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
	ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);

	return ndr_push_blob(ndr);
}
示例#10
0
文件: ndr_misc.c 项目: gojdic/samba
_PUBLIC_ enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r)
{
    if (ndr_flags & NDR_SCALARS) {
        NDR_CHECK(ndr_push_align(ndr, 4));
        NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->handle_type));
        NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->uuid));
    }
    if (ndr_flags & NDR_BUFFERS) {
    }
    return NDR_ERR_SUCCESS;
}
示例#11
0
文件: ndr_misc.c 项目: gojdic/samba
_PUBLIC_ enum ndr_err_code ndr_push_ndr_syntax_id(struct ndr_push *ndr, int ndr_flags, const struct ndr_syntax_id *r)
{
    if (ndr_flags & NDR_SCALARS) {
        NDR_CHECK(ndr_push_align(ndr, 4));
        NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->uuid));
        NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->if_version));
    }
    if (ndr_flags & NDR_BUFFERS) {
    }
    return NDR_ERR_SUCCESS;
}
示例#12
0
NTSTATUS ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r)
{
    if (ndr_flags & NDR_SCALARS) {
        NDR_CHECK(ndr_push_align(ndr, 4));
        NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->handle_type));
        NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->uuid));
    }
    if (ndr_flags & NDR_BUFFERS) {
    }
    return NT_STATUS_OK;
}
示例#13
0
static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
{
	DATA_BLOB blob;
	struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL);

	ndr->flags |= LIBNDR_FLAG_NOALIGN;

	ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
	ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);

	blob = ndr_push_blob(ndr);
	talloc_steal(mem_ctx, blob.data);
	talloc_free(ndr);
	return blob;
}
示例#14
0
/**
   \details Build an EntryID for message from folder and message source ID

 */
_PUBLIC_ enum MAPISTATUS EntryIDFromSourceIDForMessage(TALLOC_CTX *mem_ctx,
						       mapi_object_t *obj_store,
						       mapi_object_t *obj_folder,
						       mapi_object_t *obj_message,
						       struct SBinary_short *entryID)
{
	enum MAPISTATUS			retval;
	struct ndr_push			*ndr;
	mapi_object_store_t		*store;
	const struct SBinary_short	*FolderSourceKey;
	const struct SBinary_short	*MessageSourceKey;
	struct SPropTagArray		*SPropTagArray;
	struct SPropValue		*lpPropsf;
	struct SPropValue		*lpPropsm;
	uint32_t			count;

	/* Sanity checks */
	OPENCHANGE_RETVAL_IF(!obj_store, MAPI_E_INVALID_PARAMETER, NULL);
	OPENCHANGE_RETVAL_IF(!obj_folder, MAPI_E_INVALID_PARAMETER, NULL);
	OPENCHANGE_RETVAL_IF(!obj_message, MAPI_E_INVALID_PARAMETER, NULL);
	OPENCHANGE_RETVAL_IF(!entryID, MAPI_E_INVALID_PARAMETER, NULL);

	store = (mapi_object_store_t *)obj_store->private_data;

	/* Step 1. Retrieve folder Source Key */
	SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PidTagSourceKey);
	retval = GetProps(obj_folder, 0, SPropTagArray, &lpPropsf, &count);
	MAPIFreeBuffer(SPropTagArray);
	if (retval != MAPI_E_SUCCESS) return MAPI_E_NOT_FOUND;
	FolderSourceKey = (const struct SBinary_short *)get_SPropValue(lpPropsf, PidTagSourceKey);
	if (FolderSourceKey == NULL) return MAPI_E_NOT_FOUND;

	/* Step 2. Retrieve message Source Key */
	SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PidTagSourceKey);
	retval = GetProps(obj_message, 0, SPropTagArray, &lpPropsm, &count);
	MAPIFreeBuffer(SPropTagArray);
	if (retval != MAPI_E_SUCCESS) return MAPI_E_NOT_FOUND;
	MessageSourceKey = (const struct SBinary_short *)get_SPropValue(lpPropsm, PidTagSourceKey);
	if (MessageSourceKey == NULL) return MAPI_E_NOT_FOUND;

	/* Step 3. Fill PidTagEntryID */
	/* PidTagEntryId size for message is 70 bytes */
	/* Flags (4 bytes) + store guid (16 bytes) + object type (2
	 * bytes) + Folder SourceKey (22 bytes) + Pad (2 bytes) +
	 * Message Source (22 bytes) + Pad (2 bytes) == 70 bytes */
	ndr = ndr_push_init_ctx(NULL);
	ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
	ndr->offset = 0;

	ndr_push_uint32(ndr, NDR_SCALARS, 0x0);
	if (store->store_type == PublicFolder) {
		const uint8_t	ProviderUID[16] = { 0x1A, 0x44, 0x73, 0x90, 0xAA, 0x66, 0x11, 0xCD, 0x9B, 0xC8, 0x00, 0xAA, 0x00, 0x2F, 0xC4, 0x5A };

		ndr_push_array_uint8(ndr, NDR_SCALARS, ProviderUID, 16);
		ndr_push_uint16(ndr, NDR_SCALARS, 0x0009);
	} else {
		ndr_push_GUID(ndr, NDR_SCALARS, &store->guid);
		ndr_push_uint16(ndr, NDR_SCALARS, 0x0007);
	}
	ndr_push_array_uint8(ndr, NDR_SCALARS, FolderSourceKey->lpb, FolderSourceKey->cb);
	ndr_push_uint16(ndr, NDR_SCALARS, 0x0);
	ndr_push_array_uint8(ndr, NDR_SCALARS, MessageSourceKey->lpb, MessageSourceKey->cb);
	ndr_push_uint16(ndr, NDR_SCALARS, 0x0);

	entryID->cb = ndr->offset;
	entryID->lpb = talloc_steal(mem_ctx, ndr->data);

	talloc_free(ndr);

	return MAPI_E_SUCCESS;
}
示例#15
0
static enum ndr_err_code ndr_push_RemoteActivation(struct ndr_push *ndr, int flags, const struct RemoteActivation *r)
{
	uint32_t cntr_pIIDs_1;
	uint32_t cntr_protseq_0;
	uint32_t cntr_ifaces_0;
	uint32_t cntr_results_0;
	if (flags & NDR_IN) {
		NDR_CHECK(ndr_push_ORPCTHIS(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.this_object));
		NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->in.Clsid));
		if (r->in.pwszObjectName == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.pwszObjectName, CH_UTF16)));
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.pwszObjectName, CH_UTF16)));
		NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.pwszObjectName, ndr_charset_length(r->in.pwszObjectName, CH_UTF16), sizeof(uint16_t), CH_UTF16));
		if (r->in.pObjectStorage == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_MInterfacePointer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.pObjectStorage));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ClientImpLevel));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.Mode));
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.Interfaces));
		if (r->in.pIIDs == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.Interfaces));
		for (cntr_pIIDs_1 = 0; cntr_pIIDs_1 < r->in.Interfaces; cntr_pIIDs_1++) {
			NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->in.pIIDs[cntr_pIIDs_1]));
		}
		NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.num_protseqs));
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.num_protseqs));
		for (cntr_protseq_0 = 0; cntr_protseq_0 < r->in.num_protseqs; cntr_protseq_0++) {
			NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.protseq[cntr_protseq_0]));
		}
	}
	if (flags & NDR_OUT) {
		if (r->out.that == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_ORPCTHAT(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.that));
		if (r->out.pOxid == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, *r->out.pOxid));
		if (r->out.pdsaOxidBindings == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_DUALSTRINGARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.pdsaOxidBindings));
		if (r->out.ipidRemUnknown == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->out.ipidRemUnknown));
		if (r->out.AuthnHint == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.AuthnHint));
		if (r->out.ServerVersion == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_COMVERSION(ndr, NDR_SCALARS, r->out.ServerVersion));
		if (r->out.hr == NULL) {
			return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
		}
		NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, *r->out.hr));
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.Interfaces));
		for (cntr_ifaces_0 = 0; cntr_ifaces_0 < r->in.Interfaces; cntr_ifaces_0++) {
			if (r->out.ifaces[cntr_ifaces_0] == NULL) {
				return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
			}
		}
		for (cntr_ifaces_0 = 0; cntr_ifaces_0 < r->in.Interfaces; cntr_ifaces_0++) {
			NDR_CHECK(ndr_push_MInterfacePointer(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.ifaces[cntr_ifaces_0]));
		}
		NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.Interfaces));
		for (cntr_results_0 = 0; cntr_results_0 < r->in.Interfaces; cntr_results_0++) {
			NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.results[cntr_results_0]));
		}
		NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));
	}
	return NDR_ERR_SUCCESS;
}
示例#16
0
/**
   \details Add a property value to a DATA blob. This convenient
   function should be used when creating a GetPropertiesSpecific reply
   response blob.

   \param mem_ctx pointer to the memory context
   \param property the property tag which value is meant to be
   appended to the blob
   \param value generic pointer on the property value
   \param blob the data blob the function uses to return the blob
   \param layout whether values should be prefixed by a layout
   \param flagged define if the properties are flagged or not

   \note blob.length must be set to 0 before this function is called
   the first time. Also the function only supports a limited set of
   property types at the moment.

   \return 0 on success;
 */
_PUBLIC_ int libmapiserver_push_property(TALLOC_CTX *mem_ctx,
					 uint32_t property, 
					 const void *value, 
					 DATA_BLOB *blob,
					 uint8_t layout, 
					 uint8_t flagged,
					 uint8_t untyped)
{
	struct ndr_push		*ndr;
        struct SBinary_short    bin;
        struct BinaryArray_r    *bin_array;
	uint32_t		i;
	
	ndr = ndr_push_init_ctx(mem_ctx);
	ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
	ndr->offset = 0;
	if (blob->length) {
		talloc_free(ndr->data);
		ndr->data = blob->data;
		ndr->offset = blob->length;
	}

	/* Step 1. Is the property typed */
	if (untyped) {
		ndr_push_uint16(ndr, NDR_SCALARS, property & 0xFFFF);
	}



	/* Step 2. Is the property flagged */
	if (flagged) {
		switch (property & 0xFFFF) {
		case PT_ERROR:
			switch (layout) {
			case 0x1:
				ndr_push_uint8(ndr, NDR_SCALARS, layout);
				goto end;
			case PT_ERROR:
				ndr_push_uint8(ndr, NDR_SCALARS, PT_ERROR);
				break;
			}
			break;
		default:
			ndr_push_uint8(ndr, NDR_SCALARS, 0x0);
			break;
		}
	} else {
		/* Step 3. Set the layout */
		if (layout) {
			switch (property & 0xFFFF) {
			case PT_ERROR:
				ndr_push_uint8(ndr, NDR_SCALARS, PT_ERROR);
				break;
			default:
				ndr_push_uint8(ndr, NDR_SCALARS, 0x0);
			}
		}
	}

	/* Step 3. Push property data if supported */
	switch (property & 0xFFFF) {
	case PT_I2:
		ndr_push_uint16(ndr, NDR_SCALARS, *(uint16_t *) value);
		break;
	case PT_LONG:
	case PT_ERROR:
	case PT_OBJECT:
		ndr_push_uint32(ndr, NDR_SCALARS, *(uint32_t *) value);
		break;
	case PT_DOUBLE:
		ndr_push_double(ndr, NDR_SCALARS, *(double *) value);
		break;
	case PT_I8:
		ndr_push_dlong(ndr, NDR_SCALARS, *(uint64_t *) value);
		break;
	case PT_BOOLEAN:
		ndr_push_uint8(ndr, NDR_SCALARS, *(uint8_t *) value);
		break;
	case PT_STRING8:
		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM|LIBNDR_FLAG_STR_ASCII);
		ndr_push_string(ndr, NDR_SCALARS, (char *) value);
		break;
	case PT_UNICODE:
		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
		ndr_push_string(ndr, NDR_SCALARS, (char *) value);
		break;
	case PT_BINARY:
	case PT_SVREID:
                /* PropertyRow expect a 16 bit header for BLOB in RopQueryRows and RopGetPropertiesSpecific */
		bin.cb = ((struct Binary_r *) value)->cb;
		bin.lpb = ((struct Binary_r *) value)->lpb;
		ndr_push_SBinary_short(ndr, NDR_SCALARS, &bin);
		break;
	case PT_CLSID:
		ndr_push_GUID(ndr, NDR_SCALARS, (struct GUID *) value);
		break;
	case PT_SYSTIME:
		ndr_push_FILETIME(ndr, NDR_SCALARS, (struct FILETIME *) value);
		break;

	case PT_MV_LONG:
		ndr_push_mapi_MV_LONG_STRUCT(ndr, NDR_SCALARS, (struct mapi_MV_LONG_STRUCT *) value);
		break;

	case PT_MV_UNICODE:
                ndr_push_mapi_SLPSTRArrayW(ndr, NDR_SCALARS, (struct mapi_SLPSTRArrayW *) value);
		break;

	case PT_MV_BINARY:
		bin_array = (struct BinaryArray_r *) value;
		ndr_push_uint32(ndr, NDR_SCALARS, bin_array->cValues);
		for (i = 0; i < bin_array->cValues; i++) {
			bin.cb = bin_array->lpbin[i].cb;
			bin.lpb = bin_array->lpbin[i].lpb;
			ndr_push_SBinary_short(ndr, NDR_SCALARS, &bin);
		}
		break;
	default:
		if (property != 0) {
			OC_DEBUG(5, "unsupported type: %.4x", (property & 0xffff));
			abort();
		}
		break;
	}
end:
	/* Step 4. Steal ndr context */
	blob->data = ndr->data;
	talloc_steal(mem_ctx, blob->data);
	blob->length = ndr->offset;

	talloc_free(ndr);
	return 0;
}