void rta_dump_all(void);
void rta_show(struct cli *, rta *);
--u32 rt_get_igp_metric(rte *rt);
++u32 rt_get_igp_metric(const rte *rt);
#endif
int (*rte_recalculate)(struct rtable *, struct network *, struct rte *, struct rte *, struct rte *);
int (*rte_better)(struct rte *, struct rte *);
int (*rte_mergable)(struct rte *, struct rte *);
- struct rte * (*rte_modify)(struct rte *, struct linpool *);
+ struct rte *(*rte_modify)(struct rte *, struct linpool *);
void (*rte_insert)(struct network *, struct rte *);
void (*rte_remove)(struct network *, struct rte *);
-- u32 (*rte_igp_metric)(struct rte *);
++ u32 (*rte_igp_metric)(const struct rte *);
/* Hic sunt protocol-specific data */
};
}
u32
--rt_get_igp_metric(rte *rt)
++rt_get_igp_metric(const rte *rt)
{
eattr *ea = ea_find(rt->attrs->eattrs, "igp_metric");
}
static u32
--babel_rte_igp_metric(struct rte *rt)
++babel_rte_igp_metric(const rte *rt)
{
return ea_get_int(rt->attrs->eattrs, &ea_babel_metric, BABEL_INFINITY);
}
}
int
- bgp_total_aigp_metric_(struct rta *a, u64 *metric, const struct adata **ad)
-bgp_total_aigp_metric_(rte *e, u64 *metric, const struct adata **ad)
++bgp_total_aigp_metric_(const rte *e, u64 *metric, const struct adata **ad)
{
- eattr *a = ea_find(e->attrs->eattrs, BGP_EA_ID(BA_AIGP));
- if (!a)
++ rta *a = e->attrs;
++
+ eattr *ea = ea_find(a->eattrs, BGP_EA_ID(BA_AIGP));
+ if (!ea)
return 0;
- const byte *b = bgp_aigp_get_tlv(a->u.ptr, BGP_AIGP_METRIC);
+ const byte *b = bgp_aigp_get_tlv(ea->u.ptr, BGP_AIGP_METRIC);
if (!b)
return 0;
u64 aigp = get_u64(b + 3);
- u64 step = a->igp_metric;
+ u64 step = rt_get_igp_metric(e);
- if (!rte_resolvable(e) || (step >= IGP_METRIC_UNKNOWN))
+ if (!rta_resolvable(a) || (step >= IGP_METRIC_UNKNOWN))
step = BGP_AIGP_MAX;
if (!step)
}
u32
--bgp_rte_igp_metric(struct rte *rt)
++bgp_rte_igp_metric(const rte *rt)
{
- u64 metric = bgp_total_aigp_metric(rt->attrs);
+ u64 metric = bgp_total_aigp_metric(rt);
return (u32) MIN(metric, (u64) IGP_METRIC_UNKNOWN);
}
{
buf += bsprintf(buf, "/%lu", metric);
}
- else if (e->attrs->igp_metric)
+ else if (metric = rt_get_igp_metric(e))
{
- if (!rte_resolvable(e))
+ if (!rta_resolvable(e->attrs))
buf += bsprintf(buf, "/-");
- else if (e->attrs->igp_metric >= IGP_METRIC_UNKNOWN)
+ else if (metric >= IGP_METRIC_UNKNOWN)
buf += bsprintf(buf, "/?");
else
- buf += bsprintf(buf, "/%d", e->attrs->igp_metric);
+ buf += bsprintf(buf, "/%d", metric);
}
buf += bsprintf(buf, ") [");
int bgp_rte_mergable(rte *pri, rte *sec);
int bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best);
struct rte *bgp_rte_modify_stale(struct rte *r, struct linpool *pool);
--u32 bgp_rte_igp_metric(struct rte *);
-void bgp_rt_notify(struct proto *P, struct channel *C, net *n, rte *new, rte *old);
-int bgp_preexport(struct proto *, struct rte *);
-void bgp_get_route_info(struct rte *, byte *buf);
-int bgp_total_aigp_metric_(rte *e, u64 *metric, const struct adata **ad);
++u32 bgp_rte_igp_metric(const rte *);
+void bgp_rt_notify(struct proto *P, struct channel *C, const net_addr *n, rte *new, const rte *old);
+int bgp_preexport(struct channel *, struct rte *);
+void bgp_get_route_info(struct rte *, byte *);
- int bgp_total_aigp_metric_(rta *a, u64 *metric, const struct adata **ad);
++int bgp_total_aigp_metric_(const rte *e, u64 *metric, const struct adata **ad);
#define BGP_AIGP_METRIC 1
#define BGP_AIGP_MAX U64(0xffffffffffffffff)
static inline u64
- bgp_total_aigp_metric(rta *a)
-bgp_total_aigp_metric(rte *r)
++bgp_total_aigp_metric(const rte *e)
{
u64 metric = BGP_AIGP_MAX;
const struct adata *ad;
- bgp_total_aigp_metric_(a, &metric, &ad);
- bgp_total_aigp_metric_(r, &metric, &ad);
++ bgp_total_aigp_metric_(e, &metric, &ad);
return metric;
}
#include "ospf.h"
#include "lib/macro.h"
-static int ospf_preexport(struct proto *P, rte *new);
+static int ospf_preexport(struct channel *C, rte *new);
static void ospf_reload_routes(struct channel *C);
static int ospf_rte_better(struct rte *new, struct rte *old);
--static u32 ospf_rte_igp_metric(struct rte *rt);
++static u32 ospf_rte_igp_metric(const rte *rt);
static void ospf_disp(timer *timer);
}
static u32
--ospf_rte_igp_metric(struct rte *rt)
++ospf_rte_igp_metric(const rte *rt)
{
if (rt->attrs->source == RTS_OSPF_EXT2)
return IGP_METRIC_UNKNOWN;
}
static u32
--rip_rte_igp_metric(struct rte *rt)
++rip_rte_igp_metric(const rte *rt)
{
return ea_get_int(rt->attrs->eattrs, &ea_rip_metric, IGP_METRIC_UNKNOWN);
}