op_pk_convert_from_vvec()
Abstract
Converts a value vector packet to a formatted packet with a specified packet format.
Syntax
op_pk_convert_from_vvec (pk_ptr, format_name)
| Argument | Type | Description |
|---|---|---|
pk_ptr |
Packet* |
pointer to value vector packet to be converted [The value vector packet is converted to a formatted packet; all predefined fields and transmission data information remain unaffected.] |
format_name |
string |
name of an existing packet format [This is the packet format to which the value vector packet will be converted. The packet format must support conversion.] |
Return Type
Compcode
Completion code indicating whether the conversion completed successfully.
[This value can be compared to the two symbolic constants OPC_COMPCODE_SUCCESS and OPC_COMPCODE_FAILURE.]
Example

/* A value vector representing an entire packet has been */
/* completely received on an esys interface. */
/* Create a new opnet packet */
rcv_pkptr = op_pk_create_vvec ();
/* Set the value vector obtained from the esys interface into the packet */
op_pk_vvec_set (rcv_pkptr, rcv_vvec);
/* Transform, in place, the value vector form of the packet to */
/* the named field form of an "ethernet" packet. */
op_pk_convert_from_vvec (rcv_pkptr, "ethernet");
Details
This function converts a value vector packet into a formatted packet. The packet’s predefined fields are unaffected by the conversion, but the value vector that had been stored in the value vector packet is destroyed. When called, this function extracts the value vector from the target packet and then converts the packet into a formatted packet, with the user-defined fields containing values as if the formatted packet had just been created with op_pk_create_fmt().
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 for details.
The KP then calls the conversion method for the relevant packet format, passing it three arguments:
- a packet pointer
- the value vector that had been contained in the target packet
- the index of the position in the value vector containing the first bit of the packet
The conversion method typically uses the value vector to set the newly converted packet’s fields appropriately and then returns success or failure to the KP. If the conversion method returns failure, the KP also returns failure and the simulation is terminated. Finally, the KP deallocates the value vector initially extracted from the target packet.
The conversion method prototype is:
typedef int
default_convert_pk_from_vvec (Packet * pkptr, Vvec_Vector vvec,
int pos)
This function must be in a .pfp.c file named to match the base part of the function name. For example, a function named my_convert_pk_from_vvec() should be defined in the file my_convert.pfp.c.
Purpose
Provides a mechanism to convert a value vector packet to a formatted packet.
Errors
- Program Abort: Packet pointer references unowned packet (
<pk_id>). - Program Abort: Packet format (
<packet_format>) does not support converison. - Program Abort: Packet ID (
<pk_id>) can not be converted. (packet is unformatted) - Recoverable Error: Value vector is not owned by client.
- Recoverable Error: Value vector is invalid.
- Program Abort: Conversion of packet ID (
<pk_id>) from value vector form to field form failed.
Reference
- Use the KP op_pk_type() to determine the type of a packet
- Use the KP op_pk_vvec_is_set() to see if a value vector packet contains a value vector
- Use the KP op_pk_convert_to_vvec() to convert a formatted packet to a value vector packet
- Use the KP op_pk_fields_convert_from_vvec() to iterate through the fields of a packet, invoking their conversion methods