summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d/parse.y
diff options
context:
space:
mode:
authorremi <remi@cvs.openbsd.org>2019-05-26 09:27:10 +0000
committerremi <remi@cvs.openbsd.org>2019-05-26 09:27:10 +0000
commit1cebeb395da7cf93cb09ad736931487725700e70 (patch)
tree9f37d598f80574ac671263819caccc5abfcb71c2 /usr.sbin/ospf6d/parse.y
parent33d96782bafb19401b398ba4f8891951191526a3 (diff)
Allow specifying area by number as well as id. No changes to outputs.
reads OK to kn@ OK denis@
Diffstat (limited to 'usr.sbin/ospf6d/parse.y')
-rw-r--r--usr.sbin/ospf6d/parse.y32
1 files changed, 22 insertions, 10 deletions
diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y
index 633634dba6b..4a9b5331946 100644
--- a/usr.sbin/ospf6d/parse.y
+++ b/usr.sbin/ospf6d/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.43 2019/04/29 05:14:38 remi Exp $ */
+/* $OpenBSD: parse.y,v 1.44 2019/05/26 09:27:09 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -117,6 +117,7 @@ typedef struct {
int64_t number;
char *string;
struct redistribute *redist;
+ struct in_addr id;
} v;
int lineno;
} YYSTYPE;
@@ -139,6 +140,7 @@ typedef struct {
%type <v.number> yesno no optlist, optlist_l option demotecount
%type <v.string> string dependon
%type <v.redist> redistribute
+%type <v.id> areaid
%%
@@ -456,15 +458,8 @@ comma : ','
| /*empty*/
;
-area : AREA STRING {
- struct in_addr id;
- if (inet_aton($2, &id) == 0) {
- yyerror("error parsing area");
- free($2);
- YYERROR;
- }
- free($2);
- area = conf_get_area(id);
+area : AREA areaid {
+ area = conf_get_area($2);
memcpy(&areadefs, defs, sizeof(areadefs));
defs = &areadefs;
@@ -478,6 +473,23 @@ demotecount : NUMBER { $$ = $1; }
| /*empty*/ { $$ = 1; }
;
+areaid : NUMBER {
+ if ($1 < 0 || $1 > 0xffffffff) {
+ yyerror("invalid area id");
+ YYERROR;
+ }
+ $$.s_addr = htonl($1);
+ }
+ | STRING {
+ if (inet_aton($1, &$$) == 0) {
+ yyerror("error parsing area");
+ free($1);
+ YYERROR;
+ }
+ free($1);
+ }
+ ;
+
areaopts_l : areaopts_l areaoptsl nl
| areaoptsl optnl
;