libcoap 4.3.4
Encode / Decode API

API for endoding/decoding CoAP options. More...

+ Collaboration diagram for Encode / Decode API:

Functions

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...
 

Detailed Description

API for endoding/decoding CoAP options.

Function Documentation

◆ coap_decode_var_bytes()

unsigned int coap_decode_var_bytes ( const uint8_t *  buf,
size_t  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
bufThe input byte sequence to decode from
lengthThe length of the input byte sequence
Returns
The decoded value

Definition at line 38 of file coap_encode.c.

+ Here is the caller graph for this function:

◆ coap_decode_var_bytes8()

uint64_t coap_decode_var_bytes8 ( const uint8_t *  buf,
size_t  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
bufThe input byte sequence to decode from
lengthThe length of the input byte sequence
Returns
The decoded value

Definition at line 67 of file coap_encode.c.

+ Here is the caller graph for this function:

◆ 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
bufThe output buffer to encode into
lengthThe output buffer size to encode into (must be sufficient)
valueThe value to encode into the buffer
Returns
The number of bytes used to encode value (which can be 0 when encoding value of 0) or 0 on error.

Definition at line 47 of file coap_encode.c.

+ Here is the caller graph for this function:

◆ 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
bufThe output buffer to encode into
lengthThe output buffer size to encode into (must be sufficient)
valueThe value to encode into the buffer
Returns
The number of bytes used to encode value (which can be 0 when encoding value of 0) or 0 on error.

Definition at line 77 of file coap_encode.c.

+ Here is the caller graph for this function: