diff options
author | 2007-03-04 18:13:13 +0000 | |
---|---|---|
committer | 2007-03-04 18:13:13 +0000 | |
commit | 3d8e8c928e398357720f511fc1b6137536a03e64 (patch) | |
tree | 38a5ff2194b1b51d26ae13389f9e1c39ea072b94 /usr.sbin/bgpctl/irr_parser.c | |
parent | pass pointer to struct policy_item down to print_rule() instead of 3 of its (diff) | |
download | wireguard-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.c | 19 |
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: |