1 /* encode.c -- encoding and decoding of CoAP data types
3 * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
5 * This file is part of the CoAP library libcoap. Please see
6 * README for terms of use.
11 #if defined(HAVE_ASSERT_H) && !defined(assert)
23 /* Carsten suggested this when fls() is not available: */
24 int coap_fls(unsigned int i)
32 unsigned int coap_decode_var_bytes(unsigned char *buf, unsigned int len)
34 unsigned int i, n = 0;
35 for (i = 0; i < len; ++i)
36 n = (n << 8) + buf[i];
41 unsigned int coap_encode_var_bytes(unsigned char *buf, unsigned int val)
45 for (n = 0, i = val; i && n < sizeof(val); ++n)
58 bool coap_is_var_bytes(coap_option_def_t* def)