op_pk_nfd_default()

Abstract

Obtains the default value of a field in the specified formatted packet; the field-of-interest is specified by name.

Syntax

op_pk_nfd_default (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 should be a defined field within the packet's format; however, no error will occur if it is not. Instead, the constant value OPC_DBL_UNDEF will be returned.]

Return Type

double

Default value of the specified field.

[Only integer and double fields can be assigned meaningful defaults in packet formats. This KP returns a double for both integer and double default values; the returned value can be cast into an integer if required. OPC_DBL_UNDEF is returned if an error occurs.]

Example

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

/* determine the default value of the opcode field */
def_opcode = (int) op_pk_nfd_default (pkptr, "opcode");

/* restore the default value to the opcode field */
op_pk_nfd_set (pkptr, "opcode", def_opcode);

Details

The Packet Format Editor allows the default value of a field to be specified before the type of the field is specified, so any type of field may be assigned a default value. However, the default values are only used in the case of integer and double fields.

If this KP is applied to an unformatted packet or any recoverable error occurs, the constant OPC_DBL_UNDEF will be returned.

Purpose

Provides a mechanism to determine the default value for a field in a formatted packet. This is useful if a process needs to reset the field to the default value, but does not have a priori knowledge of the default value.

Errors

  • Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
  • Program Abort: Packet pointer is NIL.
  • Program Abort: Packet pointer references destroyed packet.
  • Program Abort: Packet pointer references unowned packet (<pk_id>).
  • 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