0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

First attempt at protocol configuration (now done only for RIP).

This commit is contained in:
Martin Mares 1998-11-27 21:09:57 +00:00
parent 93fb60d54c
commit c74c0e3cdf
5 changed files with 83 additions and 11 deletions

View File

@ -5,3 +5,7 @@
# Yet another comment
router id 62.168.0.1
protocol rip MyRIP_test {
preference 130
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);