52 assert(*buf_size >= 1);
81 uint8_t *pt = *buffer;
83 assert(*buf_size >= text_len);
84 (*buf_size) -= text_len;
86 memcpy(*buffer, text, text_len);
87 (*buffer) += text_len;
93 uint8_t *pt = *buffer;
102 const uint8_t *bytes,
104 uint8_t *pt = *buffer;
106 assert(*buf_size >= bytes_len);
107 (*buf_size) -= bytes_len;
109 memcpy(*buffer, bytes, bytes_len);
110 (*buffer) += bytes_len;
111 return nb + bytes_len;
116 uint8_t *pt = *buffer;
134 uint8_t *pt = *buffer;
142 uint8_t *pt = *buffer;
151 uint8_t *pt = *buffer;
158put_b_f(uint8_t **buffer, uint64_t value, uint8_t nr) {
159 uint8_t *pt = *buffer - 1;
161 for (
int q = nr; q > -1; q--) {
162 (*pt--) = (uint8_t)(vv & 0xff);
170 assert(*buf_size >= 1);
172 (**buffer) = (uint8_t)value;
175 }
else if ((value > 0x17) && (value < 0x100)) {
177 assert(*buf_size >= 2);
180 *buffer = (*buffer) + 2;
183 }
else if ((value > 0xff) && (value < 0x10000)) {
185 assert(*buf_size >= 3);
188 *buffer = (*buffer) + 3;
191 }
else if ((value > 0xffff) && (value < 0x100000000)) {
193 assert(*buf_size >= 5);
196 *buffer = (*buffer) + 5;
201 assert(*buf_size >= 9);
204 *buffer = (*buffer) + 9;
215 assert((*buf_len) > 0);
221 assert((*buf_len) > 0);
223 return ((*buffer)++)[0];
228 uint8_t element =
get_byte(buffer, buf_len);
244 if (control < 0x18) {
245 size = (uint64_t)control;
247 control = control & 0x3;
248 int num = 1 << control;
251 for (
int i = 0; i < num; i++) {
253 size = (size << 8) + getal;
261 const uint8_t *buf = data;
264 coap_log_err(
"oscore_cbor_elem_contained returns 1 \n");
318 for (
size_t i = 0; i < size; i++) {
326 for (
size_t i = 0; i < size; i++) {
343 *result = (uint8_t *)rs;
363 uint8_t control =
get_byte(data, buf_len) & 0x1f;
367 if (control < 0x18) {
370 control = control & 0x3;
371 num = 1 + (1 << control);
376 assert((*buf_len) >= num);
385 assert((*buf_len) >= (size - num));
386 *buf_len -= (size - num);
387 (*data) = (*data) + size - num;
392 for (uint16_t qq = 0; qq < nb; qq++)
398 for (uint16_t qq = 0; qq < nb; qq++) {
404 assert((*buf_len) >= 1);
422 const uint8_t *st_data = *data;
425 for (uint16_t qq = 0; qq < size; qq++)
426 (*result)[qq] = st_data[qq];
Library specific build wrapper for coap_internal.h.
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
#define coap_log_err(...)
size_t oscore_cbor_put_text(uint8_t **buffer, size_t *buf_size, const char *text, size_t text_len)
size_t oscore_cbor_get_element_size(const uint8_t **buffer, size_t *buf_len)
#define CBOR_NEGATIVE_INTEGER
int64_t oscore_cbor_get_negative_integer(const uint8_t **buffer, size_t *buf_len)
#define CBOR_SIMPLE_VALUE
size_t oscore_cbor_put_number(uint8_t **buffer, size_t *buf_size, int64_t value)
size_t oscore_cbor_put_simple_value(uint8_t **buffer, size_t *buf_size, uint8_t value)
uint8_t oscore_cbor_get_string_array(const uint8_t **data, size_t *buf_len, uint8_t **result, size_t *len)
#define CBOR_UNSIGNED_INTEGER
uint8_t oscore_cbor_strip_value(const uint8_t **data, size_t *buf_len, uint8_t **result, size_t *len)
size_t oscore_cbor_put_nil(uint8_t **buffer, size_t *buf_size)
void oscore_cbor_get_string(const uint8_t **buffer, size_t *buf_len, char *str, size_t size)
uint8_t oscore_cbor_get_simple_value(const uint8_t **data, size_t *buf_len, uint8_t *value)
size_t oscore_cbor_put_false(uint8_t **buffer, size_t *buf_size)
uint8_t oscore_cbor_get_next_element(const uint8_t **buffer, size_t *buf_len)
size_t oscore_cbor_put_negative(uint8_t **buffer, size_t *buf_size, int64_t value)
size_t oscore_cbor_put_true(uint8_t **buffer, size_t *buf_size)
size_t oscore_cbor_put_unsigned(uint8_t **buffer, size_t *buf_size, uint64_t value)
size_t oscore_cbor_put_bytes(uint8_t **buffer, size_t *buf_size, const uint8_t *bytes, size_t bytes_len)
void oscore_cbor_get_array(const uint8_t **buffer, size_t *buf_len, uint8_t *arr, size_t size)
uint64_t oscore_cbor_get_unsigned_integer(const uint8_t **buffer, size_t *buf_len)
uint8_t oscore_cbor_elem_contained(const uint8_t *data, size_t *buf_len, uint8_t *end)
uint8_t oscore_cbor_get_number(const uint8_t **data, size_t *buf_len, int64_t *value)
size_t oscore_cbor_put_array(uint8_t **buffer, size_t *buf_size, size_t elements)
size_t oscore_cbor_put_map(uint8_t **buffer, size_t *buf_size, size_t elements)
size_t oscore_cbor_put_tag(uint8_t **buffer, size_t *buf_size, uint64_t value)
static uint8_t get_byte(const uint8_t **buffer, size_t *buf_len)
static uint8_t get_byte_inc(const uint8_t **buffer, size_t *buf_len)
static void util_write_byte(uint8_t **buffer, size_t *buf_size, uint8_t value)
static void put_b_f(uint8_t **buffer, uint64_t value, uint8_t nr)
static size_t oscore_cbor_skip_value(const uint8_t **data, size_t *buf_len)