summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpctl/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bgpctl/parser.c')
-rw-r--r--usr.sbin/bgpctl/parser.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c
index cdd8cc1fe6f..4173804beb8 100644
--- a/usr.sbin/bgpctl/parser.c
+++ b/usr.sbin/bgpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.33 2006/06/15 10:04:06 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.34 2006/08/23 08:21:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -34,6 +34,7 @@ enum token_type {
ENDTOKEN,
KEYWORD,
ADDRESS,
+ PEERADDRESS,
FLAG,
ASNUM,
ASTYPE,
@@ -61,7 +62,8 @@ static const struct token t_main[];
static const struct token t_show[];
static const struct token t_show_summary[];
static const struct token t_show_fib[];
-static const struct token t_show_rib[];
+static const struct token t_show_rib[];
+static const struct token t_show_rib_neigh[];
static const struct token t_show_neighbor[];
static const struct token t_show_neighbor_modifiers[];
static const struct token t_fib[];
@@ -127,18 +129,27 @@ static const struct token t_show_rib[] = {
{ ASTYPE, "as", AS_ALL, t_show_as},
{ ASTYPE, "source-as", AS_SOURCE, t_show_as},
{ ASTYPE, "transit-as", AS_TRANSIT, t_show_as},
- { ASTYPE, "empty-as", AS_EMPTY, NULL},
- { KEYWORD, "summary", SHOW_SUMMARY, NULL},
+ { ASTYPE, "empty-as", AS_EMPTY, t_show_rib},
{ FLAG, "detail", F_CTL_DETAIL, t_show_rib},
+ { FLAG, "in", F_CTL_ADJ_IN, t_show_rib},
+ { FLAG, "out", F_CTL_ADJ_OUT, t_show_rib},
+ { KEYWORD, "neighbor", NONE, t_show_rib_neigh},
+ { KEYWORD, "summary", SHOW_SUMMARY, NULL},
{ KEYWORD, "memory", SHOW_RIB_MEM, NULL},
- { FAMILY, "", NONE, NULL},
+ { FAMILY, "", NONE, t_show_rib},
{ PREFIX, "", NONE, t_show_prefix},
{ ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_show_rib_neigh[] = {
+ { PEERADDRESS, "", NONE, t_show_rib},
+ { PEERDESC, "", NONE, t_show_rib},
+ { ENDTOKEN, "", NONE, NULL}
+};
+
static const struct token t_show_neighbor[] = {
{ NOTOKEN, "", NONE, NULL},
- { ADDRESS, "", NONE, t_show_neighbor_modifiers},
+ { PEERADDRESS, "", NONE, t_show_neighbor_modifiers},
{ PEERDESC, "", NONE, t_show_neighbor_modifiers},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -157,7 +168,7 @@ static const struct token t_fib[] = {
};
static const struct token t_neighbor[] = {
- { ADDRESS, "", NONE, t_neighbor_modifiers},
+ { PEERADDRESS, "", NONE, t_neighbor_modifiers},
{ PEERDESC, "", NONE, t_neighbor_modifiers},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -171,7 +182,7 @@ static const struct token t_neighbor_modifiers[] = {
};
static const struct token t_show_as[] = {
- { ASNUM, "", NONE, NULL},
+ { ASNUM, "", NONE, t_show_rib},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -364,6 +375,14 @@ match_token(const char *word, const struct token table[])
res.action = t->value;
}
break;
+ case PEERADDRESS:
+ if (parse_addr(word, &res.peeraddr)) {
+ match++;
+ t = &table[i];
+ if (t->value)
+ res.action = t->value;
+ }
+ break;
case PREFIX:
if (parse_prefix(word, &res.addr, &res.prefixlen)) {
match++;
@@ -468,6 +487,7 @@ show_valid_args(const struct token table[])
fprintf(stderr, " %s\n", table[i].keyword);
break;
case ADDRESS:
+ case PEERADDRESS:
fprintf(stderr, " <address>\n");
break;
case PREFIX: