op_hla_interaction_pk_struct_get()

Note: Requires High-Level Architecture functionality

Abstract

Extracts a data block from a packet field name.

Syntax

op_hla_interaction_pk_struct_get (pk_ptr, field_name, data_ptr, size_ptr)
Argument Type Description
pk_ptr Packet * Packet representing an incoming interaction
field_name const char * Field name where data will be retrieved
data_ptr char * * Pointer to variable to receive data block from field
size_ptr size_t * Pointer to variable to receive size of data block, in bytes

Return Type

Compcode

Completion code indicating success or failure in getting the data. The procedure returns OPC_COMPCODE_SUCCESS if the data was successfully retrieved. It returns OPC_COMPCODE_FAILURE if it could not retrieve the data.

Example

pk = op_pk_get (REQUEST_STRM);
op_pk_nfd_get (pk, "number ids", &num_ids);

if (num_ids != 0)
	{
	int data_size;
	int * data;
	int i;

	op_hla_interaction_pk_struct_get (pk, "ids", &data, &data_size);

for (i = 0; i < num_ids; i++)
	{
	if (data [i] == my_id)
		{
		. . .

Details

RTI interactions have fields of either a simple type (short, long, double) or an arbitrary block of data that will need to be encoded by the sender and interpreted by the recipient of the interaction. Because the actual size of the data is not known beforehand, this KP allocates an appropriate block of memory (whose address is returned in data_ptr and whose size is set in size_ptr). The KP caller is responsible for freeing the allocated block of memory using op_prg_mem_free().

Purpose

Provides a mechanism to obtain a generic data block extracted from a packet representing an interaction.

Errors

  • Recoverable Error: Unable to get field (<field_name>) of interaction packet.

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com