Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Aug 2009 22:28:15 GMT
From:      Gabor Pali <pgj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 167147 for review
Message-ID:  <200908092228.n79MSFNs012484@repoman.freebsd.org>

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

Change 167147 by pgj@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)
 {



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