10 #ifndef _COAP_ENCODE_H_ 11 #define _COAP_ENCODE_H_ 13 #if (BSD >= 199103) || defined(WITH_CONTIKI) 20 #define ENCODE_HEADER_SIZE 4 21 #define HIBIT (1 << (Nn - 1)) 22 #define EMASK ((1 << ENCODE_HEADER_SIZE) - 1) 23 #define MMASK ((1 << Nn) - 1 - EMASK) 24 #define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1)) 26 #define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK)) 32 #define coap_fls(i) fls(i) 36 #define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) 37 #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)) 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.