op_ici_attr_exists()

Abstract

Determines whether an attribute specified by name is defined within an ICI’s format.

Syntax

op_ici_attr_exists (iciptr, attr_name)
Argument Type Description
iciptr Ici * pointer to the ICI-of-interest
[A pointer to an ICI can be obtained from three KPs: op_ici_create() returns a pointer to a newly allocated ICI (in an ICI-sending process); op_intrpt_ici() returns a pointer to an ICI associated with an incoming interrupt (in an ICI-receiving process; and op_ev_ici() returns the ICI associated with a particular event.]
attr_name const char * name of the attribute-of-interest

Return Type

Boolean

Boolean value indicating if the specified attribute is present within the specified ICI. The constant OPC_FALSE will be returned if the attribute is not present or if a recoverable error occurs. The constant OPC_TRUE will be returned if the attribute does exist.

Example

Excerpt from: example model (models\std\fddi); process model (fddi_mac_v4); state (ENCAP); enter execs.

/* A frame has arrived from a higher layer. */
/* If in encap_decap mode, encapsulation is to be	*/
/* to be performed.  Place the frame in 'pdu_ptr'.	*/
if (encap_decap == OPC_TRUE)
	{
	pdu_ptr = op_pk_get (op_intrpt_strm ());
	if (pdu_ptr == OPC_NIL)
		{
		fddi_mac_error ("Unable to get packet from higher layer.", OPC_NIL, OPC_NIL);
		}
	/* Also get the interface control information	*/
	/* associated with the new frame.				*/
	ici_ptr = op_intrpt_ici ();
	if (ici_ptr == OPC_NIL)
		{
		fddi_mac_error ("Did not receive ICI with packet from higher layer.",
			OPC_NIL, OPC_NIL);
		}
	/* Extract the requested service class: synchronous or asynchronous. */
	if (op_ici_attr_exists (ici_ptr, "svc_class"))
		{
		if (op_ici_attr_get (ici_ptr, "svc_class", &svc_class) ==
			OPC_COMPCODE_FAILURE)
			{
			fddi_mac_error ("Unable to get service class field from ICI.",
				"The field does exist, but the get call failed.", OPC_NIL);
			}
		}
	else svc_class = FDDI_SVC_ASYNC;
. . .

Details

Unlike formatted packet fields, ICI attributes defined within an ICI format exist from the moment that the ICI is created, and always have an initial value. There is no notion of an ICI attribute being set or unset; therefore this KP has only to do with the existence of a particular attribute within an ICI’s format, rather than within an ICI instance.

Purpose

Attempting to set or get an ICI attribute will cause an error if the specified attribute name is not one of those defined in the ICI’s format. In order to avoid such errors and still support interfaces where several types of ICIs and possibly unknown ICI formats are used, process models need to be able to test for the existence of attributes before accessing them. The KP op_ici_attr_exists() provides this capability.

Errors

  • Program Abort: Segmentation violation. (due to an illegal ICI address, malformed ICI data structure, or malformed attr_name argument)
  • Recoverable Error: ICI pointer is NIL.

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