diff options
author | Denis Ovsienko <infrastation@yandex.ru> | 2012-01-08 15:29:19 +0400 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2012-03-25 17:06:52 +0100 |
commit | ef4de4d36c2dc10a68d41e518057d04b262ec867 (patch) | |
tree | fb194c240926977a85d3f313f65b3ab038fb8d1a | |
parent | 089082b5d51c41a4498edb6a3f495ade0d517e73 (diff) |
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".
-rw-r--r-- | babeld/message.c | 8 | ||||
-rw-r--r-- | babeld/route.c | 68 | ||||
-rw-r--r-- | babeld/route.h | 38 | ||||
-rw-r--r-- | babeld/xroute.c | 2 |
4 files changed, 58 insertions, 58 deletions
diff --git a/babeld/message.c b/babeld/message.c index bfb17625..57d875fb 100644 --- a/babeld/message.c +++ b/babeld/message.c @@ -854,7 +854,7 @@ flushupdates(struct interface *ifp) { 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 @@ send_update(struct interface *ifp, int urgent, 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 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix, 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 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix, 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 e0c9d047..a92018fd 100644 --- a/babeld/route.c +++ b/babeld/route.c @@ -58,14 +58,14 @@ THE SOFTWARE. #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 @@ find_route(const unsigned char *prefix, unsigned char plen, return NULL; } -struct route * +struct babel_route * find_installed_route(const unsigned char *prefix, unsigned char plen) { int i; @@ -91,7 +91,7 @@ find_installed_route(const unsigned char *prefix, unsigned char plen) } void -flush_route(struct route *route) +flush_route(struct babel_route *route) { int i; struct source *src; @@ -111,18 +111,18 @@ flush_route(struct route *route) 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 @@ metric_to_kernel(int metric) } void -install_route(struct route *route) +install_route(struct babel_route *route) { int rc; @@ -196,7 +196,7 @@ install_route(struct route *route) } void -uninstall_route(struct route *route) +uninstall_route(struct babel_route *route) { int rc; @@ -218,7 +218,7 @@ uninstall_route(struct route *route) 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 @@ switch_routes(struct route *old, struct route *new) } 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 @@ change_route_metric(struct route *route, unsigned newmetric) } 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 @@ update_feasible(struct source *src, } /* 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 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible, } void -update_route_metric(struct route *route) +update_route_metric(struct babel_route *route) { int oldmetric = route_metric(route); @@ -404,14 +404,14 @@ update_interface_metric(struct interface *ifp) } /* 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 @@ update_route(const unsigned char *router_id, 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 @@ send_unfeasible_request(struct neighbour *neigh, int force, 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 @@ send_unfeasible_request(struct neighbour *neigh, int force, /* 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 @@ retract_neighbour_routes(struct neighbour *neigh) } 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 @@ send_triggered_update(struct route *route, struct source *oldsrc, /* 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 @@ route_changed(struct route *route, 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 @@ expire_routes(void) 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 @@ babel_uninstall_all_routes(void) } } -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 e36f6c34..dbb205d1 100644 --- a/babeld/route.h +++ b/babeld/route.h @@ -40,7 +40,7 @@ THE SOFTWARE. #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 @@ struct route { }; 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 retract_neighbour_routes(struct neighbour *neigh); 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 42f83d07..7b09cb87 100644 --- a/babeld/xroute.c +++ b/babeld/xroute.c @@ -210,7 +210,7 @@ xroute_add_new_route(unsigned char prefix[16], unsigned char plen, 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 || |