Revision 4a9d32c1

View differences:

chunk_signaling.c
47 47
  return p;
48 48
}
49 49

  
50
int sendSignalling(int type, const struct nodeID *to_id, const struct nodeID *owner_id, struct chunkID_set *cset, int max_deliver, int trans_id)
50
int sendSignalling(int type, const struct nodeID *to_id, const struct nodeID *owner_id, struct chunkID_set *cset, int max_deliver, int cb_size, int trans_id)
51 51
{
52 52
    int buff_len, meta_len, msg_len, ret;
53 53
    uint8_t *buff;
......
59 59
    sigmex = (struct sig_nal*) meta;
60 60
    sigmex->type = type;
61 61
    sigmex->max_deliver = max_deliver;
62
    sigmex->cb_size = cb_size;
62 63
    sigmex->trans_id = trans_id;
63 64
    meta_len = sizeof(*sigmex)-1;
64 65
      sigmex->third_peer = 0;
......
98 99
 * @param[in] trans_id transaction number associated with this send
99 100
 * @return 0 on success, <0 on error
100 101
 */
101
int sendBufferMap(const struct nodeID *to_id, const struct nodeID *owner_id, struct chunkID_set *bmap, int trans_id) {
102
  return sendSignalling(MSG_SIG_BMOFF, to_id, owner_id, bmap, 0, trans_id);
102
int sendBufferMap(const struct nodeID *to_id, const struct nodeID *owner_id, struct chunkID_set *bmap, int cb_size, int trans_id) {
103
  return sendSignalling(MSG_SIG_BMOFF, to_id, owner_id, bmap, 0, cb_size, trans_id);
103 104
}
104 105

  
105
int sendMyBufferMap(const struct nodeID *to_id, struct chunkID_set *bmap, int trans_id)
106
int sendMyBufferMap(const struct nodeID *to_id, struct chunkID_set *bmap, int cb_size, int trans_id)
106 107
{
107
  return sendBufferMap(to_id, localID, bmap, trans_id);
108
  return sendBufferMap(to_id, localID, bmap, cb_size, trans_id);
108 109
}
109 110

  
110 111
int offerChunks(const struct nodeID *to_id, struct chunkID_set *cset, int max_deliver, int trans_id) {
111
  return sendSignalling(MSG_SIG_OFF, to_id, NULL, cset, max_deliver, trans_id);
112
  return sendSignalling(MSG_SIG_OFF, to_id, NULL, cset, max_deliver, -1, trans_id);
112 113
}
113 114

  
114 115
int acceptChunks(const struct nodeID *to_id, struct chunkID_set *cset, int max_deliver, int trans_id) {
115
  return sendSignalling(MSG_SIG_ACC, to_id, NULL, cset, max_deliver, trans_id);
116
  return sendSignalling(MSG_SIG_ACC, to_id, NULL, cset, max_deliver, -1, trans_id);
116 117
}
117 118

  
118 119

  
......
120 121
///        RECEIVE       ///
121 122
/// ==================== ///
122 123

  
123
void bmap_received(const struct nodeID *fromid, const struct nodeID *ownerid, struct chunkID_set *c_set, int trans_id) {
124
void bmap_received(const struct nodeID *fromid, const struct nodeID *ownerid, struct chunkID_set *c_set, int cb_size, int trans_id) {
124 125
  struct peer *owner = nodeid_to_peer(ownerid,1);
125 126
  if (owner) {	//now we have it almost sure
126 127
    chunkID_set_union(owner->bmap,c_set);	//don't send it back
128
    owner->cb_size = cb_size;
127 129
    gettimeofday(&owner->bmap_timestamp, NULL);
128 130
  }
129 131
}
......
165 167
        {
166 168
          int dummy;
167 169
          struct nodeID *ownerid = nodeid_undump(&(signal->third_peer),&dummy);
168
          bmap_received(fromid, ownerid, c_set, signal->trans_id);
170
          bmap_received(fromid, ownerid, c_set, signal->cb_size, signal->trans_id);
169 171
          free(ownerid);
170 172
          break;
171 173
        }
chunk_signaling.h
21 21
struct sig_nal {
22 22
    uint8_t type;//type of signal.
23 23
    uint8_t max_deliver;//Max number of chunks to deliver.
24
    uint16_t cb_size;
24 25
    uint16_t trans_id;//future use...
25 26
    uint8_t third_peer;//for buffer map exchange from other peers, just the first byte!
26 27
} __attribute__((packed));
......
28 29

  
29 30
int sigParseData(const struct nodeID *from_id, uint8_t *buff, int buff_len);
30 31

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

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

  
35 36
int offerChunks(const struct nodeID *to_id, struct chunkID_set *cset, int max_deliver, int trans_id);
36 37

  

Also available in: Unified diff