summaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
Diffstat (limited to 'proto')
-rw-r--r--proto/rip/config.Y6
-rw-r--r--proto/rip/rip.c9
-rw-r--r--proto/rip/rip.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/proto/rip/config.Y b/proto/rip/config.Y
index c89e59c..3e668f4 100644
--- a/proto/rip/config.Y
+++ b/proto/rip/config.Y
@@ -10,7 +10,7 @@ CF_HDR
CF_DECLS
-CF_KEYWORDS(RIP)
+CF_KEYWORDS(RIP, INFINITY)
CF_GRAMMAR
@@ -25,6 +25,10 @@ rip_proto_start: proto_start RIP {
rip_proto:
rip_proto_start proto_name '{'
| 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
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index 79b22df..23e8645 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -22,8 +22,6 @@
#include "rip.h"
-int infinity = 16;
-
/* FIXME: should be 520 */
#define RIP_PORT 1520
@@ -160,7 +158,7 @@ givemore:
if (ipa_equal(c->sendptr->whotoldme, s->daddr)) {
debug( "(split horizont)" );
/* 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].netmask );
@@ -278,7 +276,7 @@ process_block( struct proto *p, struct rip_block *block, ip_addr whotoldme )
ip_addr network = block->network;
CHK_MAGIC;
- if ((!metric) || (metric > infinity)) {
+ if ((!metric) || (metric > P->infinity)) {
log( L_WARN "Got metric %d from %I\n", metric, whotoldme );
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: Should add configurable ammount */
- if (metric < infinity)
+ if (metric < P->infinity)
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_remove = rip_rte_remove;
p->dump = rip_dump;
+ P->infinity = 16;
}
static void
diff --git a/proto/rip/rip.h b/proto/rip/rip.h
index b87ca1a..d63bb1a 100644
--- a/proto/rip/rip.h
+++ b/proto/rip/rip.h
@@ -74,6 +74,8 @@ struct rip_data {
list garbage;
list interfaces;
int magic;
+
+ int infinity; /* How much is infinity? Should be 16 */
};
#define P ((struct rip_data *) p)