op_pk_fd_set_pkt()

Abstract

Assigns the type, value, and size of a packet field in the specified packet; the field-of-interest is specified by a numeric index.

Syntax

op_pk_fd_set_pkt (pkptr, field_index, value, field_size)
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(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().]
field_index int numeric index of the field-of-interest
[This value must be non-negative, or an error will occur.]
value Packet* value to be assigned to the field
field_size OpT_Int64 modeled size (in bits) of the field contents, or OPC_FIELD_SIZE_UNCHANGED (see Details)

Return Type

Compcode

OPC_COMPCODE_SUCCESS if the field could be set; OPC_COMPCODE_FAILURE otherwise.

Example

/* create an unformatted packet */
uf_pkptr = op_pk_create (64);

/* encapsulate a higher-level packet in the packet */
enc_pkptr = op_pk_create (24);
op_pk_fd_set_pkt (uf_pkptr, 4, enc_pkptr, OPC_FIELD_SIZE_UNCHANGED);

Details

If field_size is different from the previous size of the field, the total size of the packet will change accordingly. If field_size is specified as OPC_FIELD_SIZE_UNCHANGED, the size of the field will remain as defined in the packet.

Packets that are assigned to fields are encapsulated within the higher-level packet and the invoking process loses ownership of the encapsulated packet. Encapsulated packets are not accessible until they are decapsulated by op_pk_fd_get_pkt() (or by op_pk_nfd_get_pkt(), if the packet is formatted). If the specified size of a packet field is set to a negative value, the size of the field will be set to the size of the encapsulated packet, thus accurately modeling the aggregate packet size. If the specified size of a packet field is zero or positive, it overrides the size of the assigned packet, thus supporting the modeling of stripping or compression.

Purpose

Provides a way to set the value of a packet field within a packet. This KP is usually applied to unformatted packets, but it can be applied to formatted packets as well (formatted packet field names can be converted into numeric indices using the KPs op_pk_name_to_index() and op_pk_nfd_name_to_index()).

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