op_sar_bitrange_create()
Abstract
Creates a bit-range that defines a series of contiguous bits belonging to a single packet.
Syntax
op_sar_bitrange_create (start_bit, count, pkt_size, pkt_label)
| Argument | Type | Description |
|---|---|---|
start_bit |
OpT_Sar_Size |
first bit of a bit-range [The start bit refers to the first bit’s position in the original packet.] |
count |
OpT_Sar_Size |
number of contiguous bits in the bit-range |
pkt_size |
OpT_Sar_Size |
size of the packet to which the bits belong [The size of the packet in bits.] |
pkt_label |
OpT_Int64 |
label for the packet to which the bits belong [A packet label is a user-defined numeric value that identifies a particular packet within a Sar buffer. Source packets are assigned labels when inserted into Sar segmentation buffers by op_sar_segbuf_pk_insert().] |
Return Type
Sar_Bitrange*
Bit-range defining a group of contiguous bits within a segment belonging to a single packet.
Example
/* create a new list of SAR bit ranges to assign */
/* bits within incoming vector to packets. */
/* All bits within the vector are assumed to */
/* belong to the next packet in sequence. */
bitrange_ptr = op_sar_bitrange_create (last_start, op_vvec_size_get (incoming_vvec),
MTU_SIZE, sequence_num++);
last_start += op_vvec_size_get (incoming_vvec);
/* append this bitrange pointer to bitrange list being constructed. */
op_prg_list_insert(bitrange_list_ptr, bitrange_ptr, OPC_LISTPOS_TAIL);
Details
A bit-range is a data type specific to the Sar package that stores key information about bit configuration inside segments. A bit-range specifies a series of contiguous bits that all belong to the same packet, which is identified by its user defined label. The value assigned to the starting bit of a bit-range specifies its location in the labeled packet. In addition, the packet’s total size before segmentation is also stored in the bit-range.
Bit-ranges should be destroyed after they are no longer needed to free the memory associated with them. op_sar_bitrange_create() returns OPC_NIL if the memory for a new bit-range could not be allocated.
Purpose
Provides a mechanism to create bit-ranges.
Errors
- Recoverable Error: Bitrange count (
<count>) is invalid. - Recoverable Error: Bitrange start bit (
<start>) is invalid. - Recoverable Error: Bitrange total size (
<packet size>) is invalid.
Reference
- Use the KP op_sar_bitrange_destroy() to deallocate a bit-range after it is no longer needed
- Use the KP op_sar_bitrange_info_get() to read information contained in a bit-range
- Use the KP op_sar_seg_bitrange_list_get() to get a list of bit-ranges inside a segment
- Use the KP op_sar_seg_create_vvec() to create a new segment with a value vector and list of bit-ranges