Revision f3ab0d6d src/TopologyManager/ncast_proto.c

View differences:

src/TopologyManager/ncast_proto.c
15 15
#include "ncast_proto.h"
16 16
#include "grapes_msg_types.h"
17 17

  
18
int ncast_reply(const struct peer_cache *c, struct peer_cache *local_cache)
18
struct ncast_proto_context{
19
  struct topo_context *context;
20
};
21

  
22
struct ncast_proto_context* ncast_proto_init(struct nodeID *s, void *meta, int meta_size){
23
  struct ncast_proto_context *con;
24
  con = malloc(sizeof(struct ncast_proto_context));
25

  
26
  if (!con) return NULL;
27

  
28
  con->context = topo_proto_init(s, meta, meta_size);
29
  if (!con->context){
30
    free(con);
31
    return NULL;
32
  }
33

  
34
  return con;    
35
}
36

  
37
int ncast_reply(struct ncast_proto_context *context, const struct peer_cache *c, struct peer_cache *local_cache)
19 38
{
20
  return topo_reply(c, local_cache, MSG_TYPE_TOPOLOGY, NCAST_REPLY, 0, 1);
39
  return topo_reply(context->context, c, local_cache, MSG_TYPE_TOPOLOGY, NCAST_REPLY, 0, 1);
21 40
}
22 41

  
23
int ncast_query_peer(struct peer_cache *local_cache, struct nodeID *dst)
42
int ncast_query_peer(struct ncast_proto_context *context, struct peer_cache *local_cache, struct nodeID *dst)
24 43
{
25
  return topo_query_peer(local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY, 0);
44
  return topo_query_peer(context->context, local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY, 0);
26 45
}
27 46

  
28
int ncast_query(struct peer_cache *local_cache)
47
int ncast_query(struct ncast_proto_context *context, struct peer_cache *local_cache)
29 48
{
30 49
  struct nodeID *dst;
31 50

  
......
33 52
  if (dst == NULL) {
34 53
    return 0;
35 54
  }
36
  return topo_query_peer(local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY, 0);
55
  return topo_query_peer(context->context, local_cache, dst, MSG_TYPE_TOPOLOGY, NCAST_QUERY, 0);
56
}
57

  
58
int ncast_proto_metadata_update(struct ncast_proto_context *context, void *meta, int meta_size){
59
  return topo_proto_metadata_update(context->context, meta, meta_size);
37 60
}

Also available in: Unified diff