diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-06 06:05:42 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-06 06:05:42 +0000 |
commit | 7e1f751c2571c2ea5765fe7d369e976ab8fd4efc (patch) | |
tree | 7e8cc4621670598645182775130c5cd6bdf893d3 /usr.sbin | |
parent | c5ec57031e8cf19fe93805308102674fa3d79263 (diff) |
bgpctl part of allowing alternate RIBs to be shown. Had to use the
keyword table because show rib rib foo is strange.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 22 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.h | 3 |
3 files changed, 26 insertions, 3 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index acab60aaded..d4cfb962c64 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.140 2009/05/17 13:23:08 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.141 2009/06/06 06:05:41 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -220,6 +220,7 @@ main(int argc, char *argv[]) } memcpy(&ribreq.neighbor, &neighbor, sizeof(ribreq.neighbor)); + strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib)); ribreq.af = res->af; ribreq.flags = res->flags; imsg_compose(ibuf, type, 0, 0, -1, &ribreq, sizeof(ribreq)); @@ -291,6 +292,7 @@ main(int argc, char *argv[]) case NETWORK_SHOW: bzero(&ribreq, sizeof(ribreq)); ribreq.af = res->af; + strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib)); imsg_compose(ibuf, IMSG_CTL_SHOW_NETWORK, 0, 0, -1, &ribreq, sizeof(ribreq)); show_network_head(); diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index a1ce55e2f2c..5e5340e1dbb 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.52 2009/04/23 16:20:39 sthen Exp $ */ +/* $OpenBSD: parser.c,v 1.53 2009/06/06 06:05:41 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -42,6 +42,7 @@ enum token_type { ASTYPE, PREFIX, PEERDESC, + RIBNAME, COMMUNITY, LOCALPREF, MED, @@ -72,6 +73,7 @@ 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_neigh[]; +static const struct token t_show_rib_rib[]; static const struct token t_show_neighbor[]; static const struct token t_show_neighbor_modifiers[]; static const struct token t_fib[]; @@ -148,6 +150,7 @@ static const struct token 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, "table", NONE, t_show_rib_rib}, { KEYWORD, "summary", SHOW_SUMMARY, t_show_summary}, { KEYWORD, "memory", SHOW_RIB_MEM, NULL}, { FAMILY, "", NONE, t_show_rib}, @@ -161,6 +164,11 @@ static const struct token t_show_rib_neigh[] = { { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_show_rib_rib[] = { + { RIBNAME, "", NONE, t_show_rib}, + { ENDTOKEN, "", NONE, NULL} +}; + static const struct token t_show_neighbor[] = { { NOTOKEN, "", NONE, NULL}, { PEERADDRESS, "", NONE, t_show_neighbor_modifiers}, @@ -456,6 +464,15 @@ match_token(int *argc, char **argv[], const struct token table[]) t = &table[i]; } break; + case RIBNAME: + if (!match && word != NULL && strlen(word) > 0) { + if (strlcpy(res.rib, word, sizeof(res.rib)) >= + sizeof(res.rib)) + errx(1, "rib name too long"); + match++; + t = &table[i]; + } + break; case COMMUNITY: if (word != NULL && strlen(word) > 0 && parse_community(word, &res)) { @@ -547,6 +564,9 @@ show_valid_args(const struct token table[]) case PEERDESC: fprintf(stderr, " <neighbor description>\n"); break; + case RIBNAME: + fprintf(stderr, " <rib name>\n"); + break; case COMMUNITY: fprintf(stderr, " <community>\n"); break; diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index bcc04f7fcd0..8adb5b5a9ce 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.18 2008/06/07 18:14:41 henning Exp $ */ +/* $OpenBSD: parser.h,v 1.19 2009/06/06 06:05:41 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -56,6 +56,7 @@ struct parse_result { struct filter_set_head set; struct filter_community community; char peerdesc[PEER_DESCR_LEN]; + char rib[PEER_DESCR_LEN]; char *irr_outdir; int flags; enum actions action; |