op_pk_nfd_set_info()

Abstract

Assigns the value of an information field in the specified packet; the field-of-interest is specified by name.

Syntax

op_pk_nfd_set_info (pkptr, fd_name)
Argument Type Description
pkptr Packet* pointer to the packet-of-interest
[A pointer to a packet can be obtained from many KPs, including op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().]
fd_name const char* name of the field-of-interest
[This name must be a defined field within the packet's format, or an error will occur.]

Return Type

Compcode

OPC_COMPCODE_SUCCESS if the value of the field could be set; OPC_COMPCODE_FAILURE otherwise.

Example

/* create a formatted packet */
f_pkptr = op_pk_create_fmt ("info_pkt");

/* assign an integer code to the packet */
op_pk_nfd_set (f_pkptr, "fd_type", DATA_XFER);

/* set the information field in the packet */
op_pk_nfd_set_info (f_pkptr, "fd_data");

/* send the defined packet out of the processor */
op_pk_send (f_pkptr, OUTSTRM);

Details

The actual values of the data modeled by the field are not relevant to the simulation, so only the size of the field is stored in the packet. This KP performs only the function of setting information fields within formatted packets, because the size of these fields is automatically predefined in the format. Changing the size of information fields in formatted packets cannot be performed by a direct KP call, but it can be achieved by the following process:

  1. Obtain a field index using the KP op_pk_name_to_index() or op_pk_nfd_name_to_index().
  2. Set the size of the information field using the KP op_pk_fd_set().

Getting the value of an information field via the KP op_pk_nfd_get() does not have a valid purpose; instead of causing an error, however, the string “unspecified” is copied into the passed value pointer.

Purpose

Provides a way to set the value of an information field within a packet. Because the packet is formatted, only the value of the field needs to be specified; the size of the information field is automatically looked up in the format. This KP should only be applied to formatted packets; otherwise, an error will occur

Errors

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