#include <strings.h>
#include <stdint.h>
Go to the source code of this file.
◆ COAP_PSEUDOFP_DECODE_8_4
#define COAP_PSEUDOFP_DECODE_8_4 |
( |
|
r | ) |
(r < HIBIT ? r : (r & MMASK) << (r & EMASK)) |
◆ COAP_PSEUDOFP_ENCODE_8_4_DOWN
#define COAP_PSEUDOFP_ENCODE_8_4_DOWN |
( |
|
v, |
|
|
|
ls |
|
) |
| (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) |
◆ COAP_PSEUDOFP_ENCODE_8_4_UP
◆ EMASK
◆ ENCODE_HEADER_SIZE
#define ENCODE_HEADER_SIZE 4 |
◆ HIBIT
#define HIBIT (1 << (Nn - 1)) |
◆ MAX_VALUE
◆ MMASK
#define MMASK ((1 << Nn) - 1 - EMASK) |
◆ Nn
#define Nn 8 /* duplicate definition of N if built on sky motes */ |
◆ coap_decode_var_bytes()
unsigned int coap_decode_var_bytes |
( |
const uint8_t * |
buf, |
|
|
unsigned int |
length |
|
) |
| |
Decodes multiple-length byte sequences.
buf
points to an input byte sequence of length length
. Returns the up to 4 byte decoded value.
- Parameters
-
buf | The input byte sequence to decode from |
length | The length of the input byte sequence |
- Returns
- The decoded value
Definition at line 29 of file encode.c.
◆ coap_decode_var_bytes8()
uint64_t coap_decode_var_bytes8 |
( |
const uint8_t * |
buf, |
|
|
unsigned int |
length |
|
) |
| |
Decodes multiple-length byte sequences.
buf
points to an input byte sequence of length length
. Returns the up to 8 byte decoded value.
- Parameters
-
buf | The input byte sequence to decode from |
length | The length of the input byte sequence |
- Returns
- The decoded value
Definition at line 58 of file encode.c.
◆ coap_encode_var_bytes()
- 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 118 of file encode.h.
◆ coap_encode_var_safe()
unsigned int coap_encode_var_safe |
( |
uint8_t * |
buf, |
|
|
size_t |
length, |
|
|
unsigned int |
value |
|
) |
| |
Encodes multiple-length byte sequences.
buf
points to an output buffer of sufficient length to store the encoded bytes. value
is the 4 byte value to encode. Returns the number of bytes used to encode value
or 0 on error.
- Parameters
-
buf | The output buffer to encode into |
length | The output buffer size to encode into (must be sufficient) |
value | The value to encode into the buffer |
- Returns
- The number of bytes used to encode
value
or 0
on error.
Definition at line 38 of file encode.c.
◆ coap_encode_var_safe8()
unsigned int coap_encode_var_safe8 |
( |
uint8_t * |
buf, |
|
|
size_t |
length, |
|
|
uint64_t |
value |
|
) |
| |
Encodes multiple-length byte sequences.
buf
points to an output buffer of sufficient length to store the encoded bytes. value
is the 8 byte value to encode. Returns the number of bytes used to encode value
or 0 on error.
- Parameters
-
buf | The output buffer to encode into |
length | The output buffer size to encode into (must be sufficient) |
value | The value to encode into the buffer |
- Returns
- The number of bytes used to encode
value
or 0
on error.
Definition at line 68 of file encode.c.
◆ coap_fls()
int coap_fls |
( |
unsigned int |
i | ) |
|
◆ coap_flsll()
int coap_flsll |
( |
long long |
i | ) |
|