Revision 3a85536f topology.c

View differences:

topology.c
18 18
#include <grapes_msg_types.h>
19 19
#include <topmanager.h>
20 20
#include <tman.h>
21
#include <int_coding.h>
21 22

  
22 23
#include "compatibility/timer.h"
23 24

  
......
304 305
	topAddToBlackList(id);
305 306
}
306 307

  
307
//TODO: send metadata as well
308
int encodeMetaData(uint8_t *buff, int buff_len)
309
{
310
  if (buff_len < 2 + 2 + 2 + 4 + 4) {
311
    /* Not enough space... */
312
    return -1;
313
  }
314
  int16_cpy(buff, my_metadata.cb_size);
315
  int16_cpy(buff + 2, my_metadata.cps);
316
  int_cpy(buff + 4, my_metadata.capacity);
317
  int_cpy(buff + 12, my_metadata.recv_delay);
318
  }
319

  
308 320
static int send_topo_msg(struct nodeID *dst, uint8_t type)
309 321
{
310
  char msg[2];
311
  msg[0] = MSG_TYPE_STREAMER_TOPOLOGY;
312
  msg[1] = type;
322
  int res = 0;
323
  int buff_len = 2 + sizeof(struct metadata);
313 324
  
314
  return send_to_peer(me, dst, msg, 2);
325
  uint8_t *buff = malloc(buff_len);
326
  buff[0] = MSG_TYPE_STREAMER_TOPOLOGY;
327
  buff[1] = type;
328
  
329
  encodeMetaData(buff + 2, buff_len);
330
    
331
  res = send_to_peer(me, dst, buff, buff_len);
332
  free(buff);
333
  
334
  return res;
315 335
}
316 336

  
317 337
static void add_peer(const struct nodeID *id, const struct metadata *m, bool outgoing, bool incoming)

Also available in: Unified diff