[BACK]Return to inet.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / netstat

Diff for /src/usr.bin/netstat/inet.c between version 1.15 and 1.16

version 1.15, 1997/06/25 07:56:18 version 1.16, 1997/06/29 20:17:59
Line 149 
Line 149 
                 }                  }
                 if (Aflag)                  if (Aflag)
                         if (istcp)                          if (istcp)
                                 printf("%8x ", inpcb.inp_ppcb);                                  printf("%8p ", inpcb.inp_ppcb);
                         else                          else
                                 printf("%8x ", prev);                                  printf("%8p ", prev);
                 printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,                  printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
                         sockb.so_snd.sb_cc);                          sockb.so_snd.sb_cc);
                 inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport, name, 1);                  inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport, name, 1);
                 inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport, name, 0);                  inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport, name, 0);
Line 188 
Line 188 
 #define p3(f, m) if (tcpstat.f || sflag <= 1) \  #define p3(f, m) if (tcpstat.f || sflag <= 1) \
     printf(m, tcpstat.f, plurales(tcpstat.f))      printf(m, tcpstat.f, plurales(tcpstat.f))
   
         p(tcps_sndtotal, "\t%d packet%s sent\n");          p(tcps_sndtotal, "\t%ld packet%s sent\n");
         p2(tcps_sndpack,tcps_sndbyte,          p2(tcps_sndpack,tcps_sndbyte,
                 "\t\t%d data packet%s (%qd byte%s)\n");                  "\t\t%ld data packet%s (%qd byte%s)\n");
         p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,          p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
                 "\t\t%d data packet%s (%qd byte%s) retransmitted\n");                  "\t\t%ld data packet%s (%qd byte%s) retransmitted\n");
         p2(tcps_sndacks, tcps_delack,          p2(tcps_sndacks, tcps_delack,
                 "\t\t%d ack-only packet%s (%d delayed)\n");                  "\t\t%ld ack-only packet%s (%ld delayed)\n");
         p(tcps_sndurg, "\t\t%d URG only packet%s\n");          p(tcps_sndurg, "\t\t%ld URG only packet%s\n");
         p(tcps_sndprobe, "\t\t%d window probe packet%s\n");          p(tcps_sndprobe, "\t\t%ld window probe packet%s\n");
         p(tcps_sndwinup, "\t\t%d window update packet%s\n");          p(tcps_sndwinup, "\t\t%ld window update packet%s\n");
         p(tcps_sndctrl, "\t\t%d control packet%s\n");          p(tcps_sndctrl, "\t\t%ld control packet%s\n");
         p(tcps_rcvtotal, "\t%d packet%s received\n");          p(tcps_rcvtotal, "\t%ld packet%s received\n");
         p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%d ack%s (for %qd byte%s)\n");          p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%ld ack%s (for %qd byte%s)\n");
         p(tcps_rcvdupack, "\t\t%d duplicate ack%s\n");          p(tcps_rcvdupack, "\t\t%ld duplicate ack%s\n");
         p(tcps_rcvacktoomuch, "\t\t%d ack%s for unsent data\n");          p(tcps_rcvacktoomuch, "\t\t%ld ack%s for unsent data\n");
         p2(tcps_rcvpack, tcps_rcvbyte,          p2(tcps_rcvpack, tcps_rcvbyte,
                 "\t\t%d packet%s (%qd byte%s) received in-sequence\n");                  "\t\t%ld packet%s (%qd byte%s) received in-sequence\n");
         p2(tcps_rcvduppack, tcps_rcvdupbyte,          p2(tcps_rcvduppack, tcps_rcvdupbyte,
                 "\t\t%d completely duplicate packet%s (%qd byte%s)\n");                  "\t\t%ld completely duplicate packet%s (%qd byte%s)\n");
         p(tcps_pawsdrop, "\t\t%d old duplicate packet%s\n");          p(tcps_pawsdrop, "\t\t%ld old duplicate packet%s\n");
         p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,          p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
                 "\t\t%d packet%s with some dup. data (%qd byte%s duped)\n");                  "\t\t%ld packet%s with some dup. data (%qd byte%s duped)\n");
         p2(tcps_rcvoopack, tcps_rcvoobyte,          p2(tcps_rcvoopack, tcps_rcvoobyte,
                 "\t\t%d out-of-order packet%s (%qd byte%s)\n");                  "\t\t%ld out-of-order packet%s (%qd byte%s)\n");
         p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,          p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
                 "\t\t%d packet%s (%qd byte%s) of data after window\n");                  "\t\t%ld packet%s (%qd byte%s) of data after window\n");
         p(tcps_rcvwinprobe, "\t\t%d window probe%s\n");          p(tcps_rcvwinprobe, "\t\t%ld window probe%s\n");
         p(tcps_rcvwinupd, "\t\t%d window update packet%s\n");          p(tcps_rcvwinupd, "\t\t%ld window update packet%s\n");
         p(tcps_rcvafterclose, "\t\t%d packet%s received after close\n");          p(tcps_rcvafterclose, "\t\t%ld packet%s received after close\n");
         p(tcps_rcvbadsum, "\t\t%d discarded for bad checksum%s\n");          p(tcps_rcvbadsum, "\t\t%ld discarded for bad checksum%s\n");
         p(tcps_rcvbadoff, "\t\t%d discarded for bad header offset field%s\n");          p(tcps_rcvbadoff, "\t\t%ld discarded for bad header offset field%s\n");
         p(tcps_rcvshort, "\t\t%d discarded because packet too short\n");          p(tcps_rcvshort, "\t\t%ld discarded because packet too short\n");
         p(tcps_connattempt, "\t%d connection request%s\n");          p(tcps_connattempt, "\t%ld connection request%s\n");
         p(tcps_accepts, "\t%d connection accept%s\n");          p(tcps_accepts, "\t%ld connection accept%s\n");
         p(tcps_connects, "\t%d connection%s established (including accepts)\n");          p(tcps_connects, "\t%ld connection%s established (including accepts)\n");
         p2(tcps_closed, tcps_drops,          p2(tcps_closed, tcps_drops,
                 "\t%d connection%s closed (including %d drop%s)\n");                  "\t%ld connection%s closed (including %ld drop%s)\n");
         p(tcps_conndrops, "\t%d embryonic connection%s dropped\n");          p(tcps_conndrops, "\t%ld embryonic connection%s dropped\n");
         p2(tcps_rttupdated, tcps_segstimed,          p2(tcps_rttupdated, tcps_segstimed,
                 "\t%d segment%s updated rtt (of %d attempt%s)\n");                  "\t%ld segment%s updated rtt (of %ld attempt%s)\n");
         p(tcps_rexmttimeo, "\t%d retransmit timeout%s\n");          p(tcps_rexmttimeo, "\t%ld retransmit timeout%s\n");
         p(tcps_timeoutdrop, "\t\t%d connection%s dropped by rexmit timeout\n");          p(tcps_timeoutdrop, "\t\t%ld connection%s dropped by rexmit timeout\n");
         p(tcps_persisttimeo, "\t%d persist timeout%s\n");          p(tcps_persisttimeo, "\t%ld persist timeout%s\n");
         p(tcps_keeptimeo, "\t%d keepalive timeout%s\n");          p(tcps_keeptimeo, "\t%ld keepalive timeout%s\n");
         p(tcps_keepprobe, "\t\t%d keepalive probe%s sent\n");          p(tcps_keepprobe, "\t\t%ld keepalive probe%s sent\n");
         p(tcps_keepdrops, "\t\t%d connection%s dropped by keepalive\n");          p(tcps_keepdrops, "\t\t%ld connection%s dropped by keepalive\n");
         p(tcps_predack, "\t%d correct ACK header prediction%s\n");          p(tcps_predack, "\t%ld correct ACK header prediction%s\n");
         p(tcps_preddat, "\t%d correct data packet header prediction%s\n");          p(tcps_preddat, "\t%ld correct data packet header prediction%s\n");
         p3(tcps_pcbhashmiss, "\t%d PCB cache miss%s\n");          p3(tcps_pcbhashmiss, "\t%ld PCB cache miss%s\n");
 #undef p  #undef p
 #undef p2  #undef p2
 #undef p3  #undef p3
Line 259 
Line 259 
         printf("%s:\n", name);          printf("%s:\n", name);
 #define p(f, m) if (udpstat.f || sflag <= 1) \  #define p(f, m) if (udpstat.f || sflag <= 1) \
     printf(m, udpstat.f, plural(udpstat.f))      printf(m, udpstat.f, plural(udpstat.f))
         p(udps_ipackets, "\t%u datagram%s received\n");          p(udps_ipackets, "\t%lu datagram%s received\n");
         p(udps_hdrops, "\t%u with incomplete header\n");          p(udps_hdrops, "\t%lu with incomplete header\n");
         p(udps_badlen, "\t%u with bad data length field\n");          p(udps_badlen, "\t%lu with bad data length field\n");
         p(udps_badsum, "\t%u with bad checksum\n");          p(udps_badsum, "\t%lu with bad checksum\n");
         p(udps_noport, "\t%u dropped due to no socket\n");          p(udps_noport, "\t%lu dropped due to no socket\n");
         p(udps_noportbcast, "\t%u broadcast/multicast datagram%s dropped due to no socket\n");          p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n");
         p(udps_fullsock, "\t%u dropped due to full socket buffers\n");          p(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
         delivered = udpstat.udps_ipackets -          delivered = udpstat.udps_ipackets -
                     udpstat.udps_hdrops -                      udpstat.udps_hdrops -
                     udpstat.udps_badlen -                      udpstat.udps_badlen -
Line 274 
Line 274 
                     udpstat.udps_noportbcast -                      udpstat.udps_noportbcast -
                     udpstat.udps_fullsock;                      udpstat.udps_fullsock;
         if (delivered || sflag <= 1)          if (delivered || sflag <= 1)
                 printf("\t%u delivered\n", delivered);                  printf("\t%lu delivered\n", delivered);
         p(udps_opackets, "\t%u datagram%s output\n");          p(udps_opackets, "\t%lu datagram%s output\n");
 #undef p  #undef p
 }  }
   
Line 297 
Line 297 
 #define p(f, m) if (ipstat.f || sflag <= 1) \  #define p(f, m) if (ipstat.f || sflag <= 1) \
     printf(m, ipstat.f, plural(ipstat.f))      printf(m, ipstat.f, plural(ipstat.f))
   
         p(ips_total, "\t%u total packet%s received\n");          p(ips_total, "\t%lu total packet%s received\n");
         p(ips_badsum, "\t%u bad header checksum%s\n");          p(ips_badsum, "\t%lu bad header checksum%s\n");
         p(ips_toosmall, "\t%u with size smaller than minimum\n");          p(ips_toosmall, "\t%lu with size smaller than minimum\n");
         p(ips_tooshort, "\t%u with data size < data length\n");          p(ips_tooshort, "\t%lu with data size < data length\n");
         p(ips_badhlen, "\t%u with header length < data size\n");          p(ips_badhlen, "\t%lu with header length < data size\n");
         p(ips_badlen, "\t%u with data length < header length\n");          p(ips_badlen, "\t%lu with data length < header length\n");
         p(ips_badoptions, "\t%u with bad options\n");          p(ips_badoptions, "\t%lu with bad options\n");
         p(ips_badvers, "\t%u with incorrect version number\n");          p(ips_badvers, "\t%lu with incorrect version number\n");
         p(ips_fragments, "\t%u fragment%s received\n");          p(ips_fragments, "\t%lu fragment%s received\n");
         p(ips_fragdropped, "\t%u fragment%s dropped (dup or out of space)\n");          p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
         p(ips_badfrags, "\t%u malformed fragment%s dropped\n");          p(ips_badfrags, "\t%lu malformed fragment%s dropped\n");
         p(ips_fragtimeout, "\t%u fragment%s dropped after timeout\n");          p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
         p(ips_reassembled, "\t%u packet%s reassembled ok\n");          p(ips_reassembled, "\t%lu packet%s reassembled ok\n");
         p(ips_delivered, "\t%u packet%s for this host\n");          p(ips_delivered, "\t%lu packet%s for this host\n");
         p(ips_noproto, "\t%u packet%s for unknown/unsupported protocol\n");          p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n");
         p(ips_forward, "\t%u packet%s forwarded\n");          p(ips_forward, "\t%lu packet%s forwarded\n");
         p(ips_cantforward, "\t%u packet%s not forwardable\n");          p(ips_cantforward, "\t%lu packet%s not forwardable\n");
         p(ips_redirectsent, "\t%u redirect%s sent\n");          p(ips_redirectsent, "\t%lu redirect%s sent\n");
         p(ips_localout, "\t%u packet%s sent from this host\n");          p(ips_localout, "\t%lu packet%s sent from this host\n");
         p(ips_rawout, "\t%u packet%s sent with fabricated ip header\n");          p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
         p(ips_odropped, "\t%u output packet%s dropped due to no bufs, etc.\n");          p(ips_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n");
         p(ips_noroute, "\t%u output packet%s discarded due to no route\n");          p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
         p(ips_fragmented, "\t%u output datagram%s fragmented\n");          p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
         p(ips_ofragments, "\t%u fragment%s created\n");          p(ips_ofragments, "\t%lu fragment%s created\n");
         p(ips_cantfrag, "\t%u datagram%s that can't be fragmented\n");          p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
 #undef p  #undef p
 }  }
   
Line 366 
Line 366 
 #define p(f, m) if (icmpstat.f || sflag <= 1) \  #define p(f, m) if (icmpstat.f || sflag <= 1) \
     printf(m, icmpstat.f, plural(icmpstat.f))      printf(m, icmpstat.f, plural(icmpstat.f))
   
         p(icps_error, "\t%u call%s to icmp_error\n");          p(icps_error, "\t%lu call%s to icmp_error\n");
         p(icps_oldicmp,          p(icps_oldicmp,
             "\t%u error%s not generated 'cuz old message was icmp\n");              "\t%lu error%s not generated 'cuz old message was icmp\n");
         for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)          for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
                 if (icmpstat.icps_outhist[i] != 0) {                  if (icmpstat.icps_outhist[i] != 0) {
                         if (first) {                          if (first) {
                                 printf("\tOutput histogram:\n");                                  printf("\tOutput histogram:\n");
                                 first = 0;                                  first = 0;
                         }                          }
                         printf("\t\t%s: %u\n", icmpnames[i],                          printf("\t\t%s: %lu\n", icmpnames[i],
                                 icmpstat.icps_outhist[i]);                                  icmpstat.icps_outhist[i]);
                 }                  }
         p(icps_badcode, "\t%u message%s with bad code fields\n");          p(icps_badcode, "\t%lu message%s with bad code fields\n");
         p(icps_tooshort, "\t%u message%s < minimum length\n");          p(icps_tooshort, "\t%lu message%s < minimum length\n");
         p(icps_checksum, "\t%u bad checksum%s\n");          p(icps_checksum, "\t%lu bad checksum%s\n");
         p(icps_badlen, "\t%u message%s with bad length\n");          p(icps_badlen, "\t%lu message%s with bad length\n");
         for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)          for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
                 if (icmpstat.icps_inhist[i] != 0) {                  if (icmpstat.icps_inhist[i] != 0) {
                         if (first) {                          if (first) {
                                 printf("\tInput histogram:\n");                                  printf("\tInput histogram:\n");
                                 first = 0;                                  first = 0;
                         }                          }
                         printf("\t\t%s: %u\n", icmpnames[i],                          printf("\t\t%s: %lu\n", icmpnames[i],
                                 icmpstat.icps_inhist[i]);                                  icmpstat.icps_inhist[i]);
                 }                  }
         p(icps_reflect, "\t%u message response%s generated\n");          p(icps_reflect, "\t%lu message response%s generated\n");
 #undef p  #undef p
 }  }
   
Line 414 
Line 414 
     printf(m, igmpstat.f, plural(igmpstat.f))      printf(m, igmpstat.f, plural(igmpstat.f))
 #define py(f, m) if (igmpstat.f || sflag <= 1) \  #define py(f, m) if (igmpstat.f || sflag <= 1) \
     printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y")      printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y")
         p(igps_rcv_total, "\t%u message%s received\n");          p(igps_rcv_total, "\t%lu message%s received\n");
         p(igps_rcv_tooshort, "\t%u message%s received with too few bytes\n");          p(igps_rcv_tooshort, "\t%lu message%s received with too few bytes\n");
         p(igps_rcv_badsum, "\t%u message%s received with bad checksum\n");          p(igps_rcv_badsum, "\t%lu message%s received with bad checksum\n");
         py(igps_rcv_queries, "\t%u membership quer%s received\n");          py(igps_rcv_queries, "\t%lu membership quer%s received\n");
         py(igps_rcv_badqueries, "\t%u membership quer%s received with invalid field(s)\n");          py(igps_rcv_badqueries, "\t%lu membership quer%s received with invalid field(s)\n");
         p(igps_rcv_reports, "\t%u membership report%s received\n");          p(igps_rcv_reports, "\t%lu membership report%s received\n");
         p(igps_rcv_badreports, "\t%u membership report%s received with invalid field(s)\n");          p(igps_rcv_badreports, "\t%lu membership report%s received with invalid field(s)\n");
         p(igps_rcv_ourreports, "\t%u membership report%s received for groups to which we belong\n");          p(igps_rcv_ourreports, "\t%lu membership report%s received for groups to which we belong\n");
         p(igps_snd_reports, "\t%u membership report%s sent\n");          p(igps_snd_reports, "\t%lu membership report%s sent\n");
 #undef p  #undef p
 #undef py  #undef py
 }  }
   
 struct rpcnams {  struct rpcnams {
         struct rpcnams *next;          struct rpcnams *next;
         int     port;          in_port_t port;
         char    *rpcname;          char    *rpcname;
 };  };
   
 char *  char *
 getrpcportnam(port)  getrpcportnam(port)
         int port;          in_port_t port;
 {  {
         struct sockaddr_in server_addr;          struct sockaddr_in server_addr;
         register struct hostent *hp;          register struct hostent *hp;
Line 482 
Line 482 
                         if (rpc)                          if (rpc)
                                 n->rpcname = strdup(rpc->r_name);                                  n->rpcname = strdup(rpc->r_name);
                         else {                          else {
                                 sprintf(num, "%d", head->pml_map.pm_prog);                                  sprintf(num, "%ld", head->pml_map.pm_prog);
                                 n->rpcname = strdup(num);                                  n->rpcname = strdup(num);
                         }                          }
                 }                  }
Line 502 
Line 502 
 void  void
 inetprint(in, port, proto, local)  inetprint(in, port, proto, local)
         register struct in_addr *in;          register struct in_addr *in;
         int port;          in_port_t port;
         char *proto;          char *proto;
         int local;          int local;
 {  {
Line 516 
Line 516 
                 sp = getservbyport((int)port, proto);                  sp = getservbyport((int)port, proto);
         if (sp || port == 0)          if (sp || port == 0)
                 sprintf(cp, "%.8s", sp ? sp->s_name : "*");                  sprintf(cp, "%.8s", sp ? sp->s_name : "*");
         else if (local && !nflag && (nam = getrpcportnam(ntohs((u_short)port))))          else if (local && !nflag && (nam = getrpcportnam(ntohs(port))))
                 sprintf(cp, "%d[%.8s]", ntohs((u_short)port), nam);                  sprintf(cp, "%d[%.8s]", ntohs(port), nam);
         else          else
                 sprintf(cp, "%d", ntohs((u_short)port));                  sprintf(cp, "%d", ntohs(port));
         width = Aflag ? 18 : 22;          width = Aflag ? 18 : 22;
         printf(" %-*.*s", width, width, line);          printf(" %-*.*s", width, width, line);
 }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16