op_pk_type()

摘要

确定指定数据包的类型。

语法

op_pk_type (pk_ptr)
参数 类型 说明
pk_ptr Packet* 指向目标数据包的指针

返回类型

int

指示数据包是已格式化(OPC_PACKET_TYPE_FORMATTED)、未格式化(OPC_PACKET_TYPE_UNFORMATTED)还是值向量(OPC_PACKET_TYPE_VVEC)的常量。

示例

/* Access a value vector representation from a packet that */
/* might be an SAR segment, an opnet field packet, or an */
/* opnet value vector packet. */
if (op_sar_pk_is_segment (pkptr))
	{
	/* Access the value vector in this SAR segment. */
	/* This value vector will be a duplicate of the */
	/* contents of the SAR segment. */
	op_pk_vvec_get (pkptr, &sar_vvec);
	}
else
	{
	/* This packet is not a SAR segment, and therefore */
	/* either contains fields, or contains a value vector. */
	if (op_pk_type (pkptr) == OPC_PACKET_TYPE_VVEC)
		{
		/* Access the value vector in this packet */
		...
		}
	else
		{
		/* This packet contains fields. */
		/* Convert the packet to its value vector form */
		...
		}
	}

详情

已格式化数据包包含在仿真之前通过 Packet Editor 定义的字段。未格式化数据包的字段在仿真期间动态指定。值向量数据包不包含指定的字段,而是包含一个值向量。

**注意:**如果传递给 op_pk_type() 的数据包是一个 Sar 分段,则该内核过程将其识别为未格式化数据包,除非该分段已被转换为值向量数据包,此时该内核过程将其识别为值向量数据包。

用途

提供一种识别数据包类型的机制。

错误

  • 程序中止:段违例。(由于无效或格式错误的数据包)
  • 程序中止:数据包指针为 NIL。
  • 程序中止:数据包指针指向已销毁的数据包。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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