op_pk_transfer_to_vvec()
Abstract
Creates a bit sequence based on the user-defined fields of a formatted packet and then places the bit sequence into a specified value vector.
Syntax
op_pk_transfer_to_vvec (pk_ptr, vvec, vvec_index)
| Argument | Type | Description |
|---|---|---|
pk_ptr |
Packet* |
pointer to a formatted packet [The packet’s fields are written to a value vector using the conversion method specified in the packet’s format.] |
vvec |
Vvec_Vector |
allocated value vector [This value vector receives the bit sequence generated by the conversion method. The value vector must already exist.] |
vvec_index |
int |
index number of position to receive first bit of bit sequence [The conversion method used by this KP generates a bit sequence based on the contents of the formatted packet’s user-defined fields. This argument specifies the position in the value vector at which to insert this bit sequence.] |
Return Type
Compcode
Completion code indicating whether the bit sequence was successfully placed in the value vector.
[This value can be compared to the two symbolic constants OPC_COMPCODE_SUCCESS and OPC_COMPCODE_FAILURE.]
Example
if (op_npk_field_type (pkptr, "payload") == OPC_FIELD_TYPE_PACKET)
{
/* Extract the encapsulated packet */
op_pk_nfd_get (pkptr, "payload", &encap_pkptr);
/* Have a bit representation of the encapsulated packet */
/* written into our value vector. */
op_pk_transfer_to_vvec (encap_pkptr, vvec, vvec_pos);
/* Install the encapsulated packet back into the original packet */
op_pk_nfd_set (pkptr, "payload", encap_pkptr);
}
Details
This function creates a bit representation of the contents of a formatted packet and places the resulting bit sequence in a value vector.
WARNING: The packet conversion routine of a newly created packet format is set to “NONE”, which does nothing. Before calling this function, the required conversion routine must be set to either a user-supplied routine or one of the default routines provided with Riverbed Modeler (these are applicable only to a small subset of packet formats; see Chapter 5 “Packet Conversion” on page 29).
When called, this function calls the conversion method for the target packet’s format, passing it three arguments:
- a pointer to a value vector of type bit (
Vvec_Vector) - a pointer to the target packet
- the index of the position in the value vector that is to contain the first bit generated by the conversion function
Typically, the conversion method uses the contents of the target packet’s user-defined fields to insert values into the value vector and then returns success or failure to the KP. The original packet is not affected by this KP.
Note: If a Sar segment is passed as an argument to op_pk_transfer_to_vvec() and the Sar segment is also a value vector packet, the value vector inside the packet is copied to the destination value vector. If the packet is a Sar segment but is not a value vector packet, a bit representation of the bit-range for the segment is transferred to the destination value vector.
Purpose
Provides a mechanism for creating a bit representation of the contents of a formatted packet and placing the resulting bit sequence in a value vector.
Errors
- Program Abort: Packet pointer references unowned packet (
<pk_id>). - Program Abort: Packet format (
<format_name>) does not support converison. - Program Abort: Packet ID (
<pk_id>) can not be converted. - Recoverable Error: Value vector is not owned by client
- Recoverable Error: Value vector is invalid.
Reference
- Use the KP op_pk_type() to determine the type of a packet
- Use the KP op_pk_vvec_set() to insert a value vector into a value vector packet
- Use the KP op_pk_convert_to_vvec() to convert a formatted packet to a value vector packet