PERFORCE change 163979 for review
Gabor Pali
pgj at FreeBSD.org
Wed Jun 10 12:11:15 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163979
Change 163979 by pgj at petymeg-current on 2009/06/10 12:10:12
Add st_extname property for representing extended names for specific
connections (e.g. tcp4, tcp46)
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#14 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#13 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#10 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#12 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#6 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#14 (text+ko) ====
@@ -17,6 +17,7 @@
#include <nlist.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "netstat.h"
#include "netstat_internal.h"
@@ -339,6 +340,7 @@
{
struct sockaddr_un *sa;
+ strlcpy(stp->st_extname, stp->st_name, SOCKTYPE_MAXNAME);
stp->st_qlen = xpcb->xu_socket.so_qlen;
stp->st_incqlen = xpcb->xu_socket.so_incqlen;
stp->st_qlimit = xpcb->xu_socket.so_qlimit;
@@ -378,6 +380,8 @@
extract_inet_data(struct tcpcb *tp, struct inpcb *inp, struct xsocket *so,
struct socket_type *stp)
{
+ const char *vchar;
+
stp->st_qlen = so->so_qlen;
stp->st_incqlen = so->so_incqlen;
stp->st_qlimit = so->so_qlimit;
@@ -422,4 +426,13 @@
}
#endif /* defined(TF_NEEDSYN) && defined(TF_NEEDFIN) */
}
+#ifdef INET6
+ if ((inp->inp_vflag & INP_IPV6) != 0)
+ vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
+ "46" : "6 ";
+ else
+#endif
+ vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
+ "4 " : " ";
+ sprintf(stp->st_extname, "%-3.3s%-2.2s", stp->st_name, vchar);
}
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#13 (text+ko) ====
@@ -56,6 +56,7 @@
int netstat_st_get_family(const struct socket_type *stp);
int netstat_st_get_protocol(const struct socket_type *stp);
const char *netstat_st_get_name(const struct socket_type *stp);
+const char *netstat_st_get_extname(const struct socket_type *stp);
/* XXX: move snd/rcv-related properties into a new abstract type? */
u_int netstat_st_get_snd_cc(const struct socket_type *stp);
u_int netstat_st_get_snd_hiwat(const struct socket_type *stp);
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#10 (text+ko) ====
@@ -29,6 +29,7 @@
unsigned short st_protocol;
int st_flags;
char st_name[SOCKTYPE_MAXNAME];
+ char st_extname[SOCKTYPE_MAXNAME];
#if 0
/* XXX: not used yet */
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#12 (text+ko) ====
@@ -252,6 +252,12 @@
return (stp->st_name);
}
+const char *
+netstat_st_get_extname(const struct socket_type *stp)
+{
+ return (stp->st_extname);
+}
+
u_int
netstat_st_get_rcv_cc(const struct socket_type *stp)
{
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#6 (text+ko) ====
@@ -611,7 +611,6 @@
{
static int first = 1;
char buf1[15];
- const char *vchar;
struct tcpcb tp;
struct inpcb inp;
struct xsocket so;
@@ -692,15 +691,7 @@
return;
if (Aflag)
printf("%8lx ", netstat_st_get_pcb(stp));
-#ifdef INET6
- if ((inp.inp_vflag & INP_IPV6) != 0)
- vchar = ((inp.inp_vflag & INP_IPV4) != 0) ?
- "46" : "6 ";
- else
-#endif
- vchar = ((inp.inp_vflag & INP_IPV4) != 0) ?
- "4 " : " ";
- printf("%-3.3s%-2.2s ", netstat_st_get_name(stp), vchar);
+ printf("%-5.5s ", netstat_st_get_extname(stp));
if (Lflag) {
snprintf(buf1, 15, "%d/%d/%d", netstat_st_get_qlen(stp),
netstat_st_get_incqlen(stp), netstat_st_get_qlimit(stp));
More information about the p4-projects
mailing list