Overall Packet Conversion (default_convert)
This section describes the functionality and limitations of the default overall packet conversion method. This method is named default_convert and is provided in source code form in the file default_convert.pfp.c, which resides in the <reldir>/models/std/base directory.
The default overall packet conversion method can be used to convert packets to and from value vector form whenever the overall packet format does not require any special processing.
The default overall packet conversion method most often will be called by the Kernel Procedures op_pk_convert_to_vvec() and op_pk_convert_from_vvec(). It can also be called directly, by calling the functions default_convert_pk_to_vvec() and default_convert_pk_from_vvec().
default_convert_pk_to_vvec()
Prototype
int
default_convert_pk_to_vvec (Packet * pkptr, Vvec_Vector vvec,
int pos)
Description
default_convert_pk_to_vvec() is passed a packet pointer, a value vector, and a value vector bit index. The bit index is a position into the value vector at which the conversion process should begin.
The packet conversion goes through the following steps:
- Checks for unformatted fields.
- Calls each field’s conversion method, as specified in the field’s Packet Conversion Method attribute. Uses the KP
op_pk_fields_convert_to_vvec(), which calls each field’s conversion method in turn. - Writes bits for the bulk size of the packet, based on the value of the Bulk Fill Pattern attribute for the packet format. If there is no Bulk Fill Pattern set, the value vector is filled with zeros.
default_convert_pk_from_vvec()
Prototype
int
default_convert_pk_from_vvec (Packet * pkptr, Vvec_Vector vvec,
int pos)
Description
default_convert_pk_from_vvec() is passed a packet pointer, a value vector, and a bit index.
The value vector conversion goes through the following steps:
- Checks to see if the value vector represents all fields defined in the packet pointer’s format.
- Calls each field’s conversion method, as specified in the field’s Packet Conversion Method attribute. Uses the KP
op_pk_fields_convert_from_vvec(), which calls each field’s conversion method in turn. - Determines if the vvec is longer than the packet, implying that the vvec was carrying some bulk size. If so, it sets the packet’s bulk size to the difference of the vvec’s total size and the packet’s total size, using the KP
op_pk_bulk_size_set().
Assumptions and Limitations
The default overall packet conversion method relies on certain assumptions. If these assumptions are not true, packet conversion will fail and the simulation will terminate. The following must be true:
- Packet must not contain unformatted fields.
- The value vector must completely represent all fields defined in the packet pointer’s format.
- All fields defined by the format must be set.