%include "INet:Formats.Inc"
%include "INet:Stats.Inc"

%externalpredicatespec FS lookup(%string(31) what, %integername value)

%systemroutinespec phex(%integer x)

%begin
   %record(INet statistics fm)%name s
   %integer x
      %on 9 %start;  %stop;  %finish
      %if FS lookup(INet statistics record name, x) %start
         s == record(x)
      %else
         printstring("No INet statistics?");  newline
         %stop
      %finish
      {} printstring("Statistics record at ");  phex(addr(s));  newline
      %if s_slow packets in > 0 %or s_slow packets out > 0 %start
write(s_slow packets in,             -8);  printstring(" slow in   ")
write(s_slow bytes in,               -8);  printstring(" bytes in  ")
write(s_slow errors in,              -8);  printstring(" errors in ");  newline
write(s_slow packets out,            -8);  printstring(" pkts out  ")
write(s_slow bytes out,              -8);  printstring(" bytes out ")
write(s_slow errors out,             -8);  printstring(" errors out");  newline
newline
      %finish

      %if s_fast packets in > 0 %or s_fast packets out > 0 %c
      %or s_ARP in > 0 %or s_ARP out > 0 %start
write(s_fast packets in,             -8);  printstring(" ether in  ")
write(s_fast bytes in,               -8);  printstring(" bytes in  ")
write(s_fast errors in,              -8);  printstring(" errors in ");  newline
write(s_fast packets out,            -8);  printstring(" pkts out  ")
write(s_fast bytes out,              -8);  printstring(" bytes out ")
write(s_fast errors out,             -8);  printstring(" errors out");  newline
write(s_ARP in,                      -8);  printstring(" ARP in    ")
write(s_ARP errors in,               -8);  printstring(" errors in ")
write(s_ARP unknown,                 -8);  printstring(" unknown   ");  newline
write(s_ARP for us,                  -8);  printstring(" for us    ")
write(s_ARP responses,               -8);  printstring(" responses ");  newline
write(s_ARP out,                     -8);  printstring(" ARP out   ")
write(s_ARP errors out,              -8);  printstring(" errors out");  newline
newline
      %finish

write(s_IP packets in,               -8);  printstring(" IP in     ")
write(s_IP bytes in,                 -8);  printstring(" bytes in  ")
write(s_IP old broadcasts,           -8);  printstring(" old broad ")
write(s_IP new broadcasts,           -8);  printstring(" new broad" );  newline
write(s_IP fragmented packets,       -8);  printstring(" fragmented")
write(s_IP dud lengths,              -8);  printstring(" dud length")
write(s_IP dud protocols,            -8);  printstring(" dud prot  ")
write(s_IP other errors,             -8);  printstring(" other errs");  newline
write(s_IP packets out,              -8);  printstring(" pckts out ")
write(s_IP bytes out,                -8);  printstring(" bytes out" );  newline
newline

write(s_ICMP in,                     -8);  printstring(" ICMP in   ")
write(s_ICMP errors in,              -8);  printstring(" errors in ")
write(s_ICMP broadcasts,             -8);  printstring(" broadcasts");  newline
write(s_ICMP out,                    -8);  printstring(" ICMP out  ")
write(s_ICMP errors out,             -8);  printstring(" errors out");  newline
newline

write(s_TCP packets in,              -8);  printstring(" TCP in    ")
write(s_TCP bytes in,                -8);  printstring(" bytes in  ")
write(s_TCP packets out,             -8);  printstring(" pckts out ")
write(s_TCP bytes out,               -8);  printstring(" bytes out" );  newline
write(s_TCP bogus addresses,         -8);  printstring(" bogus adrs")
write(s_TCP checksum errors,         -8);  printstring(" chck errs ")
write(s_TCP for closed,              -8);  printstring(" for closed")
write(s_TCP resets received,         -8);  printstring(" resets"    );  newline
write(s_TCP junk received,           -8);  printstring(" junk      ")
write(s_TCP SYNs received,           -8);  printstring(" SYNs      ")
write(s_TCP FINs received,           -8);  printstring(" FINs"      );  newline
write(s_TCP good ACKs received,      -8);  printstring(" good ACKs ")
write(s_TCP old ACKs received,       -8);  printstring(" old ACKs  ")
write(s_TCP dud ACKs received,       -8);  printstring(" dud ACKs  ")
write(s_TCP window updates,          -8);  printstring(" window ups");  newline
write(s_TCP connections established, -8);  printstring(" estblished")
write(s_TCP connections reset,       -8);  printstring(" reset     ")
write(s_TCP connections closed,      -8);  printstring(" closed"    );  newline
write(s_TCP acceptable segments,     -8);  printstring(" acceptable")
write(s_TCP unacceptable segments,   -8);  printstring(" unaccptble")
write(s_TCP ahead segments,          -8);  printstring(" ahead     ")
write(s_TCP duplicate bytes,         -8);  printstring(" duplicate" );  newline
write(s_TCP data bytes received,     -8);  printstring(" data bytes")
write(s_TCP data bytes sent,         -8);  printstring(" data sent ")
write(s_TCP retransmits,             -8);  printstring(" reTXs     ")
write(s_TCP retransmit timeouts,     -8);  printstring(" reTX tmos" );  newline
newline

write(s_UDP packets in,              -8);  printstring(" UDP in    ")
write(s_UDP bytes in,                -8);  printstring(" bytes in  ");  newline
write(s_UDP checksum errors,         -8);  printstring(" check errs")
write(s_UDP no checksums,            -8);  printstring(" no check  ")
write(s_UDP bogus checksums,         -8);  printstring(" bogus chck")
write(s_UDP other errors,            -8);  printstring(" other errs");  newline
write(s_UDP packets out,             -8);  printstring(" pckts out ")
write(s_UDP bytes out,               -8);  printstring(" bytes out" );  newline

%end %of %program
