Statistics
| Branch: | Revision:

grapes / include / trade_msg_la.h @ b9e0d721

History | View | Annotate | Download (1.74 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
 * @image html SOM_Internals.png "Data Exchange Protocol of the SOM module" width=50
8
 */
9
 
10
 /**
11
  * Encode a sequence of information, filling the buffer with the corresponding bit stream.
12
  * 
13
  * Encode a sequence of information given as parameters and fills a buffer (given as parameter) with the corresponding bit stream.
14
  * 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 
15
  * add this bit stream in piggybacking
16
  * 
17
  * @param[in] c Chunk to send 
18
  * @param[in] buff Buffer that will be filled with the bit stream obtained as a coding of the above parameters
19
  * @param[in] buff_len length of the buffer that will contain the bit stream
20
  * @return the lenght of the encoded bitstream (in bytes) on success, <0 on error
21
  */
22
int encodeChunk(const struct chunk *c, uint8_t *buff, int buff_len);
23

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