From: Ondrej Filip Date: Wed, 17 May 2000 19:27:51 +0000 (+0000) Subject: rte_better implemented. X-Git-Tag: v1.2.0~877 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbd76b421a1975560084e50669db9cacd61d2b58;p=thirdparty%2Fbird.git rte_better implemented. --- diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 710c41466..e73e1ceab 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -15,6 +15,7 @@ ospf_start(struct proto *p) DBG("%s: Start\n",p->name); p->if_notify=ospf_if_notify; + p->rte_better=ospf_rte_better; fib_init(&po->efib,p->pool,sizeof(struct extfib),16,init_efib); return PS_UP; @@ -69,6 +70,34 @@ ospf_init(struct proto_config *c) return p; } +/* If new is better return 1 */ +static int +ospf_rte_better(struct rte *new, struct rte *old) +{ + struct proto *p = new->attrs->proto; + + if(new->u.ospf.metric1=LSINFINITY) return 0; + + if(((new->attrs->source==RTS_OSPF) || (new->attrs->source==RTS_OSPF_IA)) + && (old->attrs->source==RTS_OSPF_EXT)) return 1; + + if(((old->attrs->source==RTS_OSPF) || (old->attrs->source==RTS_OSPF_IA)) + && (new->attrs->source==RTS_OSPF_EXT)) return 0; + + if(new->u.ospf.metric2!=0) + { + if(old->u.ospf.metric2==0) return 0; + if(new->u.ospf.metric2u.ospf.metric2) return 1; + return 0; + } + else + { + if(old->u.ospf.metric2!=0) return 1; + if(new->u.ospf.metric1u.ospf.metric1) return 1; + return 0; + } +} + static void ospf_postconfig(struct proto_config *c) { diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 13ce8fe08..7214a00d6 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -349,6 +349,8 @@ static void ospf_dump(struct proto *p); static struct proto *ospf_init(struct proto_config *c); static void ospf_preconfig(struct protocol *p, struct config *c); static void ospf_postconfig(struct proto_config *c); +static int ospf_rte_better(struct rte *new, struct rte *old); + #include "proto/ospf/hello.h" #include "proto/ospf/packet.h"