op_pk_fd_set_int32()
Abstract
Assigns the type, value, and size of a 32-bit integer field in the specified packet; the field-of-interest is specified by a numeric index.
Syntax
op_pk_fd_set_int32 (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.] |
value |
int |
value to be assigned to the field |
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 (64);
/* assign integer fields in the packet */
op_pk_fd_set_int32 (uf_pkptr, 0, 2511, 16);
int64_value = 5 * 200000000000;
op_pk_fd_set_int64 (uf_pkptr, 1, int64_value, 16);
Details
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 a 32-bit integer 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() (integer, double, and packet field version).
Reference
- Same as op_pk_fd_set() (integer, double, and packet field version).