Revision e2b6ad48 src/TopologyManager/dummy.c

View differences:

src/TopologyManager/dummy.c
4 4
 *  This is free software; see lgpl-2.1.txt
5 5
 */
6 6

  
7
#include <sys/time.h>
7 8
#include <stdint.h>
9
#include <stdlib.h>
8 10
#include <stdio.h>
9 11

  
12

  
10 13
#include "net_helper.h"
11
#include "topmanager.h"
14
#include "peersampler_iface.h"
12 15

  
13 16
#define MAX_PEERS 5000
14
static struct socketID *table[MAX_PEERS];
17
static struct nodeID *table[MAX_PEERS];
15 18

  
16
int topInit(struct nodeID *myID, void *metadata, int metadata_size, const char *config)
19
static int dummy_init(struct nodeID *myID, void *metadata, int metadata_size, const char *config)
17 20
{
18 21
  FILE *f;
19 22
  int i = 0;
......
27 30
    res = fscanf(f, "%s %d\n", addr, &port);
28 31
    if ((res == 2) && (i < MAX_PEERS - 1)) {
29 32
fprintf(stderr, "Creating table[%d]\n", i);
30
      table[i++] = create_socket(addr, port);
33
      table[i++] = create_node(addr, port);
31 34
    }
32 35
  }
33 36
  table[i] = NULL;
......
35 38
  return i;
36 39
}
37 40

  
38
int topAddNeighbour(struct socketID *neighbour)
41
static int dummy_change_metadata(void *metadata, int metadata_size)
42
{
43
  /* Metadata not supported: fail! */
44
  return -1;
45
}
46

  
47
static int dummy_add_neighbour(struct nodeID *neighbour, void *metadata, int metadata_size)
39 48
{
40 49
  int i;
41 50

  
......
46 55
  return i;
47 56
}
48 57

  
49
int topParseData(const struct connectionID *conn, const uint8_t *buff, int len)
58
static int dummy_parse_data(const uint8_t *buff, int len)
50 59
{
51 60
  /* FAKE! */
52 61
  return 0;
53 62
}
54 63

  
55
const struct socketID **topGetNeighbourhood(int *n)
64
static const struct nodeID **dummy_get_neighbourhood(int *n)
56 65
{
57 66
  for (*n = 0; table[*n] != NULL; (*n)++) {
58 67
fprintf(stderr, "Checking table[%d]\n", *n);
59 68
  }
60
  return (const struct socketID **)table;
69
  return (const struct nodeID **)table;
70
}
71

  
72
static const void *dummy_get_metadata(int *metadata_size)
73
{
74
  /* Metadata not supported: fail! */
75
  *metadata_size = -1;
76

  
77
  return NULL;
78
}
79

  
80
static int dummy_grow_neighbourhood(int n)
81
{
82
  return -1;
83
}
84

  
85
static int dummy_shrink_neighbourhood(int n)
86
{
87
  return -1;
88
}
89

  
90
static int dummy_remove_neighbour(struct nodeID *neighbour)
91
{
92
  return -1;
61 93
}
94

  
95

  
96
struct peersampler_iface dummy = {
97
  .init = dummy_init,
98
  .change_metadata = dummy_change_metadata,
99
  .add_neighbour = dummy_add_neighbour,
100
  .parse_data = dummy_parse_data,
101
  .get_neighbourhood = dummy_get_neighbourhood,
102
  .get_metadata = dummy_get_metadata,
103
  .grow_neighbourhood = dummy_grow_neighbourhood,
104
  .shrink_neighbourhood = dummy_shrink_neighbourhood,
105
  .remove_neighbour = dummy_remove_neighbour,
106
};
107

  

Also available in: Unified diff