op_pk_nfd_size_set()

Abstract

Sets the size of a named field.

Syntax

op_pk_nfd_size_set (pkptr, fd_name, 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_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
size OpT_Packet_Size size to set for the field, in bits

Return Type

Compcode

OPC_COMPCODE_SUCCESS if the field size is set successfully; OPC_COMPCODE_FAILURE otherwise.

Example

/* obtain an arriving packet */
pkptr = op_pk_get (0);

/* adjust size of the data field, if necessary */
data_size = op_pk_nfd_size (pkptr, "data fd");
new_data_size = sizeof (new_data) * 8;
if (data_size < new_data_size)
	op_pk_nfd_size_set (pkptr, "data fd", new_data_size);

/* put new data in field */
op_pk_nfd_set (pkptr, "data fd", new_data);

Details

None.

Purpose

Provides a mechanism to set the size of a named field.

Errors

  • Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
  • Program Abort: Packet pointer references unowned packet (<pk_id>).
  • Recoverable Error: Packet (<pk_id>) is of a type that does not contain formatted fields.
  • Recoverable Error: No field named (<fd_name>) in packet (<pk_id>).

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