]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Infinity is now configurable ammount.
authorPavel Machek <pavel@ucw.cz>
Tue, 1 Dec 1998 16:17:10 +0000 (16:17 +0000)
committerPavel Machek <pavel@ucw.cz>
Tue, 1 Dec 1998 16:17:10 +0000 (16:17 +0000)
proto/rip/config.Y
proto/rip/rip.c
proto/rip/rip.h

index c89e59c8816a0fa6f61b2c2f8c7553fea6688611..3e668f4b3cb5641956378048b91b6e1198d64242 100644 (file)
@@ -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
index 79b22dfdb477f8b173921aeaadd4b5b75ff08102..23e8645228fca589093662b6fc2931e22e82931f 100644 (file)
@@ -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
index b87ca1a121ca00853dc968308c8667a6a3fd85ee..d63bb1a52f0bdacf01fd4134f0d5dbd4762987a6 100644 (file)
@@ -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)