diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-04 18:51:24 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-04 18:51:24 +0000 |
commit | 28b7b3ac46fb9369695f70ad210291f7a919568d (patch) | |
tree | 54b06bd568c9f4258f6c3095332266be1ecffd20 /usr.sbin/bgpd | |
parent | c7bb0964d9cd0217cdaf4a82ab3d44c63597eaaf (diff) |
allow "show neighbor" to be limited to one specific neighbor
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 12 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 19 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 8 |
4 files changed, 32 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index f7d8f6ba2bf..2f97b8a0c74 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.50 2004/01/03 20:37:34 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.51 2004/01/04 18:51:23 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -75,6 +75,16 @@ struct msgbuf { TAILQ_HEAD(bufs, buf) bufs; }; +struct bgpd_addr { + sa_family_t af; + union { + struct in_addr v4; + struct in6_addr v6; + } ba; /* 128-bit address */ +#define v4 ba.v4 +#define v6 ba.v6 +}; + struct bgpd_config { int opts; u_int16_t as; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index fbeb4f22f24..7eb6dda7f69 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.7 2004/01/03 20:22:07 henning Exp $ */ +/* $OpenBSD: control.c,v 1.8 2004/01/04 18:51:23 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -173,6 +173,7 @@ control_dispatch_msg(struct pollfd *pfd, int i) struct ctl_conn *c; int n; struct peer *p; + struct bgpd_addr *addr; if ((c = control_connbyfd(pfd->fd)) == NULL) { log_err("control_dispatch_msg: fd %d: not found", pfd->fd); @@ -195,9 +196,19 @@ control_dispatch_msg(struct pollfd *pfd, int i) switch (imsg.hdr.type) { case IMSG_CTL_SHOW_NEIGHBOR: - for (p = peers; p != NULL; p = p->next) - imsg_compose(&c->ibuf, IMSG_CTL_SHOW_NEIGHBOR, - 0, p, sizeof(struct peer)); + if (imsg.hdr.len == IMSG_HEADER_SIZE + + sizeof(struct bgpd_addr)) { + addr = imsg.data; + p = getpeerbyip(addr->v4.s_addr); + if (p != NULL) + imsg_compose(&c->ibuf, + IMSG_CTL_SHOW_NEIGHBOR, + 0, p, sizeof(struct peer)); + } else + for (p = peers; p != NULL; p = p->next) + imsg_compose(&c->ibuf, + IMSG_CTL_SHOW_NEIGHBOR, + 0, p, sizeof(struct peer)); imsg_compose(&c->ibuf, IMSG_CTL_END, 0, NULL, 0); break; default: diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 25c01842f45..f7df8dfbc99 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.59 2004/01/04 17:19:41 henning Exp $ */ +/* $OpenBSD: session.c,v 1.60 2004/01/04 18:51:23 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -78,8 +78,6 @@ void session_dispatch_imsg(struct imsgbuf *, int); void session_up(struct peer *); void session_down(struct peer *); -struct peer *getpeerbyip(in_addr_t); - struct bgpd_config *conf, *nconf = NULL; struct peer *npeers; volatile sig_atomic_t session_quit = 0; diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 8ad48abdd65..96be2a88899 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.7 2004/01/03 22:44:29 henning Exp $ */ +/* $OpenBSD: session.h,v 1.8 2004/01/04 18:51:23 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -144,9 +144,11 @@ struct peer { struct peer *peers; /* session.c */ -void session_socket_blockmode(int, enum blockmodes); -int session_main(struct bgpd_config *, struct peer *, int[2], +void session_socket_blockmode(int, enum blockmodes); +int session_main(struct bgpd_config *, struct peer *, int[2], int[2]); +struct peer *getpeerbyip(in_addr_t); + /* log.c */ void log_peer_err(const struct peer *, const char *, ...); |