summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
Diffstat (limited to 'conf')
-rw-r--r--conf/Makefile3
-rw-r--r--conf/cf-lex.l5
-rw-r--r--conf/conf.c11
-rw-r--r--conf/conf.h10
-rw-r--r--conf/confbase.Y8
5 files changed, 25 insertions, 12 deletions
diff --git a/conf/Makefile b/conf/Makefile
index c1a906e3..cc2b13c6 100644
--- a/conf/Makefile
+++ b/conf/Makefile
@@ -3,6 +3,8 @@ obj := $(src-o-files)
$(all-daemon)
+tests_objs := $(tests_objs) $(src-o-files)
+
ifdef DEBUG
BISON_DEBUG=-t
#FLEX_DEBUG=-d
@@ -24,6 +26,7 @@ $(o)cf-lex.c: $(s)cf-lex.l
$(FLEX) $(FLEX_DEBUG) -s -B -8 -Pcf_ -o$@ $<
$(o)cf-lex.o: $(o)cf-parse.tab.h $(o)keywords.h
+$(o)cf-lex.o: CFLAGS+=-Wno-sign-compare -Wno-unused-function
$(addprefix $(o), cf-parse.y keywords.h commands.h cf-parse.tab.h cf-parse.tab.c cf-lex.c): $(objdir)/.dir-stamp
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index dd99b497..bd6dfff2 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -30,6 +30,7 @@
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <stdint.h>
#include <unistd.h>
#include <libgen.h>
#include <glob.h>
@@ -202,6 +203,7 @@ else: {
["][^"\n]*["] {
yytext[yyleng-1] = 0;
cf_lval.t = cfg_strdup(yytext+1);
+ yytext[yyleng-1] = '"';
return TEXT;
}
@@ -233,6 +235,7 @@ else: {
<CCOMM>.
\!\= return NEQ;
+\!\~ return NMA;
\<\= return LEQ;
\>\= return GEQ;
\&\& return AND;
@@ -575,7 +578,7 @@ cf_lex_init(int is_cli, struct config *c)
cf_lex_init_kh();
ifs_head = ifs = push_ifs(NULL);
- if (!is_cli)
+ if (!is_cli)
{
ifs->file_name = c->file_name;
ifs->fd = c->file_fd;
diff --git a/conf/conf.c b/conf/conf.c
index 8d4d28e3..a2837886 100644
--- a/conf/conf.c
+++ b/conf/conf.c
@@ -56,6 +56,7 @@
#include "conf/conf.h"
#include "filter/filter.h"
+
static jmp_buf conf_jmpbuf;
struct config *config, *new_config;
@@ -85,7 +86,7 @@ int undo_available; /* Undo was not requested from last reconfiguration */
* further use. Returns a pointer to the structure.
*/
struct config *
-config_alloc(byte *name)
+config_alloc(const char *name)
{
pool *p = rp_new(&root_pool, "Config");
linpool *l = lp_new(p, 4080);
@@ -96,6 +97,7 @@ config_alloc(byte *name)
char *ndup = lp_allocu(l, nlen);
memcpy(ndup, name, nlen);
+ init_list(&c->tests);
c->mrtdump_file = -1; /* Hack, this should be sysdep-specific */
c->pool = p;
c->mem = l;
@@ -405,7 +407,7 @@ config_confirm(void)
* if it's been queued due to another reconfiguration being in progress now,
* %CONF_UNQUEUED if a scheduled reconfiguration is removed, %CONF_NOTHING
* if there is no relevant configuration to undo (the previous config request
- * was config_undo() too) or %CONF_SHUTDOWN if BIRD is in shutdown mode and
+ * was config_undo() too) or %CONF_SHUTDOWN if BIRD is in shutdown mode and
* no new configuration changes are accepted.
*/
int
@@ -450,7 +452,7 @@ config_undo(void)
extern void cmd_reconfig_undo_notify(void);
static void
-config_timeout(struct timer *t)
+config_timeout(struct timer *t UNUSED)
{
log(L_INFO "Config timeout expired, starting undo");
cmd_reconfig_undo_notify();
@@ -512,6 +514,7 @@ cf_error(const char *msg, ...)
va_start(args, msg);
if (bvsnprintf(buf, sizeof(buf), msg, args) < 0)
strcpy(buf, "<bug: error message too long>");
+ va_end(args);
new_config->err_msg = cfg_strdup(buf);
new_config->err_lino = ifs->lino;
new_config->err_file_name = ifs->file_name;
@@ -529,7 +532,7 @@ cf_error(const char *msg, ...)
* and we want to preserve it for further use.
*/
char *
-cfg_strdup(char *c)
+cfg_strdup(const char *c)
{
int l = strlen(c) + 1;
char *z = cfg_allocu(l);
diff --git a/conf/conf.h b/conf/conf.h
index 03fecd32..4b245e00 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -9,6 +9,8 @@
#ifndef _BIRD_CONF_H_
#define _BIRD_CONF_H_
+#include "sysdep/config.h"
+#include "lib/ip.h"
#include "lib/resource.h"
#include "sysdep/unix/timer.h"
@@ -20,7 +22,8 @@ struct config {
linpool *mem; /* Linear pool containing configuration data */
list protos; /* Configured protocol instances (struct proto_config) */
list tables; /* Configured routing tables (struct rtable_config) */
- list logfiles; /* Configured log fils (sysdep) */
+ list logfiles; /* Configured log files (sysdep) */
+ list tests; /* Configured unit tests (f_bt_test_suite) */
int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */
char *syslog_name; /* Name used for syslog (NULL -> no syslog) */
@@ -60,7 +63,7 @@ struct config {
extern struct config *config; /* Currently active configuration */
extern struct config *new_config; /* Configuration being parsed */
-struct config *config_alloc(byte *name);
+struct config *config_alloc(const char *name);
int config_parse(struct config *);
int cli_parse(struct config *);
void config_free(struct config *);
@@ -94,7 +97,7 @@ extern linpool *cfg_mem;
#define cfg_alloc(size) lp_alloc(cfg_mem, size)
#define cfg_allocu(size) lp_allocu(cfg_mem, size)
#define cfg_allocz(size) lp_allocz(cfg_mem, size)
-char *cfg_strdup(char *c);
+char *cfg_strdup(const char *c);
void cfg_copy_list(list *dest, list *src, unsigned node_size);
/* Lexer */
@@ -161,6 +164,7 @@ static inline int cf_symbol_is_constant(struct symbol *sym)
/* Parser */
+extern char *cf_text;
int cf_parse(void);
/* Sysdep hooks */
diff --git a/conf/confbase.Y b/conf/confbase.Y
index e64d7593..094c81b5 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -87,7 +87,7 @@ CF_DECLS
%nonassoc PREFIX_DUMMY
%left AND OR
-%nonassoc '=' '<' '>' '~' GEQ LEQ NEQ PO PC
+%nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC
%left '+' '-'
%left '*' '/' '%'
%left '!'
@@ -143,7 +143,7 @@ expr_us:
/* Switches */
bool:
- expr {$$ = !!$1; }
+ expr { $$ = !!$1; }
| ON { $$ = 1; }
| YES { $$ = 1; }
| OFF { $$ = 0; }
@@ -202,7 +202,7 @@ net_roa4_: net_ip4_ MAX NUM AS NUM
{
$$ = cfg_alloc(sizeof(net_addr_roa4));
net_fill_roa4($$, net4_prefix(&$1), net4_pxlen(&$1), $3, $5);
- if ($3 < net4_pxlen(&$1) || $3 > IP4_MAX_PREFIX_LENGTH)
+ if ($3 < (int) net4_pxlen(&$1) || $3 > IP4_MAX_PREFIX_LENGTH)
cf_error("Invalid max prefix length %d", $3);
};
@@ -210,7 +210,7 @@ net_roa6_: net_ip6_ MAX NUM AS NUM
{
$$ = cfg_alloc(sizeof(net_addr_roa6));
net_fill_roa6($$, net6_prefix(&$1), net6_pxlen(&$1), $3, $5);
- if ($3 < net6_pxlen(&$1) || $3 > IP6_MAX_PREFIX_LENGTH)
+ if ($3 < (int) net6_pxlen(&$1) || $3 > IP6_MAX_PREFIX_LENGTH)
cf_error("Invalid max prefix length %d", $3);
};