]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added configuration of the device internal protocol. This is primarily
authorMartin Mares <mj@ucw.cz>
Sun, 29 Nov 1998 22:03:58 +0000 (22:03 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 29 Nov 1998 22:03:58 +0000 (22:03 +0000)
intended to serve as an example of interface pattern list use. As a side
effect, you can disable generating of device routes by disabling
this protocol.

TODO
bird.conf
conf/confbase.Y
nest/config.Y
nest/protocol.h
nest/rt-dev.c
nest/rt-dev.h [new file with mode: 0644]

diff --git a/TODO b/TODO
index 02e32a49fedf71d2c7754563d4741ceab5a5d364..5dc5948b5a75544c4d28e5c0d93a8d377bee44a7 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,7 +2,6 @@ Core
 ~~~~
 * right usage of DBG vs. debug
 * cleanup debugging calls!
-- global "interface weed out list"
 
 - TOS not supported by kernel -> automatically drop routes with TOS<>0
 
index 314e2426ca910cf75230098286f105beeb1e5a0f..6797aee0c40fc5f75701bf8f0a90af8d0a24772b 100644 (file)
--- a/bird.conf
+++ b/bird.conf
@@ -8,7 +8,12 @@ router id 62.168.0.1
 
 define xyzzy = 120+10
 
-protocol rip MyRIP_test {
-       preference xyzzy
-       debug all
+#protocol rip MyRIP_test {
+#      preference xyzzy
+#      debug all
+#}
+
+protocol device {
+#      disabled
+#      interface "-eth*", "*"
 }
index db6d02149cd268a7e9618134a1369b12e1febb92..24fff87b9aa27ee1ec8860097eaaa86047afdd9c 100644 (file)
@@ -14,6 +14,7 @@ CF_HDR
 #include "lib/socket.h"
 #include "lib/timer.h"
 #include "nest/protocol.h"
+#include "nest/iface.h"
 
 CF_DECLS
 
index 9efebbe672b414b8701199f91b4c73ae7d15ea96..7b82ba72f71b5f4e6fb051fde3b546a996090063 100644 (file)
@@ -10,9 +10,14 @@ CF_HDR
 
 static struct proto *this_proto;
 
+#include "nest/rt-dev.h"
+
+void rt_dev_add_iface(char *);
+
 CF_DECLS
 
-CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF)
+CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DEVICE)
+CF_KEYWORDS(INTERFACE)
 
 %type <i> idval
 
@@ -64,6 +69,40 @@ proto_item:
  | DEBUG OFF { this_proto->debug = 0; }
  ;
 
+/* Device protocol */
+
+CF_ADDTO(proto, dev_proto '}')
+
+dev_proto_start: proto_start DEVICE {
+     if (!(this_proto = cf_dev_proto)) cf_error("Device protocol already defined");
+     cf_dev_proto = NULL;
+   }
+ ;
+
+dev_proto:
+   dev_proto_start '{'
+ | dev_proto proto_item ';'
+ | dev_proto dev_iface_list ';'
+ ;
+
+dev_iface_list:
+   INTERFACE TEXT {
+     init_list(&((struct rt_dev_proto *) this_proto)->iface_list);
+     rt_dev_add_iface($2);
+   }
+ | dev_iface_list ',' TEXT { rt_dev_add_iface($3); }
+ ;
+
 CF_CODE
 
+void
+rt_dev_add_iface(char *n)
+{
+  struct rt_dev_proto *p = (void *) this_proto;
+  struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
+
+  k->pattern = cfg_strcpy(n);
+  add_tail(&p->iface_list, &k->n);
+}
+
 CF_END
index 34624e95d4859c214e22b000fc0390196b752a43..59db428716f688aa4b100900fd75a095289cb7f0 100644 (file)
@@ -75,7 +75,6 @@ struct proto {
   void (*rte_remove)(struct network *, struct rte *);
 
   /* Reconfigure function? */
-  /* Interface patterns */
   /* Input/output filters */
   /* Connection to routing tables? */
 
@@ -90,4 +89,10 @@ void *proto_new(struct protocol *, unsigned size);
 
 extern list proto_list, inactive_proto_list;
 
+/*
+ *     Known unique protocol instances as referenced by config routines
+ */
+
+extern struct proto *cf_dev_proto;
+
 #endif
index 7ef04f0965c60884906855a7bc9c5d7f4c46e463..e7d43fb13c80e935dc0d1a47688643e03c7f2916 100644 (file)
 #include "nest/iface.h"
 #include "nest/protocol.h"
 #include "nest/route.h"
+#include "nest/rt-dev.h"
+#include "conf/conf.h"
 #include "lib/resource.h"
 
+struct proto *cf_dev_proto;
+
 static void
 dev_if_notify(struct proto *p, unsigned c, struct iface *old, struct iface *new)
 {
+  struct rt_dev_proto *P = (void *) p;
+
+  if (old && !iface_patt_match(&P->iface_list, old) ||
+      new && !iface_patt_match(&P->iface_list, new))
+    return;
   if (c & IF_CHANGE_DOWN)
     {
       net *n;
@@ -72,11 +81,17 @@ dev_init(struct protocol *p)
 static void
 dev_preconfig(struct protocol *x)
 {
-  struct proto *p = proto_new(&proto_device, sizeof(struct proto));
+  struct rt_dev_proto *P = proto_new(&proto_device, sizeof(struct rt_dev_proto));
+  struct proto *p = &P->p;
+  struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
 
+  cf_dev_proto = p;
   p->preference = DEF_PREF_DIRECT;
   p->start = dev_start;
   p->if_notify = dev_if_notify;
+  init_list(&P->iface_list);
+  k->pattern = "*";
+  add_tail(&P->iface_list, &k->n);
 }
 
 static void
diff --git a/nest/rt-dev.h b/nest/rt-dev.h
new file mode 100644 (file)
index 0000000..05a7f4c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ *     BIRD -- Direct Device Routes
+ *
+ *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_RT_DEV_H_
+#define _BIRD_RT_DEV_H_
+
+struct rt_dev_proto {
+  struct proto p;
+  list iface_list;
+};
+
+#endif