diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-16 04:41:50 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-16 04:41:50 +0000 |
commit | 60fff3a941a1653c5e203b115b3d6abbdef961b6 (patch) | |
tree | 452eff560ec08138b77b381534f3b5be0eac72be /usr.sbin/bgpctl | |
parent | 27838d159af1013338d85a71c521ecc43a8d0e68 (diff) |
in the neighbor view, add support for local/remote addr beeing v6 ones
Diffstat (limited to 'usr.sbin/bgpctl')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 15646110cae..3d3f1ef01aa 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.49 2004/04/13 22:55:01 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.50 2004/04/16 04:41:49 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -281,8 +281,8 @@ int show_neighbor_msg(struct imsg *imsg, enum neighbor_views nv) { struct peer *p; - struct sockaddr_in *sa_in; struct in_addr ina; + char buf[48]; switch (imsg->hdr.type) { case IMSG_CTL_SHOW_NEIGHBOR: @@ -325,18 +325,30 @@ show_neighbor_msg(struct imsg *imsg, enum neighbor_views nv) break; } printf("\n"); - if (p->sa_local.ss_family == AF_INET) { - sa_in = (struct sockaddr_in *)&p->sa_local; + if (inet_ntop(p->sa_local.ss_family, &p->sa_local, + buf, sizeof(buf)) == NULL) + strlcpy(buf, "????????", sizeof(buf)); + if (p->sa_local.ss_family == AF_INET) printf(" Local host: %20s, Local port: %5u\n", - inet_ntoa(sa_in->sin_addr), - ntohs(sa_in->sin_port)); - } - if (p->sa_remote.ss_family == AF_INET) { - sa_in = (struct sockaddr_in *)&p->sa_remote; - printf(" Foreign host: %20s, Foreign port: %5u\n", - inet_ntoa(sa_in->sin_addr), - ntohs(sa_in->sin_port)); - } + buf, ntohs(((struct sockaddr_in *) + &p->sa_local)->sin_port)); + if (p->sa_local.ss_family == AF_INET6) + printf(" Local host: %20s, Local port: %5u\n", + buf, ntohs(((struct sockaddr_in6 *) + &p->sa_local)->sin6_port)); + + if (inet_ntop(p->sa_remote.ss_family, &p->sa_remote, + buf, sizeof(buf)) == NULL) + strlcpy(buf, "????????", sizeof(buf)); + if (p->sa_remote.ss_family == AF_INET) + printf(" Remote host: %20s, Remote port: %5u\n", + buf, ntohs(((struct sockaddr_in *) + &p->sa_remote)->sin_port)); + if (p->sa_remote.ss_family == AF_INET6) + printf(" Remote host: %20s, Remote port: %5u\n", + buf, ntohs(((struct sockaddr_in6 *) + &p->sa_remote)->sin6_port)); + printf("\n"); break; case IMSG_CTL_END: |