op_sar_seg_bitrange_list_get()
Abstract
Returns a list of bit-ranges present in a specified segment.
Syntax
op_sar_seg_bitrange_list_get (src_pkptr)
| Argument | Type | Description |
|---|---|---|
src_pkptr |
Packet* |
pointer to a packet [The packet must be a segment created in a segmentation or resegmentation buffer. A pointer to a packet can be obtained from many KP’s, such as op_pk_copy() and op_pk_get().] |
Return Type
List*
Pointer to a newly created list, in which each list element is a bit-range.
Example
/* retrieve a segment from source buffer. */
segpk_ptr = op_sar_srcbuf_seg_remove (transmit_buf, MTU_SIZE);
/* before converting a segment to bits, get */
/* bit-range information from the segment so */
/* that a segment can be reconstructed later. */
bitrange_list_ptr = op_sar_seg_bitrange_list_get (segpk_ptr);
/* convert the segment to bits and extract its */
/* vector. Destroy the segment once this is */
/* done. */
op_pk_convert_to_vvec (segpk_ptr);
op_pk_vvec_get (segpk_ptr, &vvec);
op_pk_destroy (segpk_ptr);
Details
A segment may contain non-contiguous groups of bits from one packet, or even groups of bits from different packets. This KP provides a new list with each bit-range in the segment.
As with other lists, the memory associated with lists returned by this function should be deallocated when the lists are no longer necessary.
Purpose
Provides a mechanism for obtaining a list of contents for a segment, which may contain non-contiguous bits from the same packets or bits from separate packets.
Errors
- Program Abort: Segmentation violation (due to a nil or corrupted packet pointer being passed as an argument)
- Recoverable Error: Packet (
<id>) must be a segment of another packet
Reference
- Use the KP op_prg_list_free() to remove the contents from a list without deallocating the list itself
- Use the KP op_prg_mem_free() to deallocate the list after freeing its elements
- Use the KP op_prg_list_access() to access an element in a list
- Use the KP op_sar_bitrange_info_get() to read information contained in a bit-range