op_pk_nfd_set_pkt()

Abstract

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

Syntax

op_pk_nfd_set_pkt (pkptr, fd_name, value)
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.]
value Packet* value to be assigned to the field

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 ("example_pkt");

/* encapsulate a higher-level packet in the packet */
enc_pkptr = op_pk_create (24);
op_pk_nfd_set_pkt (f_pkptr, "fd_packet", enc_pkptr);

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

Details

If the specified field has not been set before, the size of the new field is determined from the packet's format and added to the total size of the packet.

Packets that are assigned to fields are "encapsulated" within the packet being operated on by this KP, and the invoking process loses ownership of the encapsulated packet. These encapsulated packets are not accessible until they are decapsulated by op_pk_fd_get_pkt() (or optionally op_pk_nfd_get_pkt(), if the packet is formatted).

Fields of type packet use a special technique for dynamic size determination. When this type of field is defined in a packet format using the Packet Format Editor, field size is specified in one of the data table columns. If the specified size of the field is set to "inherited", the size of the field will track the size of the encapsulated packet, thus accurately modeling the aggregate packet size. If the size of such a field is specified in the table as zero or positive, it overrides the size of any encapsulated packet, thus supporting the modeling of data compression.

Purpose

Provides a way to set the value of a packet field within a packet. Because the packet is formatted, only the value of the field needs to be specified; the type and size of the field are automatically obtained from 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