summaryrefslogtreecommitdiff
path: root/proto/rip/rip.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-12-10 22:30:46 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2013-12-10 22:30:46 +0100
commit6601a14831cdd32fc671ebc9dc299d2be427e489 (patch)
tree00b89854e36fbecd17443d09587c7cd80352893f /proto/rip/rip.c
parent2d0b7e24a52d51904faa8a8e96d68863491c110a (diff)
parent283c7dfada53a6dee6a8a17ecab492ffafd44b66 (diff)
Merge branch 'add-path'
Diffstat (limited to 'proto/rip/rip.c')
-rw-r--r--proto/rip/rip.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index ad285bb3..5cc40403 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -263,16 +263,18 @@ find_interface(struct proto *p, struct iface *what)
* This part is responsible for any updates that come from network
*/
+static int rip_rte_better(struct rte *new, struct rte *old);
+
static void
rip_rte_update_if_better(rtable *tab, net *net, struct proto *p, rte *new)
{
rte *old;
- old = rte_find(net, p);
- if (!old || p->rte_better(new, old) ||
+ old = rte_find(net, p->main_source);
+ if (!old || rip_rte_better(new, old) ||
(ipa_equal(old->attrs->from, new->attrs->from) &&
(old->u.rip.metric != new->u.rip.metric)) )
- rte_update(tab, net, p, p, new);
+ rte_update(p, net, new);
else
rte_free(new);
}
@@ -295,7 +297,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme, struct
int pxlen;
bzero(&A, sizeof(A));
- A.proto = p;
+ A.src= p->main_source;
A.source = RTS_RIP;
A.scope = SCOPE_UNIVERSE;
A.cast = RTC_UNICAST;
@@ -614,20 +616,10 @@ rip_start(struct proto *p)
add_head( &P->interfaces, NODE rif );
CHK_MAGIC;
- rip_init_instance(p);
-
DBG( "RIP: ...done\n");
return PS_UP;
}
-static struct proto *
-rip_init(struct proto_config *cfg)
-{
- struct proto *p = proto_new(cfg, sizeof(struct rip_proto));
-
- return p;
-}
-
static void
rip_dump(struct proto *p)
{
@@ -855,7 +847,7 @@ rip_gen_attrs(struct linpool *pool, int metric, u16 tag)
static int
rip_import_control(struct proto *p, struct rte **rt, struct ea_list **attrs, struct linpool *pool)
{
- if ((*rt)->attrs->proto == p) /* My own must not be touched */
+ if ((*rt)->attrs->src->proto == p) /* My own must not be touched */
return 1;
if ((*rt)->attrs->source != RTS_RIP) {
@@ -907,7 +899,7 @@ rip_rt_notify(struct proto *p, struct rtable *table UNUSED, struct network *net,
if (e->metric > P_CF->infinity)
e->metric = P_CF->infinity;
- if (new->attrs->proto == p)
+ if (new->attrs->src->proto == p)
e->whotoldme = new->attrs->from;
if (!e->metric) /* That's okay: this way user can set his own value for external
@@ -929,7 +921,7 @@ rip_rte_same(struct rte *new, struct rte *old)
static int
rip_rte_better(struct rte *new, struct rte *old)
{
- struct proto *p = new->attrs->proto;
+ struct proto *p = new->attrs->src->proto;
if (ipa_equal(old->attrs->from, new->attrs->from))
return 1;
@@ -940,7 +932,7 @@ rip_rte_better(struct rte *new, struct rte *old)
if (old->u.rip.metric > new->u.rip.metric)
return 1;
- if (old->attrs->proto == new->attrs->proto) /* This does not make much sense for different protocols */
+ if (old->attrs->src->proto == new->attrs->src->proto) /* This does not make much sense for different protocols */
if ((old->u.rip.metric == new->u.rip.metric) &&
((now - old->lastmod) > (P_CF->timeout_time / 2)))
return 1;
@@ -956,7 +948,7 @@ rip_rte_better(struct rte *new, struct rte *old)
static void
rip_rte_insert(net *net UNUSED, rte *rte)
{
- struct proto *p = rte->attrs->proto;
+ struct proto *p = rte->attrs->src->proto;
CHK_MAGIC;
DBG( "rip_rte_insert: %p\n", rte );
add_head( &P->garbage, &rte->u.rip.garbage );
@@ -969,16 +961,18 @@ static void
rip_rte_remove(net *net UNUSED, rte *rte)
{
#ifdef LOCAL_DEBUG
- struct proto *p = rte->attrs->proto;
+ struct proto *p = rte->attrs->src->proto;
CHK_MAGIC;
DBG( "rip_rte_remove: %p\n", rte );
#endif
rem_node( &rte->u.rip.garbage );
}
-void
-rip_init_instance(struct proto *p)
+static struct proto *
+rip_init(struct proto_config *cfg)
{
+ struct proto *p = proto_new(cfg, sizeof(struct rip_proto));
+
p->accept_ra_types = RA_OPTIMAL;
p->if_notify = rip_if_notify;
p->rt_notify = rip_rt_notify;
@@ -989,6 +983,8 @@ rip_init_instance(struct proto *p)
p->rte_same = rip_rte_same;
p->rte_insert = rip_rte_insert;
p->rte_remove = rip_rte_remove;
+
+ return p;
}
void