op_pk_fields_convert_from_vvec()

Abstract

Iterates through a formatted packet’s fields, calling each field’s conversion method.

Syntax

op_pk_fields_convert_from_vvec (pk_ptr, vvec, vvec_index)
Argument Type Description
pk_ptr Packet* pointer to a formatted packet
[Typically this formatted packet has just been converted to a given format from a value vector packet.]
vvec Vvec_vector value vector to use when setting the packet’s fields
[Typically this is a value vector contained in a value vector packet that is being converted to a formatted packet.]
vvec_index int index of the position in the value vector containing the packet’s first bit

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

/* A value vector representing an entire TCP packet has */
/* been compeletly received on an esys interface.        */

tcp_pkptr = op_pk_create_fmt ("tcp_seg");

/* Have each field's conversion-from-vvec method called */
/* to set values in the opnet TCP packet. */
op_pk_convert_fields_from_vvec (tcp_pkptr, vvec, 0);

/* The opnet TCP packet models the checksum field as    */
/* "information", but the value vector for this          */
/* packet contains a real checksum value.                */
/* Test the checksum value...                            */

Details

This function, typically called by a packet conversion method, uses a value vector to systematically set each field in a formatted packet based upon the contents of a value vector. It iterates through each field using the fields’ conversion order attributes to determine the order in which the fields are converted. When setting a field, the KP calls the conversion specified by the field’s conversion method attribute.

WARNING: The field conversion routines of a newly created packet format are set to “NONE”, which does nothing. Before calling this function, the required conversion routines 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.

op_pk_fields_convert_from_vvec() passes four arguments to the field conversion method:

  • a pointer to a packet
  • a field index
  • a value vector of type bit (Vvec_Vector)
  • an index for the position of the field in the value vector. The Simulation Kernel calculates this position using the bit sizes of the fields defined in the packet format.

Note: The Simulation Kernel may not always be able to calculate the exact position. In such cases, it passes OPC_FIELD_BIT_POSE_UNKNOWN to the conversion method.)

The conversion method prototype is:

typedef int
default_convert_field_from_vvec (Packet * pkptr, int fd_index,
	Vvec_Vector vvec, int pos)

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

Purpose

Provides a mechanism to iterate through a packet’s fields, calling their conversion methods.

Errors

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

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