0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Added hooks for show route.

Fixed passing metrics around routing tables.
This commit is contained in:
Pavel Machek 1999-12-08 13:33:44 +00:00
parent dc82daaa9b
commit dff1f57917

View File

@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include "nest/bird.h" #include "nest/bird.h"
#include "nest/iface.h" #include "nest/iface.h"
@ -519,6 +520,12 @@ rip_dump(struct proto *p)
} }
} }
static void
rip_get_route_info(rte *rte, char *buf)
{
sprintf(buf, "(%d/%d) t%04x", rte->u.rip.metric, rte->pref, rte->u.rip.tag );
}
static int static int
rip_want_this_if(struct rip_interface *iface) rip_want_this_if(struct rip_interface *iface)
{ {
@ -635,7 +642,7 @@ rip_gen_attrs(struct proto *p, struct linpool *pool, int metric, u16 tag)
l->attrs[0].flags = 0; l->attrs[0].flags = 0;
l->attrs[0].type = EAF_TYPE_INT | EAF_INLINE; l->attrs[0].type = EAF_TYPE_INT | EAF_INLINE;
l->attrs[0].u.data = tag; l->attrs[0].u.data = tag;
l->attrs[1].id = EA_RIP_TAG; l->attrs[1].id = EA_RIP_METRIC;
l->attrs[1].flags = 0; l->attrs[1].flags = 0;
l->attrs[1].type = EAF_TYPE_INT | EAF_INLINE; l->attrs[1].type = EAF_TYPE_INT | EAF_INLINE;
l->attrs[1].u.data = metric; l->attrs[1].u.data = metric;
@ -669,7 +676,7 @@ rip_store_tmp_attrs(struct rte *rt, struct ea_list *attrs)
struct proto *p = rt->attrs->proto; struct proto *p = rt->attrs->proto;
rt->u.rip.tag = ea_find(attrs, EA_RIP_TAG)->u.data; rt->u.rip.tag = ea_find(attrs, EA_RIP_TAG)->u.data;
rt->u.rip.metric = ea_find(attrs, EA_RIP_TAG)->u.data; rt->u.rip.metric = ea_find(attrs, EA_RIP_METRIC)->u.data;
} }
static void static void
@ -692,11 +699,11 @@ rip_rt_notify(struct proto *p, struct network *net, struct rte *new, struct rte
e->nexthop = new->attrs->gw; e->nexthop = new->attrs->gw;
e->tag = ea_find(attrs, EA_RIP_TAG)->u.data; e->tag = ea_find(attrs, EA_RIP_TAG)->u.data;
e->metric = ea_find(attrs, EA_RIP_TAG)->u.data; e->metric = ea_find(attrs, EA_RIP_METRIC)->u.data;
if (e->metric > P_CF->infinity) if (e->metric > P_CF->infinity)
e->metric = P_CF->infinity; e->metric = P_CF->infinity;
if (!e->metric) if (!e->metric) /* FIXME: this is metric for external routes. Should it be configurable? */
e->metric = 1; e->metric = 5;
e->whotoldme = new->attrs->from; e->whotoldme = new->attrs->from;
e->updated = e->changed = now; e->updated = e->changed = now;
e->flags = 0; e->flags = 0;
@ -784,6 +791,7 @@ struct protocol proto_rip = {
name: "RIP", name: "RIP",
preconfig: rip_preconfig, preconfig: rip_preconfig,
postconfig: rip_postconfig, postconfig: rip_postconfig,
get_route_info: rip_get_route_info,
init: rip_init, init: rip_init,
dump: rip_dump, dump: rip_dump,