op_pk_nfd_exists()
Abstract
Determines whether a packet contains a specified field.
Syntax
op_pk_nfd_exists (pkptr, fd_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_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
fd_name |
const char* |
name of the field-of-interest |
Return Type
OpT_Boolean
OPC_TRUE if the field is present in the packet; OPC_FALSE otherwise.
Example
/* variable declarations */
Packet *pkptr;
/* obtain an arriving packet */
pkptr = op_pk_get (0);
/* process the payload, if any */
if (op_pk_nfd_exists (pkptr, "payload"))
{
/* do something */
}
Details
If the specified packet is unformatted (in which case there are no named fields), a recoverable error is generated and the function returns OPC_DBL_UNDEF.
Purpose
Provides a mechanism to determine if a particular field is present in a packet.
Errors
- Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
- Program Abort: Packet pointer references unowned packet (<pk_id>).
- Recoverable Error: Packet (<pk_id>) is of a type that does not contain formatted fields.
Reference
- None.