udi_buf_tag_compute(3udi)
Compute values from tagged buffer data
#include <udi.h>udi_ubit32_t udi_buf_tag_compute ( udi_buf_t *buf, udi_size_t off, udi_size_t len, udi_tagtype_t tag_type );ARGUMENTS buf is the buffer for which the tag value is to be computed.
off is the offset into the buffer at which the computation is to begin. The offset specified must point to valid buffer data.
len is the number of bytes in the buffer to be used for the computation. All bytes in the buffer specified by off and len must be valid buffer data.
tag_type is the tag value to be computed. Only one tag type may be specified (only one bit may be set for this argument) and it must be one of the Value category tags (i.e. one of the tag types in the UDI_BUFTAG_VALUES category).
DESCRIPTION The udi_buf_tag_compute utility routine is used to calculate the specified tag value for a portion of data contained in the buffer; the most common tag value computed is the 16-bit big-endian checksum value used for network packets.
The buffer range specified must consist entirely of valid data bytes.
The tag_type argument specifies what type of tag value is to be calculated. It is assumed (but not required) that this utility will take advantage of existing tags attached to the buffer to optimize the computation of the tag values.
This utility function does not actually set a tag of the corresponding tag_type on the buffer itself; that activity is left to the caller if needed.
Note - This function could be implemented entirely as a series of calls to various UDI service calls such as udi_buf_read and udi_buf_tag_get, but is expected in most environments to be implemented more directly in terms of the underlying implementation-specific data structures for greater efficiency.