📄 netshow.c
字号:
printf ("PROMISCUOUS "); if (!(flag & IFF_NOTRAILERS)) printf ("TRAILERS "); if (!(flag & IFF_NOARP)) printf ("ARP "); if (flag & IFF_RUNNING) printf ("RUNNING "); if (flag & IFF_DEBUG) printf ("DEBUG "); printf ("\n"); }/********************************************************************************* ifEtherPrint - print Ethernet address in ":" notation** RETURNS: N/A.*/LOCAL void ifEtherPrint ( u_char enaddr[6] /* ethernet address */ ) { unsigned char *en = (unsigned char *)enaddr; printf(" Ethernet address is %02x:%02x:%02x:%02x:%02x:%02x\n", en [0], en [1], en [2], en [3], en [4], en [5]); }/********************************************************************************* inetPrint - Pretty print an Internet address (net address + port).** RETURNS: N/A.*/LOCAL void inetPrint ( FAST struct in_addr *in, u_short port ) { char line[80]; char *cp; int width; char addrString [INET_ADDR_LEN]; inet_ntoa_b ((*in), addrString); (void) sprintf (line, "%.*s.", 15, addrString); cp = index (line, '\0'); (void) sprintf (cp, "%d", ntohs((u_short)port)); width = 18; printf (" %-*.*s", width, width, line); }/********************************************************************************* inetstatShow - display all active connections for Internet protocol sockets** This routine displays a list of all active Internet protocol sockets in a* format similar to the UNIX `netstat' command.** RETURNS: N/A*/void inetstatShow (void) { printf("Active Internet connections (including servers)\n"); printf("%-8.8s %-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n", "PCB", "Proto", "Recv-Q", "Send-Q", "Local Address", "Foreign Address", "(state)"); printf("%-8.8s %-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n", "--------", "-----", "------", "------", "------------------", "------------------", "-------"); if (_pTcpPcbHead != NULL) inpcbPrint ("TCP", _pTcpPcbHead->lh_first); if (_pUdpPcbHead != NULL) inpcbPrint ("UDP", _pUdpPcbHead->lh_first); }/********************************************************************************* inpcbPrint - print a list of protocol control blocks for an Internet protocol** Prints a list of active protocol control blocks for the specified* Internet protocols in a nice and pretty format.** RETURNS: N/A.*/LOCAL void inpcbPrint ( char *name, struct inpcb *pInpcb ) { FAST struct inpcb *inp; struct socket *pSock; BOOL isTcp = 0; if (strcmp (name, "TCP") == 0) isTcp = 1; for (inp = pInpcb; inp != NULL; inp = inp->inp_list.le_next) { pSock = inp->inp_socket; /* * Print "inp" here to allow manual deletion of the stale * PCB's by using in_pcbdetach (inp). */ printf ("%-8x ", (u_int) inp); printf("%-5.5s %6ld %6ld ", name, pSock->so_rcv.sb_cc, pSock->so_snd.sb_cc); inetPrint (&(inp->inp_laddr), inp->inp_lport); inetPrint (&(inp->inp_faddr), inp->inp_fport); /* if tcp is included then only print the tcp information */ if (isTcp && (_pTcpPcbPrint != NULL)) (*_pTcpPcbPrint) (inp); (void) printf ("\n"); } }/********************************************************************************* ipstatShow - display IP statistics** This routine displays detailed statistics for the IP protocol.** RETURNS: N/A*/void ipstatShow ( BOOL zero /* TRUE = reset statistics to 0 */ ) { static char *ipstat_name[] = { "total", "badsum", "tooshort", "toosmall", "badhlen", "badlen", "infragments", "fragdropped", "fragtimeout", "forward", "cantforward", "redirectsent", "unknownprotocol", "nobuffers", "reassembled", "outfragments", "noroute" }; char *fmt = "%20s %4d\n"; int ix = 0; printf (fmt, ipstat_name [ix++], ipstat.ips_total); /* total packets received */ printf (fmt, ipstat_name [ix++], ipstat.ips_badsum); /* checksum bad */ printf (fmt, ipstat_name [ix++], ipstat.ips_tooshort); /* packet too short */ printf (fmt, ipstat_name [ix++], ipstat.ips_toosmall); /* not enough data */ printf (fmt, ipstat_name [ix++], ipstat.ips_badhlen); /* ip header length < data size */ printf (fmt, ipstat_name [ix++], ipstat.ips_badlen); /* ip length < ip header length */ printf (fmt, ipstat_name [ix++], ipstat.ips_fragments); /* fragments received */ printf (fmt, ipstat_name [ix++], ipstat.ips_fragdropped); /* frags dropped (dups, out of space) */ printf (fmt, ipstat_name [ix++], ipstat.ips_fragtimeout); /* fragments timed out */ printf (fmt, ipstat_name [ix++], ipstat.ips_forward); /* packets forwarded */ printf (fmt, ipstat_name [ix++], ipstat.ips_cantforward); /* packets rcvd for unreachable dest */ printf (fmt, ipstat_name [ix++], ipstat.ips_redirectsent); /* packets forwarded on same net */ printf (fmt, ipstat_name [ix++], ipstat.ips_noproto); /* pkts recieved with unknown protos */ printf (fmt, ipstat_name [ix++], ipstat.ips_odropped); /* pkts dropped for no buffers */ printf (fmt, ipstat_name [ix++], ipstat.ips_reassembled); /* total packets reassembled ok */ printf (fmt, ipstat_name [ix++], ipstat.ips_ofragments); /* output fragments created */ printf (fmt, ipstat_name [ix++], ipstat.ips_noroute); /* packets discarded due to no route */ printf ("\n"); if (zero) bzero ((char*)&ipstat, sizeof (ipstat)); }/********************************************************************************* clPoolShow - show cluster pool information** This function shows cluster pool information.** NOMANUAL** RETURNS: N/A*/LOCAL void clPoolShow ( NET_POOL_ID pNetPool /* pointer the netPool */ ) { UCHAR clType; CL_POOL_ID pClPool; printf ("__________________\n"); printf ("CLUSTER POOL TABLE\n"); printf ("_______________________________________________________________________________\n"); printf ("size clusters free usage\n"); printf ("-------------------------------------------------------------------------------\n"); for (clType = pNetPool->clLg2Min; clType <= pNetPool->clLg2Max; clType++) { if ((pClPool = netClPoolIdGet (pNetPool, CL_LOG2_TO_CL_SIZE(clType), TRUE)) != NULL) { printf ("%-9d", pClPool->clSize); printf ("%-10d", pClPool->clNum); printf ("%-10d", pClPool->clNumFree); printf ("%-14d\n", pClPool->clUsage); } } printf ("-------------------------------------------------------------------------------\n"); }/********************************************************************************* netPoolShow - show pool statistics** This routine displays the distribution of `mBlk's and clusters in a given* network pool ID.** RETURNS: N/A*/void netPoolShow ( NET_POOL_ID pNetPool ) { static int mt_types [NUM_MBLK_TYPES] = { MT_FREE, MT_DATA, MT_HEADER, MT_SOCKET, MT_PCB, MT_RTABLE, MT_HTABLE, MT_ATABLE, MT_SONAME, MT_ZOMBIE, MT_SOOPTS, MT_FTABLE, MT_RIGHTS, MT_IFADDR, MT_CONTROL, MT_OOBDATA, MT_IPMOPTS, MT_IPMADDR, MT_IFMADDR, MT_MRTABLE }; static char mt_names [NUM_MBLK_TYPES][10] = { "FREE", "DATA", "HEADER", "SOCKET", "PCB", "RTABLE", "HTABLE", "ATABLE", "SONAME", "ZOMBIE", "SOOPTS", "FTABLE", "RIGHTS", "IFADDR", "CONTROL", "OOBDATA", "IPMOPTS", "IPMADDR", "IFMADDR", "MRTABLE" }; int totalMbufs = 0; FAST int ix; if (pNetPool == NULL || pNetPool->pPoolStat == NULL) return ; printf ("type number\n"); printf ("--------- ------\n"); for (ix = 0; ix < NUM_MBLK_TYPES; ix++) { printf ("%-8s: %3ld\n", mt_names [ix], pNetPool->pPoolStat->mTypes [mt_types [ix]]); totalMbufs += pNetPool->pPoolStat->m_mtypes [mt_types [ix]]; } printf ("%-8s: %3d\n", "TOTAL", totalMbufs); printf ("number of mbufs: %ld\n", pNetPool->pPoolStat->mNum); printf ("number of times failed to find space: %ld\n", pNetPool->pPoolStat->mDrops); printf ("number of times waited for space: %ld\n", pNetPool->pPoolStat->mWait); printf ("number of times drained protocols for space: %ld\n", pNetPool->pPoolStat->mDrain); clPoolShow (pNetPool); } /********************************************************************************* netStackDataPoolShow - show network stack data pool statistics** This routine displays the distribution of `mBlk's and clusters in a* the network data pool. The network data pool is used only for data* transfer through the network stack.** RETURNS: N/A** SEE ALSO: netStackSysPoolShow(), netBufLib*/void netStackDataPoolShow (void) { netPoolShow (_pNetDpool); }/********************************************************************************* netStackSysPoolShow - show network stack system pool statistics** This routine displays the distribution of `mBlk's and clusters in a* the network system pool. The network system pool is used only for system* structures such as sockets, routes, interface addresses, protocol control* blocks, multicast addresses, and multicast route entries.** RETURNS: N/A** SEE ALSO: netStackDataPoolShow(), netBufLib*/void netStackSysPoolShow (void) { netPoolShow (_pNetSysPool); }/********************************************************************************* mbufShow - report mbuf statistics** This routine displays the distribution of mbufs in the network.** RETURNS: N/A*/void mbufShow (void) { netPoolShow (_pNetDpool); }/******************************************************************************** netShowInit - initialize network show routines** This routine links the network show facility into the VxWorks system.* These routines are included automatically if INCLUDE_NET_SHOW* is defined in configAll.h.** RETURNS: N/A*/void netShowInit (void) { }/********************************************************************************* arpShow - display entries in the system ARP table** This routine displays the current Internet-to-Ethernet address mappings * in the ARP table.** EXAMPLE* .CS* -> arpShow** LINK LEVEL ARP TABLE* destination gateway flags Refcnt Use Interface* -----------------------------------------------------------------------* 90.0.0.63 08:00:3e:23:79:e7 405 0 82 lo0* -----------------------------------------------------------------------* .CE** RETURNS: N/A*/void arpShow (void) { char *dashLine = "--------------------------------------------------------------------------\n"; char *topLine = "destination gateway flags Refcnt Use Interface\n"; printf ("\nLINK LEVEL ARP TABLE\n"); printf ("%s", topLine); printf ("%s", dashLine); rtTblShow (RT_ARP); /* show ARP routes */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -