Statistics
| Branch: | Revision:

grapes / include / trade_msg_ha.h @ master

History | View | Annotate | Download (2.23 KB)

1
/** @file trade_msg_ha.h
2
 *
3
 * @brief Chunk Delivery API - Higher Abstraction
4
 *
5
 * The Chunk Delivery HA provides the primitives for effective chunks exchange with other peers. <br>
6
 * This is a part of the Data Exchange Protocol which provides high level abstraction for sending chunks to a target peers.
7
 * See @link chunk_sending_test.c chunk_sending_test.c @endlink for an usage example
8
 *
9
 */
10

    
11
/** @example chunk_sending_test.c
12
 * 
13
 * A test program showing how to use the chunk delivery API.
14
 *
15
 */
16

    
17
#include "chunk.h"
18

    
19
/**
20
 * @brief Parse an incoming chunk message, providing the chunk structure and transaction ID.
21
 * @return 1 on success, <0 on error.
22
 *
23
 * @param[in] buff containing the incoming message.
24
 * @param[in] buff_len length of the buffer.
25
 * @param[out] c the chunk filled with data (an already allocated chunk structure must be passed!).
26
 * @param[out] transid the transaction ID.
27
 * @return 1 on success, <0 on error.
28
 */
29
int parseChunkMsg(const uint8_t *buff, int buff_len, struct chunk *c, uint16_t *transid);
30

    
31
/**
32
  * @brief Send a Chunk to a target Peer
33
  *
34
  * Send a single Chunk to a given Peer
35
  *
36
  * @param[in] to destination peer
37
  * @param[in] c Chunk to send
38
  * @param[in] transid the ID of transaction this send belongs to (if any)
39
  * @return 0 on success, <0 on error
40
  */
41
int sendChunk(const struct nodeID * localID, const struct nodeID *to, const struct chunk *c, uint16_t transid);
42

    
43
/**
44
  * @brief Init the Chunk trading internals.
45
  *
46
  * Initialization facility.
47
  * @param myID address of this peer
48
  * @return >= 0 on success, <0 on error
49
  */
50
int chunkDeliveryInit(struct nodeID *myID);
51

    
52

    
53
#if 0
54
/** 
55
  * @brief Notification function for a Chunk arrival
56
  */
57
typedef int (*ChunkNotification)(struct peer *from, struct chunk  *c);
58

59
/**
60
  * @brief Register a notification for Chunk arrival
61
  * 
62
  * Register a notification function that should be called at every Chunk arrival
63
  *
64
  * @param[in] som Handle to the enclosing SOM instance
65
  * @param[in] p notify a send of chunk from Peer p, or from any peer if NULL
66
  * @param[in] fn pointer to the notification function.
67
  * @return a handle to the notification or NULL on error @see unregisterSendChunk
68
  */
69
void registerSendChunkNotifier(struct peer *p, ChunkNotification *fn);
70
#endif