[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ipv6 patch for fstat
fstatのIPv6 patchを作ってみました。下記のように、IPv6 addressを[]で
括ってみましたが、括るのとの括らないのはどちらがいいですかね?
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
root telnetd 559 wd / 2 drwxr-xr-x 512 r
root telnetd 559 0* internet6 stream tcp f06d3b00 [3ffe:501:1831:0:210:4bff:fe73:fdfc]:23 <-> [3ffe:501:1831:0:210:4bff:fe73:fdfc]:49154
root telnetd 559 1* internet6 stream tcp f06d3b00 [3ffe:501:1831:0:210:4bff:fe73:fdfc:]23 <-> [3ffe:501:1831:0:210:4bff:fe73:fdfc]:49154
root telnetd 559 2* internet6 stream tcp f06d3b00 [3ffe:501:1831:0:210:4bff:fe73:fdfc]:23 <-> [3ffe:501:1831:0:210:4bff:fe73:fdfc]:49154
root telnetd 559 3 / 7892 crw-rw-rw- ptyp1 rw
root telnetd 559 4 / 7891 crw--w---- ttyp1 rw
ura telnet 558 wd /usr/local/src 420620 drwxr-xr-x 512 r
ura telnet 558 0 / 7889 crw--w---- ttyp0 rw
ura telnet 558 1 / 7889 crw--w---- ttyp0 rw
ura telnet 558 2 / 7889 crw--w---- ttyp0 rw
ura telnet 558 3* internet6 stream tcp f06d38f0 [3ffe:501:1831:0:210:4bff:fe73:fdfc]:49154 <-> [3ffe:501:1831:0:210:4bff:fe73:fdfc]:23
--
ura
Index: fstat.c
===================================================================
RCS file: /cvsroot/netbsd/basesrc/usr.bin/fstat/fstat.c,v
retrieving revision 1.37
diff -u -u -r1.37 fstat.c
--- fstat.c 1999/08/02 17:39:13 1.37
+++ fstat.c 2000/01/14 09:35:07
@@ -81,6 +81,10 @@
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
+#include <netinet/ip6.h>
+#include <netinet6/in6_systm.h>
+#include <netinet6/in6_pcb.h>
+
#include <arpa/inet.h>
#include <ctype.h>
@@ -618,9 +622,11 @@
struct protosw proto;
struct domain dom;
struct inpcb inpcb;
+ struct in6pcb in6pcb;
struct unpcb unpcb;
int len;
char dname[32];
+ char addrbuf[INET6_ADDRSTRLEN];
PREFIX(i);
@@ -682,8 +688,7 @@
inpcb.inp_laddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_laddr), ntohs(inpcb.inp_lport));
if (inpcb.inp_fport) {
- printf(" <-> ");
- printf("%s:%d",
+ printf(" <-> %s:%d",
inpcb.inp_faddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_faddr),
ntohs(inpcb.inp_fport));
@@ -705,6 +710,52 @@
inpcb.inp_faddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_faddr),
ntohs(inpcb.inp_fport));
+ } else if (so.so_pcb)
+ printf(" %lx", (long)so.so_pcb);
+ break;
+ case AF_INET6:
+ getinetproto(proto.pr_protocol);
+ if (proto.pr_protocol == IPPROTO_TCP) {
+ if (so.so_pcb == NULL)
+ break;
+ if (kvm_read(kd, (u_long)so.so_pcb, (char *)&in6pcb,
+ sizeof(struct in6pcb)) != sizeof(struct in6pcb)) {
+ dprintf("can't read in6pcb at %p", so.so_pcb);
+ goto bad;
+ }
+ printf(" %lx", (long)in6pcb.in6p_ppcb);
+ printf(" [%s]:%d",
+ IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_laddr) ? "*" :
+ inet_ntop(AF_INET6, &in6pcb.in6p_laddr,
+ addrbuf, sizeof(addrbuf)),
+ ntohs(in6pcb.in6p_lport));
+ if (in6pcb.in6p_fport) {
+ printf(" <-> [%s]:%d",
+ IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_faddr) ? "*" :
+ inet_ntop(AF_INET6, &in6pcb.in6p_faddr,
+ addrbuf, sizeof(addrbuf)),
+ ntohs(in6pcb.in6p_fport));
+ }
+ } else if (proto.pr_protocol == IPPROTO_UDP) {
+ if (so.so_pcb == NULL)
+ break;
+ if (kvm_read(kd, (u_long)so.so_pcb, (char *)&in6pcb,
+ sizeof(struct in6pcb)) != sizeof(struct in6pcb)) {
+ dprintf("can't read inpcb at %p", so.so_pcb);
+ goto bad;
+ }
+ printf(" %lx", (long)so.so_pcb);
+ printf(" [%s]:%d",
+ IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_laddr) ? "*" :
+ inet_ntop(AF_INET6, &in6pcb.in6p_laddr,
+ addrbuf, sizeof(addrbuf)),
+ ntohs(in6pcb.in6p_lport));
+ if (in6pcb.in6p_fport)
+ printf(" <-> [%s]:%d",
+ IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_faddr) ? "*" :
+ inet_ntop(AF_INET6, &in6pcb.in6p_faddr,
+ addrbuf, sizeof(addrbuf)),
+ ntohs(in6pcb.in6p_fport));
} else if (so.so_pcb)
printf(" %lx", (long)so.so_pcb);
break;