babeld: address FreeBSD "struct route" issue
FreeBSD system headers have their own "struct route", which made it
impossible to compile babeld. Switching babeld to "struct babel_route".
diff --git a/babeld/message.c b/babeld/message.c
index bfb1762..57d875f 100644
--- a/babeld/message.c
+++ b/babeld/message.c
@@ -854,7 +854,7 @@
{
babel_interface_nfo *babel_ifp = NULL;
struct xroute *xroute;
- struct route *route;
+ struct babel_route *route;
const unsigned char *last_prefix = NULL;
unsigned char last_plen = 0xFF;
int i;
@@ -1004,7 +1004,7 @@
if(ifp == NULL) {
struct interface *ifp_aux;
struct listnode *linklist_node = NULL;
- struct route *route;
+ struct babel_route *route;
FOR_ALL_INTERFACES(ifp_aux, linklist_node)
send_update(ifp_aux, urgent, prefix, plen);
if(prefix) {
@@ -1392,7 +1392,7 @@
unsigned short seqno, const unsigned char *id)
{
struct xroute *xroute;
- struct route *route;
+ struct babel_route *route;
struct neighbour *successor = NULL;
xroute = find_xroute(prefix, plen);
@@ -1438,7 +1438,7 @@
if(!successor || successor == neigh) {
/* We were about to forward a request to its requestor. Try to
find a different neighbour to forward the request to. */
- struct route *other_route;
+ struct babel_route *other_route;
other_route = find_best_route(prefix, plen, 0, neigh);
if(other_route && route_metric(other_route) < INFINITY)
diff --git a/babeld/route.c b/babeld/route.c
index e0c9d04..a92018f 100644
--- a/babeld/route.c
+++ b/babeld/route.c
@@ -58,14 +58,14 @@
#include "message.h"
#include "resend.h"
-static void consider_route(struct route *route);
+static void consider_route(struct babel_route *route);
-struct route *routes = NULL;
+struct babel_route *routes = NULL;
int numroutes = 0, maxroutes = 0;
int kernel_metric = 0;
int allow_duplicates = -1;
-struct route *
+struct babel_route *
find_route(const unsigned char *prefix, unsigned char plen,
struct neighbour *neigh, const unsigned char *nexthop)
{
@@ -79,7 +79,7 @@
return NULL;
}
-struct route *
+struct babel_route *
find_installed_route(const unsigned char *prefix, unsigned char plen)
{
int i;
@@ -91,7 +91,7 @@
}
void
-flush_route(struct route *route)
+flush_route(struct babel_route *route)
{
int i;
struct source *src;
@@ -111,18 +111,18 @@
src = route->src;
if(i != numroutes - 1)
- memcpy(routes + i, routes + numroutes - 1, sizeof(struct route));
+ memcpy(routes + i, routes + numroutes - 1, sizeof(struct babel_route));
numroutes--;
- VALGRIND_MAKE_MEM_UNDEFINED(routes + numroutes, sizeof(struct route));
+ VALGRIND_MAKE_MEM_UNDEFINED(routes + numroutes, sizeof(struct babel_route));
if(numroutes == 0) {
free(routes);
routes = NULL;
maxroutes = 0;
} else if(maxroutes > 8 && numroutes < maxroutes / 4) {
- struct route *new_routes;
+ struct babel_route *new_routes;
int n = maxroutes / 2;
- new_routes = realloc(routes, n * sizeof(struct route));
+ new_routes = realloc(routes, n * sizeof(struct babel_route));
if(new_routes != NULL) {
routes = new_routes;
maxroutes = n;
@@ -171,7 +171,7 @@
}
void
-install_route(struct route *route)
+install_route(struct babel_route *route)
{
int rc;
@@ -196,7 +196,7 @@
}
void
-uninstall_route(struct route *route)
+uninstall_route(struct babel_route *route)
{
int rc;
@@ -218,7 +218,7 @@
must be the same. */
static void
-switch_routes(struct route *old, struct route *new)
+switch_routes(struct babel_route *old, struct babel_route *new)
{
int rc;
@@ -249,7 +249,7 @@
}
static void
-change_route_metric(struct route *route, unsigned newmetric)
+change_route_metric(struct babel_route *route, unsigned newmetric)
{
int old, new;
@@ -276,26 +276,26 @@
}
static void
-retract_route(struct route *route)
+retract_route(struct babel_route *route)
{
route->refmetric = INFINITY;
change_route_metric(route, INFINITY);
}
int
-route_feasible(struct route *route)
+route_feasible(struct babel_route *route)
{
return update_feasible(route->src, route->seqno, route->refmetric);
}
int
-route_old(struct route *route)
+route_old(struct babel_route *route)
{
return route->time < babel_now.tv_sec - route->hold_time * 7 / 8;
}
int
-route_expired(struct route *route)
+route_expired(struct babel_route *route)
{
return route->time < babel_now.tv_sec - route->hold_time;
}
@@ -320,11 +320,11 @@
}
/* This returns the feasible route with the smallest metric. */
-struct route *
+struct babel_route *
find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
struct neighbour *exclude)
{
- struct route *route = NULL;
+ struct babel_route *route = NULL;
int i;
for(i = 0; i < numroutes; i++) {
@@ -344,7 +344,7 @@
}
void
-update_route_metric(struct route *route)
+update_route_metric(struct babel_route *route)
{
int oldmetric = route_metric(route);
@@ -404,14 +404,14 @@
}
/* This is called whenever we receive an update. */
-struct route *
+struct babel_route *
update_route(const unsigned char *router_id,
const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short refmetric,
unsigned short interval,
struct neighbour *neigh, const unsigned char *nexthop)
{
- struct route *route;
+ struct babel_route *route;
struct source *src;
int metric, feasible;
int add_metric;
@@ -488,11 +488,11 @@
return NULL;
}
if(numroutes >= maxroutes) {
- struct route *new_routes;
+ struct babel_route *new_routes;
int n = maxroutes < 1 ? 8 : 2 * maxroutes;
new_routes = routes == NULL ?
- malloc(n * sizeof(struct route)) :
- realloc(routes, n * sizeof(struct route));
+ malloc(n * sizeof(struct babel_route)) :
+ realloc(routes, n * sizeof(struct babel_route));
if(new_routes == NULL)
return NULL;
maxroutes = n;
@@ -521,7 +521,7 @@
unsigned short seqno, unsigned short metric,
struct source *src)
{
- struct route *route = find_installed_route(src->prefix, src->plen);
+ struct babel_route *route = find_installed_route(src->prefix, src->plen);
if(seqno_minus(src->seqno, seqno) > 100) {
/* Probably a source that lost its seqno. Let it time-out. */
@@ -539,9 +539,9 @@
/* This takes a feasible route and decides whether to install it. */
static void
-consider_route(struct route *route)
+consider_route(struct babel_route *route)
{
- struct route *installed;
+ struct babel_route *installed;
struct xroute *xroute;
if(route->installed)
@@ -606,7 +606,7 @@
}
void
-send_triggered_update(struct route *route, struct source *oldsrc,
+send_triggered_update(struct babel_route *route, struct source *oldsrc,
unsigned oldmetric)
{
unsigned newmetric, diff;
@@ -665,12 +665,12 @@
/* A route has just changed. Decide whether to switch to a different route or
send an update. */
void
-route_changed(struct route *route,
+route_changed(struct babel_route *route,
struct source *oldsrc, unsigned short oldmetric)
{
if(route->installed) {
if(route_metric(route) > oldmetric) {
- struct route *better_route;
+ struct babel_route *better_route;
better_route =
find_best_route(route->src->prefix, route->src->plen, 1, NULL);
if(better_route &&
@@ -692,7 +692,7 @@
void
route_lost(struct source *src, unsigned oldmetric)
{
- struct route *new_route;
+ struct babel_route *new_route;
new_route = find_best_route(src->prefix, src->plen, 1, NULL);
if(new_route) {
consider_route(new_route);
@@ -715,7 +715,7 @@
i = 0;
while(i < numroutes) {
- struct route *route = &routes[i];
+ struct babel_route *route = &routes[i];
if(route->time > babel_now.tv_sec || /* clock stepped */
route_old(route)) {
@@ -744,7 +744,7 @@
}
}
-struct route *
+struct babel_route *
babel_route_get_by_source(struct source *src)
{
int i;
diff --git a/babeld/route.h b/babeld/route.h
index e36f6c3..dbb205d 100644
--- a/babeld/route.h
+++ b/babeld/route.h
@@ -40,7 +40,7 @@
#include "babel_interface.h"
#include "source.h"
-struct route {
+struct babel_route {
struct source *src;
unsigned short metric;
unsigned short refmetric;
@@ -53,38 +53,38 @@
};
static inline int
-route_metric(const struct route *route)
+route_metric(const struct babel_route *route)
{
return route->metric;
}
-extern struct route *routes;
+extern struct babel_route *routes;
extern int numroutes, maxroutes;
extern int kernel_metric, allow_duplicates;
-struct route *find_route(const unsigned char *prefix, unsigned char plen,
+struct babel_route *find_route(const unsigned char *prefix, unsigned char plen,
struct neighbour *neigh, const unsigned char *nexthop);
-struct route *find_installed_route(const unsigned char *prefix,
+struct babel_route *find_installed_route(const unsigned char *prefix,
unsigned char plen);
-void flush_route(struct route *route);
+void flush_route(struct babel_route *route);
void flush_neighbour_routes(struct neighbour *neigh);
void flush_interface_routes(struct interface *ifp, int v4only);
-void install_route(struct route *route);
-void uninstall_route(struct route *route);
-void switch_route(struct route *old, struct route *new);
-int route_feasible(struct route *route);
-int route_old(struct route *route);
-int route_expired(struct route *route);
+void install_route(struct babel_route *route);
+void uninstall_route(struct babel_route *route);
+void switch_route(struct babel_route *old, struct babel_route *new);
+int route_feasible(struct babel_route *route);
+int route_old(struct babel_route *route);
+int route_expired(struct babel_route *route);
int update_feasible(struct source *src,
unsigned short seqno, unsigned short refmetric);
-struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
+struct babel_route *find_best_route(const unsigned char *prefix, unsigned char plen,
int feasible, struct neighbour *exclude);
-struct route *install_best_route(const unsigned char prefix[16],
+struct babel_route *install_best_route(const unsigned char prefix[16],
unsigned char plen);
void update_neighbour_metric(struct neighbour *neigh, int change);
void update_interface_metric(struct interface *ifp);
-void update_route_metric(struct route *route);
-struct route *update_route(const unsigned char *a,
+void update_route_metric(struct babel_route *route);
+struct babel_route *update_route(const unsigned char *a,
const unsigned char *p, unsigned char plen,
unsigned short seqno, unsigned short refmetric,
unsigned short interval, struct neighbour *neigh,
@@ -93,12 +93,12 @@
void send_unfeasible_request(struct neighbour *neigh, int force,
unsigned short seqno, unsigned short metric,
struct source *src);
-void send_triggered_update(struct route *route,
+void send_triggered_update(struct babel_route *route,
struct source *oldsrc, unsigned oldmetric);
-void route_changed(struct route *route,
+void route_changed(struct babel_route *route,
struct source *oldsrc, unsigned short oldmetric);
void route_lost(struct source *src, unsigned oldmetric);
void expire_routes(void);
void babel_uninstall_all_routes(void);
-struct route *babel_route_get_by_source(struct source *src);
+struct babel_route *babel_route_get_by_source(struct source *src);
diff --git a/babeld/xroute.c b/babeld/xroute.c
index 42f83d0..7b09cb8 100644
--- a/babeld/xroute.c
+++ b/babeld/xroute.c
@@ -210,7 +210,7 @@
if(metric < INFINITY) {
rc = add_xroute(prefix, plen, metric, ifindex, proto);
if(rc > 0) {
- struct route *route;
+ struct babel_route *route;
route = find_installed_route(prefix, plen);
if(route) {
if(allow_duplicates < 0 ||