summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-10-18 14:50:43 +0200
committerMartin Mares <mj@ucw.cz>1998-10-18 14:50:43 +0200
commit7e7790c61f14dff300d7c5464fdd47e4c15a0731 (patch)
treefaa06678f7dc7bf821af328f29211a03a7ee7b3a
parent8b1688177b2b3c6a3740f792997f3057b9bff0da (diff)
downloadbird-7e7790c61f14dff300d7c5464fdd47e4c15a0731.tar
bird-7e7790c61f14dff300d7c5464fdd47e4c15a0731.zip
Since almost every UNIX system requires different techniques for reading
the kernel routing table as opposed to modifying it which is approximately the same on non-netlink systems, I've split the kernel routing table routines to read and write parts. To be implemented later ;-)
-rw-r--r--sysdep/linux/Modules2
-rw-r--r--sysdep/linux/krt-scan.c58
-rw-r--r--sysdep/linux/krt-scan.h17
-rw-r--r--sysdep/unix/Modules3
-rw-r--r--sysdep/unix/krt-set.c35
-rw-r--r--sysdep/unix/krt-set.h15
-rw-r--r--sysdep/unix/krt.h35
-rw-r--r--sysdep/unix/main.c1
-rw-r--r--sysdep/unix/sync-rt.c37
-rw-r--r--sysdep/unix/unix.h4
10 files changed, 183 insertions, 24 deletions
diff --git a/sysdep/linux/Modules b/sysdep/linux/Modules
index e69de29..5562ab2 100644
--- a/sysdep/linux/Modules
+++ b/sysdep/linux/Modules
@@ -0,0 +1,2 @@
+krt-scan.c
+krt-scan.h
diff --git a/sysdep/linux/krt-scan.c b/sysdep/linux/krt-scan.c
new file mode 100644
index 0000000..caae54d
--- /dev/null
+++ b/sysdep/linux/krt-scan.c
@@ -0,0 +1,58 @@
+/*
+ * BIRD -- Linux Routing Table Scanning
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <string.h>
+
+#define LOCAL_DEBUG
+
+#include "nest/bird.h"
+#include "nest/iface.h"
+#include "nest/route.h"
+#include "nest/protocol.h"
+#include "lib/timer.h"
+#include "lib/unix.h"
+#include "lib/krt.h"
+
+#define SCANOPT struct krt_scan_params *p = &x->scanopt
+
+static void
+krt_scan_fire(timer *t)
+{
+ DBG("Scanning kernel table...\n");
+}
+
+void
+krt_scan_preconfig(struct krt_proto *x)
+{
+ SCANOPT;
+
+ p->recurrence = 10; /* FIXME: use reasonable default value */
+}
+
+void
+krt_scan_start(struct krt_proto *x)
+{
+ SCANOPT;
+ timer *t = tm_new(x->p.pool);
+
+ p->timer = t;
+ t->hook = krt_scan_fire;
+ t->data = x;
+ t->recurrent = p->recurrence;
+ krt_scan_fire(t);
+ if (t->recurrent)
+ tm_start(t, t->recurrent);
+}
+
+void
+krt_scan_shutdown(struct krt_proto *x)
+{
+ SCANOPT;
+
+ tm_stop(p->timer);
+}
diff --git a/sysdep/linux/krt-scan.h b/sysdep/linux/krt-scan.h
new file mode 100644
index 0000000..1ea1ca7
--- /dev/null
+++ b/sysdep/linux/krt-scan.h
@@ -0,0 +1,17 @@
+/*
+ * BIRD -- Linux Kernel Route Syncer -- Scanning Parameters
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_KRT_SCAN_H_
+#define _BIRD_KRT_SCAN_H_
+
+struct krt_scan_params {
+ int recurrence; /* How often should we scan krt, 0=only on startup */
+ struct timer *timer;
+};
+
+#endif
diff --git a/sysdep/unix/Modules b/sysdep/unix/Modules
index f3e68e8..70ed145 100644
--- a/sysdep/unix/Modules
+++ b/sysdep/unix/Modules
@@ -5,3 +5,6 @@ io.c
unix.h
sync-if.c
sync-rt.c
+krt.h
+krt-set.c
+krt-set.h
diff --git a/sysdep/unix/krt-set.c b/sysdep/unix/krt-set.c
new file mode 100644
index 0000000..9da836d
--- /dev/null
+++ b/sysdep/unix/krt-set.c
@@ -0,0 +1,35 @@
+/*
+ * BIRD -- Unix Routing Table Syncing
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#define LOCAL_DEBUG
+
+#include "nest/bird.h"
+#include "nest/iface.h"
+#include "nest/route.h"
+#include "nest/protocol.h"
+#include "lib/timer.h"
+#include "lib/unix.h"
+#include "lib/krt.h"
+
+void
+krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
+{
+ DBG("krt_set_notify(%I/%d)\n", net->n.prefix, net->n.pxlen);
+}
+
+void
+krt_set_preconfig(struct krt_proto *x)
+{
+ x->p.rt_notify = krt_set_notify;
+}
diff --git a/sysdep/unix/krt-set.h b/sysdep/unix/krt-set.h
new file mode 100644
index 0000000..3b906ba
--- /dev/null
+++ b/sysdep/unix/krt-set.h
@@ -0,0 +1,15 @@
+/*
+ * BIRD -- Unix Kernel Route Syncer -- Setting Parameters
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_KRT_SET_H_
+#define _BIRD_KRT_SET_H_
+
+struct krt_set_params {
+};
+
+#endif
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
new file mode 100644
index 0000000..e7b5597
--- /dev/null
+++ b/sysdep/unix/krt.h
@@ -0,0 +1,35 @@
+/*
+ * BIRD -- Unix Kernel Route Syncer
+ *
+ * (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_KRT_H_
+#define _BIRD_KRT_H_
+
+#include "lib/krt-scan.h"
+#include "lib/krt-set.h"
+
+/* sync-rt.c */
+
+extern struct protocol proto_unix_kernel;
+
+struct krt_proto {
+ struct proto p;
+ struct krt_set_params setopt;
+ struct krt_scan_params scanopt;
+};
+
+/* krt-scan.c */
+
+void krt_scan_preconfig(struct krt_proto *);
+void krt_scan_start(struct krt_proto *);
+void krt_scan_shutdown(struct krt_proto *);
+
+/* krt-set.c */
+
+void krt_set_preconfig(struct krt_proto *);
+
+#endif
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index a6c4748..4c60ee6 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -19,6 +19,7 @@
#include "nest/confile.h"
#include "unix.h"
+#include "krt.h"
/*
* Debugging
diff --git a/sysdep/unix/sync-rt.c b/sysdep/unix/sync-rt.c
index c1bf7f7..69b2bde 100644
--- a/sysdep/unix/sync-rt.c
+++ b/sysdep/unix/sync-rt.c
@@ -21,42 +21,39 @@
#include "lib/timer.h"
#include "unix.h"
+#include "krt.h"
void
-uk_rt_notify(struct proto *p, net *net, rte *new, rte *old)
+krt_start(struct proto *P)
{
+ struct krt_proto *p = (struct krt_proto *) P;
+ krt_scan_start(p);
}
void
-uk_start(struct proto *p)
+krt_shutdown(struct proto *P, int time)
{
+ struct krt_proto *p = (struct krt_proto *) P;
+ krt_scan_shutdown(p);
}
void
-uk_init(struct protocol *x)
+krt_preconfig(struct protocol *x)
{
-}
-
-void
-uk_preconfig(struct protocol *x)
-{
- struct proto *p = proto_new(&proto_unix_kernel, sizeof(struct proto));
+ struct krt_proto *p = (struct krt_proto *) proto_new(&proto_unix_kernel, sizeof(struct krt_proto));
- p->preference = DEF_PREF_UKR;
- p->rt_notify = uk_rt_notify;
- p->start = uk_start;
-}
-
-void
-uk_postconfig(struct protocol *x)
-{
+ p->p.preference = DEF_PREF_UKR;
+ p->p.start = krt_start;
+ p->p.shutdown = krt_shutdown;
+ krt_scan_preconfig(p);
+ krt_set_preconfig(p);
}
struct protocol proto_unix_kernel = {
{ NULL, NULL },
"kernel",
0,
- uk_init,
- uk_preconfig,
- uk_postconfig
+ NULL, /* init */
+ krt_preconfig,
+ NULL /* postconfig */
};
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 7b0a921..127101e 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -22,8 +22,4 @@ extern int if_scan_period;
void scan_if_init(void);
-/* sync-rt.c */
-
-extern struct protocol proto_unix_kernel;
-
#endif