diff options
author | 2014-10-23 16:45:57 +0000 | |
---|---|---|
committer | 2014-10-23 16:45:57 +0000 | |
commit | 0ee187a131304f77f3a51f7e7df7d033a2c3dada (patch) | |
tree | b62fe73737822aa7b76ab807ed5c3b9fee2b5733 | |
parent | Now that gcc2 is gone revert the removal of anonymous unions, means not having to (diff) | |
download | wireguard-openbsd-0ee187a131304f77f3a51f7e7df7d033a2c3dada.tar.xz wireguard-openbsd-0ee187a131304f77f3a51f7e7df7d033a2c3dada.zip |
Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.
-rw-r--r-- | usr.bin/netstat/inet.c | 22 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 9 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 15 | ||||
-rw-r--r-- | usr.bin/netstat/show.c | 14 |
4 files changed, 17 insertions, 43 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index cf64fbb49b1..8ce93c6b87f 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.134 2014/08/14 12:55:50 mpi Exp $ */ +/* $OpenBSD: inet.c,v 1.135 2014/10/23 16:45:57 schwarze Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -801,7 +801,6 @@ inetname(struct in_addr *inp) char *cp; static char line[50]; struct hostent *hp; - struct netent *np; static char domain[MAXHOSTNAMELEN]; static int first = 1; @@ -818,19 +817,12 @@ inetname(struct in_addr *inp) int net = inet_netof(*inp); int lna = inet_lnaof(*inp); - if (lna == INADDR_ANY) { - np = getnetbyaddr(net, AF_INET); - if (np) - cp = np->n_name; - } - if (cp == NULL) { - hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); - if (hp) { - if ((cp = strchr(hp->h_name, '.')) && - !strcmp(cp + 1, domain)) - *cp = '\0'; - cp = hp->h_name; - } + hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); + if (hp) { + if ((cp = strchr(hp->h_name, '.')) && + !strcmp(cp + 1, domain)) + *cp = '\0'; + cp = hp->h_name; } } if (inp->s_addr == INADDR_ANY) diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 84c753da3bd..f3074c99ef9 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.101 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.102 2014/10/23 16:45:57 schwarze Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -372,13 +372,6 @@ main(int argc, char *argv[]) printproto(tp, tp->pr_name, af, tableid, pcbaddr); exit(0); } - /* - * Keep file descriptors open to avoid overhead - * of open/close on each call to get* routines. - */ - sethostent(1); - setnetent(1); - if (iflag) { intpr(interval, repeatcount); exit(0); diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index ead50ddcb26..30992709276 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: netstat.1,v 1.71 2014/05/10 23:31:40 jmc Exp $ +.\" $OpenBSD: netstat.1,v 1.72 2014/10/23 16:45:57 schwarze Exp $ .\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $ .\" .\" Copyright (c) 1983, 1990, 1992, 1993 @@ -30,7 +30,7 @@ .\" .\" from: @(#)netstat.1 8.8 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: May 10 2014 $ +.Dd $Mdocdate: October 23 2014 $ .Dt NETSTAT 1 .Os .Sh NAME @@ -312,12 +312,10 @@ Address formats are of the form or .Dq network.port if a socket's address specifies a network but no specific host address. -When known, the host and network addresses are displayed symbolically -according to the databases -.Pa /etc/hosts -and -.Pa /etc/networks , -respectively. +When known, the host addresses are displayed symbolically +according to the +.Xr hosts 5 +database. If a symbolic name for an address is unknown, or if the .Fl n option is specified, the address is printed numerically, according @@ -427,7 +425,6 @@ Subsequent lines of output show values accumulated over the preceding interval. .Xr netintro 4 , .Xr route 4 , .Xr hosts 5 , -.Xr networks 5 , .Xr protocols 5 , .Xr services 5 , .Xr iostat 8 , diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index 53ecac7ae9e..e27e30198e1 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.42 2014/05/08 09:28:08 mpi Exp $ */ +/* $OpenBSD: show.c,v 1.43 2014/10/23 16:45:57 schwarze Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -713,21 +713,13 @@ routename6(struct sockaddr_in6 *sin6) char * netname4(in_addr_t in, in_addr_t mask) { - char *cp = NULL; - struct netent *np = NULL; int mbits; in = ntohl(in); mask = ntohl(mask); - if (!nflag && in != INADDR_ANY) { - if ((np = getnetbyaddr(in, AF_INET)) != NULL) - cp = np->n_name; - } - if (in == INADDR_ANY && mask == INADDR_ANY) - cp = "default"; mbits = mask ? 33 - ffs(mask) : 0; - if (cp) - strlcpy(line, cp, sizeof(line)); + if (in == INADDR_ANY && mask == INADDR_ANY) + strlcpy(line, "default", sizeof(line)); #define C(x) ((x) & 0xff) else if (mbits < 9) snprintf(line, sizeof(line), "%u/%d", C(in >> 24), mbits); |