]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Synced kernel interface to new interface.
authorMartin Mares <mj@ucw.cz>
Fri, 5 Feb 1999 21:38:50 +0000 (21:38 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 Feb 1999 21:38:50 +0000 (21:38 +0000)
sysdep/unix/krt-iface.Y
sysdep/unix/krt-iface.h
sysdep/unix/krt-set.c
sysdep/unix/krt-set.h
sysdep/unix/krt.Y
sysdep/unix/krt.h
sysdep/unix/sync-if.c
sysdep/unix/sync-rt.c

index becb70cf803c5d5a9dff10a1611030d9c667bafd..c74eb02b45cbfcb71154b2c29fd66eec72130c83 100644 (file)
@@ -21,7 +21,7 @@ CF_ADDTO(kern_proto, kern_proto krt_if_item ';')
 krt_if_item:
    SCAN TIME expr {
       /* Scan time of 0 means scan on startup only */
-      ((struct krt_proto *) this_proto)->ifopt.scan_time = $3;
+      ((struct krt_config *) this_proto)->ifopt.scan_time = $3;
    }
  ;
 
index 95cfff8c1c3e15934580a75c823f4b16fb8a158d..87c8851528979b6af641c2de7c14bb121ee5cae6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Kernel Interface Syncer -- Setting 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.
  */
@@ -13,4 +13,7 @@ struct krt_if_params {
   int scan_time;
 };
 
+struct krt_if_status {
+};
+
 #endif
index 83984fec3c016b738f74d58a1129f439d00973a6..c66116c483fde4fd0ed5ff990b1547d039dfbb6d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Routing Table Syncing
  *
- *     (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.
  */
@@ -115,8 +115,8 @@ krt_add_route(rte *new)
 void
 krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
 {
-  if (x->state != PRS_UP)
-    return;
+  if (x->proto_state != PS_UP)
+    bug("FIXME: krt_set_notify called for downed protocol");
   if (old)
     krt_remove_route(old);
   if (new)
@@ -124,9 +124,14 @@ krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
 }
 
 void
-krt_set_preconfig(struct krt_proto *x)
+krt_set_start(struct krt_proto *x)
 {
   if (if_scan_sock < 0)
     bug("krt set: missing socket");
   x->p.rt_notify = krt_set_notify;
 }
+
+void
+krt_set_preconfig(struct krt_config *c)
+{
+}
index 214d91ac3cae348faedb72adc20d056299319bfe..53b1146430ba5d9ea4298f4352d03d512edd869c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Kernel Route Syncer -- Setting 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_set_params {
 };
 
+struct krt_set_status {
+};
+
 void krt_remove_route(rte *old);
 void krt_add_route(rte *new);
 int krt_capable(rte *e);
+void krt_set_notify(struct proto *x, net *net, rte *new, rte *old);
 
 #endif
index d4dd082416a242ffe23e49b6bc68829d2c2a889f..7711f3ba7944327558a96058680d31b9f17a8d04 100644 (file)
@@ -21,8 +21,8 @@ CF_GRAMMAR
 CF_ADDTO(proto, kern_proto '}')
 
 kern_proto_start: proto_start KERNEL {
-     if (!(this_proto = cf_krt_proto)) cf_error("Kernel protocol already defined");
-     cf_krt_proto = NULL;
+     if (!(this_proto = cf_krt)) cf_error("Kernel protocol already defined");
+     cf_krt = NULL;
    }
  ;
 
index 4ea88d50b4cf09f5d1d616a3bc7d125344155bce..5631bc5cb03c194c417873a6ced0f25f4ccd0c03 100644 (file)
 
 extern struct protocol proto_unix_kernel;
 
-struct krt_proto {
-  struct proto p;
+struct krt_config {
+  struct proto_config c;
   struct krt_set_params setopt;
   struct krt_scan_params scanopt;
   struct krt_if_params ifopt;
 };
 
-extern struct proto *cf_krt_proto;
+struct krt_proto {
+  struct proto p;
+  struct krt_set_status setstat;
+  struct krt_scan_status scanstat;
+  struct krt_if_status ifstat;
+};
+
+extern struct proto_config *cf_krt;
 
 /* krt-scan.c */
 
-void krt_scan_preconfig(struct krt_proto *);
+void krt_scan_preconfig(struct krt_config *);
 void krt_scan_start(struct krt_proto *);
 void krt_scan_shutdown(struct krt_proto *);
 void krt_scan_ifaces_done(struct krt_proto *);
 
 /* krt-set.c */
 
-void krt_set_preconfig(struct krt_proto *);
+void krt_set_preconfig(struct krt_config *);
+void krt_set_start(struct krt_proto *);
 
 /* sync-if.c */
 
-void krt_if_preconfig(struct krt_proto *);
+void krt_if_preconfig(struct krt_config *);
 void krt_if_start(struct krt_proto *);
 void krt_if_shutdown(struct krt_proto *);
 
index 70a2c0ce46f24616eed3bd3c6f2cd6225affab46..cec3e864cf917557210e925b559fa80252ae823a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Interface Scanning and Syncing
  *
- *     (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.
  */
@@ -174,25 +174,26 @@ scan_if(timer *t)
 void
 krt_if_start(struct krt_proto *p)
 {
-  if_scan_timer = tm_new(&root_pool);
+  struct krt_config *c = (struct krt_config *) p->p.cf;
+
+  if_scan_timer = tm_new(p->p.pool);
   if_scan_timer->hook = scan_if;
   if_scan_timer->data = p;
-  if_scan_timer->recurrent = p->ifopt.scan_time;
+  if_scan_timer->recurrent = c->ifopt.scan_time;
   scan_if(if_scan_timer);
-  tm_start(if_scan_timer, p->ifopt.scan_time);
+  tm_start(if_scan_timer, c->ifopt.scan_time);
 }
 
 void
-krt_if_preconfig(struct krt_proto *p)
+krt_if_preconfig(struct krt_config *c)
 {
-  p->ifopt.scan_time = 60;
+  c->ifopt.scan_time = 60;
 }
 
 void
 krt_if_shutdown(struct krt_proto *p)
 {
   tm_stop(if_scan_timer);
-  rfree(if_scan_timer);
   /* FIXME: What should we do with interfaces? */
 }
 
index dc79118dd2d614d3cf1b3fa6d33bb46a5b8a5bd9..094da1c24b9aa4daeb957fdc62a6265d0d697e08 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Routing Table Scanning and Syncing
  *
- *     (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.
  */
 #include "unix.h"
 #include "krt.h"
 
-struct proto *cf_krt_proto;
+struct proto_config *cf_krt;
 
-void
-krt_start(struct proto *P)
+static int
+krt_start(struct proto *p)
 {
-  struct krt_proto *p = (struct krt_proto *) P;
-  krt_scan_start(p);
-  krt_if_start(p);
+  struct krt_proto *k = (struct krt_proto *) p;
+
+  krt_scan_start(k);
+  krt_set_start(k);
+  krt_if_start(k);
+  return PS_UP;
+}
+
+int
+krt_shutdown(struct proto *p)
+{
+  struct krt_proto *k = (struct krt_proto *) p;
+
+  krt_scan_shutdown(k);
+  krt_if_shutdown(k);
+  return PS_DOWN;
 }
 
-void
-krt_shutdown(struct proto *P, int time)
+static void
+krt_preconfig(struct protocol *x, struct config *c)
 {
-  struct krt_proto *p = (struct krt_proto *) P;
-  krt_scan_shutdown(p);
-  krt_if_shutdown(p);
+  struct krt_config *z = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config));
+
+  cf_krt = &z->c;
+  z->c.preference = DEF_PREF_UKR;
+  krt_scan_preconfig(z);
+  krt_set_preconfig(z);
+  krt_if_preconfig(z);
 }
 
-void
-krt_preconfig(struct protocol *x)
+static struct proto *
+krt_init(struct proto_config *c)
 {
-  struct krt_proto *p = (struct krt_proto *) proto_new(&proto_unix_kernel, sizeof(struct krt_proto));
+  struct krt_proto *p = proto_new(c, sizeof(struct krt_proto));
 
-  cf_krt_proto = &p->p;
-  p->p.preference = DEF_PREF_UKR;
-  p->p.start = krt_start;
-  p->p.shutdown = krt_shutdown;
-  krt_scan_preconfig(p);
-  krt_set_preconfig(p);
-  krt_if_preconfig(p);
+  return &p->p;
 }
 
 struct protocol proto_unix_kernel = {
-  { NULL, NULL },
-  "kernel",
-  0,
-  NULL,                                        /* init */
-  krt_preconfig,
-  NULL                                 /* postconfig */
+  name:                "Kernel",
+  preconfig:   krt_preconfig,
+  init:                krt_init,
+  start:       krt_start,
+  shutdown:    krt_shutdown,
 };