op_pk_format()

Abstract

Obtains the name of the packet format associated with the specified packet.

Syntax

op_pk_format (pkptr, fmt_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(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and `op_subq_pk_remove().]
fmt_name char* name of the packet’s format (filled in by this KP)
[This value should be a statically declared character array, or a character pointer which points to dynamically allocated memory; either way, it must point to a string large enough to hold the format name for the specified packet. If the specified packet is unformatted, the string is set to “NONE”.]

Return Type

void

No return value.

Example

/* obtain the arriving packet */
pkptr = op_pk_get (INPUT_STRM);

/* determine the format of the packet */
op_pk_format (pkptr, pk_format);

/* print out a debug statement */
printf ("processing packet with format [%s]\n", pk_format);

/* store the packet in the second subqueue */
op_subq_pk_insert (1, pkptr, OPC_QPOS_TAIL);

Details

Formatted packets can be created via the KP op_pk_create_fmt(). At creation, a format is specified that sets the internal structure of the created packet. Packet formats can be defined in a mode of the Packet Format Editor, or through an Ema program. Formats consist of a list of named packet fields, each of which has a specified type, a size (in terms of bits), and a default value which can be set or unset upon packet creation.

Every formatted packet has an associated format. Both unformatted and formatted packets can be passed to this KP, but only formatted packets will produce meaningful results; unformatted packets cause the string “NONE” to be assigned to the passed character pointer.

Purpose

Provides a mechanism for determining the name of a packet’s format. This can be useful information for performing branches in process logic which are conditional on the type of packet being processed. Debug statements that show the formats of arriving packets are also useful, as in the example on the previous page.

Errors

  • Program Abort: Segmentation violation. (due to an invalid packet pointer, malformed packet or invalid fmt_name argument)
  • Program Abort: Packet pointer is NIL.
  • Program Abort: Packet pointer references destroyed packet.

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