Functions for accessing information about an existing MIP packet.
More...
Use these functions to get information about a MIP packet after it has been parsed. Generally, first the descriptor set would be inspected followed by iterating the fields using the MipFieldIteration functions.
With the exception of mip_packet_checksum_value() (and any function which calls it, e.g. mip_packet_is_valid()), these functions may also be used on packets which are under construction via the PacketBuilding functions.
- Warning
- Do not call the packet-building functions unless you know the input buffer is not const.
◆ mip_packet_from_buffer()
void mip::C::mip_packet_from_buffer |
( |
mip_packet_view * |
packet, |
|
|
const uint8_t * |
buffer, |
|
|
size_t |
length |
|
) |
| |
Use this when receiving or parsing MIP packets.
The data in the buffer should be a valid or suspected MIP packet.
- Parameters
-
packet | |
buffer | The data buffer containing the bytes for a MIP packet. Must be at least MIP_PACKET_LENGTH_MIN bytes in size. |
length | The length of the data pointed to by buffer. |
- Note
- The data does not need to be a valid MIP packet, for instance to use the mip_packet_is_sane() or mip_packet_is_valid() functions. However, if it is NOT a valid MIP packet, the result of calling any accessor function is unpredictable. In particular, if length is less than MIP_PACKET_LENGTH_MIN bytes, calling the accessor functions is undefined behavior.
◆ mip_packet_descriptor_set()
uint8_t mip::C::mip_packet_descriptor_set |
( |
const mip_packet_view * |
packet | ) |
|
◆ mip_packet_total_length()
uint_least16_t mip::C::mip_packet_total_length |
( |
const mip_packet_view * |
packet | ) |
|
- Returns
- The length of the packet. Always at least MIP_PACKET_LENGTH_MIN.
◆ mip_packet_payload_length()
uint8_t mip::C::mip_packet_payload_length |
( |
const mip_packet_view * |
packet | ) |
|
◆ mip_packet_buffer()
const uint8_t * mip::C::mip_packet_buffer |
( |
const mip_packet_view * |
packet | ) |
|
◆ mip_packet_buffer_w()
◆ mip_packet_data()
◆ mip_packet_payload()
const uint8_t * mip::C::mip_packet_payload |
( |
const mip_packet_view * |
packet | ) |
|
◆ mip_packet_payload_w()
◆ mip_packet_checksum_value()
uint16_t mip::C::mip_packet_checksum_value |
( |
const mip_packet_view * |
packet | ) |
|
◆ mip_packet_compute_checksum()
uint16_t mip::C::mip_packet_compute_checksum |
( |
const mip_packet_view * |
packet | ) |
|
- Returns
- The computed checksum value.
◆ mip_packet_is_sane()
If the packet is not 'sane', then none of the mip_packet_* functions may be used to access it (to do so is undefined behavior). This should never occur in normal circumstances.
◆ mip_packet_is_valid()
◆ mip_packet_is_empty()
- Parameters
-
- Returns
- true if the packet has a payload length of 0.
◆ mip_packet_buffer_length()
uint_least16_t mip::C::mip_packet_buffer_length |
( |
const mip_packet_view * |
packet | ) |
|
- Note
- This is the entire buffer size and not the packet length.
◆ mip_packet_remaining_space()
This is equal to the buffer size less the total packet length.
- Warning
- The result may be negative if the packet length exceeds the actual buffer capacity. Such packets are not 'sane' (mip_packet_is_sane) and can only be produced by manipulating the buffered data directly.
◆ mip_packet_is_data()
- See also
- is_data_descriptor_set
- Returns
- true if the packet contains data.
-
false if it contains commands or replies.