summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sysdep/unix/krt-iface.Y2
-rw-r--r--sysdep/unix/krt-iface.h5
-rw-r--r--sysdep/unix/krt-set.c13
-rw-r--r--sysdep/unix/krt-set.h6
-rw-r--r--sysdep/unix/krt.Y4
-rw-r--r--sysdep/unix/krt.h20
-rw-r--r--sysdep/unix/sync-if.c15
-rw-r--r--sysdep/unix/sync-rt.c66
8 files changed, 81 insertions, 50 deletions
diff --git a/sysdep/unix/krt-iface.Y b/sysdep/unix/krt-iface.Y
index becb70c..c74eb02 100644
--- a/sysdep/unix/krt-iface.Y
+++ b/sysdep/unix/krt-iface.Y
@@ -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;
}
;
diff --git a/sysdep/unix/krt-iface.h b/sysdep/unix/krt-iface.h
index 95cfff8..87c8851 100644
--- a/sysdep/unix/krt-iface.h
+++ b/sysdep/unix/krt-iface.h
@@ -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
diff --git a/sysdep/unix/krt-set.c b/sysdep/unix/krt-set.c
index 83984fe..c66116c 100644
--- a/sysdep/unix/krt-set.c
+++ b/sysdep/unix/krt-set.c
@@ -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)
+{
+}
diff --git a/sysdep/unix/krt-set.h b/sysdep/unix/krt-set.h
index 214d91a..53b1146 100644
--- a/sysdep/unix/krt-set.h
+++ b/sysdep/unix/krt-set.h
@@ -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.
*/
@@ -12,8 +12,12 @@
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
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
index d4dd082..7711f3b 100644
--- a/sysdep/unix/krt.Y
+++ b/sysdep/unix/krt.Y
@@ -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;
}
;
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
index 4ea88d5..5631bc5 100644
--- a/sysdep/unix/krt.h
+++ b/sysdep/unix/krt.h
@@ -25,29 +25,37 @@
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 *);
diff --git a/sysdep/unix/sync-if.c b/sysdep/unix/sync-if.c
index 70a2c0c..cec3e86 100644
--- a/sysdep/unix/sync-if.c
+++ b/sysdep/unix/sync-if.c
@@ -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? */
}
diff --git a/sysdep/unix/sync-rt.c b/sysdep/unix/sync-rt.c
index dc79118..094da1c 100644
--- a/sysdep/unix/sync-rt.c
+++ b/sysdep/unix/sync-rt.c
@@ -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.
*/
@@ -23,43 +23,53 @@
#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,
};