summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet.c6
-rw-r--r--usr.bin/netstat/sctp.c98
2 files changed, 14 insertions, 90 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 54ab56f..6f912ac 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -418,10 +418,10 @@ protopr(u_long off, const char *name, int af1, int proto)
"Tcpcb");
if (Lflag)
xo_emit((Aflag && !Wflag) ?
- "{T:/%-5.5s} {T:/%-14.14s} {T:/%-18.18s}" :
+ "{T:/%-5.5s} {T:/%-32.32s} {T:/%-18.18s}" :
((!Wflag || af1 == AF_INET) ?
- "{T:/%-5.5s} {T:/%-14.14s} {T:/%-22.22s}" :
- "{T:/%-5.5s} {T:/%-14.14s} {T:/%-45.45s}"),
+ "{T:/%-5.5s} {T:/%-32.32s} {T:/%-22.22s}" :
+ "{T:/%-5.5s} {T:/%-32.32s} {T:/%-45.45s}"),
"Proto", "Listen", "Local Address");
else if (Tflag)
xo_emit((Aflag && !Wflag) ?
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index 0ab933a..fd133e3 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -104,93 +104,14 @@ struct xraddr_entry {
LIST_ENTRY(xraddr_entry) xraddr_entries;
};
-/*
- * Construct an Internet address representation.
- * If numeric_addr has been supplied, give
- * numeric value, otherwise try for symbolic name.
- */
#ifdef INET
-static char *
-inetname(struct in_addr *inp)
-{
- char *cp;
- static char line[MAXHOSTNAMELEN];
- struct hostent *hp;
- struct netent *np;
-
- cp = 0;
- if (!numeric_addr && inp->s_addr != INADDR_ANY) {
- 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) {
- cp = hp->h_name;
- trimdomain(cp, strlen(cp));
- }
- }
- }
- if (inp->s_addr == INADDR_ANY)
- strcpy(line, "*");
- else if (cp) {
- strlcpy(line, cp, sizeof(line));
- } else {
- inp->s_addr = ntohl(inp->s_addr);
-#define C(x) ((u_int)((x) & 0xff))
- sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24),
- C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr));
- inp->s_addr = htonl(inp->s_addr);
- }
- return (line);
-}
+char *
+inetname(struct in_addr *inp);
#endif
#ifdef INET6
-static char ntop_buf[INET6_ADDRSTRLEN];
-
-static char *
-inet6name(struct in6_addr *in6p)
-{
- char *cp;
- static char line[50];
- struct hostent *hp;
- static char domain[MAXHOSTNAMELEN];
- static int first = 1;
-
- if (first && !numeric_addr) {
- first = 0;
- if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
- (cp = strchr(domain, '.')))
- (void) strcpy(domain, cp + 1);
- else
- domain[0] = 0;
- }
- cp = 0;
- if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
- hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
- if (hp) {
- if ((cp = strchr(hp->h_name, '.')) &&
- !strcmp(cp + 1, domain))
- *cp = 0;
- cp = hp->h_name;
- }
- }
- if (IN6_IS_ADDR_UNSPECIFIED(in6p))
- strcpy(line, "*");
- else if (cp)
- strcpy(line, cp);
- else
- sprintf(line, "%s",
- inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
- sizeof(ntop_buf)));
- return (line);
-}
+char *
+inet6name(struct in6_addr *in6p);
#endif
static void
@@ -447,7 +368,8 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
first = 0;
}
xladdr = (struct xsctp_laddr *)(buf + *offset);
- if (Lflag && !is_listening) {
+ if ((!aflag && is_listening) ||
+ (Lflag && !is_listening)) {
sctp_skip_xinpcb_ifneed(buf, buflen, offset);
return;
}
@@ -513,8 +435,10 @@ retry:
xo_open_instance("local-address");
if (xladdr_total == 0) {
- xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
- pname, tname);
+ if (!Lflag) {
+ xo_emit("{:protocol/%-6.6s/%s} "
+ "{:type/%-5.5s/%s} ", pname, tname);
+ }
} else {
xo_emit("\n");
xo_emit(Lflag ? "{P:/%-21.21s} " : "{P:/%-12.12s} ",
@@ -529,7 +453,7 @@ retry:
"{:state/CLOSED}", " ");
} else {
xo_emit("{P:/%-45.45s} "
- "{:state:LISTEN}", " ");
+ "{:state/LISTEN}", " ");
}
} else {
if (process_closed) {
OpenPOWER on IntegriCloud