Use these functions to get information about a MIP packet after it has been parsed. More...
Functions | |
uint8_t * | mip_packet_buffer (mip_packet *packet) |
Returns a writable pointer to the data buffer. More... | |
packet_length | mip_packet_buffer_size (const mip_packet *packet) |
Returns the size of the buffer backing the MIP packet. More... | |
uint16_t | mip_packet_checksum_value (const mip_packet *packet) |
Returns the value of the checksum as written in the packet. More... | |
uint16_t | mip_packet_compute_checksum (const mip_packet *packet) |
Computes the checksum of the MIP packet. More... | |
uint8_t | mip_packet_descriptor_set (const mip_packet *packet) |
Returns the MIP descriptor set for this packet. More... | |
void | mip_packet_from_buffer (mip_packet *packet, uint8_t *buffer, size_t length) |
Initializes a MIP packet from an existing buffer. More... | |
bool | mip_packet_is_data (const mip_packet *packet) |
Returns true if the packet is from a data descriptor set. More... | |
bool | mip_packet_is_empty (const mip_packet *packet) |
Returns true if the mip packet contains no payload. More... | |
bool | mip_packet_is_sane (const mip_packet *packet) |
Returns true if the packet buffer is not NULL and is at least the minimum size (MIP_PACKET_LENGTH_MIN). More... | |
bool | mip_packet_is_valid (const mip_packet *packet) |
Returns true if the packet is valid. More... | |
const uint8_t * | mip_packet_payload (const mip_packet *packet) |
Returns a pointer to the packet's payload (the first field). More... | |
uint8_t | mip_packet_payload_length (const mip_packet *packet) |
Returns the length of the payload (MIP fields). More... | |
const uint8_t * | mip_packet_pointer (const mip_packet *packet) |
Returns a pointer to the data buffer containing the packet. More... | |
remaining_count | mip_packet_remaining_space (const mip_packet *packet) |
Returns the remaining space available for more payload data. More... | |
packet_length | mip_packet_total_length (const mip_packet *packet) |
Returns the total length of the packet, in bytes. 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.
uint8_t* mip_packet_buffer | ( | mip_packet * | packet | ) |
Returns a writable pointer to the data buffer.
Definition at line 113 of file mip_packet.c.
packet_length mip_packet_buffer_size | ( | const mip_packet * | packet | ) |
Returns the size of the buffer backing the MIP packet.
Definition at line 224 of file mip_packet.c.
uint16_t mip_packet_checksum_value | ( | const mip_packet * | packet | ) |
Returns the value of the checksum as written in the packet.
This function does not compute the checksum. To do so, use mip_packet_compute_checksum().
Definition at line 140 of file mip_packet.c.
uint16_t mip_packet_compute_checksum | ( | const mip_packet * | packet | ) |
Computes the checksum of the MIP packet.
Definition at line 152 of file mip_packet.c.
uint8_t mip_packet_descriptor_set | ( | const mip_packet * | packet | ) |
Returns the MIP descriptor set for this packet.
Definition at line 87 of file mip_packet.c.
void mip_packet_from_buffer | ( | mip_packet * | packet, |
uint8_t * | buffer, | ||
size_t | length | ||
) |
Initializes a MIP packet from an existing buffer.
Use this when receiving or parsing MIP packets.
The data in the buffer should be a valid or suspected MIP packet.
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. |
Definition at line 36 of file mip_packet.c.
bool mip_packet_is_data | ( | const mip_packet * | packet | ) |
Returns true if the packet is from a data descriptor set.
Definition at line 247 of file mip_packet.c.
bool mip_packet_is_empty | ( | const mip_packet * | packet | ) |
Returns true if the mip packet contains no payload.
packet |
Definition at line 210 of file mip_packet.c.
bool mip_packet_is_sane | ( | const mip_packet * | packet | ) |
Returns true if the packet buffer is not NULL and is at least the minimum size (MIP_PACKET_LENGTH_MIN).
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.
Definition at line 179 of file mip_packet.c.
bool mip_packet_is_valid | ( | const mip_packet * | packet | ) |
Returns true if the packet is valid.
A packet is valid if:
Definition at line 192 of file mip_packet.c.
const uint8_t* mip_packet_payload | ( | const mip_packet * | packet | ) |
Returns a pointer to the packet's payload (the first field).
Definition at line 129 of file mip_packet.c.
uint8_t mip_packet_payload_length | ( | const mip_packet * | packet | ) |
Returns the length of the payload (MIP fields).
Definition at line 95 of file mip_packet.c.
const uint8_t* mip_packet_pointer | ( | const mip_packet * | packet | ) |
Returns a pointer to the data buffer containing the packet.
Definition at line 121 of file mip_packet.c.
remaining_count mip_packet_remaining_space | ( | const mip_packet * | packet | ) |
Returns the remaining space available for more payload data.
This is equal to the buffer size less the total packet length.
Definition at line 234 of file mip_packet.c.
packet_length mip_packet_total_length | ( | const mip_packet * | packet | ) |
Returns the total length of the packet, in bytes.
Definition at line 105 of file mip_packet.c.