summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2001-06-15 20:47:01 +0000
committerimp <imp@FreeBSD.org>2001-06-15 20:47:01 +0000
commit6f314caece31aef6e6e71ee3a0b4dc54e77c766d (patch)
treed0e6dc18015dc741e0cdc8c933dd4595e4629f1d /usr.bin/netstat
parent0dbb10c226d48483c1c1c5d69068245f9f0a7e0d (diff)
downloadFreeBSD-src-6f314caece31aef6e6e71ee3a0b4dc54e77c766d.zip
FreeBSD-src-6f314caece31aef6e6e71ee3a0b4dc54e77c766d.tar.gz
Print symbolic names for appletalk ports. Also some very minor style 9 issues.
PR: bin/4157 Submitted by: Denny Gentry <denny1@home.com>
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/atalk.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c
index a8ddbcf..fddda0c 100644
--- a/usr.bin/netstat/atalk.c
+++ b/usr.bin/netstat/atalk.c
@@ -50,8 +50,9 @@ static const char rcsid[] =
#include <netatalk/at.h>
#include <netatalk/ddp_var.h>
-#include <nlist.h>
#include <errno.h>
+#include <nlist.h>
+#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "netstat.h"
@@ -106,6 +107,7 @@ static char *
at_pr_port(struct sockaddr_at *sat)
{
static char mybuf[50];
+ struct servent *serv;
switch(sat->sat_port) {
case ATADDR_ANYPORT:
@@ -113,7 +115,18 @@ static char mybuf[50];
case 0xff:
return "????";
default:
- sprintf(mybuf,"%d",(unsigned int)sat->sat_port);
+ if (nflag) {
+ (void)snprintf(mybuf, sizeof(mybuf), "%d",
+ (unsigned int)sat->sat_port);
+ } else {
+ serv = getservbyport(sat->sat_port, "ddp");
+ if (serv == NULL)
+ (void)snprintf(mybuf, sizeof(mybuf), "%d",
+ (unsigned int) sat->sat_port);
+ else
+ (void) snprintf(mybuf, sizeof(mybuf), "%s",
+ serv->s_name);
+ }
}
return mybuf;
}
OpenPOWER on IntegriCloud