Revision df98cd3a som/TopologyManager/topo_proto.c

View differences:

som/TopologyManager/topo_proto.c
38 38
  return p - payload;
39 39
}
40 40

  
41
int topo_reply(const struct peer_cache *c, struct peer_cache *local_cache)
41
static int topo_reply(const struct peer_cache *c, struct peer_cache *local_cache, int protocol, int type)
42 42
{
43 43
  uint8_t pkt[MAX_MSG_SIZE];
44 44
  struct topo_header *h = (struct topo_header *)pkt;
......
53 53
  }
54 54
#endif
55 55
  dst = nodeid(c, 0);
56
  h->protocol = MSG_TYPE_TOPOLOGY;
57
  h->type = NCAST_REPLY;
56
  h->protocol = protocol;
57
  h->type = type;
58 58
  len = ncast_payload_fill(pkt + sizeof(struct topo_header), MAX_MSG_SIZE - sizeof(struct topo_header), local_cache, dst);
59 59

  
60 60
  res = len > 0 ? send_to_peer(nodeid(myEntry, 0), dst, pkt, sizeof(struct topo_header) + len) : len;
......
62 62
  return res;
63 63
}
64 64

  
65
int topo_query_peer(struct peer_cache *local_cache, struct nodeID *dst)
65
static int topo_query_peer(struct peer_cache *local_cache, struct nodeID *dst, int protocol, int type)
66 66
{
67 67
  uint8_t pkt[MAX_MSG_SIZE];
68 68
  struct topo_header *h = (struct topo_header *)pkt;
69 69
  int len;
70 70

  
71
  h->protocol = MSG_TYPE_TOPOLOGY;
72
  h->type = NCAST_QUERY;
71
  h->protocol = protocol;
72
  h->type = type;
73 73
  len = ncast_payload_fill(pkt + sizeof(struct topo_header), MAX_MSG_SIZE - sizeof(struct topo_header), local_cache, dst);
74 74
  return len > 0  ? send_to_peer(nodeid(myEntry, 0), dst, pkt, sizeof(struct topo_header) + len) : len;
75 75
}
76 76

  
77
int topo_query(struct peer_cache *local_cache)
77
int ncast_reply(const struct peer_cache *c, struct peer_cache *local_cache)
78
{
79
  return topo_reply(c, local_cache, MSG_TYPE_TOPOLOGY, NCAST_REPLY);
80
}
81

  
82
int tman_reply(const struct peer_cache *c, struct peer_cache *local_cache)
83
{
84
  return topo_reply(c, local_cache, MSG_TYPE_TMAN, TMAN_REPLY);
85
}
86

  
87
int ncast_query_peer(struct peer_cache *local_cache, struct nodeID *dst)
88
{
89
  return topo_query_peer(local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY);
90
}
91

  
92
int tman_query_peer(struct peer_cache *local_cache, struct nodeID *dst)
93
{
94
  return topo_query_peer(local_cache, dst, MSG_TYPE_TMAN, TMAN_QUERY);
95
}
96

  
97
int ncast_query(struct peer_cache *local_cache)
78 98
{
79 99
  struct nodeID *dst;
80 100

  
81
  dst = rand_peer(local_cache);
101
  dst = rand_peer(local_cache, NULL);
82 102
  if (dst == NULL) {
83 103
    return 0;
84 104
  }
85
  return topo_query_peer(local_cache, dst);
105
  return topo_query_peer(local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY);
86 106
}
87 107

  
88 108
int topo_proto_metadata_update(struct nodeID *peer, void *meta, int meta_size)

Also available in: Unified diff