Infinity is now configurable ammount.

This commit is contained in:
Pavel Machek 1998-12-01 16:17:10 +00:00
parent 50d8424ad1
commit 9b999c393c
3 changed files with 11 additions and 6 deletions

View file

@ -10,7 +10,7 @@ CF_HDR
CF_DECLS CF_DECLS
CF_KEYWORDS(RIP) CF_KEYWORDS(RIP, INFINITY)
CF_GRAMMAR CF_GRAMMAR
@ -25,6 +25,10 @@ rip_proto_start: proto_start RIP {
rip_proto: rip_proto:
rip_proto_start proto_name '{' rip_proto_start proto_name '{'
| rip_proto proto_item ';' | rip_proto proto_item ';'
| rip_proto INFINITY expr ';' {
if ($3 < 0 || $3 > 64) cf_error("Invalid infinity");
((struct rip_data *) this_proto)->infinity = $3;
}
; ;
CF_CODE CF_CODE

View file

@ -22,8 +22,6 @@
#include "rip.h" #include "rip.h"
int infinity = 16;
/* FIXME: should be 520 */ /* FIXME: should be 520 */
#define RIP_PORT 1520 #define RIP_PORT 1520
@ -160,7 +158,7 @@ givemore:
if (ipa_equal(c->sendptr->whotoldme, s->daddr)) { if (ipa_equal(c->sendptr->whotoldme, s->daddr)) {
debug( "(split horizont)" ); debug( "(split horizont)" );
/* FIXME: should we do it in all cases? */ /* FIXME: should we do it in all cases? */
packet->block[i].metric = infinity; packet->block[i].metric = P->infinity;
} }
ipa_hton( packet->block[i].network ); ipa_hton( packet->block[i].network );
ipa_hton( packet->block[i].netmask ); ipa_hton( packet->block[i].netmask );
@ -278,7 +276,7 @@ process_block( struct proto *p, struct rip_block *block, ip_addr whotoldme )
ip_addr network = block->network; ip_addr network = block->network;
CHK_MAGIC; CHK_MAGIC;
if ((!metric) || (metric > infinity)) { if ((!metric) || (metric > P->infinity)) {
log( L_WARN "Got metric %d from %I\n", metric, whotoldme ); log( L_WARN "Got metric %d from %I\n", metric, whotoldme );
return; return;
} }
@ -286,7 +284,7 @@ process_block( struct proto *p, struct rip_block *block, ip_addr whotoldme )
/* FIXME: Check if destination looks valid - ie not net 0 or 127 */ /* FIXME: Check if destination looks valid - ie not net 0 or 127 */
/* FIXME: Should add configurable ammount */ /* FIXME: Should add configurable ammount */
if (metric < infinity) if (metric < P->infinity)
metric++; metric++;
debug( "block: %I tells me: %I/%I available, metric %d... ", whotoldme, network, block->netmask, metric ); debug( "block: %I tells me: %I/%I available, metric %d... ", whotoldme, network, block->netmask, metric );
@ -622,6 +620,7 @@ rip_init_instance(struct proto *p)
p->rte_insert = rip_rte_insert; p->rte_insert = rip_rte_insert;
p->rte_remove = rip_rte_remove; p->rte_remove = rip_rte_remove;
p->dump = rip_dump; p->dump = rip_dump;
P->infinity = 16;
} }
static void static void

View file

@ -74,6 +74,8 @@ struct rip_data {
list garbage; list garbage;
list interfaces; list interfaces;
int magic; int magic;
int infinity; /* How much is infinity? Should be 16 */
}; };
#define P ((struct rip_data *) p) #define P ((struct rip_data *) p)