summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/parse.y
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-05-23 15:32:49 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-05-23 15:32:49 +0000
commitf0898a4e73520d0f7450c9698a42dfd318a5a5d6 (patch)
tree389c1f2f61543d2e92a6b74f3d5e4c82b6c363eb /usr.sbin/ldpd/parse.y
parent8c7a3088998986abf4031885c3eb9c737d045994 (diff)
Add support for including additional configuration files.
Pulled from ospfd. Original author: dlg@
Diffstat (limited to 'usr.sbin/ldpd/parse.y')
-rw-r--r--usr.sbin/ldpd/parse.y20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index ac54e52d742..c8f971ef8e3 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.33 2016/05/23 15:30:43 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.34 2016/05/23 15:32:48 renato Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -136,6 +136,7 @@ typedef struct {
%token PSEUDOWIRE NEIGHBOR PWID
%token EXTTAG
%token YES NO
+%token INCLUDE
%token ERROR
%token <v.string> STRING
%token <v.number> NUMBER
@@ -147,6 +148,7 @@ typedef struct {
%%
grammar : /* empty */
+ | grammar include '\n'
| grammar '\n'
| grammar conf_main '\n'
| grammar varset '\n'
@@ -157,6 +159,21 @@ grammar : /* empty */
| grammar error '\n' { file->errors++; }
;
+include : INCLUDE STRING {
+ struct file *nfile;
+
+ if ((nfile = pushfile($2, 1)) == NULL) {
+ yyerror("failed to include file %s", $2);
+ free($2);
+ YYERROR;
+ }
+ free($2);
+
+ file = nfile;
+ lungetc('\n');
+ }
+ ;
+
string : string STRING {
if (asprintf(&$$, "%s %s", $1, $2) == -1) {
free($1);
@@ -650,6 +667,7 @@ lookup(char *s)
{"ethernet", ETHERNET},
{"ethernet-tagged", ETHERNETTAGGED},
{"fib-update", FIBUPDATE},
+ {"include", INCLUDE},
{"interface", INTERFACE},
{"keepalive", KEEPALIVE},
{"l2vpn", L2VPN},