op_pk_convert_to_vvec()

Abstract

Converts a formatted packet to a value vector packet.

Syntax

op_pk_convert_to_vvec (pk_ptr)
Argument Type Description
pk_ptr Packet* pointer to a formatted packet
[The packet’s fields are converted to a value vector using the conversion method specified in the packet’s format.]

Return Type

Compcode

Completion code indicating whether the conversion completed successfully.

[This value can be compared to the two symbolic constants OPC_COMPCODE_SUCCESS and OPC_COMPCODE_FAILURE.]

Example

if (op_pk_type (pkptr) != OPC_PK_TYPE_VVEC)
	{
	/* Convert packet to value vector form */
	op_pk_convert_to_vvec (pkptr);
	}

/* Extract the value vector from the converted packet */
op_pk_vvec_get (pkptr, &pk_vvec);

/* The packet is no longer needed */
op_pk_destroy (pkptr);

/* Invoke child process to "clock" bits of value vector to external system... */

Details

This function converts a formatted packet into a value vector packet. The packet’s predefined fields are unaffected by the conversion.

WARNING: The packet conversion routine of a newly created packet format is set to “NONE”, which does nothing. Before calling this function, the required conversion routine must be set to either a user-supplied routine or one of the default routines provided with Riverbed Modeler (these are applicable only to a small subset of packet formats; see Chapter 5 “Packet Conversion” on page 29.

When called, this function creates a value vector and then calls the conversion method for the target packet’s format, passing it three arguments:

  • a pointer to the newly created value vector
  • a pointer to the target packet
  • the index of the position in the value vector that is to contain the first bit generated by the conversion function

Typically, the conversion method uses the contents of the target packet’s user-defined fields to insert values into the value vector and then returns success or failure to the KP. If it returns failure, the KP returns failure and the simulation terminates. If it returns success, the KP converts the target packet from a formatted packet to a value vector packet and sets the value vector in the packet.

The conversion method prototype is:

typedef int
default_convert_pk_to_vvec (Packet * pkptr, Vvec_Vector vvec,
	int pos)

This function must be in a .pfp.c file named to match the base part of the function name. For example, a function named my_convert_pk_to_vvec() should be defined in the file my_convert.pfp.c.

Note: It is possible to pass a Sar segment to op_pk_convert_to_vvec(). The Sar segment becomes a value vector packet. When queried with op_pk_type(), the converted packet is a value vector packet; when queried with op_sar_pk_is_segment(), the packet is a Sar segment.

Purpose

Provides a mechanism to convert a formatted packet to a value vector packet.

Errors

  • Program Abort: Packet pointer references unowned packet (<pk_id>).
  • Program Abort: Packet format (<packet_format>) does not support converison.
  • Program Abort: Conversion of packet ID (<pk_id>) from field form to value vector form failed.
  • Program Abort: Packet ID (<pk_id>) can not be converted.
  • Program Abort: Value vector is not owned by client.
  • Program Abort: Value vector is invalid.

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