op_id_to_type()

摘要

获取指定对象的类型。

语法

op_id_to_type (objid)
参数 类型 说明
objid Objid 目标对象的对象 ID
[对象 ID 可以从本包中的其他几个内核过程获得:op_id_self()、op_id_from_userid() 和 op_id_from_name()。对象 ID 也可以通过 op_intrpt_source()、op_topo_assoc() 以及 Topo 包中的许多其他内核过程获得]

返回类型

int

指定对象的类型。

[该值是表示各种可能对象类型之一的整数代码;可与表 69 “Object Type Symbolic Constants“ 第 19 页中的常量进行比较。]

示例

/* determine the object ID of the surrounding node */
node_objid = op_topo_parent (op_id_self ());
/* determine the number of outgoing links (of any type) the node is connected to */
num_out_links = op_topo_assoc_count (node_objid, OPC_TOPO_ASSOC_OUT,
	OPC_OBJMTYPE_LINK);
/* loop through each outgoing link */
for (ol = 0; ol < num_out_links; ol++)
	{
	/* obtain object ID of outgoing link */
	ol_objid = op_topo_assoc (node_objid, OPC_TOPO_ASSOC_OUT, OPC_OBJMTYPE_LINK, ol);
	/* switch based on specific type of outgoing link */
	switch (op_id_to_type (ol_objid))
		{
		case OPC_OBJTYPE_LKBUS: /* ... */ break;

		case OPC_OBJTYPE_LKDUP: /* ... */ break;

		case OPC_OBJTYPE_LKSIMP: /* ... */ break;
		}

详情

无。

用途

提供一种根据对象 ID 确定对象类型的机制。当进程获得某个对象 ID 并需要确定该对象的类型以调整其处理方式时,通常需要这样做。当一个通用编写的进程试图使用 Topo 包中提供所在模块或节点输入/输出关联对象 ID 的内核过程来确定其本地互连拓扑时,通常就需要这种机制。

错误

  • 可恢复错误:对象 ID(<objid>)超出范围。
  • 可恢复错误:对象 ID(<objid>)指向受限对象。

参考

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