PERFORCE change 167147 for review
Gabor Pali
pgj at FreeBSD.org
Sun Aug 9 22:28:16 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167147
Change 167147 by pgj at petymeg-current on 2009/08/09 22:27:37
Add netstat_family_name(), a utility function for resolving protocol
family values into a string representation.
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#60 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#65 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#60 (text+ko) ====
@@ -265,6 +265,8 @@
const char *netstat_strerror(int);
const char *netstat_kvmerror(const struct session_type *);
+const char *netstat_family_name(int);
+
/* "Session" */
struct session_type *netstat_session_new(void* kvm_handle);
void netstat_session_free(struct session_type *);
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#65 (text+ko) ====
@@ -160,6 +160,49 @@
return ("Unknown error");
}
+const char *
+netstat_family_name(int pf)
+{
+ const char *pfname;
+ static char buf[64];
+
+ switch (pf) {
+ case PF_INET:
+ pfname = "Internet";
+ break;
+#ifdef INET6
+ case PF_INET6:
+ pfname = "Internet6";
+ break;
+#endif
+ case PF_IPX:
+ pfname = "IPX";
+ break;
+ case PF_ISO:
+ pfname = "ISO";
+ break;
+ case PF_APPLETALK:
+ pfname = "AppleTalk";
+ break;
+ case PF_CCITT:
+ pfname = "X.25";
+ break;
+ case PF_NETGRAPH:
+ pfname = "Netgraph";
+ break;
+ default:
+ pfname = NULL;
+ break;
+ }
+
+ if (pfname != NULL)
+ snprintf(buf, sizeof(buf), "%s", pfname);
+ else
+ snprintf(buf, sizeof(buf), "Protocol Family %d", pf);
+
+ return (buf);
+}
+
struct session_type *
netstat_session_new(void *kvm_handle)
{
More information about the p4-projects
mailing list