summaryrefslogtreecommitdiff
path: root/ospf6d
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2009-12-09 14:43:17 +0300
committerDenis Ovsienko <infrastation@yandex.ru>2009-12-09 14:43:17 +0300
commit1352ef32d70dcc102074814de63b5d08e591dd2d (patch)
treea0a4a40bf9a7726914f76cfa3a108529c7cc59df /ospf6d
parent3949a60c350fea947d2701e2fe709b174ae7af16 (diff)
lib: move check_bit into prefix common code
Make one version of check prefix bit, and put it inline with proper prototype. This gets rid of some macro's and also some assert() that can never happen on a non-broken compiler. * bgpd/bgp_table.c * CHECK_BIT(): sayonara * check_bit(): sayonara * SET_LINK(): sayonara * set_link(): make use of prefix_bit() instead of check_bit() * bgp_node_match(): idem * bgp_node_lookup(): idem * bgp_node_get(): idem * lib/prefix.h * prefix_bit(): new inline version of check_bit() * lib/table.c * CHECK_BIT(): sayonara * check_bit(): sayonara * SET_LINK(): sayonara * set_link(): make use of prefix_bit() instead of check_bit() * route_node_match(): idem * route_node_lookup(): idem * route_node_get(): idem * ospf6d/ospf6_lsdb.c * CHECK_BIT(): sayonara * ospf6_lsdb_lookup_next(): make use of prefix_bit() instead of CHECK_BIT() * ospf6_lsdb_type_router_head(): idem * ospf6_lsdb_type_head(): idem * ospf6d/ospf6_route.c * CHECK_BIT(): sayonara * ospf6_route_match_head() make use of prefix_bit() instead of * CHECK_BIT()
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ospf6_lsdb.c9
-rw-r--r--ospf6d/ospf6_route.c5
2 files changed, 4 insertions, 10 deletions
diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c
index ea387e3d..d2e3e04c 100644
--- a/ospf6d/ospf6_lsdb.c
+++ b/ospf6d/ospf6_lsdb.c
@@ -258,9 +258,6 @@ ospf6_lsdb_lookup (u_int16_t type, u_int32_t id, u_int32_t adv_router,
return (struct ospf6_lsa *) node->info;
}
-/* Macro version of check_bit (). */
-#define CHECK_BIT(X,P) ((((u_char *)(X))[(P) / 8]) >> (7 - ((P) % 8)) & 1)
-
struct ospf6_lsa *
ospf6_lsdb_lookup_next (u_int16_t type, u_int32_t id, u_int32_t adv_router,
struct ospf6_lsdb *lsdb)
@@ -291,7 +288,7 @@ ospf6_lsdb_lookup_next (u_int16_t type, u_int32_t id, u_int32_t adv_router,
prefix_match (&node->p, p))
{
matched = node;
- node = node->link[CHECK_BIT(&p->u.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(&p->u.prefix, node->p.prefixlen)];
}
if (matched)
@@ -384,7 +381,7 @@ ospf6_lsdb_type_router_head (u_int16_t type, u_int32_t adv_router,
/* Walk down tree. */
while (node && node->p.prefixlen <= key.prefixlen &&
prefix_match (&node->p, (struct prefix *) &key))
- node = node->link[CHECK_BIT(&key.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(&key.prefix, node->p.prefixlen)];
if (node)
route_lock_node (node);
@@ -438,7 +435,7 @@ ospf6_lsdb_type_head (u_int16_t type, struct ospf6_lsdb *lsdb)
node = lsdb->table->top;
while (node && node->p.prefixlen <= key.prefixlen &&
prefix_match (&node->p, (struct prefix *) &key))
- node = node->link[CHECK_BIT(&key.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(&key.prefix, node->p.prefixlen)];
if (node)
route_lock_node (node);
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 9832f570..1e1f4fb5 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -706,9 +706,6 @@ ospf6_route_best_next (struct ospf6_route *route)
return next;
}
-/* Macro version of check_bit (). */
-#define CHECK_BIT(X,P) ((((u_char *)(X))[(P) / 8]) >> (7 - ((P) % 8)) & 1)
-
struct ospf6_route *
ospf6_route_match_head (struct prefix *prefix,
struct ospf6_route_table *table)
@@ -720,7 +717,7 @@ ospf6_route_match_head (struct prefix *prefix,
node = table->table->top;
while (node && node->p.prefixlen < prefix->prefixlen &&
prefix_match (&node->p, prefix))
- node = node->link[CHECK_BIT(&prefix->u.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(&prefix->u.prefix, node->p.prefixlen)];
if (node)
route_lock_node (node);