diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-05-21 11:52:33 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-05-21 11:52:33 +0000 |
commit | 10f34db6e4360c71ca33653464c00bc64184dbd9 (patch) | |
tree | 8a8488343f938fc049bb20f8e74a5d65c811ca25 /usr.sbin | |
parent | 2e37efc589c0992b17faac7080ceda911771b752 (diff) |
Make it possible to add, delete, flush and show network announcements.
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 42 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 18 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.h | 8 |
3 files changed, 64 insertions, 4 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 8b80109e553..a1b5153d888 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.58 2004/05/20 12:17:04 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.59 2004/05/21 11:52:32 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -53,6 +53,7 @@ void print_timer(const char *, time_t, u_int); static char *fmt_timeframe(time_t t); static char *fmt_timeframe_core(time_t t); void show_fib_head(void); +void show_network_head(void); int show_fib_msg(struct imsg *); void show_nexthop_head(void); int show_nexthop_msg(struct imsg *); @@ -83,6 +84,7 @@ main(int argc, char *argv[]) struct sockaddr_un sun; int fd, n, done; struct imsg imsg; + struct network_config net; struct parse_result *res; if ((res = parse(argc, argv)) == NULL) @@ -184,6 +186,30 @@ main(int argc, char *argv[]) printf("request sent.\n"); done = 1; break; + case NETWORK_ADD: + case NETWORK_REMOVE: + bzero(&net, sizeof(net)); + memcpy(&net.prefix, &res->addr, sizeof(res->addr)); + net.prefixlen = res->prefixlen; + /* attribute sets are not supported */ + if (res->action == NETWORK_ADD) + imsg_compose(&ibuf, IMSG_NETWORK_ADD, 0, + &net, sizeof(net)); + else + imsg_compose(&ibuf, IMSG_NETWORK_REMOVE, 0, + &net, sizeof(net)); + printf("request sent.\n"); + done = 1; + break; + case NETWORK_FLUSH: + imsg_compose(&ibuf, IMSG_NETWORK_FLUSH, 0, NULL, 0); + printf("request sent.\n"); + done = 1; + break; + case NETWORK_SHOW: + imsg_compose(&ibuf, IMSG_CTL_SHOW_NETWORK, 0, NULL, 0); + show_network_head(); + break; } while (ibuf.w.queued) @@ -224,6 +250,9 @@ main(int argc, char *argv[]) case SHOW_RIB: done = show_rib_summary_msg(&imsg); break; + case NETWORK_SHOW: + done = show_fib_msg(&imsg); + break; case NONE: case RELOAD: case FIB: @@ -232,6 +261,9 @@ main(int argc, char *argv[]) case NEIGHBOR: case NEIGHBOR_UP: case NEIGHBOR_DOWN: + case NETWORK_ADD: + case NETWORK_REMOVE: + case NETWORK_FLUSH: break; } imsg_free(&imsg); @@ -516,6 +548,13 @@ show_fib_head(void) printf("flags destination gateway\n"); } +void +show_network_head(void) +{ + printf("flags: S = Static\n"); + printf("flags destination\n"); +} + int show_fib_msg(struct imsg *imsg) { @@ -524,6 +563,7 @@ show_fib_msg(struct imsg *imsg) switch (imsg->hdr.type) { case IMSG_CTL_KROUTE: + case IMSG_CTL_SHOW_NETWORK: if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(struct kroute)) errx(1, "wrong imsg len"); k = imsg->data; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 90bd808eded..0aee651fc91 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.5 2004/03/11 16:34:21 henning Exp $ */ +/* $OpenBSD: parser.c,v 1.6 2004/05/21 11:52:32 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -55,12 +55,15 @@ static const struct token t_neighbor_modifiers[]; static const struct token t_show_as[]; static const struct token t_show_prefix[]; static const struct token t_show_ip[]; +static const struct token t_nexthop[]; +static const struct token t_prefix[]; static const struct token t_main[] = { { KEYWORD, "reload", RELOAD, NULL}, { KEYWORD, "show", SHOW, t_show}, { KEYWORD, "fib", FIB, t_fib}, { KEYWORD, "neighbor", NEIGHBOR, t_neighbor}, + { KEYWORD, "network", NONE, t_nexthop}, { ENDTOKEN, "", NONE, NULL} }; @@ -144,6 +147,19 @@ static const struct token t_show_ip[] = { { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_nexthop[] = { + { KEYWORD, "add", NETWORK_ADD, t_prefix}, + { KEYWORD, "delete", NETWORK_REMOVE, t_prefix}, + { KEYWORD, "flush", NETWORK_FLUSH, NULL}, + { KEYWORD, "show", NETWORK_SHOW, NULL}, + { ENDTOKEN, "", NONE, NULL} +}; + +static const struct token t_prefix[] = { + { PREFIX, "", NONE, NULL}, + { ENDTOKEN, "", NONE, NULL} +}; + static struct parse_result res; const struct token *match_token(const char *, const struct token []); diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index 42c8cfefc57..8352f4a5dce 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.3 2004/03/02 19:32:43 claudio Exp $ */ +/* $OpenBSD: parser.h,v 1.4 2004/05/21 11:52:32 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -36,7 +36,11 @@ enum actions { FIB_DECOUPLE, NEIGHBOR, NEIGHBOR_UP, - NEIGHBOR_DOWN + NEIGHBOR_DOWN, + NETWORK_ADD, + NETWORK_REMOVE, + NETWORK_FLUSH, + NETWORK_SHOW }; struct parse_result { |