⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netshow.c

📁 vxworks5.5.1源代码。完整源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (flag & IFF_LOOPBACK)	printf ("LOOPBACK ");    if (flag & IFF_POINTOPOINT)	printf ("POINT-TO-POINT ");    if (flag & IFF_BROADCAST)	printf ("BROADCAST ");    if (flag & IFF_MULTICAST)	printf ("MULTICAST ");     if (flag & IFF_PROMISC)	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 ");    if (flag & IFF_FP_ENABLE)	printf ("FASTPATH ");    if (flag & IFF_DONT_FORWARD)	printf ("NOFORWARD ");    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 = 21;    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.** If you want inetstatShow() to display TCP socket status, then* INCLUDE_TCP_SHOW needs to be included.** 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 inetstatShow (void)    {#ifdef VIRTUAL_STACK    virtualStackIdCheck();    printf("Active Internet connections (including servers) (stack number %d)\n", myStackNum);#else    printf("Active Internet connections (including servers)\n");#endif /* VIRTUAL_STACK */    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);    else        printf("No TCP show routine included.  TCP connections not shown.\n");        if (_pUdpPcbHead != NULL)        inpcbPrint ("UDP", _pUdpPcbHead->lh_first);    else        printf("No UDP show routine included.  UDP connections not shown.\n");#ifdef VIRTUAL_STACK    inpcbPrint ("RAW", ripcb.lh_first);#endif /* VIRTUAL_STACK */    }/********************************************************************************* 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** 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 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;#ifdef VIRTUAL_STACK    virtualStackIdCheck();    printf (fmt, "stack number",	myStackNum);                    /* stack number */    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));#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]];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -