C MIP-SDK
Functions
mip.c File Reference
#include "mip.h"

Functions

u16 mip_init (u8 *mip_buffer, u16 buffer_size, u8 descriptor_set)
u16 mip_is_initialized (u8 *mip_buffer, u8 descriptor_set)
u16 mip_add_field (u8 *mip_buffer, u16 buffer_size, void *field_data, u16 data_size, u16 data_descriptor)
u16 mip_add_formatted_field (u8 *mip_buffer, u16 buffer_size, void *field)
u16 mip_finalize (u8 *mip_buffer)
u16 mip_is_mip_packet (u8 *mip_buffer)
u16 mip_get_packet_size (u8 *mip_buffer)
u16 mip_get_first_field (u8 *mip_buffer, mip_field_header **field_header, u8 **field_data, u16 *field_offset)
u16 mip_get_next_field (u8 *mip_buffer, mip_field_header **field_header, u8 **field_data, u16 *field_offset)
u8 mip_get_packet_descriptor_set (u8 *mip_buffer)
u8 mip_get_payload_size (u8 *mip_buffer)
u8 * mip_get_payload_ptr (u8 *mip_buffer)
u16 mip_is_checksum_valid (u8 *mip_buffer)
u16 mip_calculate_checksum (u8 *mip_buffer)

Detailed Description

Author:
Nathan Miller
Version:
1.1

Function Documentation

u16 mip_add_field ( u8 *  mip_buffer,
u16  buffer_size,
void *  field_data,
u16  data_size,
u16  data_descriptor 
)

DESCRIPTION

Adds a field to an initialized MIP packet buffer.

DETAILS

Parameters:
[in,out]u8*mip_buffer - pointer to memory used to construct the mip packet.
[in]u16buffer_size - size of the mip mempory buffer.
[in]void*field_data - buffer containing the field data.
[in]u8u16 data_size - size of the field data (exlcuding the field header).
[in]u8u16 data_descriptor - the data descriptor for the field.
Return values:
MIP_OK- field added to MIP packet.
MIP_ERROR- A pointer is NULL.
MIP_MEMORY_ERROR- Not enough room in the mip buffer to add the field or
the packet will be too large for a MIP.

NOTES

None

u16 mip_add_formatted_field ( u8 *  mip_buffer,
u16  buffer_size,
void *  field 
)

DESCRIPTION

Adds a pre-formatted field (header and data already assembled) to an initialized MIP packet buffer.

DETAILS

Parameters:
[in,out]u8*mip_buffer - pointer to memory used to construct the mip packet.
[in]u16buffer_size - size of the mip mempory buffer.
[in]void*field - buffer containing the field (must have header and data already assembled).
Return values:
MIP_OK- field added to MIP packet.
MIP_ERROR- A pointer is NULL.
MIP_MEMORY_ERROR- Not enough room in the mip buffer to add the field or
the packet will be too large for a MIP.

NOTES

None

u16 mip_calculate_checksum ( u8 *  mip_buffer)

DESCRIPTION

Calculates the 16-bit Fletcher checksum for the MIP packet.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Returns:
The MIP packet checksum, if mip_buffer contains a valid MIP packet.
0x00 otherwise.

NOTES

None

u16 mip_finalize ( u8 *  mip_buffer)

DESCRIPTION

Calculates the MIP checksum and updates the checksum field in the buffer.

DETAILS

Parameters:
[in,out]u8*mip_buffer - pointer to memory used to construct the mip packet.
Returns:
Size of the MIP Packet in bytes.

NOTES

None

u16 mip_get_first_field ( u8 *  mip_buffer,
mip_field_header **  field_header,
u8 **  field_data,
u16 *  field_offset 
)

DESCRIPTION

Gets the first MIP field (a wrapper for mip_get_next_field that makes it easier to use).

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
[out]mip_field_header**field_header - pointer to the first field header.
[out]u8**field_data - pointer to the first field data.
[out]u16*field_offset - integer offset from start of packet payload of first field.
Returns:
See mip_get_next_field definition.

NOTES

None

u16 mip_get_next_field ( u8 *  mip_buffer,
mip_field_header **  field_header,
u8 **  field_data,
u16 *  field_offset 
)

DESCRIPTION

Gets the next data field at field_offset.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
[out]mip_field_header**field_header - pointer to the current field header.
[out]u8**field_data - pointer to the current field data.
[in,out]u16*field_offset - integer offset from start of packet payload of next field.
Return values:
MIP_OK- c\ field_header and field_data contain the parsed information.
MIP_ERROR- A pointer is NULL.
MIP_INVALID_PACKET- The buffer does not contain a valid MIP packet.
MIP_FIELD_NOT_AVAILABLE- The requested field does not exist.

NOTES

None

u8 mip_get_packet_descriptor_set ( u8 *  mip_buffer)

DESCRIPTION

Returns the MIP packet descriptor set.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Returns:
The MIP descriptor set byte if the buffer points to a valid packet.
0x00 otherwise.

NOTES

None

u16 mip_get_packet_size ( u8 *  mip_buffer)

DESCRIPTION

Gets the size of the MIP packet.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Returns:
0 - An error occurred
Size of the MIP packet, otherwise

NOTES

None

u8* mip_get_payload_ptr ( u8 *  mip_buffer)

DESCRIPTION

Returns a pointer to the start of the MIP payload data.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Returns:
A pointer to the MIP payload data.
NULL otherwise.

NOTES

None

u8 mip_get_payload_size ( u8 *  mip_buffer)

DESCRIPTION

Returns the MIP payload size.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Returns:
The MIP payload size if the buffer points to a valid packet.
0x00 otherwise.

NOTES

None

u16 mip_init ( u8 *  mip_buffer,
u16  buffer_size,
u8  descriptor_set 
)

DESCRIPTION

Initialize a MIP packet header.

DETAILS

Parameters:
[out]u8*mip_buffer - pointer to memory used to construct the mip packet.
[in]u16buffer_size - size of the mip memory buffer.
[in]u8descriptor_set - descriptor set field value.
Return values:
MIP_OK- MIP packet initialized.
MIP_ERROR- The pointer is NULL.
MIP_MEMORY_ERROR- Not enough room in the mip buffer.

NOTES

None

u16 mip_is_checksum_valid ( u8 *  mip_buffer)

DESCRIPTION

Returns the state of the MIP packet checksum.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory containing the mip packet.
Return values:
MIP_OK- The checksum is valid.
MIP_ERROR- The pointer is NULL.
MIP_INVALID_PACKET- The buffer does not contain a valid MIP packet.

NOTES

None

u16 mip_is_initialized ( u8 *  mip_buffer,
u8  descriptor_set 
)

DESCRIPTION

Check if a MIP packet is initialized.

DETAILS

Parameters:
[in]u8*mip_buffer - pointer to memory used to construct the mip packet.
[in]u8descriptor_set - expected descriptor set field value.
Return values:
MIP_OK- MIP packet initialized.
MIP_ERROR- The pointer is NULL or the MIP packet is not intialized.

NOTES

None

u16 mip_is_mip_packet ( u8 *  mip_buffer)

DESCRIPTION

Checks if the buffer contains a valid MIP header.

DETAILS

Parameters:
[in,out]u8*mip_buffer - pointer to memory containing the mip packet.
Return values:
MIP_OK- Header is valid.
MIP_ERROR- The pointer is NULL.
MIP_MEMORY_ERROR- The buffer does not contain a valid MIP packet header.

NOTES

None

 All Data Structures Files Functions Defines