Statistics
| Branch: | Revision:

grapes / include / trade_sig_la.h @ master

History | View | Annotate | Download (2.09 KB)

1 997f0e20 Luca Abeni
/** @file trade_sig_la.h
2
 *
3 7fcd5e5c MarcoBiazzini
 * @brief Chunk Signaling  API - Lower Abstraction
4 997f0e20 Luca Abeni
 *
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 4affd2bf MarcoBiazzini

7 997f0e20 Luca Abeni
 */
8
9
#ifndef TRADE_SIG_LA_H 
10
#define TRADE_SIG_LA_H
11
12
 /**
13 9e4a282c MarcoBiazzini
  * @brief Decode the bit streamEncode a sequence of information, filling the buffer with the corresponding bit stream.
14 997f0e20 Luca Abeni
  * 
15
  * Encode a sequence of information given as parameters and fills a buffer (given as parameter) with the corresponding bit stream.
16
  * 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 
17
  * add this bit stream in piggybacking
18
  * 
19
  * @param[in] h set of ChunkIDs
20
  * @param[in] meta metadata associated to the ChunkID set
21
  * @param[in] meta_len length of the metadata
22
  * @param[in] buff Buffer that will be filled with the bit stream obtained as a coding of the above parameters
23
  * @param[in] buff_len length of the buffer that will contain the bit stream
24
  * @return 0 on success, <0 on error
25
  */
26
int encodeChunkSignaling(const struct chunkID_set *h, const void *meta, int meta_len, uint8_t *buff, int buff_len);
27
28
/**
29 8b5d213f MarcoBiazzini
  * @brief Decode the bit stream.
30
  *
31 997f0e20 Luca Abeni
  * Decode the bit stream contained int the buffer, filling the other parameters. This is the dual of the encode function.
32
  *  
33
  * @param[in] meta pointer to the metadata associated to the ChunkID set
34
  * @param[in] meta_len length of the metadata
35
  * @param[in] buff Buffer which contain the bit stream to decode, filling the above parameters
36
  * @param[in] buff_len length of the buffer that contain the bit stream
37 31d92fdb Alessandro Russo
  * @return a pointer to the chunk ID set or NULL with meta-data when on success, NULL with empty values on error.
38 997f0e20 Luca Abeni
  */
39
struct chunkID_set *decodeChunkSignaling(void **meta, int *meta_len, const uint8_t *buff, int buff_len);
40
41 9e4a282c MarcoBiazzini
42 997f0e20 Luca Abeni
#endif /* TRADE_SIG_LA_H */