Revision fe9f1a6d nest/route.h

View differences:

nest/route.h
35 35
struct fib_node {
36 36
  struct fib_node *next;		/* Next in hash chain */
37 37
  struct fib_iterator *readers;		/* List of readers of this node */
38
  byte pxlen;
39
  byte flags;				/* User-defined */
40
  byte x0, x1;				/* User-defined */
41
  u32 uid;				/* Unique ID based on hash */
42
  ip_addr prefix;			/* In host order */
38
  byte flags;				/* User-defined, will be removed */
39
  u32 uid;				/* Unique ID based on hash, will be removed */
40
  net_addr addr[0];
43 41
};
44 42

  
45 43
struct fib_iterator {			/* See lib/slists.h for an explanation */
......
50 48
  uint hash;
51 49
};
52 50

  
53
typedef void (*fib_init_func)(struct fib_node *);
51
typedef void (*fib_init_fn)(void *);
54 52

  
55 53
struct fib {
56 54
  pool *fib_pool;			/* Pool holding all our data */
......
59 57
  uint hash_size;			/* Number of hash table entries (a power of two) */
60 58
  uint hash_order;			/* Binary logarithm of hash_size */
61 59
  uint hash_shift;			/* 16 - hash_log */
60
  uint addr_type;			/* Type of address data stored in fib (NET_*) */
61
  uint node_size;	/* XXXX */
62
  uint node_offset;	/* XXXX */
62 63
  uint entries;				/* Number of entries */
63 64
  uint entries_min, entries_max;	/* Entry count limits (else start rehashing) */
64
  fib_init_func init;			/* Constructor */
65
  fib_init_fn init;			/* Constructor */
65 66
};
66 67

  
67
void fib_init(struct fib *, pool *, unsigned node_size, unsigned hash_order, fib_init_func init);
68
void *fib_find(struct fib *, ip_addr *, int);	/* Find or return NULL if doesn't exist */
69
void *fib_get(struct fib *, ip_addr *, int); 	/* Find or create new if nonexistent */
70
void *fib_route(struct fib *, ip_addr, int);	/* Longest-match routing lookup */
68
void fib_init(struct fib *f, pool *p, uint addr_type, uint node_size, uint node_offset, uint hash_order, fib_init_fn init);
69
void *fib_find(struct fib *, net_addr *);	/* Find or return NULL if doesn't exist */
70
void *fib_get(struct fib *, net_addr *); 	/* Find or create new if nonexistent */
71
void *fib_route(struct fib *, net_addr *);	/* Longest-match routing lookup */
71 72
void fib_delete(struct fib *, void *);	/* Remove fib entry */
72 73
void fib_free(struct fib *);		/* Destroy the fib */
73 74
void fib_check(struct fib *);		/* Consistency check for debugging */
......
77 78
void fit_put(struct fib_iterator *, struct fib_node *);
78 79
void fit_put_next(struct fib *f, struct fib_iterator *i, struct fib_node *n, uint hpos);
79 80

  
80

  
81
/* XXXX: return user entries */
81 82
#define FIB_WALK(fib, z) do {					\
82 83
	struct fib_node *z, **ff = (fib)->hash_table;		\
83 84
	uint count = (fib)->hash_size;				\
......
126 127
  char *name;
127 128
  struct rtable *table;
128 129
  struct proto_config *krt_attached;	/* Kernel syncer attached to this table */
130
  uint addr_type;			/* Type of address data stored in table (NET_*) */
129 131
  int gc_max_ops;			/* Maximum number of operations before GC is run */
130 132
  int gc_min_time;			/* Minimum time between two consecutive GC runs */
131 133
  byte sorted;				/* Routes of network are sorted according to rte_better() */
......
136 138
  struct fib fib;
137 139
  char *name;				/* Name of this table */
138 140
  list hooks;				/* List of announcement hooks */
141
  uint addr_type;			/* Type of address data stored in table (NET_*) */
139 142
  int pipe_busy;			/* Pipe loop detection */
140 143
  int use_count;			/* Number of protocols using this table */
141 144
  struct hostcache *hostcache;
......
160 163
#define RPS_RUNNING	2
161 164

  
162 165
typedef struct network {
163
  struct fib_node n;			/* FIB flags reserved for kernel syncer */
164 166
  struct rte *routes;			/* Available routes for this network */
167
  struct fib_node n;			/* FIB flags reserved for kernel syncer */
165 168
} net;
166 169

  
167 170
struct hostcache {
......
262 265
void rt_lock_table(rtable *);
263 266
void rt_unlock_table(rtable *);
264 267
void rt_setup(pool *, rtable *, char *, struct rtable_config *);
265
static inline net *net_find(rtable *tab, ip_addr addr, unsigned len) { return (net *) fib_find(&tab->fib, &addr, len); }
266
static inline net *net_get(rtable *tab, ip_addr addr, unsigned len) { return (net *) fib_get(&tab->fib, &addr, len); }
268
static inline net *net_find(rtable *tab, net_addr *addr) { return (net *) fib_find(&tab->fib, addr); }
269
static inline net *net_get(rtable *tab, net_addr *addr) { return (net *) fib_get(&tab->fib, addr); }
270

  
271
static inline net *net_find_ipa(rtable *tab, ip_addr px, uint pxlen)
272
{ net_addr addr; net_fill_ipa(&addr, px, pxlen); return (net *) fib_find(&tab->fib, &addr); }
273
static inline net *net_get_ipa(rtable *tab, ip_addr px, uint pxlen)
274
{ net_addr addr; net_fill_ipa(&addr, px, pxlen); return (net *) fib_get(&tab->fib, &addr); }
275

  
267 276
rte *rte_find(net *net, struct rte_src *src);
268 277
rte *rte_get_temp(struct rta *);
269 278
void rte_update2(struct announce_hook *ah, net *net, rte *new, struct rte_src *src);
270 279
static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_ahook, net, new, p->main_source); }
271 280
void rte_discard(rtable *tab, rte *old);
272
int rt_examine(rtable *t, ip_addr prefix, int pxlen, struct proto *p, struct filter *filter);
281
int rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter);
273 282
rte *rt_export_merged(struct announce_hook *ah, net *net, rte **rt_free, struct ea_list **tmpa, int silent);
274 283
void rt_refresh_begin(rtable *t, struct announce_hook *ah);
275 284
void rt_refresh_end(rtable *t, struct announce_hook *ah);
......
283 292
int rt_feed_baby(struct proto *p);
284 293
void rt_feed_baby_abort(struct proto *p);
285 294
int rt_prune_loop(void);
286
struct rtable_config *rt_new_table(struct symbol *s);
295
struct rtable_config *rt_new_table(struct symbol *s, uint addr_type);
287 296

  
288 297
static inline void
289 298
rt_mark_for_prune(rtable *tab)

Also available in: Unified diff