summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2007-03-04 18:13:14 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2007-03-04 18:13:14 +0000
commita1c6aeedee79fc907a4d042219a3b4d2b7f0f1a0 (patch)
tree09b439e376119d79b6b4fc680bdede1555d9e2a1 /usr.sbin
parentd29002bf8a72d2aa7422da8d3aba539f12e74a2c (diff)
store peer AS numerically
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpctl/irr_output.c5
-rw-r--r--usr.sbin/bgpctl/irr_parser.c19
-rw-r--r--usr.sbin/bgpctl/irrfilter.h6
3 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/bgpctl/irr_output.c b/usr.sbin/bgpctl/irr_output.c
index c5519e59d78..50872ba7219 100644
--- a/usr.sbin/bgpctl/irr_output.c
+++ b/usr.sbin/bgpctl/irr_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: irr_output.c,v 1.5 2007/03/04 17:47:31 henning Exp $ */
+/* $OpenBSD: irr_output.c,v 1.6 2007/03/04 18:13:13 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -94,7 +94,6 @@ process_policies(FILE *fh, struct policy_head *head)
policy_prettyprint(fh, pi);
policy_torule(fh, pi);
- free(pi->peer_as);
free(pi->peer_addr);
free(pi->action);
free(pi->filter);
@@ -111,7 +110,7 @@ policy_prettyprint(FILE *fh, struct policy_item *pi)
fprintf(fh, "# import: from ");
else
fprintf(fh, "# export: to ");
- fprintf(fh, "%s ", pi->peer_as);
+ fprintf(fh, "AS%u ", pi->peer_as);
if (pi->peer_addr)
fprintf(fh, "%s ", pi->peer_addr);
if (pi->action)
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:
diff --git a/usr.sbin/bgpctl/irrfilter.h b/usr.sbin/bgpctl/irrfilter.h
index 1cd55f7dce5..ca15a25d6d5 100644
--- a/usr.sbin/bgpctl/irrfilter.h
+++ b/usr.sbin/bgpctl/irrfilter.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: irrfilter.h,v 1.1 2007/03/03 11:45:30 henning Exp $ */
+/* $OpenBSD: irrfilter.h,v 1.2 2007/03/04 18:13:13 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -31,11 +31,11 @@ enum pdir {
struct policy_item {
TAILQ_ENTRY(policy_item) entry;
- enum pdir dir;
- char *peer_as;
char *peer_addr;
char *action;
char *filter;
+ enum pdir dir;
+ u_int16_t peer_as;
};
TAILQ_HEAD(policy_head, policy_item);