libcoap  4.1.2
Macros | Functions
encode.h File Reference
#include <strings.h>
Include dependency graph for encode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Nn   8 /* duplicate definition of N if built on sky motes */
 
#define ENCODE_HEADER_SIZE   4
 
#define HIBIT   (1 << (Nn - 1))
 
#define EMASK   ((1 << ENCODE_HEADER_SIZE) - 1)
 
#define MMASK   ((1 << Nn) - 1 - EMASK)
 
#define MAX_VALUE   ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1))
 
#define COAP_PSEUDOFP_DECODE_8_4(r)   (r < HIBIT ? r : (r & MMASK) << (r & EMASK))
 
#define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v, ls)   (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls)
 
#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))
 

Functions

int coap_fls (unsigned int i)
 
unsigned int coap_decode_var_bytes (unsigned char *buf, unsigned int len)
 Decodes multiple-length byte sequences. More...
 
unsigned int coap_encode_var_bytes (unsigned char *buf, unsigned int val)
 Encodes multiple-length byte sequences. More...
 

Macro Definition Documentation

§ COAP_PSEUDOFP_DECODE_8_4

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

Definition at line 26 of file encode.h.

§ COAP_PSEUDOFP_ENCODE_8_4_DOWN

#define COAP_PSEUDOFP_ENCODE_8_4_DOWN (   v,
  ls 
)    (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls)

Definition at line 36 of file encode.h.

§ COAP_PSEUDOFP_ENCODE_8_4_UP

#define COAP_PSEUDOFP_ENCODE_8_4_UP (   v,
  ls,
 
)    (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))

Definition at line 37 of file encode.h.

§ EMASK

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

Definition at line 22 of file encode.h.

§ ENCODE_HEADER_SIZE

#define ENCODE_HEADER_SIZE   4

Definition at line 20 of file encode.h.

§ HIBIT

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

Definition at line 21 of file encode.h.

§ MAX_VALUE

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

Definition at line 24 of file encode.h.

§ MMASK

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

Definition at line 23 of file encode.h.

§ Nn

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

Definition at line 19 of file encode.h.

Function Documentation

§ coap_decode_var_bytes()

unsigned int coap_decode_var_bytes ( unsigned char *  buf,
unsigned int  len 
)

Decodes multiple-length byte sequences.

buf points to an input byte sequence of length len. Returns the decoded value.

Definition at line 25 of file encode.c.

Here is the caller graph for this function:

§ coap_encode_var_bytes()

unsigned int coap_encode_var_bytes ( unsigned char *  buf,
unsigned int  val 
)

Encodes multiple-length byte sequences.

buf points to an output buffer of sufficient length to store the encoded bytes. val is the value to encode. Returns the number of bytes used to encode val or 0 on error.

Definition at line 34 of file encode.c.

Here is the caller graph for this function:

§ coap_fls()

int coap_fls ( unsigned int  i)

Definition at line 17 of file encode.c.

Here is the caller graph for this function: