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

📄 icmpshow.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
字号:
/* icmpShow.c - ICMP Information display routines *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01c,31jul97,kbw  fixed man page problems found in beta review01b,20apr97,kbw  fixed man page format, spell check.01a,08mar97,vin  written.*//*DESCRIPTIONThis library provides routines to show ICMP relatedstatistics.Interpreting these statistics requires detailed knowledge of Internetnetwork protocols.  Information on these protocols can be found inthe following books:.iP  .I "TCP/IP Illustrated Volume II, The Implementation,"by Richard Stevens.iP .I "The Design and Implementation of the 4.4 BSD UNIX Operating System,"by Leffler, McKusick, Karels and Quarterman.LPThe icmpShowInit() routine links the ICMP show facility into the VxWorkssystem.  This is performed automatically if INCLUDE_NET_SHOW is definedin configAll.h.SEE ALSO: netLib, netShow,.I "Network Programmer's Guide"*/#include "vxWorks.h"#include "sys/types.h"#include "netinet/in.h"#include "netinet/in_systm.h"#include "netinet/ip.h"#include "netinet/ip_var.h"#include "netinet/ip_icmp.h"#include "netinet/icmp_var.h"#include "errno.h"#include "string.h"#include "stdio.h"#define plural(num)	((num) > 1 ? "s": "")/******************************************************************************** icmpShowInit - initialize ICMP show routines** This routine links the ICMP show facility into the VxWorks system.* These routines are included automatically if INCLUDE_NET_SHOW* and INCLUDE_ICMP are defined in configAll.h.** RETURNS: N/A*/void icmpShowInit (void)    {        }/********************************************************************************* icmpstatShow - display statistics for ICMP** This routine displays statistics for the ICMP * (Internet Control Message Protocol) protocol.** RETURNS: N/A*/void icmpstatShow (void)    {    static char *icmpNames[] =    {	"echo reply",	"#1",	"#2",	"destination unreachable",	"source quench",	"routing redirect",	"#6",	"#7",	"echo",	"#9",	"#10",	"time exceeded",	"parameter problem",	"time stamp",	"time stamp reply",	"information request",	"information request reply",	"address mask request",	"address mask reply",    };    FAST int ix;    FAST int first;    printf("ICMP:\n\t%u call%s to icmp_error\n",	   (int)icmpstat.icps_error, plural(icmpstat.icps_error));    printf("\t%u error%s not generated because old message was icmp\n",	   (int)icmpstat.icps_oldicmp, plural(icmpstat.icps_oldicmp));    for (first = 1, ix = 0; ix < ICMP_MAXTYPE + 1; ix++)	{	if (icmpstat.icps_outhist [ix] != 0)	    {	    if (first)		{		printf("\tOutput histogram:\n");		first = 0;		}	    printf("\t\t%s: %u\n", icmpNames [ix],		   (int)icmpstat.icps_outhist [ix]);	    }	}    printf("\t%u message%s with bad code fields\n",	   (int)icmpstat.icps_badcode, plural(icmpstat.icps_badcode));    printf("\t%u message%s < minimum length\n",	   (int)icmpstat.icps_tooshort, plural(icmpstat.icps_tooshort));    printf("\t%u bad checksum%s\n",	   (int)icmpstat.icps_checksum, plural(icmpstat.icps_checksum));    printf("\t%u message%s with bad length\n",	   (int)icmpstat.icps_badlen, plural(icmpstat.icps_badlen));    for (first = 1, ix = 0; ix < ICMP_MAXTYPE + 1; ix++)	{	if (icmpstat.icps_inhist [ix] != 0)	    {	    if (first)		{		printf("\tInput histogram:\n");		first = 0;		}	    printf("\t\t%s: %u\n", icmpNames [ix],		   (int)icmpstat.icps_inhist [ix]);	    }	}    printf("\t%u message response%s generated\n",	   (int)icmpstat.icps_reflect, plural(icmpstat.icps_reflect));    }

⌨️ 快捷键说明

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