libcoap 4.3.2rc2

Functions
coap_encode.h File Reference

Encoding and decoding of CoAP data types. More...

`#include <strings.h>`
`#include <stdint.h>`

Go to the source code of this file.

## Functions
int | coap_fls (unsigned int i)
int | coap_flsll (long long i)
unsigned int | coap_decode_var_bytes (const uint8_t *buf, size_t length)
| Decodes multiple-length byte sequences. More...
uint64_t | coap_decode_var_bytes8 (const uint8_t *buf, size_t length)
| Decodes multiple-length byte sequences. More...
unsigned int | coap_encode_var_safe (uint8_t *buf, size_t length, unsigned int value)
| Encodes multiple-length byte sequences. More...
unsigned int | coap_encode_var_safe8 (uint8_t *buf, size_t length, uint64_t value)
| Encodes multiple-length byte sequences. More...
COAP_STATIC_INLINE COAP_DEPRECATED int | coap_encode_var_bytes (uint8_t *buf, unsigned int value)

## Detailed Description

Encoding and decoding of CoAP data types.

Definition in file coap_encode.h.

## Function Documentation

## ◆ coap_encode_var_bytes()

COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes | ( | uint8_t * | buf,
|  | unsigned int | value
| ) |  |

Deprecated:
  Use coap_encode_var_safe() instead. Provided for backward compatibility. As `value` has a maximum value of 0xffffffff, and buf is usually defined as an array, it is unsafe to continue to use this variant if buf[] is less than buf[4].

For example char buf[1],oops; .. coap_encode_var_bytes(buf, 0xfff); would cause oops to get overwritten. This error can only be found by code inspection. coap_encode_var_safe(buf, sizeof(buf), 0xfff); would catch this error at run-time and should be used instead.

Definition at line 123 of file coap_encode.h.

## ◆ coap_fls()

int coap_fls | ( | unsigned int | i | ) |

Definition at line 21 of file coap_encode.c.

## ◆ coap_flsll()

int coap_flsll | ( | long long | i | ) |

Definition at line 28 of file coap_encode.c.