Commit 74c1ff37 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make the xroute table private to xroute.c.

parent a08dde85
...@@ -962,11 +962,19 @@ dump_route_callback(struct route *route, void *closure) ...@@ -962,11 +962,19 @@ dump_route_callback(struct route *route, void *closure)
route_feasible(route) ? " (feasible)" : ""); route_feasible(route) ? " (feasible)" : "");
} }
static void
dump_xroute_callback(struct xroute *xroute, void *closure)
{
FILE *out = (FILE*)closure;
fprintf(out, "%s metric %d (exported)\n",
format_prefix(xroute->prefix, xroute->plen),
xroute->metric);
}
static void static void
dump_tables(FILE *out) dump_tables(FILE *out)
{ {
struct neighbour *neigh; struct neighbour *neigh;
int i;
fprintf(out, "\n"); fprintf(out, "\n");
...@@ -982,11 +990,7 @@ dump_tables(FILE *out) ...@@ -982,11 +990,7 @@ dump_tables(FILE *out)
neigh->ifp->channel, neigh->ifp->channel,
if_up(neigh->ifp) ? "" : " (down)"); if_up(neigh->ifp) ? "" : " (down)");
} }
for(i = 0; i < numxroutes; i++) { for_all_xroutes(dump_xroute_callback, out);
fprintf(out, "%s metric %d (exported)\n",
format_prefix(xroutes[i].prefix, xroutes[i].plen),
xroutes[i].metric);
}
for_all_routes(dump_route_callback, out); for_all_routes(dump_route_callback, out);
fflush(out); fflush(out);
} }
......
...@@ -222,6 +222,12 @@ local_notify_route(struct route *route, int kind) ...@@ -222,6 +222,12 @@ local_notify_route(struct route *route, int kind)
return; return;
} }
static void
local_notify_xroute_callback(struct xroute *xroute, void *closure)
{
local_notify_xroute(xroute, LOCAL_ADD);
}
static void static void
local_notify_route_callback(struct route *route, void *closure) local_notify_route_callback(struct route *route, void *closure)
{ {
...@@ -231,7 +237,7 @@ local_notify_route_callback(struct route *route, void *closure) ...@@ -231,7 +237,7 @@ local_notify_route_callback(struct route *route, void *closure)
void void
local_notify_all() local_notify_all()
{ {
int i, rc; int rc;
struct neighbour *neigh; struct neighbour *neigh;
const char *header = "BABEL 0.0\n"; const char *header = "BABEL 0.0\n";
...@@ -246,8 +252,7 @@ local_notify_all() ...@@ -246,8 +252,7 @@ local_notify_all()
FOR_ALL_NEIGHBOURS(neigh) { FOR_ALL_NEIGHBOURS(neigh) {
local_notify_neighbour(neigh, LOCAL_ADD); local_notify_neighbour(neigh, LOCAL_ADD);
} }
for(i = 0; i < numxroutes; i++) for_all_xroutes(local_notify_xroute_callback, NULL);
local_notify_xroute(&xroutes[i], LOCAL_ADD);
for_all_routes(local_notify_route_callback, NULL); for_all_routes(local_notify_route_callback, NULL);
return; return;
......
...@@ -1181,11 +1181,16 @@ update_myseqno() ...@@ -1181,11 +1181,16 @@ update_myseqno()
seqno_time = now; seqno_time = now;
} }
static void
send_xroute_update_callback(struct xroute *xroute, void *closure)
{
struct interface *ifp = (struct interface*)closure;
send_update(ifp, 0, xroute->prefix, xroute->plen);
}
void void
send_self_update(struct interface *ifp) send_self_update(struct interface *ifp)
{ {
int i;
if(ifp == NULL) { if(ifp == NULL) {
struct interface *ifp_aux; struct interface *ifp_aux;
FOR_ALL_INTERFACES(ifp_aux) { FOR_ALL_INTERFACES(ifp_aux) {
...@@ -1198,8 +1203,7 @@ send_self_update(struct interface *ifp) ...@@ -1198,8 +1203,7 @@ send_self_update(struct interface *ifp)
if(!interface_idle(ifp)) { if(!interface_idle(ifp)) {
debugf("Sending self update to %s.\n", ifp->name); debugf("Sending self update to %s.\n", ifp->name);
for(i = 0; i < numxroutes; i++) for_all_xroutes(send_xroute_update_callback, ifp);
send_update(ifp, 0, xroutes[i].prefix, xroutes[i].plen);
} }
} }
......
...@@ -39,9 +39,8 @@ THE SOFTWARE. ...@@ -39,9 +39,8 @@ THE SOFTWARE.
#include "interface.h" #include "interface.h"
#include "local.h" #include "local.h"
struct xroute *xroutes; static struct xroute *xroutes;
int numxroutes = 0; static int numxroutes = 0, maxxroutes = 0;
int maxxroutes = 0;
struct xroute * struct xroute *
find_xroute(const unsigned char *prefix, unsigned char plen) find_xroute(const unsigned char *prefix, unsigned char plen)
...@@ -120,6 +119,15 @@ add_xroute(unsigned char prefix[16], unsigned char plen, ...@@ -120,6 +119,15 @@ add_xroute(unsigned char prefix[16], unsigned char plen,
return 1; return 1;
} }
void
for_all_xroutes(void (*f)(struct xroute*, void*), void *closure)
{
int i;
for(i = 0; i < numxroutes; i++)
(*f)(&xroutes[i], closure);
}
int int
check_xroutes(int send_updates) check_xroutes(int send_updates)
{ {
......
...@@ -28,11 +28,9 @@ struct xroute { ...@@ -28,11 +28,9 @@ struct xroute {
int proto; int proto;
}; };
extern struct xroute *xroutes;
extern int numxroutes;
struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen); struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen);
void flush_xroute(struct xroute *xroute); void flush_xroute(struct xroute *xroute);
int add_xroute(unsigned char prefix[16], unsigned char plen, int add_xroute(unsigned char prefix[16], unsigned char plen,
unsigned short metric, unsigned int ifindex, int proto); unsigned short metric, unsigned int ifindex, int proto);
void for_all_xroutes(void (*f)(struct xroute*, void*), void *closure);
int check_xroutes(int send_updates); int check_xroutes(int send_updates);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment