Date: Wed, 10 Jun 2009 19:12:45 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 164033 for review Message-ID: <200906101912.n5AJCjre059375@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906101912.n5AJCjre059375>