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_nameargument) - Recoverable Error: ICI pointer is NIL.
Reference
- Use the KP op_intrpt_ici() to obtain the ICI pointer associated with an incoming interrupt
- Use the KPs op_ici_attr_get_dbl(), op_ici_attr_get_int32(), op_ici_attr_get_int64(), and op_ici_attr_get_ptr() to obtain the value of an ICI attribute
- Use the KPs op_ici_attr_set_dbl(), op_ici_attr_set_int32(), op_ici_attr_set_int64(), and op_ici_attr_set_ptr() to modify the value of an ICI attribute