Contiki 2.5
sdnv.h
Go to the documentation of this file.
1 /**
2  * \addtogroup agent
3  * @{
4  */
5 
6 /**
7  * \defgroup sdnv SDNV Functions
8  *
9  * @{
10  */
11 
12 /**
13  * \file
14  * \brief Headerfile for sdnv functions
15  * \author Georg von Zengen <vonzeng@ibr.cs.tu-bs.de>
16  */
17 
18 #ifndef __SDNV_H__
19 #define __SDNV_H__
20 
21 #include <stdint.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 
25 #include "contiki.h"
26 
27 typedef uint8_t * sdnv_t;
28 
29 /**
30  * \brief encodes an uint32 value in sdnv
31  * \param val value to be encoded
32  * \param bp pointer to sdnv
33  * \param len size of sdnv
34  * \return length of sndv
35  */
36 int sdnv_encode(uint32_t val, uint8_t * bp, size_t len);
37 
38 /**
39  * \brief calculates the length needed to encode an uint32 value in sdnv
40  * \param val value to be encoded
41  * \return length of sndv
42  */
43 size_t sdnv_encoding_len(uint32_t val);
44 
45 /**
46  * \brief decodes a sdnv to an uint32 value
47  * \param bp pointer to sdnv
48  * \param len length of sdnv
49  * \param val pointer to uint32 value
50  * \return length of sndv
51  */
52 int sdnv_decode(const uint8_t * bp, size_t len, uint32_t * val);
53 
54 /**
55  * \brief calculates the length of a sdnv
56  * \param bp pointer to sdnv
57  * \return length of sndv
58  */
59 size_t sdnv_len(const uint8_t * bp);
60 
61 #define sdnv_decode2(a,b) sdnv_decode(a,sdnv_len(a),b)
62 
63 #endif
64 /** @} */
65 /** @} */