From owner-p4-projects@FreeBSD.ORG Wed Jun 10 19:12:46 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D73A11065698; Wed, 10 Jun 2009 19:12:45 +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 9378A1065691 for ; Wed, 10 Jun 2009 19:12:45 +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 676148FC15 for ; Wed, 10 Jun 2009 19:12:45 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5AJCjIa059377 for ; Wed, 10 Jun 2009 19:12:45 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5AJCjre059375 for perforce@freebsd.org; Wed, 10 Jun 2009 19:12:45 GMT (envelope-from pgj@FreeBSD.org) Date: Wed, 10 Jun 2009 19:12:45 GMT Message-Id: <200906101912.n5AJCjre059375@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 164033 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: Wed, 10 Jun 2009 19:12:47 -0000 http://perforce.freebsd.org/chv.cgi?CH=164033 Change 164033 by pgj@petymeg-current on 2009/06/10 19:12:40 Add support for more protocols in netstat_socket() Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#20 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#20 (text+ko) ==== @@ -39,6 +39,10 @@ { .n_name = "_tcbinfo" }, #define X_UDBINFO 6 { .n_name = "_udbinfo" }, +#define X_DIVCBINFO 7 + { .n_name = "_divcbinfo" }, +#define X_RIPCBINFO 8 + { .n_name = "_ripcbinfo" }, { .n_name = NULL }, }; @@ -50,10 +54,6 @@ static const char *const socktype[] = { "#0", "stream", "dgram", "raw", "rdm", "seqpacket" }; -static const char *const ipproto[] = - { "#0", "#1", "#2", "#3", "#4", "#5", "tcp", "#7", "#8", "#9", "#10", - "#11", "#12", "#13", "#14", "#15", "#16", "udp" }; - static int net_local_pcblist_sysctl(int type, struct socket_type_list *list, int flags) { @@ -106,6 +106,7 @@ char *buf; size_t len; char mibvar[64]; + const char *ipproto; struct xinpgen *xig, *oxig; struct tcpcb *tp = NULL; @@ -114,7 +115,23 @@ struct socket_type *stp; - sprintf(mibvar, "net.inet.%s.pcblist", ipproto[protocol]); + switch (protocol) { + case IPPROTO_TCP: + ipproto = "tcp"; + break; + case IPPROTO_UDP: + ipproto = "udp"; + break; + case IPPROTO_DIVERT: + ipproto = "divert"; + break; + default: + case IPPROTO_RAW: + ipproto = "raw"; + break; + } + + sprintf(mibvar, "net.inet.%s.pcblist", ipproto); len = 0; if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) { @@ -175,7 +192,7 @@ continue; stp = _netstat_st_allocate(list, PF_INET, protocol, - ipproto[protocol]); + ipproto); extract_inet_data(tp, inp, so, stp); } @@ -332,9 +349,16 @@ } break; case PF_INET: + case PF_INET6: switch (protocol) { case IPPROTO_TCP: case IPPROTO_UDP: + case IPPROTO_DIVERT: + case IPPROTO_RAW: + case IPPROTO_ICMP: + case IPPROTO_IGMP: + case IPPROTO_PIM: + case IPPROTO_ICMPV6: if (use_kvm) NPCB_KVM(inet, protocol, list, kvm, nl, flags); else @@ -347,9 +371,15 @@ flags); NPCB_KVM(inet, IPPROTO_UDP, list, kvm, nl, flags); + NPCB_KVM(inet, IPPROTO_DIVERT, list, kvm, nl, + flags); + NPCB_KVM(inet, IPPROTO_RAW, list, kvm, nl, + flags); } else { NPCB_SCT(inet, IPPROTO_TCP, list, flags); NPCB_SCT(inet, IPPROTO_UDP, list, flags); + NPCB_SCT(inet, IPPROTO_DIVERT, list, flags); + NPCB_SCT(inet, IPPROTO_RAW, list, flags); } break; default: