From c27b2449d1f57e780974ed13fbd572a48e2a3602 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 8 Feb 2010 16:01:03 +0100 Subject: Shows source (Router ID) for OSPF routes and adds such attribute. A sad thing is that we does not have a 'router_id' filter type, so it must be given as decimal number in filters. --- proto/ospf/ospf.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'proto/ospf/ospf.c') diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 232803d7..d2ceab25 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -278,19 +278,20 @@ ospf_rte_same(struct rte *new, struct rte *old) return new->u.ospf.metric1 == old->u.ospf.metric1 && new->u.ospf.metric2 == old->u.ospf.metric2 && - new->u.ospf.tag == old->u.ospf.tag; + new->u.ospf.tag == old->u.ospf.tag && + new->u.ospf.router_id == old->u.ospf.router_id; } static ea_list * ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2, - u32 tag) + u32 tag, u32 rid) { struct ea_list *l = - lp_alloc(pool, sizeof(struct ea_list) + 3 * sizeof(eattr)); + lp_alloc(pool, sizeof(struct ea_list) + 4 * sizeof(eattr)); l->next = next; l->flags = EALF_SORTED; - l->count = 3; + l->count = 4; l->attrs[0].id = EA_OSPF_METRIC1; l->attrs[0].flags = 0; l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP; @@ -303,6 +304,10 @@ ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2, l->attrs[2].flags = 0; l->attrs[2].type = EAF_TYPE_INT | EAF_TEMP; l->attrs[2].u.data = tag; + l->attrs[3].id = EA_OSPF_ROUTER_ID; + l->attrs[3].flags = 0; + l->attrs[3].type = EAF_TYPE_INT | EAF_TEMP; + l->attrs[3].u.data = rid; return l; } @@ -435,7 +440,7 @@ ospf_import_control(struct proto *p, rte ** new, ea_list ** attrs, if (p == e->attrs->proto) return -1; /* Reject our own routes */ - *attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0); + *attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0, 0); return 0; /* Leave decision to the filters */ } @@ -443,7 +448,7 @@ struct ea_list * ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool) { return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2, - rt->u.ospf.tag); + rt->u.ospf.tag, rt->u.ospf.router_id); } void @@ -452,6 +457,7 @@ ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs) rt->u.ospf.metric1 = ea_get_int(attrs, EA_OSPF_METRIC1, LSINFINITY); rt->u.ospf.metric2 = ea_get_int(attrs, EA_OSPF_METRIC2, 10000); rt->u.ospf.tag = ea_get_int(attrs, EA_OSPF_TAG, 0); + rt->u.ospf.router_id = ea_get_int(attrs, EA_OSPF_ROUTER_ID, 0); } /** @@ -569,6 +575,8 @@ ospf_get_route_info(rte * rte, byte * buf, ea_list * attrs UNUSED) { buf += bsprintf(buf, " [%x]", rte->u.ospf.tag); } + if (rte->u.ospf.router_id) + buf += bsprintf(buf, " [%R]", rte->u.ospf.router_id); } static int @@ -583,7 +591,10 @@ ospf_get_attr(eattr * a, byte * buf, int buflen UNUSED) bsprintf(buf, "metric2"); return GA_NAME; case EA_OSPF_TAG: - bsprintf(buf, "tag: %08x", a->u.data); + bsprintf(buf, "tag: %08x (%u)", a->u.data, a->u.data); + return GA_FULL; + case EA_OSPF_ROUTER_ID: + bsprintf(buf, "router_id: %R (%u)", a->u.data, a->u.data); return GA_FULL; default: return GA_UNKNOWN; -- cgit v1.2.3