Go to the documentation of this file.
38 assert(buffer != NULL);
144 return ((uint16_t)(packet->
_buffer[index+0]) << 8) | (uint16_t)(packet->
_buffer[index+1]);
161 for(uint_least16_t i=0; i<
length; i++)
167 return ((uint16_t)(a) << 8) | (uint16_t)(b);
200 return listed_checksum == computed_checksum;
291 uint8_t* payload_buffer;
296 memcpy(payload_buffer, payload, payload_length);
333 assert(payload_ptr_out != NULL);
340 *payload_ptr_out = NULL;
342 if( field_length <= remaining )
354 return remaining - field_length;
380 assert(payload_ptr != NULL);
387 const int delta_length = new_field_length - old_field_length;
416 assert(payload_ptr != NULL);
uint_least16_t _buffer_length
Length of the buffer (NOT the packet length!).
uint8_t * _buffer
Pointer to the packet data.
uint_least16_t mip_packet_total_length(const mip_packet *packet)
Returns the total length of the packet, in bytes.
void mip_packet_create(mip_packet *packet, uint8_t *buffer, size_t buffer_size, uint8_t descriptor_set)
Create a brand-new MIP packet in the given buffer.
int mip_packet_alloc_field(mip_packet *packet, uint8_t field_descriptor, uint8_t payload_length, uint8_t **const payload_ptr_out)
Allocate a MIP field within the packet and return the payload pointer.
bool mip_packet_is_valid(const mip_packet *packet)
Returns true if the packet is valid.
int mip_packet_cancel_last_field(mip_packet *packet, uint8_t *payload_ptr)
Removes the last field from the packet after having allocated it.
uint8_t * mip_packet_buffer(mip_packet *packet)
Returns a writable pointer to the data buffer.
@ MIP_FIELD_PAYLOAD_LENGTH_MAX
uint8_t mip_packet_payload_length(const mip_packet *packet)
Returns the length of the payload (MIP fields).
uint16_t mip_packet_compute_checksum(const mip_packet *packet)
Computes the checksum of the MIP packet.
const uint8_t * mip_packet_payload(const mip_packet *packet)
Returns a pointer to the packet's payload (the first field).
void mip_packet_reset(mip_packet *packet, uint8_t descriptor_set)
Reinitialize the packet with the given descriptor set.
bool mip_packet_is_empty(const mip_packet *packet)
Returns true if the mip packet contains no payload.
bool mip_is_data_descriptor_set(uint8_t descriptor_set)
Determines if the descriptor set represents some kind of data.
const uint8_t * mip_packet_pointer(const mip_packet *packet)
Returns a pointer to the data buffer containing the packet.
@ MIP_FIELD_HEADER_LENGTH
void mip_packet_finalize(mip_packet *packet)
Prepares the packet for transmission by adding the checksum.
@ MIP_INDEX_FIELD_PAYLOAD
bool mip_packet_add_field(mip_packet *packet, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length)
Adds a pre-constructed MIP field to the packet.
uint8_t mip_packet_descriptor_set(const mip_packet *packet)
Returns the MIP descriptor set for this packet.
int mip_packet_realloc_last_field(mip_packet *packet, uint8_t *payload_ptr, uint8_t new_payload_length)
Changes the size of the last field in the packet.
uint16_t mip_packet_checksum_value(const mip_packet *packet)
Returns the value of the checksum as written in the packet.
bool mip_packet_is_data(const mip_packet *packet)
Returns true if the packet is from a data descriptor set.
Structure representing a MIP Packet.
int mip_packet_remaining_space(const mip_packet *packet)
Returns the remaining space available for more payload data.
uint_least16_t mip_packet_buffer_size(const mip_packet *packet)
Returns the size of the buffer backing the MIP packet.
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
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...
void mip_packet_from_buffer(mip_packet *packet, uint8_t *buffer, size_t length)
Initializes a MIP packet from an existing buffer.