libcoap  4.1.1
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Macros | Functions
encode.h File Reference
#include <strings.h>

Go to the source code of this file.

Macros

#define Nn   8 /* duplicate definition of N if built on sky motes */
 
#define E   4
 
#define HIBIT   (1 << (Nn - 1))
 
#define EMASK   ((1 << E) - 1)
 
#define MMASK   ((1 << Nn) - 1 - EMASK)
 
#define MAX_VALUE   ( (1 << Nn) - (1 << E) ) * (1 << ((1 << E) - 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<<E<<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

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

Definition at line 25 of file encode.h.

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

Definition at line 35 of file encode.h.

#define COAP_PSEUDOFP_ENCODE_8_4_UP (   v,
  ls,
 
)    (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<<E<<ls)-1)) >> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls))

Definition at line 36 of file encode.h.

#define E   4

Definition at line 19 of file encode.h.

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

Definition at line 21 of file encode.h.

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

Definition at line 20 of file encode.h.

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

Definition at line 23 of file encode.h.

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

Definition at line 22 of file encode.h.

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

Definition at line 18 of file encode.h.

Function Documentation

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.

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.

int coap_fls ( unsigned int  i)

Definition at line 17 of file encode.c.