9 #ifndef _COAP_ENCODE_H_
10 #define _COAP_ENCODE_H_
12 #if (BSD >= 199103) || defined(WITH_CONTIKI)
20 #define HIBIT (1 << (Nn - 1))
21 #define EMASK ((1 << E) - 1)
22 #define MMASK ((1 << Nn) - 1 - EMASK)
23 #define MAX_VALUE ( (1 << Nn) - (1 << E) ) * (1 << ((1 << E) - 1))
25 #define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK))
31 #define coap_fls(i) fls(i)
35 #define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls)
36 #define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<<E<<ls)-1)) >> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls))
int coap_fls(unsigned int i)
unsigned int coap_encode_var_bytes(unsigned char *buf, unsigned int val)
Encodes multiple-length byte sequences.
unsigned int coap_decode_var_bytes(unsigned char *buf, unsigned int len)
Decodes multiple-length byte sequences.