=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/systat/netstat.c,v retrieving revision 1.25 retrieving revision 1.26 diff -c -r1.25 -r1.26 *** src/usr.bin/systat/netstat.c 2004/04/26 19:22:30 1.25 --- src/usr.bin/systat/netstat.c 2004/09/29 21:59:28 1.26 *************** *** 1,4 **** ! /* $OpenBSD: netstat.c,v 1.25 2004/04/26 19:22:30 itojun Exp $ */ /* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: netstat.c,v 1.26 2004/09/29 21:59:28 deraadt Exp $ */ /* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */ /*- *************** *** 34,40 **** #if 0 static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: netstat.c,v 1.25 2004/04/26 19:22:30 itojun Exp $"; #endif /* not lint */ /* --- 34,40 ---- #if 0 static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93"; #endif ! static char rcsid[] = "$OpenBSD: netstat.c,v 1.26 2004/09/29 21:59:28 deraadt Exp $"; #endif /* not lint */ /* *************** *** 78,87 **** static void enter(struct inpcb *, struct socket *, int, char *); static const char *inetname(struct in_addr); static void inetprint(struct in_addr *, int, char *); - #ifdef INET6 static const char *inet6name(struct in6_addr *); static void inet6print(struct in6_addr *, int, char *); - #endif #define streq(a,b) (strcmp(a,b)==0) #define YMAX(w) ((w)->_maxy-1) --- 78,85 ---- *************** *** 105,118 **** short nif_state; /* tcp state */ char *nif_proto; /* protocol */ struct in_addr nif_laddr; /* local address */ - #ifdef INET6 struct in6_addr nif_laddr6; /* local address */ - #endif long nif_lport; /* local port */ struct in_addr nif_faddr; /* foreign address */ - #ifdef INET6 struct in6_addr nif_faddr6; /* foreign address */ - #endif long nif_fport; /* foreign port */ long nif_rcvcc; /* rcv buffer character count */ long nif_sndcc; /* snd buffer character count */ --- 103,112 ---- *************** *** 216,235 **** prev = next; next = inpcb.inp_queue.cqe_next; - #ifndef INET6 if (inpcb.inp_flags & INP_IPV6) continue; - #endif if (!aflag) { if (!(inpcb.inp_flags & INP_IPV6) && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) continue; - #ifdef INET6 if ((inpcb.inp_flags & INP_IPV6) && IN6_IS_ADDR_UNSPECIFIED(&inpcb.inp_laddr6)) continue; - #endif } if (nhosts && !checkhost(&inpcb)) continue; --- 210,225 ---- *************** *** 262,273 **** * data structures. */ for (p = netcb.nif_forw; p != (struct netinfo *)&netcb; p = p->nif_forw) { - #ifdef INET6 if (p->nif_family == AF_INET && (inp->inp_flags & INP_IPV6)) continue; if (p->nif_family == AF_INET6 && !(inp->inp_flags & INP_IPV6)) continue; - #endif if (!streq(proto, p->nif_proto)) continue; if (p->nif_family == AF_INET) { --- 252,261 ---- *************** *** 278,295 **** p->nif_fport == inp->inp_fport) break; ! } ! #ifdef INET6 ! else if (p->nif_family == AF_INET6) { if (p->nif_lport != inp->inp_lport || !IN6_ARE_ADDR_EQUAL(&p->nif_laddr6, &inp->inp_laddr6)) continue; if (IN6_ARE_ADDR_EQUAL(&p->nif_faddr6, &inp->inp_faddr6) && p->nif_fport == inp->inp_fport) break; ! } ! #endif ! else continue; } if (p == (struct netinfo *)&netcb) { --- 266,279 ---- p->nif_fport == inp->inp_fport) break; ! } else if (p->nif_family == AF_INET6) { if (p->nif_lport != inp->inp_lport || !IN6_ARE_ADDR_EQUAL(&p->nif_laddr6, &inp->inp_laddr6)) continue; if (IN6_ARE_ADDR_EQUAL(&p->nif_faddr6, &inp->inp_faddr6) && p->nif_fport == inp->inp_fport) break; ! } else continue; } if (p == (struct netinfo *)&netcb) { *************** *** 306,319 **** p->nif_fport = inp->inp_fport; p->nif_proto = proto; p->nif_flags = NIF_LACHG|NIF_FACHG; - #ifdef INET6 if (inp->inp_flags & INP_IPV6) { p->nif_laddr6 = inp->inp_laddr6; p->nif_faddr6 = inp->inp_faddr6; p->nif_family = AF_INET6; ! } else ! #endif ! { p->nif_laddr = inp->inp_laddr; p->nif_faddr = inp->inp_faddr; p->nif_family = AF_INET; --- 290,300 ---- p->nif_fport = inp->inp_fport; p->nif_proto = proto; p->nif_flags = NIF_LACHG|NIF_FACHG; if (inp->inp_flags & INP_IPV6) { p->nif_laddr6 = inp->inp_laddr6; p->nif_faddr6 = inp->inp_faddr6; p->nif_family = AF_INET6; ! } else { p->nif_laddr = inp->inp_laddr; p->nif_faddr = inp->inp_faddr; p->nif_family = AF_INET; *************** *** 399,410 **** inetprint(&p->nif_laddr, p->nif_lport, p->nif_proto); break; - #ifdef INET6 case AF_INET6: inet6print(&p->nif_laddr6, p->nif_lport, p->nif_proto); break; - #endif } p->nif_flags &= ~NIF_LACHG; } --- 380,389 ---- *************** *** 415,434 **** inetprint(&p->nif_faddr, p->nif_fport, p->nif_proto); break; - #ifdef INET6 case AF_INET6: inet6print(&p->nif_faddr6, p->nif_fport, p->nif_proto); break; - #endif } p->nif_flags &= ~NIF_FACHG; } mvwaddstr(wnd, p->nif_line, PROTO, p->nif_proto); - #ifdef INET6 if (p->nif_family == AF_INET6) waddstr(wnd, "6"); - #endif mvwprintw(wnd, p->nif_line, RCVCC, "%6d", p->nif_rcvcc); mvwprintw(wnd, p->nif_line, SNDCC, "%6d", p->nif_sndcc); if (streq(p->nif_proto, "tcp")) { --- 394,409 ---- *************** *** 475,481 **** waddstr(wnd, line); } - #ifdef INET6 static void inet6print(struct in6_addr *in6, int port, char *proto) { --- 450,455 ---- *************** *** 499,505 **** *cp = '\0'; waddstr(wnd, line); } - #endif /* * Construct an Internet address representation. --- 473,478 ---- *************** *** 542,548 **** return (line); } - #ifdef INET6 static const char * inet6name(struct in6_addr *in6) { --- 515,520 ---- *************** *** 562,568 **** return line; return "?"; } - #endif int cmdnetstat(char *cmd, char *args) --- 534,539 ----