From owner-p4-projects@FreeBSD.ORG Sun Aug 9 22:28:16 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C73C31065673; Sun, 9 Aug 2009 22:28:15 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 848601065670 for ; Sun, 9 Aug 2009 22:28:15 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 738F88FC1A for ; Sun, 9 Aug 2009 22:28:15 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n79MSFlu012486 for ; Sun, 9 Aug 2009 22:28:15 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n79MSFNs012484 for perforce@freebsd.org; Sun, 9 Aug 2009 22:28:15 GMT (envelope-from pgj@FreeBSD.org) Date: Sun, 9 Aug 2009 22:28:15 GMT Message-Id: <200908092228.n79MSFNs012484@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pgj@FreeBSD.org using -f From: Gabor Pali To: Perforce Change Reviews Cc: Subject: PERFORCE change 167147 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Aug 2009 22:28:16 -0000 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) {