Statistics
| Branch: | Revision:

streamers / chunk_signaling.h @ fa81d544

History | View | Annotate | Download (1.14 KB)

1
#ifndef CHUNK_SIGNALING_H
2
#define CHUNK_SIGNALING_H
3

    
4
#include "chunkidset.h"
5

    
6
//Type of signaling message
7
//Request a ChunkIDSet
8
#define MSG_SIG_REQ 0
9
//Diliver a ChunkIDSet (reply to a request)
10
#define MSG_SIG_DEL 1
11
//Offer a ChunkIDSet
12
#define MSG_SIG_OFF 2
13
//Accept a ChunkIDSet (reply to an offer)
14
#define MSG_SIG_ACC 3
15
//Receive the BufferMap
16
#define MSG_SIG_BMOFF 4
17
//Request the BufferMap
18
#define MSG_SIG_BMREQ 5
19

    
20

    
21
struct sig_nal {
22
    uint8_t type;//type of signal.
23
    uint8_t max_deliver;//Max number of chunks to deliver.
24
    uint16_t trans_id;//future use...
25
    uint8_t third_peer;//for buffer map exchange from other peers, just the first byte!
26
} ;
27

    
28

    
29
int sigParseData(uint8_t *buff, int buff_len);
30

    
31
int sendBufferMap(const struct nodeID *to_id, const struct nodeID *owner_id, ChunkIDSet *bmap, int bmap_len, int trans_id);
32

    
33
int sendMyBufferMap(const struct nodeID *to_id, ChunkIDSet *bmap, int bmap_len, int trans_id);
34

    
35
/**
36
  * Init the chunk signaling stuff...
37
  *
38
  *
39
  * @param myID address of this peer
40
  * @param pset the peerset to use
41
  * @return >= 0 on success, <0 on error
42
  */
43
int sigInit(struct nodeID *myID, struct peerset *pset);
44

    
45
#endif