Statistics
| Branch: | Revision:

grapes / include / trade_msg_la.h @ edd2bc82

History | View | Annotate | Download (1.69 KB)

1
/** @file trade_msg_la.h
2
 *
3
 * @brief Chunk Delivery API - Lower Abstraction
4
 *
5
 * The Chunk Delivery LA provides the primitives to encode the send operation of a Chunk to a target Peer and decode the Chunk reception from a Peer. The former returns a bit stream obteined by the encoding of the Chunk to send, it is the packet that will be sent. The latter decode a packet received, the bit stream, in the corresponding Chunk.
6

7
 */
8
 
9
 /**
10
  * Encode a sequence of information, filling the buffer with the corresponding bit stream.
11
  * 
12
  * Encode a sequence of information given as parameters and fills a buffer (given as parameter) with the corresponding bit stream.
13
  * The main reason to encode a return the bit stream is the possibility to either send directly a packet with the encoded bit stream, or 
14
  * add this bit stream in piggybacking
15
  * 
16
  * @param[in] c Chunk to send 
17
  * @param[in] buff Buffer that will be filled with the bit stream obtained as a coding of the above parameters
18
  * @param[in] buff_len length of the buffer that will contain the bit stream
19
  * @return the lenght of the encoded bitstream (in bytes) on success, <0 on error
20
  */
21
int encodeChunk(const struct chunk *c, uint8_t *buff, int buff_len);
22

    
23
/**
24
  * @brief Decode the bit stream.
25
  *
26
  * Decode the bit stream contained int the buffer, filling the other parameters. This is the dual of the encode function.
27
  *  
28
  * @param[in] c Chunks that has been transmitted
29
  * @param[in] buff Buffer which contain the bit stream to decode, filling the above parameters
30
  * @param[in] buff_len length of the buffer that contain the bit stream
31
  * @return 0 on success, <0 on error
32
  */
33
int decodeChunk(struct chunk *c, const uint8_t *buff, int buff_len);