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

📄 netshow.c

📁 vxworks的完整的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* netShow.c - network information display routines *//* Copyright 1984 - 2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03v,25jun02,ann  making a temporary change to the 64 bit counter lookups03u,10may02,kbw  making man page edits03t,22apr02,rae  inetstatShow warns if TCP or UDP show routine absent                 (SPR #72838)03s,28mar02,vvv  fixed problem with route show routines executed over the		 network (SPR #69286/73759)03r,07dec01,rae  merge from synth ver 03z (SPR #67790)03q,15oct01,rae  merge from truestack ver 03x, base 03j (SPRs 69550,                 67790, 67148, 65788 etc.)03p,07feb01,spm  added internal documentation for parallel host shell routines03o,15jan01,zhu  SPR#6329803x,15aug01,vvv  added entries for all interface types in pIfTypes 		 array (SPR #69550)03w,13jul01,ann  eliminated the global mibStyle flag by incorporating it in                 the END object's flags03v,27jun01,spm  consolidated and updated route show routines; replaced use                 of visibility flag for duplicate routes03u,19jun01,rae  merged venus changes from tor3_x ver 03t		 SPRs 67790 67148 6578803t,01may01,niq  Correcting the mod history03s,01may01,niq  Merging Fastpath changes from tor2_0.open_stack branch                  version 04i (netShow.c@@/main/tor2_0_x/tor2_0_0.sustaining/                 tor2_0.open_stack/26)03r,29mar01,spm  merged changes from version 04h of tor2_0.open_stack                 branch (wpwr VOB, base 03q) for unified code base03q,13mar01,rae  merged from 03p of tor2_0.barney branch (base: 03h)		 SPR#63298, SPR#27395, RFC2233, etc.03p,09mar01,ham  fixed output format in rtEntryPrint() routine (SPR #64321)03o,24feb01,ham  fixed S_objLib_OBJ_ID_ERROR return (SPR 64383).03n,20feb01,ham  fixed printf's format in rtEntryPrint() (SPR #63298).03m,03nov00,ham  doc: added an example in netPoolShow.03l,25oct00,ham  doc: cleanup for vxWorks AE 1.0.03k,19apr00,ham  merged TOR2_0-NPT-FCS(03j,08nov99,pul).                 fixed incorrect printf (SPR #26699).03j,08nov99,pul  T2 cumulative patch 203i,10may99,spm  fixed arpShow routine to display proxy entries (SPR #24397)03h,26aug98,fle  doc : added .CS in EXAMPLE of arpShow header03g,14dec97,jdi  doc: cleanup.03f,10dec97,kbw  minor man page fixes03e,03dec97,vin  added netStackDataPoolShow() netStackSysPoolShow().03d,26oct97,kbw  minor man page fixes03c,26sep97,rjc  fix for SPR 932603b,26aug97,spm  removed compiler warnings (SPR #7866)03a,12aug97,vin  added netpool specific stuff for mbufShow.02z,12aug97,rjc  added if type to ifShow SPR7555.02y,11aug97,vin  changed clPoolShow.02x,01aug97,kbw  fix man page problems found in beta review02w,07jul97,rjc  modifications for newer version of rtentry.02v,30jun97,rjc  restored old rtentry structure size.02u,03jun97,rjc  stopped converting all 0 mask to all 1.02t,02jun97,spm  corrected modification history entry02s,29may97,rjc  fixed mRouteShow byte order in mask.02r,08mar97,vin  added changes to accomodate changes in pcb structure.		 moved out igmp, icmp, udp, tcp code to igmpShow, icmpShow,                 udpShow, tcpShow.02q,07apr97,spm  removed DHCP client dependencies02p,13feb97,rjc  added mRouteShow02o,31jan97,vin  fixed a bug in clPoolShow().02n,31jan97,spm  moved DHCP client show routines to dhcpShowLib.c02m,29jan97,spm  made global variables for DHCP client unique.02l,29jan97,spm  removed conditional includes from DHCP client code.02k,07jan97,vin  added unknown protocol in ipstatShow.02j,05dec96,vin  added new mbufTypes MT_IPMADDR,MT_IFMADDR,MT_MRTABLE.02i,03dec96,spm  correcting errors in DHCP client show routines.02h,27nov96,spm  added show routines for DHCP client.02g,17nov96,vin	 modified show routines to include new clusters.		 deleted cluster related fields from mbufShow().02f,11sep96,vin  modified for BSD4.4.02e,13mar95,dzb  changed tcpDebugShow() to call tcpReportRtn (SPR #3928).02d,18jan95,rhp  add pointers to literature in library man page (SPR#3591)02c,18jan95,jdi  doc cleanup for tcpDebugShow().02b,11aug94,dzb  added tcpDebugShow() to get at tcp_debug.c:tcp_report().                 warning cleanup.02a,11aug93,jmm  Changed ioctl.h and socket.h to sys/ioctl.h and sys/socket.h01z,02feb93,jdi  documentation cleanup for 5.1.01y,13nov92,dnw  added include of semLibP.h01x,12oct92,jdi  fixed mangen problem in routestatShow().01w,04sep92,jmm  fixed typo in printf in inpcbPrint()                 changed field width in inetPrint() to 15 from 12 (spr 1470)01v,29jul92,smb  changed putchar() to printf().01u,27jul92,elh  Moved routeShow and hostShow here.01t,04jul92,smb  added include vxWorks.h01s,26jun92,wmd  modified inetPrint() to always print port address. 01r,11jun92,elh	 moved arpShow here from arpLib.01q,26may92,rrr  the tree shuffle		  -changed includes to have absolute path from h/01p,26may92,kdl  changed ifShow() to more robustly avoid dereferencing		 null ptr (SPR #1389).01o,01jan92,elh  changed arptabShow to call arpShow.01n,13dec91,gae  ANSI fixes.01m,17nov91,elh	 added routestatShow().01l,07nov91,elh	 changed calls to inet_ntoa to inet_ntoa_b, so memory isn't lost.01k,04oct91,rrr  passed through the ansification filter                  -changed functions to ansi style		  -changed includes to have absolute path from h/		  -changed VOID to void		  -changed copyright notice01j,14aug91,jrb  (intel) improved instrumentation for udp in udpstatShow command		 with the following fields: udptotal - total packets,		 ipackets - input, opackets - output, fullsock - socket		 overflows, noportbcast - broadcast port messages with no		 listener. Taken from latest BSD reno udp.01i,17jun91,del  added include of strLib.h.01h,07may91,jdi	 documentation tweaks.01g,05apr91,jdi	 documentation -- removed header parens and x-ref numbers;		 doc review by elh.01f,20feb91,jaa	 documentation.01e,08oct90,hjb  moved include of "ip.h" above "tcp.h" to avoid redefinition of		 IP_MSS.01d,02oct90,hjb  deleted "netdb.h".  made ipstatShow() void.01c,12aug90,hjb  added arptabShow().01b,10aug90,kdl  added forward declarations for functions returning void.01a,26jun90,hjb  created by moving Show routines out of various files.*//*DESCRIPTIONThis library provides routines to show various network-relatedstatistics, such as configuration parameters for network interfaces,protocol statistics, socket statistics, and so on.Interpreting these statistics requires detailed knowledge of Internetnetwork protocols.  Information on these protocols can be found inthe following books:.iP.I "Internetworking with TCP/IP Volume III,"by Douglas Comer and David Stevens.iP.I "UNIX Network Programming,"by Richard Stevens.iP.I "The Design and Implementation of the 4.3 BSD UNIX Operating System,"by Leffler, McKusick, Karels and Quarterman.LPThe netShowInit() routine links the network show facility into the VxWorkssystem.  This is performed automatically if INCLUDE_NET_SHOW is defined.If you want inetstatShow() to display TCP socket status, then INCLUDE_TCP_SHOWneeds to be included.INTERNALSome routines within this module are preempted by parallel versionsbuilt in to the Tornado shell source code in the $WIND_BASE/host/src/windshdirectory. Changes to these routines must be duplicated within the shell tomaintain consistent output. The versions in this module can still beaccessed by prepending an "@" sign to the routine name (e.g. "@ifShow").Currently, the following routines are preempted:     ifShow, inetstatShow, ipstatShow, routestatShow, hostShowSEE ALSO: ifLib, icmpShow, igmpShow, tcpShow, udpShow INTERNALSome routines within this module are preempted by parallel versionsbuilt in to the Tornado shell source code in the $WIND_BASE/host/src/windshdirectory. Changes to these routines must be duplicated within the shell tomaintain consistent output. The versions in this module can still beaccessed by prepending an "@" sign to the routine name (e.g. "@ifShow").Currently, the following routines are preempted:     ifShow, inetstatShow, ipstatShow, routestatShow, hostShow     */#include "vxWorks.h"#include "sys/types.h"#include "netinet/in.h"#include "net/socketvar.h"#include "sys/socket.h"#include "netinet/in_systm.h"#include "netinet/ip.h"#include "netinet/ip_var.h"#include "net/route.h"#include "net/radix.h"#include "netinet/in_pcb.h"#include "hostLib.h"#include "net/if.h"#include "net/if_dl.h"#include "netinet/if_ether.h"#include "netinet/in_var.h"#include "errno.h"#include "net/mbuf.h"#include "inetLib.h"#include "string.h"#include "stdio.h"#include "stdlib.h"#include "arpLib.h"#include "private/semLibP.h"#include "routeEnhLib.h"#include "private/muxLibP.h"#include "private/memPartLibP.h"#include "end.h"#include "ipProto.h"#include "math.h"#ifdef VIRTUAL_STACK#include "netinet/vsLib.h"#include "netinet/vsIp.h" 	/* for _in_ifaddr definition */#include "netinet/vsShow.h" 	/* for _pTcpPcbHead and _pUdpPcbHead */#include "netinet/vsHost.h" 	/* for hostList and hostListSem */#include "netinet/vsRadix.h" 	/* for rt_tables definition */#endif /* VIRTUAL_STACK *//* externs */#ifndef VIRTUAL_STACKIMPORT struct rtstat	rtstat;		/* routing statistics */IMPORT struct ifnet 	*ifnet;		/* list of all network interfaces */IMPORT struct in_ifaddr *in_ifaddr; 	/* list of addr for net interfaces */IMPORT struct ipstat	ipstat;IMPORT struct radix_node_head *rt_tables[]; /* table of radix nodes */IMPORT LIST 		hostList;IMPORT SEM_ID 		hostListSem;IMPORT NET_POOL_ID	_pNetDpool;IMPORT BOOL              bufferedRtShow;         /* buffered route printing */IMPORT UINT              rtMem;                  /* memory for route display *//* globals */struct inpcbhead *	_pUdpPcbHead  = NULL;	/* initialized in udpShow.c */struct inpcbhead *	_pTcpPcbHead  = NULL;	/* initialized in tcpShow.c */#endif /* VIRTUAL_STACK */VOIDFUNCPTR		_pTcpPcbPrint =	NULL;	/* initialized in tcpShow.c *//* locals */LOCAL char *  pIfTypes [] =      /* interface types from mib-2 */    {    "UNDEFINED",    "OTHER",     "REGULAR_1822",     "HDH1822",     "DDN_X25",     "RFC877_X25",     "ETHERNET_CSMACD",     "ISO88023_CSMACD",     "ISO88024_TOKENBUS",     "ISO88025_TOKENRING",     "ISO88026_MAN",     "STARLAN",     "PROTEON_10MBIT",     "PROTEON_80MBIT",     "HYPERCHANNEL",     "FDDI",     "LAPB",     "SDLC",     "DS1",     "E1",     "BASIC_ISDN",     "PRIMARY_ISDN",     "PROP_POINT_TO_POINT_SERIAL",     "PPP",     "SOFTWARE_LOOPBACK",     "EON",     "ETHERNET_3MBIT",     "NSIP",     "SLIP",     "ULTRA",     "DS3",     "SIP",     "FRAME_RELAY",     "RS232",    "PARA",    "ARCNET",    "ARCNET_PLUS",    "ATM",    "MIOX25",    "SONET",    "X25PLE",    "ISO88022LLC",    "LOCAL_TALK",    "SMDS_DXI",    "FRAME_RELAY_SERVICE",    "V35",    "HSSI",    "HIPPI",    "MODEM",    "AAL5",    "SONET_PATH",    "SONET_VT",    "SMDS_ICIP",    "PROP_VIRTUAL",    "PROP_MULTIPLEXOR",    "IEEE80212",    "FIBRE_CHANNEL",    "HIPPI_INTERFACE",    "FRAME_RELAY_INTERCONNECT",    "AFLANE8023",    "AFLANE8025",    "CCT_EMUL",    "FAST_ETHER",    "ISDN",    "V11",    "V36",    "G703AT64K",    "G703AT2MB",    "QLLC",    "FAST_ETHER_FX",    "CHANNEL",    "IEEE80211",    "IBM370PAR_CHAN",    "ESCON",    "DLSW",    "ISDNS",    "ISDNU",    "LAPD",    "IP_SWITCH",    "RSRB",    "ATM_LOGICAL",    "DS0",    "DS0_BUNDLE",    "BSC",    "ASYNC",    "CNR",    "ISO88025_DTR",    "EPLRS",    "ARAP",    "PROP_CNLS",    "HOST_PAD",    "TERM_PAD",    "FRAME_RELAY_MPI",    "X213",    "ADSL",    "RADSL",    "SDSL",    "VDSL",    "ISO88025_CRFP_INT",    "MYRINET",    "VOICE_EM",    "VOICE_FXO",    "VOICE_FXS",    "VOICE_ENCAP",    "VOICE_OVER_IP",    "ATM_DXI",    "ATM_FUNI",    "ATM_IMA",    "PPP_MULTILINK_BUNDLE",    "IP_OVER_CDLC",    "IP_OVER_CLAW",    "STACK_TO_STACK",    "VIRTUAL_IP_ADDRESS",    "MPC",    "IP_OVER_ATM",    "ISO88025_FIBER",    "TDLC",    "GIGABIT_ETHERNET",    "HDLC",    "LAPF",    "V37",    "X25MLP",    "X25HUNT_GROUP",    "TRASNP_HDLC",    "INTERLEAVE",    "FAST",    "IP",    "DOCS_CABLE_MACLAYER",    "DOCS_CABLE_DOWNSTREAM",    "DOCS_CABLE_UPSTREAM",    "A12_MPP_SWITCH",    "TUNNEL",    "COFFEE",    "CES",    "ATM_SUB_INTERFACE",    "L2VLAN",    "L3IPVLAN",    "L3IPXVLAN",    "DIGITAL_POWERLINE",    "MEDIA_MAIL_OVER_IP",    "DTM",    "DCN",    "IP_FORWARD",    "MSDSL",    "IEEE1394",    "IF_GSN",    "DVB_RCC_MAC_LAYER",    "DVB_RCC_DOWNSTREAM",    "DVB_RCC_UPSTREAM",    "ATM_VIRTUAL",    "MPLS_TUNNEL",    "SRP",    "VOICE_OVER_ATM",    "VOICE_OVER_FRAME_RELAY",    "IDSL",    "COMPOSITE_LINK",    "SS7_SIG_LINK",    "PMP",     };LOCAL int bufIndex;                 /* index into route buffer */LOCAL char *routeBuf;               /* buffer to store routing table *//* forward static functions */static void ifAddrPrint (char *str, struct sockaddr *addr);static void ifFlagPrint (u_short flag);static void ifEtherPrint (u_char enaddr [ 6 ]);static void inetPrint (struct in_addr *in, u_short port);LOCAL BOOL routeEntryPrint (struct rtentry *, void *, BOOL);static void routeTableShow (int rtType);static void inpcbPrint (char *name, struct inpcb *pInpcb);static int routeNodeShow (struct radix_node* rn, void* w);#define RT_ENTRY_LEN    90#define plural(num)	((num) > 1 ? "s": "")#define RT_NET		0x001			/* print network route */#define RT_HST		0x010			/* print host route */#define RT_ARP		0x100			/* print arp route entry *//********************************************************************************* ifShow - display the attached network interfaces** This routine displays the attached network interfaces for debugging and* diagnostic purposes.  If <ifName> is given, only the interfaces belonging* to that group are displayed.  If <ifName> is omitted, all attached* interfaces are displayed.** For each interface selected, the following are shown: Internet* address, point-to-point peer address (if using SLIP), broadcast address,* netmask, subnet mask, Ethernet address, route metric, maximum transfer* unit, number of packets sent and received on this interface, number of* input and output errors, and flags (such as loopback, point-to-point,* broadcast, promiscuous, ARP, running, and debug).** EXAMPLE:* The following call displays all interfaces whose names begin with "ln",* (such as "ln0", "ln1", and "ln2"):* .CS*     -> ifShow "ln"* .CE* The following call displays just the interface "ln0":* .CS*     -> ifShow "ln0"* .CE** RETURNS: N/A** SEE ALSO: routeShow(), ifLib** 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 ifShow    (    char *ifName                /* name of the interface to show */    )    {    FAST struct ifnet 		*ifp;    FAST struct ifaddr 		*ifa;    FAST struct in_ifaddr 	*ia = 0;    FAST int			 nameLen;    BOOL 			 found;    int				 ifUnit;    IP_DRV_CTRL *                pDrvCtrl = NULL;    END_OBJ *                    pEnd;

⌨️ 快捷键说明

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