summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-11-27 22:09:57 +0100
committerMartin Mares <mj@ucw.cz>1998-11-27 22:09:57 +0100
commitc74c0e3cdf008988a8873d3f76c0d71b29ab8673 (patch)
treeb1392eb7bc193f820f7f57b8b12eea7ff56239e8
parent93fb60d54ca7ce3efec1cc0b39fb0840d055ccd1 (diff)
downloadbird-c74c0e3cdf008988a8873d3f76c0d71b29ab8673.tar
bird-c74c0e3cdf008988a8873d3f76c0d71b29ab8673.zip
First attempt at protocol configuration (now done only for RIP).
-rw-r--r--bird.conf4
-rw-r--r--conf/confbase.Y4
-rw-r--r--nest/config.Y37
-rw-r--r--proto/rip/config.Y32
-rw-r--r--sysdep/unix/main.c17
5 files changed, 83 insertions, 11 deletions
diff --git a/bird.conf b/bird.conf
index 1704af6..57df7ec 100644
--- a/bird.conf
+++ b/bird.conf
@@ -5,3 +5,7 @@
# Yet another comment
router id 62.168.0.1
+
+protocol rip MyRIP_test {
+ preference 130
+}
diff --git a/conf/confbase.Y b/conf/confbase.Y
index 3eb104d..b20986a 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -10,6 +10,10 @@ CF_HDR
#include "nest/bird.h"
#include "conf/conf.h"
+#include "lib/resource.h"
+#include "lib/socket.h"
+#include "lib/timer.h"
+#include "nest/protocol.h"
CF_DECLS
diff --git a/nest/config.Y b/nest/config.Y
index f14331b..1de0446 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -8,18 +8,22 @@
CF_HDR
+static struct proto *this_proto;
+
CF_DECLS
-CF_KEYWORDS(ROUTER, ID)
+CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE)
%type <i> idval
CF_GRAMMAR
+/* Setting of router ID */
+
CF_ADDTO(conf, rtrid)
rtrid: ROUTER ID idval {
router_id = $3;
- }
+ }
;
idval:
@@ -27,6 +31,35 @@ idval:
| IPA { $$ = ipa_to_u32($1); }
;
+/* Definition of protocols */
+
+CF_ADDTO(conf, proto)
+
+proto_start: PROTOCOL
+
+proto_name:
+ /* EMPTY */ {
+ struct symbol *s = cf_default_name(this_proto->proto->name);
+ s->class = SYM_PROTO;
+ s->def = this_proto;
+ this_proto->name = s->name;
+ }
+ | SYM {
+ if ($1->class) cf_error("Symbol already defined");
+ $1->class = SYM_PROTO;
+ $1->def = this_proto;
+ this_proto->name = $1->name;
+ }
+ ;
+
+proto_item:
+ /* EMPTY */
+ | PREFERENCE NUM {
+ if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
+ this_proto->preference = $2;
+ }
+ ;
+
CF_CODE
CF_END
diff --git a/proto/rip/config.Y b/proto/rip/config.Y
index e69de29..c89e59c 100644
--- a/proto/rip/config.Y
+++ b/proto/rip/config.Y
@@ -0,0 +1,32 @@
+/*
+ * BIRD -- RIP Configuration
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/rip/rip.h"
+
+CF_DECLS
+
+CF_KEYWORDS(RIP)
+
+CF_GRAMMAR
+
+CF_ADDTO(proto, rip_proto '}')
+
+rip_proto_start: proto_start RIP {
+ this_proto = proto_new(&proto_rip, sizeof(struct rip_data));
+ rip_init_instance(this_proto);
+ }
+ ;
+
+rip_proto:
+ rip_proto_start proto_name '{'
+ | rip_proto proto_item ';'
+ ;
+
+CF_CODE
+
+CF_END
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index c649cb2..4aeb9c1 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -78,9 +78,12 @@ read_config(void)
conf_fd = open(PATH_CONFIG, O_RDONLY);
if (conf_fd < 0)
die("Unable to open configuration file " PATH_CONFIG ": %m");
+ protos_preconfig();
cf_read_hook = cf_read;
cf_lex_init(1);
cf_parse();
+ add_tail(&protocol_list, &proto_unix_kernel.n); /* FIXME: Must be _always_ the last one */
+ protos_postconfig();
}
/*
@@ -93,29 +96,25 @@ main(void)
log(L_INFO "Launching BIRD -1.-1-pre-omega...");
log_init_debug(NULL);
- resource_init();
-
- debug("Reading configuration file.\n");
- read_config();
debug("Initializing.\n");
+ resource_init();
io_init();
rt_init();
if_init();
+
protos_build();
- add_tail(&protocol_list, &proto_unix_kernel.n); /* FIXME: Must be _always_ the last one */
protos_init();
- protos_preconfig();
- protos_postconfig();
+
+ debug("Reading configuration file.\n");
+ read_config();
signal_init();
scan_if_init();
auto_router_id();
-#if 0
protos_start();
-#endif
handle_sigusr(0);