📄 netshow.c
字号:
_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));#else 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));#endif /* VIRTUAL_STACK */ }/********************************************************************************* 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.** EXAMPLE:** .CS* void endPoolShow* (* char * devName, /@ The inteface name: "dc", "ln" ...@/* int unit /@ the unit number: usually 0 @/* )* {* END_OBJ * pEnd;* * if ((pEnd = endFindByName (devName, unit)) != NULL)* netPoolShow (pEnd->pNetPool);* else* printf ("Could not find device %s\n", devName);* return;* }* .CE** 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.** The "clusters" column indicates the total number of clusters of that size* that have been allocated. The "free" column indicates the number of* available clusters of that size (the total number of clusters minus those* clusters that are in use). The "usage" column indicates the number of times* clusters have been allocated (not, as you might expect, the number of* clusters currently in use).** RETURNS: N/A** SEE ALSO: netStackSysPoolShow(), netBufLib*/void netStackDataPoolShow (void) {#ifdef VIRTUAL_STACK virtualStackIdCheck(); printf("stack number %d\n", myStackNum);#endif /* VIRTUAL_STACK */ 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.** The "clusters" column indicates the total number of clusters of that size* that have been allocated. The "free" column indicates the number of* available clusters of that size (the total number of clusters minus those* clusters that are in use). The "usage" column indicates the number of times* clusters have been allocated (not, as you might expect, the number of* clusters currently in use).** RETURNS: N/A** SEE ALSO: netStackDataPoolShow(), netBufLib*/void netStackSysPoolShow (void) {#ifdef VIRTUAL_STACK virtualStackIdCheck(); printf("stack number %d\n", myStackNum);#endif /* VIRTUAL_STACK */ netPoolShow (_pNetSysPool); }/********************************************************************************* mbufShow - report mbuf statistics** This routine displays the distribution of mbufs in the network.** RETURNS: N/A*/void mbufShow (void) {#ifdef VIRTUAL_STACK virtualStackIdCheck(); printf("stack number %d\n", myStackNum);#endif /* VIRTUAL_STACK */ 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.** RETURNS: N/A*/void netShowInit (void) { if (bufferedRtShow) routeBuf = KHEAP_ALLOC (rtMem); }/********************************************************************************* 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 LL Address Flags Refcnt Use Interface* ---------------------------------------------------------------------* 90.0.0.63 08:00:3e:23:79:e7 0x405 0 82 lo0* ---------------------------------------------------------------------* .CE** Some configuration is required when this routine is to be used remotely over* the network eg. through a telnet session or through the host shell using * WDB_COMM_NETWORK. If more than 5 entries are expected in the table the * parameter RT_BUFFERED_DISPLAY should be set to TRUE to prevent a possible* deadlock. This requires a buffer whose size can be set with RT_DISPLAY_MEMORY.* It will limit the number of entries that can be displayed (each entry requires* approx. 70 bytes).** RETURNS: N/A*/void arpShow (void) { char *dashLine = "---------------------------------------------------------------------\n"; char *topLine = "Destination LL Address Flags Refcnt Use Interface\n";#ifdef VIRTUAL_STACK printf("stack number %d\n", myStackNum);#endif /* VIRTUAL_STACK */ printf ("\nLINK LEVEL ARP TABLE\n"); printf ("%s", topLine); printf ("%s", dashLine); routeTableShow (RT_ARP); /* show ARP routes */ printf ("%s", dashLine); }/********************************************************************************* arptabShow - display the known ARP entries** This routine displays current Internet-to-Ethernet address mappings in the* ARP table.** RETURNS: N/A** INTERNAL* This just calls arpShow. It is provided for compatablity.* Migrating to arpShow to be more compliant with WRS naming.*/void arptabShow (void) { arpShow (); }/******************************************************************************* routestatShow - display routing statistics** This routine displays routing statistics.** RETURNS: N/A** INTERNAL* When using the Tornado shell, this routine is only available if an* "@" sign is prepended to the routine name. Otherwise, it is preempted* by a built-in version.*/void routestatShow (void) {#ifdef VIRTUAL_STACK virtualStackIdCheck(); printf ("routing: (stack number %d)\n", myStackNum);#else printf ("routing:\n");#endif /* VIRTUAL_STACK */ printf ("\t%u bad routing redirect%s\n", rtstat.rts_badredirect, plural (rtstat.rts_badredirect)); printf ("\t%u dynamically created route%s\n", rtstat.rts_dynamic, plural (rtstat.rts_dynamic)); printf ("\t%u new gateway%s due to redirects\n", rtstat.rts_newgateway, plural (rtstat.rts_newgateway)); printf ("\t%u destination%s found unreachable\n", rtstat.rts_unreach, plural (rtstat.rts_unreach)); printf ("\t%u use%s of a wildcard route\n", rtstat.rts_wildcard, plural (rtstat.rts_wildcard)); }/********************************************************************************* routeShow - display all IP routes (summary information)** This routine displays the list of destinations in the routing table* along with the next-hop gateway and associated interface for each entry.* It separates the routes into network routes and host-specific entries,* but does not display the netmask for a route since it was created for* class-based routes which used predetermined values for that field.** The IP forwarding process will only use the first route entry to a * destination. When multiple routes exist to the same destination with* the same netmask (which is not shown), the first route entry uses the* lowest administrative weight. The remaining entries (listed as additional* routes) use the same destination address. One of those entries will* replace the primary route if it is deleted.** EXAMPLE* .CS* -> routeShow** ROUTE NET TABLE* Destination Gateway Flags Refcnt Use Interface* --------------------------------------------------------------------* 90.0.0.0 90.0.0.63 0x1 1 142 enp0* 10.0.0.0 90.0.0.70 0x1 1 142 enp0* Additional routes to 10.0.0.0:* 80.0.0.70 0x1 0 120 enp1* --------------------------------------------------------------------** ROUTE HOST TABLE* Destination Gateway Flags Refcnt Use Interface* --------------------------------------------------------------------* 127.0.0.1 127.0.0.1 0x101 0 82 lo0* --------------------------------------------------------------------* .CE** The flags field represents a decimal value of the flags specified* for a given route. The following is a list of currently available* flag values:** .TS* tab(|);* l l .* 0x1 | - route is usable (that is, "up")* 0x2 | - destination is a gateway* 0x4 | - host specific routing entry* 0x8 | - host or net unreachable* 0x10 | - created dynamically (by redirect)* 0x20 | - modified dynamically (by redirect)* 0x40 | - message confirmed* 0x80 | - subnet mask present* 0x100 | - generate new routes on use* 0x200 | - external daemon resolves name* 0x400 | - generated by ARP* 0x800 | - manually added (static)* 0x1000 | - just discard packets (during updates)* 0x2000 | - modified by management protocol* 0x4000 | - protocol specific routing flag* 0x8000 | - protocol specific routing flag* .TE** In the above display example, the entry in the ROUTE NET TABLE has a * flag value of 1, which indicates that this route is "up" and usable and * network specific (the 0x4 bit is turned off). The entry in the ROUTE * HOST TABLE has a flag value of 5 (0x1 OR'ed with 0x4), which indicates * that this route is "up" and usable and host-specific.** Some configuration is required when this routine is to be used remotely over* the network eg. through a telnet session or through the host shell using * WDB_COMM_NETWORK. If more than 5 routes are expected in the table the * parameter RT_BUFFERED_DISPLAY should be set to TRUE to prevent a possible* deadlock. This requires a buffer whose size can be set with RT_DISPLAY_MEMORY.* It will limit the number of routes that can be displayed (each route requires* approx. 70 bytes).** RETURNS: N/A*/void routeShow (void) { char *dashLine = "--------------------------------------------------------------------\n"; char *topLine = "Destination Gateway Flags Refcnt Use Interface\n";#ifdef VIRTUAL_STACK virtualStackIdCheck(); printf("stack number %d\n", myStackNum);#endif /* VIRTUAL_STACK */ printf ("\nROUTE NET TABLE\n"); printf ("%s", topLine); printf ("%s", dashLine); routeTableShow (RT_NET); /* show network routes */ printf ("%s", dashLine); printf ("\nROUTE HOST TABLE\n"); printf ("%s", topLine); printf ("%s", dashLine); routeTableShow (RT_HST); /* show host routes */ printf ("%s", dashLine); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -