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)
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
dump_tables(FILE *out)
{
struct neighbour *neigh;
int i;
fprintf(out, "\n");
......@@ -982,11 +990,7 @@ dump_tables(FILE *out)
neigh->ifp->channel,
if_up(neigh->ifp) ? "" : " (down)");
}
for(i = 0; i < numxroutes; i++) {
fprintf(out, "%s metric %d (exported)\n",
format_prefix(xroutes[i].prefix, xroutes[i].plen),
xroutes[i].metric);
}
for_all_xroutes(dump_xroute_callback, out);
for_all_routes(dump_route_callback, out);
fflush(out);
}
......
......@@ -222,6 +222,12 @@ local_notify_route(struct route *route, int kind)
return;
}
static void
local_notify_xroute_callback(struct xroute *xroute, void *closure)
{
local_notify_xroute(xroute, LOCAL_ADD);
}
static void
local_notify_route_callback(struct route *route, void *closure)
{
......@@ -231,7 +237,7 @@ local_notify_route_callback(struct route *route, void *closure)
void
local_notify_all()
{
int i, rc;
int rc;
struct neighbour *neigh;
const char *header = "BABEL 0.0\n";
......@@ -246,8 +252,7 @@ local_notify_all()
FOR_ALL_NEIGHBOURS(neigh) {
local_notify_neighbour(neigh, LOCAL_ADD);
}
for(i = 0; i < numxroutes; i++)
local_notify_xroute(&xroutes[i], LOCAL_ADD);
for_all_xroutes(local_notify_xroute_callback, NULL);
for_all_routes(local_notify_route_callback, NULL);
return;
......
......@@ -1181,11 +1181,16 @@ update_myseqno()
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
send_self_update(struct interface *ifp)
{
int i;
if(ifp == NULL) {
struct interface *ifp_aux;
FOR_ALL_INTERFACES(ifp_aux) {
......@@ -1198,8 +1203,7 @@ send_self_update(struct interface *ifp)
if(!interface_idle(ifp)) {
debugf("Sending self update to %s.\n", ifp->name);
for(i = 0; i < numxroutes; i++)
send_update(ifp, 0, xroutes[i].prefix, xroutes[i].plen);
for_all_xroutes(send_xroute_update_callback, ifp);
}
}
......
......@@ -39,9 +39,8 @@ THE SOFTWARE.
#include "interface.h"
#include "local.h"
struct xroute *xroutes;
int numxroutes = 0;
int maxxroutes = 0;
static struct xroute *xroutes;
static int numxroutes = 0, maxxroutes = 0;
struct xroute *
find_xroute(const unsigned char *prefix, unsigned char plen)
......@@ -120,6 +119,15 @@ add_xroute(unsigned char prefix[16], unsigned char plen,
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
check_xroutes(int send_updates)
{
......
......@@ -28,11 +28,9 @@ struct xroute {
int proto;
};
extern struct xroute *xroutes;
extern int numxroutes;
struct xroute *find_xroute(const unsigned char *prefix, unsigned char plen);
void flush_xroute(struct xroute *xroute);
int add_xroute(unsigned char prefix[16], unsigned char plen,
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);
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