used for automatic generation of instance names.
protocol->name is the official name
protocol->template is the name template (usually "name%d"),
should be all lowercase.
Updated all protocols to define the templates, checked that their configuration
grammar includes proto_name which generates the name and interns it in the
symbol table.
- config: executable config files
- config: when parsing prefix, check zero bits
- config: useless rules when protocols disabled
-- config: remove protocol startup priority hacks?
- config: better datetime format
-- config: avoid upper case in default protocol names
- krt: rescan interfaces when route addition fails?
- krt: does PERSIST mode have any sense if kernel syncer is shut down as last?
- does everybody test return value of sk_open?
- add references to RFC's we did follow
- protocols: implement CLI hooks
+- protocols: implement reconfigure hook
- protocols: use locking
Various ideas
/*
* BIRD -- Configuration Lexer
*
- * (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ * (c) 1998--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "filter/filter.h"
#include "conf/conf.h"
#include "conf/cf-parse.tab.h"
+#include "lib/string.h"
static struct keyword {
byte *name;
}
struct symbol *
-cf_default_name(char *prefix, int *counter)
+cf_default_name(char *template, int *counter)
{
char buf[32];
struct symbol *s;
+ char *perc = strchr(template, '%');
- do
+ for(;;)
{
- sprintf(buf, "%s%d", prefix, ++(*counter));
+ bsprintf(buf, template, ++(*counter));
s = cf_find_sym(buf, cf_hash(buf));
- if (!s) cf_error("Unable to generate default name");
+ if (!s)
+ break;
+ if (s->class == SYM_VOID)
+ return s;
+ if (!perc)
+ break;
}
- while (s->class != SYM_VOID);
- return s;
+ cf_error("Unable to generate default name");
}
void
int cf_lex(void);
void cf_lex_init(int is_cli);
struct symbol *cf_find_symbol(byte *c);
-struct symbol *cf_default_name(char *prefix, int *counter);
+struct symbol *cf_default_name(char *template, int *counter);
void cf_define_symbol(struct symbol *symbol, int type, void *def);
void cf_push_scope(struct symbol *);
void cf_pop_scope(void);
proto_name:
/* EMPTY */ {
- struct symbol *s = cf_default_name(this_proto->protocol->name, &this_proto->protocol->name_counter);
+ struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
s->class = SYM_PROTO;
s->def = this_proto;
this_proto->name = s->name;
struct protocol {
node n;
char *name;
+ char *template; /* Template for automatic generation of names */
unsigned debug; /* Default debugging flags */
int priority; /* Protocol priority (usually 0) */
int name_counter; /* Counter for automatic name generation */
struct protocol proto_device = {
name: "Direct",
+ template: "direct%d",
priority: 90,
init: dev_init,
reconfigure: dev_reconfigure
struct protocol proto_ospf = {
name: "OSPF",
+ template: "ospf%d",
init: ospf_init,
dump: ospf_dump,
start: ospf_start,
struct protocol proto_pipe = {
name: "Pipe",
+ template: "pipe%d",
postconfig: pipe_postconfig,
init: pipe_init,
start: pipe_start,
struct protocol proto_rip = {
name: "RIP",
+ template: "rip%d",
preconfig: rip_preconfig,
postconfig: rip_postconfig,
get_route_info: rip_get_route_info,
/*
* BIRD -- Static Route Generator
*
- * (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ * (c) 1998--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
return p;
}
+static int
+static_reconfigure(struct proto *p, struct proto_config *new)
+{
+ return 0;
+}
+
struct protocol proto_static = {
name: "Static",
+ template: "static%d",
init: static_init,
dump: static_dump,
start: static_start,
+ reconfigure: static_reconfigure,
};
static void
/*
* BIRD -- Static Route Generator
*
- * (c) 1998 Martin Mares <mj@ucw.cz>
+ * (c) 1998--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/*
* BIRD -- UNIX Kernel Syncer Configuration
*
- * (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ * (c) 1998--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
}
;
-CF_ADDTO(kif_proto, kif_proto_start '{')
+CF_ADDTO(kif_proto, kif_proto_start proto_name '{')
CF_ADDTO(kif_proto, kif_proto proto_item ';')
CF_ADDTO(kif_proto, kif_proto kif_item ';')
struct protocol proto_unix_iface = {
name: "Device",
+ template: "device%d",
priority: 100,
preconfig: kif_preconfig,
init: kif_init,
struct protocol proto_unix_kernel = {
name: "Kernel",
+ template: "kernel%d",
priority: 80,
preconfig: krt_preconfig,
postconfig: krt_postconfig,