Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions
kaa_platform_utils.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "kaa_error.h"
#include "kaa_platform_common.h"

Go to the source code of this file.

Data Structures

struct  kaa_platform_message_writer_t
 
struct  kaa_platform_message_reader_t
 

Macros

#define KAA_MESSAGE_WRITER(buffer, len)   (kaa_platform_message_writer_t){ (buffer), (buffer), (buffer) + (len) }
 
#define KAA_MESSAGE_READER(buffer, len)   (kaa_platform_message_reader_t){ (buffer), (buffer), (buffer) + (len) }
 
#define KAA_ALIGNED_SIZE(s)   ((s) + (KAA_ALIGNMENT - (s) % KAA_ALIGNMENT) % KAA_ALIGNMENT)
 
#define KAA_STATIC_ASSERT(name, expr)   static char static_assertion_##name[expr] __attribute__((unused))
 

Functions

kaa_error_t kaa_platform_message_writer_create (kaa_platform_message_writer_t **writer_p, uint8_t *buf, size_t len)
 
void kaa_platform_message_writer_destroy (kaa_platform_message_writer_t *writer)
 
kaa_error_t kaa_platform_message_write (kaa_platform_message_writer_t *writer, const void *data, size_t data_size)
 
kaa_error_t kaa_platform_message_write_alignment (kaa_platform_message_writer_t *writer)
 
kaa_error_t kaa_platform_message_write_aligned (kaa_platform_message_writer_t *writer, const void *data, size_t data_size)
 
kaa_error_t kaa_platform_message_header_write (kaa_platform_message_writer_t *writer, uint32_t protocol_id, uint16_t protocol_version)
 
kaa_error_t kaa_platform_message_write_extension_header (kaa_platform_message_writer_t *writer, uint16_t extension_type, uint16_t options, uint32_t payload_size)
 
kaa_error_t kaa_platform_message_reader_create (kaa_platform_message_reader_t **reader_p, const uint8_t *buffer, size_t len)
 
void kaa_platform_message_reader_destroy (kaa_platform_message_reader_t *reader)
 
kaa_error_t kaa_platform_message_read (kaa_platform_message_reader_t *reader, void *buffer, size_t expected_size)
 
kaa_error_t kaa_platform_message_read_aligned (kaa_platform_message_reader_t *reader, void *buffer, size_t expected_size)
 
kaa_error_t kaa_platform_message_header_read (kaa_platform_message_reader_t *reader, uint32_t *protocol_id, uint16_t *protocol_version, uint16_t *extension_count)
 
kaa_error_t kaa_platform_message_read_extension_header (kaa_platform_message_reader_t *reader, uint16_t *extension_type, uint16_t *extension_options, uint32_t *extension_payload_length)
 
bool kaa_platform_message_is_buffer_large_enough (kaa_platform_message_reader_t *reader, size_t size)
 
kaa_error_t kaa_platform_message_skip (kaa_platform_message_reader_t *reader, size_t size)
 
static size_t kaa_aligned_size_get (size_t size)
 

Macro Definition Documentation

#define KAA_ALIGNED_SIZE (   s)    ((s) + (KAA_ALIGNMENT - (s) % KAA_ALIGNMENT) % KAA_ALIGNMENT)
#define KAA_MESSAGE_READER (   buffer,
  len 
)    (kaa_platform_message_reader_t){ (buffer), (buffer), (buffer) + (len) }
#define KAA_MESSAGE_WRITER (   buffer,
  len 
)    (kaa_platform_message_writer_t){ (buffer), (buffer), (buffer) + (len) }
#define KAA_STATIC_ASSERT (   name,
  expr 
)    static char static_assertion_##name[expr] __attribute__((unused))

Function Documentation

static size_t kaa_aligned_size_get ( size_t  size)
inlinestatic
kaa_error_t kaa_platform_message_header_read ( kaa_platform_message_reader_t reader,
uint32_t *  protocol_id,
uint16_t *  protocol_version,
uint16_t *  extension_count 
)
kaa_error_t kaa_platform_message_header_write ( kaa_platform_message_writer_t writer,
uint32_t  protocol_id,
uint16_t  protocol_version 
)
bool kaa_platform_message_is_buffer_large_enough ( kaa_platform_message_reader_t reader,
size_t  size 
)
kaa_error_t kaa_platform_message_read ( kaa_platform_message_reader_t reader,
void *  buffer,
size_t  expected_size 
)
kaa_error_t kaa_platform_message_read_aligned ( kaa_platform_message_reader_t reader,
void *  buffer,
size_t  expected_size 
)
kaa_error_t kaa_platform_message_read_extension_header ( kaa_platform_message_reader_t reader,
uint16_t *  extension_type,
uint16_t *  extension_options,
uint32_t *  extension_payload_length 
)
kaa_error_t kaa_platform_message_reader_create ( kaa_platform_message_reader_t **  reader_p,
const uint8_t *  buffer,
size_t  len 
)
Deprecated:
Use KAA_MESSAGE_READER instead – it doesn't allocate memory.
void kaa_platform_message_reader_destroy ( kaa_platform_message_reader_t reader)
kaa_error_t kaa_platform_message_skip ( kaa_platform_message_reader_t reader,
size_t  size 
)
kaa_error_t kaa_platform_message_write ( kaa_platform_message_writer_t writer,
const void *  data,
size_t  data_size 
)
kaa_error_t kaa_platform_message_write_aligned ( kaa_platform_message_writer_t writer,
const void *  data,
size_t  data_size 
)
kaa_error_t kaa_platform_message_write_alignment ( kaa_platform_message_writer_t writer)
kaa_error_t kaa_platform_message_write_extension_header ( kaa_platform_message_writer_t writer,
uint16_t  extension_type,
uint16_t  options,
uint32_t  payload_size 
)
kaa_error_t kaa_platform_message_writer_create ( kaa_platform_message_writer_t **  writer_p,
uint8_t *  buf,
size_t  len 
)
Deprecated:
Use KAA_MESSAGE_WRITER instead – it doesn't allocate memory.
void kaa_platform_message_writer_destroy ( kaa_platform_message_writer_t writer)