Statistics
| Branch: | Revision:

grapes / include / trade_sig_la.h @ b9e0d721

History | View | Annotate | Download (2.38 KB)

1
/** @file trade_sig_la.h
2
 *
3
 * @brief Chunk Signaling  API - Lower Abstraction
4
 *
5
 * The Chunk Signaling LA provides a set of primitives which encode and decode the signaling messages for chunks' negotiation. The former encode the signaling message returning a bit stream which is essentially the packet that will be sent, while the latter decode the received packet returning the signaling message understandable by the protocol.
6
 *
7
 * @image html SOM_Internals.png "Data Exchange Protocol of the SOM module" width=50
8
 */
9

    
10
#ifndef TRADE_SIG_LA_H 
11
#define TRADE_SIG_LA_H
12

    
13
 /**
14
  * Encode a sequence of information, filling the buffer with the corresponding bit stream.
15
  * 
16
  * Encode a sequence of information given as parameters and fills a buffer (given as parameter) with the corresponding bit stream.
17
  * The main reason to encode and return the bit stream is the possibility to either send directly a packet with the encoded bit stream, or 
18
  * add this bit stream in piggybacking
19
  * 
20
  * @param[in] h set of ChunkIDs
21
  * @param[in] meta metadata associated to the ChunkID set
22
  * @param[in] meta_len length of the metadata
23
  * @param[in] buff Buffer that will be filled with the bit stream obtained as a coding of the above parameters
24
  * @param[in] buff_len length of the buffer that will contain the bit stream
25
  * @return 0 on success, <0 on error
26
  */
27
int encodeChunkSignaling(const struct chunkID_set *h, const void *meta, int meta_len, uint8_t *buff, int buff_len);
28

    
29
/**
30
  * Decode the bit stream contained int the buffer, filling the other parameters. This is the dual of the encode function.
31
  *  
32
  * @param[in] meta pointer to the metadata associated to the ChunkID set
33
  * @param[in] meta_len length of the metadata
34
  * @param[in] buff Buffer which contain the bit stream to decode, filling the above parameters
35
  * @param[in] buff_len length of the buffer that contain the bit stream
36
  * @return a pointer to the chunk ID set on success, NULL on error
37
  */
38
struct chunkID_set *decodeChunkSignaling(void **meta, int *meta_len, const uint8_t *buff, int buff_len);
39

    
40
/**
41
  * Decode the bit stream contained int the buffer, transforming it in a chunk
42
  * ID set.
43
  *  
44
  * @param[in] buff Buffer which contain the bit stream to decode
45
  * @param[in] buff_len length of the buffer that contain the bit stream
46
  * @param meta pointer to the metadata
47
  * @param meta_len metadata lenght
48
  */
49
#endif /* TRADE_SIG_LA_H */