op_sar_bitrange_info_get()
Abstract
Obtains information about a bit-range, placing the number of the starting bit, the number of bits, the size of the original packet, or the packet’s label into a variable.
Syntax
op_sar_bitrange_info_get (bit_range, property, dest)
| Argument | Type | Description |
|---|---|---|
bit_range |
Sar_Bitrange* |
bit-range to query |
property |
int |
item of interest in the bit-range. See Details for possible values. |
dest |
int * or OpT_Sar_Size * |
variable that receives the value of the queried component |
Return Type
Compcode
Completion code indicating whether the property was successfully retrieved.
[This value can be compared to the two symbolic constants OPC_COMPCODE_SUCCESS and OPC_COMPCODE_FAILURE.]
Example
/* obtain the label associated with a bitrange and */
/* encode it as an integer value in an unused packet field. */
bitrange_ptr = (Sar_Bitrange *) op_prg_list_access (bitrange_list_ptr,
OPC_LISTPOS_HEAD);
op_sar_bitrange_info_get (bitrange_ptr, OPC_SAR_BITRANGE_PROPERTY_LABEL,
&label_value);
/* encode the label in packet field. */
op_pk_nfd_set (pkptr, "encoded label", label_value);
/* send packet down to lower layer. */
op_pk_send (pkptr, 0);
Details
A bit-range contains four properties that can be queried by this KP. The starting bit is the first bit’s position in the original packet. The number of bits in the bit-range, the original packet size, and the original packet label can also be retrieved.
The property argument can have the following values:
OPC_SAR_BITRANGE_PROPERTY_COUNT(destis int)OPC_SAR_BITRANGE_PROPERTY_COUNT_INT64(destis OpT_Int64)OPC_SAR_BITRANGE_PROPERTY_STARTBIT(destis int)OPC_SAR_BITRANGE_PROPERTY_STARTBIT_INT64(destis OpT_Int64)OPC_SAR_BITRANGE_PROPERTY_LABEL(destis int)OPC_SAR_BITRANGE_PROPERTY_LABEL_INT64(destis OpT_Int64)OPC_SAR_BITRANGE_PROPERTY_PKSIZE(destis int)OPC_SAR_BITRANGE_PROPERTY_PKSIZE_INT64(destis OpT_Int64)
Purpose
Provides a mechanism to retrieve information about a bit-range.
Errors
- Recoverable Error: Invalid bitrange.
- Recoverable Error: Bitrange property is invalid.
Reference
- Use the KP op_sar_bitrange_create() to create new bit-ranges
- Use the KP op_sar_bitrange_destroy() to deallocate the memory associated with a bit-range
- Use the KP op_sar_seg_bitrange_list_get() to get a list of bit-ranges inside a segment