]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Synced Linux sysdeps to new interface.
authorMartin Mares <mj@ucw.cz>
Fri, 5 Feb 1999 21:39:21 +0000 (21:39 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 Feb 1999 21:39:21 +0000 (21:39 +0000)
sysdep/linux/krt-scan.Y
sysdep/linux/krt-scan.c
sysdep/linux/krt-scan.h

index d02df113307d03ace59a256e4dcc2396aa4f1721..58339895a52fc1dea1f3229a81469230469b5525 100644 (file)
@@ -20,11 +20,11 @@ CF_ADDTO(kern_proto, kern_proto krt_scan_item ';')
 
 krt_scan_item:
    LEARN bool {
-      ((struct krt_proto *) this_proto)->scanopt.learn = $2;
+      ((struct krt_config *) this_proto)->scanopt.learn = $2;
    }
  | ROUTE SCAN TIME expr {
       /* Scan time of 0 means scan on startup only */
-      ((struct krt_proto *) this_proto)->scanopt.scan_time = $4;
+      ((struct krt_config *) this_proto)->scanopt.scan_time = $4;
    }
  ;
 
index f1c00908bb66eda358ba4cdd86562294fbcaa620..55ba3a864eb56576613940aa1026d22fddf83abd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Linux Routing Table Scanning
  *
- *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -23,7 +23,8 @@
 #include "lib/unix.h"
 #include "lib/krt.h"
 
-#define SCANOPT struct krt_scan_params *p = &x->scanopt
+#define SCANOPT struct krt_scan_params *p = &(((struct krt_config *)(x->p.cf))->scanopt)
+#define SCANSTAT struct krt_scan_status *s = &x->scanstat
 
 static int krt_scan_fd = -1;
 
@@ -33,15 +34,16 @@ struct iface *
 krt_temp_iface(struct krt_proto *x, char *name)
 {
   SCANOPT;
+  SCANSTAT;
   struct iface *i;
 
-  WALK_LIST(i, p->temp_ifs)
+  WALK_LIST(i, s->temp_ifs)
     if (!strcmp(i->name, name))
       return i;
   i = mb_alloc(x->p.pool, sizeof(struct iface));
   bzero(i, sizeof(*i));
   strcpy(i->name, name);
-  add_tail(&p->temp_ifs, &i->n);
+  add_tail(&s->temp_ifs, &i->n);
   return i;
 }
 
@@ -64,8 +66,9 @@ krt_uptodate(rte *k, rte *e)
 }
 
 static void
-krt_parse_entry(byte *ent, struct krt_proto *p)
+krt_parse_entry(byte *ent, struct krt_proto *x)
 {
+  SCANOPT;
   u32 dest0, gw0, mask0;
   ip_addr dest, gw, mask;
   unsigned int flags, verdict;
@@ -118,7 +121,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p)
       return;
     }
 
-  a.proto = &p->p;
+  a.proto = &x->p;
   a.source = RTS_INHERIT;
   a.scope = SCOPE_UNIVERSE;
   a.cast = RTC_UNICAST;
@@ -129,7 +132,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p)
 
   if (flags & RTF_GATEWAY)
     {
-      neighbor *ng = neigh_find(&p->p, &gw, 0);
+      neighbor *ng = neigh_find(&x->p, &gw, 0);
       if (ng)
        a.iface = ng->iface;
       else
@@ -147,7 +150,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p)
     {
       a.dest = RTD_DEVICE;
       a.gw = IPA_NONE;
-      a.iface = krt_temp_iface(p, iface);
+      a.iface = krt_temp_iface(x, iface);
     }
   else
     {
@@ -167,7 +170,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p)
       else
        verdict = KRF_UPDATE;
     }
-  else if (p->scanopt.learn && !net->routes)
+  else if (p->learn && !net->routes)
     verdict = KRF_LEARN;
   else
     verdict = KRF_DELETE;
@@ -305,33 +308,34 @@ void
 krt_scan_ifaces_done(struct krt_proto *x)
 {
   SCANOPT;
+  SCANSTAT;
 
-  p->accum_time += x->ifopt.scan_time;
-  if (p->scan_time && p->accum_time >= p->scan_time)
+  s->accum_time += p->scan_time;
+  if (p->scan_time && s->accum_time >= p->scan_time)
     {
-      p->accum_time %= p->scan_time;
+      s->accum_time %= p->scan_time;
       if (krt_scan_proc(x))
        krt_prune(x);
     }
 }
 
 void
-krt_scan_preconfig(struct krt_proto *x)
+krt_scan_preconfig(struct krt_config *c)
 {
-  SCANOPT;
-
-  p->scan_time = 1;
-  p->learn = 0;
-  init_list(&p->temp_ifs);
+  c->scanopt.scan_time = 1;
+  c->scanopt.learn = 0;
 }
 
 void
 krt_scan_start(struct krt_proto *x)
 {
   SCANOPT;
+  SCANSTAT;
 
   /* Force krt scan after first interface scan */
-  p->accum_time = p->scan_time - x->ifopt.scan_time;
+  s->accum_time = p->scan_time - ((struct krt_config *) x->p.cf)->ifopt.scan_time;
+
+  init_list(&s->temp_ifs);
 }
 
 void
index fe41d46cfe0a453244ad1f980fde10ba77f1bbc2..ef1f729007641f310dfa9a9c65af1968b2cc26e4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Linux Kernel Route Syncer -- Scanning Parameters
  *
- *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
 struct krt_scan_params {
   int learn;                           /* Should we learn routes from the kernel? */
-  list temp_ifs;                       /* Temporary interfaces */
   int scan_time;                       /* How often should we scan krt, 0=only on startup */
+};
+
+struct krt_scan_status {
+  list temp_ifs;                       /* Temporary interfaces */
   int accum_time;                      /* Accumulated scanning time */
 };