op_pk_fd_set_info()
Abstract
Assigns the type and size of an information field in the specified packet; the field-of-interest is specified by a numeric index.
Syntax
op_pk_fd_set_info (pkptr, field_index, value, field_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(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
field_index |
int |
numeric index of the field-of-interest [This value must be non-negative, or an error will occur.] |
field_size |
OpT_Int64 |
modeled size (in bits) of the field contents, or OPC_FIELD_SIZE_UNCHANGED (see Details) |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the field could be set; OPC_COMPCODE_FAILURE otherwise.
Example
/* create an unformatted packet */
uf_pkptr = op_pk_create (0);
/* assign an integer code to the packet */
op_pk_fd_set (uf_pkptr, FD_TYPE, OPC_FIELD_TYPE_INTEGER, DATA_XFER, 16);
/* assign an information field to the packet */
op_pk_fd_set_info (uf_pkptr, FD_DATA, 1500);
/* send the defined packet out of the processor */
op_pk_send (uf_pkptr, OUTSTRM);
Details
For information fields, only the size of the field needs to be specified, because the actual values of the data modeled by the field are irrelevant to the simulation. Getting the value of an information field via the KP op_pk_fd_get() does not have a valid purpose, but instead of causing an error, the string “unspecified” is copied into the passed value pointer.
If field_size is different from the previous size of the field, the total size of the packet will change accordingly. If field_size is specified as OPC_FIELD_SIZE_UNCHANGED, the size of the field will remain as defined in the packet.
Purpose
Provides a way to set the value of an information field within a packet. This KP is usually applied to unformatted packets, but it can be applied to formatted packets as well (formatted packet field names can be converted into numeric indices using the KPs op_pk_name_to_index() and op_pk_nfd_name_to_index()).
Errors
- Same as op_pk_fd_set() (information field version).
Reference
- Same as op_pk_fd_set() (information field version).