Documentation

Documentation

Includes

stdint.h

#include <stdint.h>
#include 

Macros

Marco COAP_ENCODE_H_

#define COAP_ENCODE_H_


      

Marco Nn

#define Nn 8 /* duplicate definition of N if built on sky motes */


      

Marco ENCODE_HEADER_SIZE

#define ENCODE_HEADER_SIZE 4


      

Marco HIBIT

#define HIBIT (1 << (Nn - 1))


      

Marco EMASK

#define EMASK ((1 << ENCODE_HEADER_SIZE) - 1)


      

Marco MMASK

#define MMASK ((1 << Nn) - 1 - EMASK)


      

Marco MAX_VALUE

#define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1))


      

Marco COAP_PSEUDOFP_DECODE_8_4(r)

#define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK))


      

Marco coap_fls(i)

#define coap_fls(i) fls(i)


      

Marco coap_flsll(i)

#define coap_flsll(i) flsll(i)


      

Marco COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls)

#define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls)
/* ls and s must be integer variables */

Marco COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s)

#define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls))

      

Functions

Func coap_decode_var_bytes

unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int length);
/**
 * Decodes multiple-length byte sequences. @p buf points to an input byte
 * sequence of length @p length. Returns the decoded value.
 *
 * @param buf The input byte sequence to decode from
 * @param length The length of the input byte sequence
 *
 * @return      The decoded value
 */

Func coap_encode_var_safe

unsigned int coap_encode_var_safe(uint8_t *buf,
                                 size_t length,
                                 unsigned int value);
/**
 * Encodes multiple-length byte sequences. @p buf points to an output buffer of
 * sufficient length to store the encoded bytes. @p value is the value to
 * encode.
 * Returns the number of bytes used to encode @p value or 0 on error.
 *
 * @param buf    The output buffer to decode into
 * @param length The output buffer size to encode into (must be sufficient)
 * @param value  The value to encode into the buffer
 *
 * @return       The number of bytes used to encode @p value or @c 0 on error.
 */

Vars

Consts

Types

Typedefs