10 #ifndef COAP_ENCODE_H_ 11 #define COAP_ENCODE_H_ 13 #if (BSD >= 199103) || defined(WITH_CONTIKI) || defined(_WIN32) 22 #define ENCODE_HEADER_SIZE 4 23 #define HIBIT (1 << (Nn - 1)) 24 #define EMASK ((1 << ENCODE_HEADER_SIZE) - 1) 25 #define MMASK ((1 << Nn) - 1 - EMASK) 26 #define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1)) 28 #define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK)) 34 #define coap_fls(i) fls(i) 41 #define coap_flsll(i) flsll(i) 45 #define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) 46 #define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<<ENCODE_HEADER_SIZE<<ls)-1)) >> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls)) unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value)
Encodes multiple-length byte sequences.
int coap_fls(unsigned int i)
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes(uint8_t *buf, unsigned int value)
unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int length)
Decodes multiple-length byte sequences.
uint64_t coap_decode_var_bytes8(const uint8_t *buf, unsigned int length)
Decodes multiple-length byte sequences.
#define COAP_STATIC_INLINE
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t value)
Encodes multiple-length byte sequences.
int coap_flsll(long long i)