Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jun 2009 00:52:56 GMT
From:      Gabor Pali <pgj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 164314 for review
Message-ID:  <200906140052.n5E0qudP011035@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=164314

Change 164314 by pgj@petymeg-current on 2009/06/14 00:52:12

	Fix port information storage and port name rendering

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#28 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#16 edit

Differences ...

==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#28 (text+ko) ====

@@ -743,12 +743,12 @@
 		    C(in->s_addr));
 	}
 	result = _netstat_at_allocate(type, address, NULL);
-	result->at_port = port;
+	result->at_port = ntohs(port);
 	sp = getservbyport((int)port, proto);
 	if ((sp != NULL || port == 0) && !anonport)
 		sprintf(result->at_portname, "%.15s", sp ? sp->s_name : "*");
 	else
-		sprintf(result->at_portname, "%d", ntohs(port));
+		sprintf(result->at_portname, "%d", result->at_port);
 
 	return (result);
 #undef C

==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#16 (text+ko) ====

@@ -933,7 +933,10 @@
 	sprintf(line, "%.*s.", Wflag ? 39 : (Aflag && !numeric) ? 12 : 16,
 	    netstat_at_get_name(atp));
 	cp = index(line, '\0');
-	sprintf(cp, "%.15s ", netstat_at_get_portname(atp));
+	if (numeric && (netstat_at_get_port(atp) > 0))
+		sprintf(cp, "%d ", netstat_at_get_port(atp));
+	else
+		sprintf(cp, "%.15s ", netstat_at_get_portname(atp));
 	width = Wflag ? 45 : Aflag ? 18 : 22;
 	printf("%-*.*s ", width, width, line);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906140052.n5E0qudP011035>