summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bgpctl/irr_parser.c
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2007-03-04 18:13:13 +0000
committerhenning <henning@openbsd.org>2007-03-04 18:13:13 +0000
commit3d8e8c928e398357720f511fc1b6137536a03e64 (patch)
tree38a5ff2194b1b51d26ae13389f9e1c39ea072b94 /usr.sbin/bgpctl/irr_parser.c
parentpass pointer to struct policy_item down to print_rule() instead of 3 of its (diff)
downloadwireguard-openbsd-3d8e8c928e398357720f511fc1b6137536a03e64.tar.xz
wireguard-openbsd-3d8e8c928e398357720f511fc1b6137536a03e64.zip
store peer AS numerically
Diffstat (limited to 'usr.sbin/bgpctl/irr_parser.c')
-rw-r--r--usr.sbin/bgpctl/irr_parser.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/bgpctl/irr_parser.c b/usr.sbin/bgpctl/irr_parser.c
index f9fe2e2f149..9157323b6ef 100644
--- a/usr.sbin/bgpctl/irr_parser.c
+++ b/usr.sbin/bgpctl/irr_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: irr_parser.c,v 1.4 2007/03/04 12:37:07 henning Exp $ */
+/* $OpenBSD: irr_parser.c,v 1.5 2007/03/04 18:13:13 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/param.h>
+#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -271,11 +272,21 @@ parse_policy(char *key, char *val)
st = nextst;
break;
case PO_PEER_KEY:
- if (pi->peer_as == NULL) {
+ if (pi->peer_as == 0) {
+ const char *errstr;
+
if (nextst != PO_NONE)
goto ppoerr;
- if ((pi->peer_as = strdup(tok)) == NULL)
- err(1, NULL);
+ if (strlen(tok) < 3 ||
+ strncasecmp(tok, "AS", 2) ||
+ !isdigit(tok[2]))
+ errx(1, "peering spec \"%s\": format "
+ "error, AS expected", tok);
+ pi->peer_as = strtonum(tok + 2, 1, USHRT_MAX,
+ &errstr);
+ if (errstr)
+ errx(1, "peering spec \"%s\": format "
+ "error: %s", tok, errstr);
} else {
switch (nextst) {
case PO_NONE: