op_pk_nfd_size_set()
Abstract
Sets the size of a named field.
Syntax
op_pk_nfd_size_set (pkptr, fd_name, size)
| 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 |
size |
OpT_Packet_Size |
size to set for the field, in bits |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the field size is set successfully; OPC_COMPCODE_FAILURE otherwise.
Example
/* obtain an arriving packet */
pkptr = op_pk_get (0);
/* adjust size of the data field, if necessary */
data_size = op_pk_nfd_size (pkptr, "data fd");
new_data_size = sizeof (new_data) * 8;
if (data_size < new_data_size)
op_pk_nfd_size_set (pkptr, "data fd", new_data_size);
/* put new data in field */
op_pk_nfd_set (pkptr, "data fd", new_data);
Details
None.
Purpose
Provides a mechanism to set the size of a named field.
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.
- Recoverable Error: No field named (<fd_name>) in packet (<pk_id>).
Reference
- Use the KP
op_pk_nfd_size()to determine the current size of a named field