From c74c0e3cdf008988a8873d3f76c0d71b29ab8673 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 27 Nov 1998 21:09:57 +0000 Subject: First attempt at protocol configuration (now done only for RIP). --- bird.conf | 4 ++++ conf/confbase.Y | 4 ++++ nest/config.Y | 37 +++++++++++++++++++++++++++++++++++-- proto/rip/config.Y | 32 ++++++++++++++++++++++++++++++++ sysdep/unix/main.c | 17 ++++++++--------- 5 files changed, 83 insertions(+), 11 deletions(-) diff --git a/bird.conf b/bird.conf index 1704af60..57df7ec7 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 3eb104d0..b20986ae 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 f14331b3..1de0446b 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 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 e69de29b..c89e59c8 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 c649cb27..4aeb9c19 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); -- cgit v1.2.3