diff options
author | Maria Matejka <mq@ucw.cz> | 2019-03-18 12:54:40 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-03-18 12:54:40 +0100 |
commit | 8d65add626b34256879a3e83855af3c0fa8ce4e7 (patch) | |
tree | dafa110c47bc328f4006d4298fd641e8210381b4 /proto/ospf/ospf.c | |
parent | 2f02c25e36f3946019c24dafe9b894a9e195350d (diff) | |
parent | 5d511948cddee415c2f0f1103bda0468a193f2d6 (diff) |
Merge branch 'master' into HEAD
Diffstat (limited to 'proto/ospf/ospf.c')
-rw-r--r-- | proto/ospf/ospf.c | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 816f33aa..f26f0160 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -106,8 +106,8 @@ #include "ospf.h" static int ospf_preexport(struct proto *P, rte **new, struct linpool *pool); -static struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool); -static void ospf_store_tmp_attrs(struct rte *rt); +static void ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool); +static void ospf_store_tmp_attrs(struct rte *rt, struct linpool *pool); static void ospf_reload_routes(struct channel *C); static int ospf_rte_better(struct rte *new, struct rte *old); static int ospf_rte_same(struct rte *new, struct rte *old); @@ -364,35 +364,6 @@ ospf_rte_same(struct rte *new, struct rte *old) 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 rid) -{ - struct ea_list *l = - lp_alloc(pool, sizeof(struct ea_list) + 4 * sizeof(eattr)); - - l->next = next; - l->flags = EALF_SORTED; - l->count = 4; - l->attrs[0].id = EA_OSPF_METRIC1; - l->attrs[0].flags = 0; - l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP; - l->attrs[0].u.data = m1; - l->attrs[1].id = EA_OSPF_METRIC2; - l->attrs[1].flags = 0; - l->attrs[1].type = EAF_TYPE_INT | EAF_TEMP; - l->attrs[1].u.data = m2; - l->attrs[2].id = EA_OSPF_TAG; - 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_ROUTER_ID | EAF_TEMP; - l->attrs[3].u.data = rid; - return l; -} - void ospf_schedule_rtcalc(struct ospf_proto *p) @@ -467,20 +438,24 @@ ospf_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED) return 0; } -static struct ea_list * +static void 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.router_id); + rte_init_tmp_attrs(rt, pool, 4); + rte_make_tmp_attr(rt, EA_OSPF_METRIC1, EAF_TYPE_INT, rt->u.ospf.metric1); + rte_make_tmp_attr(rt, EA_OSPF_METRIC2, EAF_TYPE_INT, rt->u.ospf.metric2); + rte_make_tmp_attr(rt, EA_OSPF_TAG, EAF_TYPE_INT, rt->u.ospf.tag); + rte_make_tmp_attr(rt, EA_OSPF_ROUTER_ID, EAF_TYPE_ROUTER_ID, rt->u.ospf.router_id); } static void -ospf_store_tmp_attrs(struct rte *rt) +ospf_store_tmp_attrs(struct rte *rt, struct linpool *pool) { - rt->u.ospf.metric1 = ea_get_int(rt->attrs->eattrs, EA_OSPF_METRIC1, LSINFINITY); - rt->u.ospf.metric2 = ea_get_int(rt->attrs->eattrs, EA_OSPF_METRIC2, 10000); - rt->u.ospf.tag = ea_get_int(rt->attrs->eattrs, EA_OSPF_TAG, 0); - rt->u.ospf.router_id = ea_get_int(rt->attrs->eattrs, EA_OSPF_ROUTER_ID, 0); + rte_init_tmp_attrs(rt, pool, 4); + rt->u.ospf.metric1 = rte_store_tmp_attr(rt, EA_OSPF_METRIC1); + rt->u.ospf.metric2 = rte_store_tmp_attr(rt, EA_OSPF_METRIC2); + rt->u.ospf.tag = rte_store_tmp_attr(rt, EA_OSPF_TAG); + rt->u.ospf.router_id = rte_store_tmp_attr(rt, EA_OSPF_ROUTER_ID); } /** |