CMUSNMP.SAV$ CMUSNMP.SAV\BACK/LOG ALL:*.*/EXCL=TGVSTATUS.* USERS:[ANONYMOUS]CMUSNMP.SAV/SAVE/NOCRC/GROUP=0/BLOCK=2048 ADELMAN @F8ۓV5.3 _KAOS::  _KAOS$DUA0: V5.3 (*[MULTINET_PLUS.MULTINET.SNMP]$HISTORY.;2+,F. / 4N -E0@123KPWO 56 7uo80E<9FRQٓGHDJLVersion .91: Changed the ASN type for the types: Counter, Ipaddress, gauge,Ktimeticks, and opaque. The SMI defines them as application specific types,%not ASN_INTEGER and ASN_OCTET_STRING.MVersion 1.0 Added snmpnetstat, snmptrap, snmptrapd. Everything runs on a newNAPI that has an asynchronous interface. Most old hard-coded limits are eitherNnon-existent or much larger than necessary. The mib module now gets it's dataGby parsing a text file in the same ASN.1 format as is given in RFC1066.**[MULTINET_PLUS.MULTINET.SNMP]$M$AKEFILE.;2+,G. / 4 -E0@123KPWO 56`f7@o8@hғ9FRQٓGHDJ CMUSNMP.SAVGE*[MULTINET_PLUS.MULTINET.SNMP]$M$AKEFILE.;2 vTARG = bin/snmpget bin/snmpgetnext bin/snmpstatus bin/snmpwalk bin/snmptest bin/snmptrap bin/snmptrapd bin/snmpnetstat all: ${TARG}bin/snmpget: apps/snmpget cp apps/snmpget $@!bin/snmpgetnext: apps/snmpgetnext cp apps/snmpgetnext $@bin/snmpstatus: apps/snmpstatus cp apps/snmpstatus $@bin/snmpwalk: apps/snmpwalk cp apps/snmpwalk $@bin/snmptest: apps/snmptest cp apps/snmptest $@bin/snmptrap: apps/snmptrap cp apps/snmptrap $@bin/snmptrapd: apps/snmptrapd cp apps/snmptrapd $@-bin/snmpnetstat: apps/snmpnetstat/snmpnetstat# cp apps/snmpnetstat/snmpnetstat $@apps/snmpget apps/snmpgetnext apps/snmpstatus apps/snmpwalk apps/snmptest apps/snmptrap apps/snmptrapd apps/snmpnetstat/snmpnetstat: makeallmakeall: cd snmplib; make cd apps; make cd apps/snmpnetstat; makeclean: cd snmplib; make clean cd apps; make clean cd apps/snmpnetstat; make clean rm -f bin/*'*[MULTINET_PLUS.MULTINET.SNMP]$README.;2+,H./ 4W -E0@123KPWO56 7o8{ғ9FRQٓGHDJ CMUSNMP.SAVHE'[MULTINET_PLUS.MULTINET.SNMP]$README.;2WH The files in this directory compromise the 1.0 release of the CMU SNMP@distribution. This includes the SNMP/ASN.1 library, many clientLapplications, and supporting documentation. The snmp agent for the KineticsNbox is included in this distribution, but the KIP code it links against is notJyet distributable (this is not the released KIP code). This will probably=be distributed at another time if there is sufficient demand.CThis code was written with efficiency and portability in mind. TheMapplications compile and run on the following systems: IBM PC/RT running ACISJRelease 3, Sun3/60 running SUNOS 3.5, DEC microVax running Ultrix 2.2, andLDECStation 3100's runing Ultrix 3.0. They are expected to run on any system!with a Berkeley socket interface.KThe agent compiles into about 10 KB of 68000 code. The machine independent@portions of this agent also run on CMU's IBM PC/AT based router.JThe applications are designed to be useful in the real world. SnmpnetstatJis a port of the Berkeley Unix netstat that gathers it's information usingNSNMP. (Many people will enjoy "snmpnetstat mygateway public -r"). SnmpstatusKcollects several pieces of information and presents them in a useful formatOand is good for everyday status monitoring. The rest of the tools are simpler,Ibut still interpret input and output symbolicly (they can be used withoutreferencing the RFC's!).For instance, (snmpnetstat mygateway public -r returns:Routing tables5Destination Gateway  CMUSNMP.SAVHE'[MULTINET_PLUS.MULTINET.SNMP]$README.;2Wq Flags Interface5bbn-net-temp psc-gw3.psc.edu UG Ethernet05arpanet prpnet-gw.cc.cmu.e UG Ethernet05xerox-net psc-gw3.psc.edu UG Ethernet05hp-internet psc-gw3.psc.edu UG Ethernet0...snmpstatus returns:7[128.2.56.220]=>[Kinetics Fastpath2] Up: 1 day, 4:43:31=Recv/Trans packets - Interface: 262874/39867 | IP 47432/34587KThe rest of the applications typically present a variable in a form similarto the following:)Name: interfaces.ifTable.ifEntry.ifType.1INTEGER: ethernet-csmacd(6)KThe parsing and printing of symbolic object identifiers and the printing of?typed variables is driven by a database that describes the MIB.NThe MIB database is now retrieved from a text file in the ASN.1 format used inRthe RFC1066 MIB. This makes adding new (enterprise specific) mibs to the databaseWvery simple. I will solicit description files from other SNMP vendors and redistributeRthem via anonymous FTP. Initially, the mib.txt file contains a discription of theWRFC 1066 MIB and portions of the CMU enterprise specific MIB. I had help in optimizing8the parser from Phil Lapsley of Berkeley (Thanks Phil!).OFor further information, please consult the man pages. There are man pages forUeach of the applications, as well as for the Application Programming Interface (API).PThe API has been redesigned to present a very convenient and useful asynchronousOinterface to the SNMP transport. In addition, snmp_client.c contains a tool CMUSNMP.SAVHE'[MULTINET_PLUS.MULTINET.SNMP]$README.;2WekitOof routines that simplify writing client applications. In particular, there isLa synchronous interface built on top of the asyncronous interface that makeswriting applications very easy.HThis distribution is coprighted by CMU, but may be used and sold withoutRpermission. The snmpnetstat application is derived from the Berkeley 4.3 netstat,Qand is therefore also copyrighted by Berkeley. Consult the copyright notices forfurther information.<The distribution is available by anonymous FTP from the hostOlancaster.andrew.cmu.edu (128.2.13.21) as the file pub/cmu-snmp1.0.tar. I willImaintain a repository of mib description files in the directory pub/mibs.OPlease direct questions, comments, and bug reports to sw0l+snmp@andrew.cmu.edu.PI have received very helpful feedback in the past that has been integrated into 6the current release. This wil continue in the future.KIf you pick up this package, please send me a note to the above address, soIthat I may notify you of future enhancements/changes and additions to theQset of applications (several are planned). I will also redistribute applicationsWusing the CMU SNMP library that were written elsewhere and placed in the public domain.HThere are already several such applications pending such a distribution.IThere is a gateway at CMU running the agent. Feel free to query it. YouGcan access as netdev-kbox.cc.cmu.edu (128.2.56.220) with community name "public".Steve WaldbusserNetwork DevelopmentCarnegie-Mello CMUSNMP.SAVHE'[MULTINET_PLUS.MULTINET.SNMP]$README.;2WH n University'*[MULTINET_PLUS.MULTINET.SNMP]APPS.DIR;1+,I./ 4-E0123 KPWO56󜪓7`!󜪓8+ 9FRQٓGHDJI $M$AKEFILE.JMAKE.COMK SNMPGET.CL SNMPGET.EXEqK  SNMPGET.OBJ K  SNMPGET.OPTO SNMPGETNEXT.CPSNMPNETSTAT.DIRQ SNMPSTATUS.C_SNMPSTATUS.EXErK SNMPSTATUS.OBJ%K SNMPSTATUS.OPTb SNMPTEST.Cc SNMPTRAP.Cd SNMPTRAPD.Ce CMUSNMP.SAVIE'[MULTINET_PLUS.MULTINET.SNMP]APPS.DIR;1? SNMPWALK.Cf SNMPWALK.EXEsK  SNMPWALK.OBJ9K  SNMPWALK.OPTiSNMPWALK_ASY.CjSNMPWALK_ASY.EXEtK SNMPWALK_ASY.OBJTK SNMPWALK_ASY.OPTm TGVSTATUS.Cn TGVSTATUS.EXEuK  TGVSTATUS.OBJ^K  TGVSTATUS.OPTq/*[MULTINET_PLUS.MULTINET.SNMP.APPS]$M$AKEFILE.;2+,J. / 4V $-I0@123KPWO 56@*'7 o8 zaғ9FRQٓGHJ#V# Makefile for snmpget, snmpgetnext, snmpwalk, snmpstatus, snmptest snmptrap snmptrapd#ITARG= snmpget snmpgetnext snmpwalk snmpstatus snmptest snmptrap snmptrapdLIBS= ../snmplib/libsnmp.aCFLAGS=-O -I../snmplib all: $(TARG)snmpget: snmpget.o ${LIBS} ${CC} -o $@ snmpget.o ${LIBS}%snmpgetnext: snmpgetnext.o ${LIBS}" ${CC} -o $@ snmpgetnext.o ${LIBS}snmpwalk: snmpwalk.o ${LIBS} ${CC} -o $@ snmpwalk.o ${LIBS}#snmpstatus: snmpstatus.o ${LIBS}! ${CC} -o $@ snm CMUSNMP.SAVJI/[MULTINET_PLUS.MULTINET.SNMP.APPS]$M$AKEFILE.;2V epstatus.o ${LIBS}snmptest: snmptest.o ${LIBS} ${CC} -o $@ snmptest.o ${LIBS}snmptrap: snmptrap.o ${LIBS} ${CC} -o $@ snmptrap.o ${LIBS}!snmptrapd: snmptrapd.o ${LIBS} ${CC} -o $@ snmptrapd.o ${LIBS}clean: rm -f *.o ${TARG}install: cp ${TARG} ../bin,*[MULTINET_PLUS.MULTINET.SNMP.APPS]MAKE.COM;8+,K./ 4i<-I0@123KPWO56e)7`o8@@* 9FRQٓGHJ$!!$! Compile and link SNMP programs$!-$ If P1 .Eqs. "VMSINSTAL" Then Goto VMSinstal$ SAVE_VERIFY='F$VERIFY(0)$ Set Symbol/Scope=NoGlobalG$ GCC := GCC/DEBUG/DEFINE=("""vax11c""","""unix""")/INCLUDE=[-.SNMPLIB]>$ If "''LINKFLAGS'" .Eqs. "" Then LINKFLAGS = "/NOTRACE/NOMAP"$4$ CALL MAKE SNMPGET.OBJ "GCC SNMPGET" SNMPGET.C_$ CALL MAKE SNMPGET.EXE "LINK''LINKFLAGS' SNMPGET/OPT" SNMPGET.OBJ [-.SNMPLIB]LIBSNMP.OLB:$ CALL MAKE SNMPSTATUS.OBJ "GCC SNMPSTATUS" SNMPSTATUS.Ce$ CALL  CMUSNMP.SAVKI,[MULTINET_PLUS.MULTINET.SNMP.APPS]MAKE.COM;8ie MAKE SNMPSTATUS.EXE "LINK''LINKFLAGS' SNMPSTATUS/OPT" SNMPSTATUS.OBJ [-.SNMPLIB]LIBSNMP.OLB6$ CALL MAKE SNMPWALK.OBJ "GCC SNMPWALK" SNMPWALK.Ca$ CALL MAKE SNMPWALK.EXE "LINK''LINKFLAGS' SNMPWALK/OPT" SNMPWALK.OBJ [-.SNMPLIB]LIBSNMP.OLB>$ CALL MAKE SNMPWALK_ASY.OBJ "GCC SNMPWALK_ASY" SNMPWALK_ASY.Ci$ CALL MAKE SNMPWALK_ASY.EXE "LINK''LINKFLAGS' SNMPWALK_ASY/OPT" SNMPWALK_ASY.OBJ [-.SNMPLIB]LIBSNMP.OLB8$ CALL MAKE TGVSTATUS.OBJ "GCC TGVSTATUS" TGVSTATUS.Cc$ CALL MAKE TGVSTATUS.EXE "LINK''LINKFLAGS' TGVSTATUS/OPT" TGVSTATUS.OBJ [-.SNMPLIB]LIBSNMP.OLB$ SET DEFAULT [.SNMPNETSTAT]$ @MAKE$ SET DEFAULT [-]$ EXIT $VMSinstal:$ Exit5$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES$ V = 'F$Verify(0)"$! P1 = What we are trying to make$! P2 = Command to make it$! P3 - P8 What it depends on$+$ If F$Search(P1) .Eqs. "" Then Goto Makeit#$ Time = F$CvTime(F$File(P1,"RDT"))$arg=3$Loop:$ Argument = P'arg%$ If Argument .Eqs. "" Then Goto Exit$ El=0$Loop2:#$ File = F$Element(El," ",Argument)"$ If File .Eqs. " " Then Goto Endl $ AFile = ""$Loop3:$ OFile = AFile$ AFile = F$Search(File);$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl>$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3$NextEL: $ El = El + 1 $ Goto Loop2$EndL: $ arg=arg+1$ If arg .Le. 8 Then Goto Loop $ Goto Exit$$Makeit: $ Set Verify$ 'P2$ VV='F$Verify(0)$Exit:$ If V Then Set Verify$ENDSUBROUTINE  CMUSNMP.SAVLI-[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3bu-*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3+,L./ 4b <-I0@123KPWO56 {岒7 -o8jG}9FRQٓGHJ/*: * snmpget.c - send snmp GET requests to a network entity. * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University All Rights ReservedEPermission to use, copy, modify, and distribute this software and its@documentation for any purpose and without fee is hereby granted,Fprovided that the above copyright notice appear in all copies and that?both that copyright notice and this permission notice appear in9supporting documentation, and that the name of CMU not beBused in advertising or publicity pertaining to distribution of the4software without specific, written prior permission.DCMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGHALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLCCMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORCANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,FWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER   CMUSNMP.SAVLI-[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3bTORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************/#include #include #include #include #include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "snmp_api.h"#include "snmp_client.h"extern int errno;int snmp_dump_packet = 0;main(argc, argv) int argc; char *argv[];{% struct snmp_session session, *ss;$ struct snmp_pdu *pdu, *response; struct variable_list *vars; int arg; char *gateway = NULL; char *community = NULL; int count, current_name = 0; char *names[128]; oid name[MAX_NAME_LEN]; int name_length; int status; init_mib(); /*1 * usage: snmpget gateway-name community-name */$ for(arg = 1; arg < argc; arg++){ if (argv[arg][0] == '-'){ switch(argv[arg][1]){ case 'd': snmp_dump_packet++; break; default:4 printf("invalid option: -%c\n", argv[arg][1]); break; } continue; } if (gateway == NULL){ gateway = argv[arg]; } else if (community == NULL){ community = argv[arg]; } else {' names[current_name++] = argv[arg]; } }5 if (!(gateway && community && current_name > 0)){b printf("usage: snmpget gateway-name community-name object-identifier [object-identifier ...]\n"); exit(1); }9 bzero((char *)&ses  CMUSNMP.SAVLI-[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3b>sion, sizeof(struct snmp_session)); session.peername = gateway;, session.community = (u_char *)community;6 session.community_len = strlen((char *)community);+ session.retries = SNMP_DEFAULT_RETRIES;+ session.timeout = SNMP_DEFAULT_TIMEOUT;! session.authenticator = NULL; snmp_synch_setup(&session); ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); }' pdu = snmp_pdu_create(GET_REQ_MSG);2 for(count = 0; count < current_name; count++){ name_length = MAX_NAME_LEN;4 if (!read_objid(names[count], name, &name_length)){= printf("Invalid object identifier: %s\n", names[count]); }+ snmp_add_null_var(pdu, name, name_length); }retry:5 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){, if (response->errstat == SNMP_ERR_NOERROR){F for(vars = response->variables; vars; vars = vars->next_variable)6 print_variable(vars->name, vars->name_length, vars); } else {Q printf("Error in packet.\nReason: %s\n", snmp_errstring(response->errstat));3 if (response->errstat == SNMP_ERR_NOSUCHNAME){& printf("This name doesn't exist: ");Q for(count = 1, vars = response->variables; vars && count != response->errindex;* vars = vars->next_variable, count++) ; if (vars)1 print_objid(vars->name, vars->name_length); printf("\n"); }= if ((pdu = snmp_fix_pdu(response, GET_REQ_MSG)) != NULL) goto retry; }' } else  CMUSNMP.SAVLI-[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3b if (status == STAT_TIMEOUT){* printf("No Response from %s\n", gateway);' } else { /* status == STAT_ERROR */) printf("An error occurred, Quitting\n"); } if (response) snmp_free_pdu(response); snmp_close(ss);}/*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1+,qK .(/ 4()-I0D123 KPWO)56(ɓ7(ɓ8 9FRQٓGHJ0DX0205(d(IL SNMPGETV1.0]d(ɓ04-00#& ' ?0!MULTINET_SOCKET_LIBRARY_001!  LIBRTL_001 ! VAXCRTL_001@!d FORRTL_001y! MTHRTL_001!f SMGSHR_001 CMUSNMP.SAVqK I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1(e ----,,,-5-P-.iso.org.dod.internet.mgmt.mib6? FO Yh s ~         !invalid option: -%c usage: snmpget gateway-name community-name object-identifier [object-identifier ...] Couldn't open snmp Invalid object identifier: %s Error in packet. Reason: %s This name doesn't exist: No Response from %s An error occurred, Quitting ET^ЬWЬSVTU RRWNBcP`-$d62BcP~ϨuEVBcVTBcT BcEUWRVTUσ;E.E$RRDVTT EPԭR$R&PWD~D CMUSNMP.SAVqK I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1(~ PTSSUD\R@XXRC} PCCDXRT USTTWa#P1TPՠ РDR1Rݢݢ~bR1TPݠ$P#DRbTPѠEbSTPРDRTPS bRSRR ݢݢ C~Tj!PT1:PVϮC ϶CT T 1W'%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02d<ЬUǏdPǏQPSSQďQQQPQǏQTTPďPPQPR>~SRP~Ϛݳ DPݳ Ra>Wrong Type (should be INTEGER): INTEGER: %dINTEGER: %s(%d) ЬRЬSЬ PQ 3R>R=~SRP~Ѡ РQ`PPQݳ R=ݳ QR=Wrong Type (should be Gauge): Gauge: %lu ЬRЬS B#Rg=Rb=~SRP~mݳ RA=Wrong Type (should be Counter): Counter: %lu ЬRЬS A#R<R<~SRP~ݳ R<Network Address: %02X<ЬSЬRS<S<PSТ TТURRU+~Sv<Sq<PSPRP:URWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%d ЬSЬR @#S<S;~RSP~Т P~~~`~S;INTEGER (0..65535): %lu ЬRЬS $>R;R;~SRP~ϛݳ Ro;Wrong Type (should be NULL): NULL ЬRЬS "R.;R);~SRP~5R ;Variable has bad typeݬ:ЬRЬQ PPBfݬ QR_QRUTQRDIQR>QRZ3QR(QRQRQRϘRmib.txtMIBFILEMULTINET:SNMP_MIB.TXTCouldn't find mib file 3RbPt9P PbPhbPOIZ9/969(ЬR1Ϣ0 h (08@HPX`PϮ8N8F8>(86ϸ8.ϼ8& CMUSNMP.SAVqK I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1( B8 88d8ϲ8b{ТRЬTRSTQDQPQPTcPPPB`UR Ѣ,THТRR>c.caURUU ωPТ,TТRR T6_6Pffk6@6߰Tc.PVWbPfffP%s ^P.RPݬݬHR5ЬQP.QPݬ ݬName: %s |^Ь VU.RUݬݬPURTT5ScPR cRP!cPT 5PTTL5ե8ݥ4V8ݥ4V65 ^ЬTЬWV.RVݬ ݬ,PVRUT4ScPRQcRP!CcP8TS4PUUT4T4PTզ8 ݦ4WT8 ݦ4WTwMTB4 ^ЬSЬR7PPݬ ݬzՠ8 ݠ4RS8 ݠ4RS$ ^Ь SPRRPݬݬ5ՠ8 ݠ4SR8ݠ4SϘ3%d.|ЬTЬUЬ SЬRVS8мSЏQQURxSSUSPPQRRW~VT%PTfRPRfҏQQSPPPPxSSRRTP<^ЬSЬTЬUSR RPRSRPPPdѭePݭݬR. ЭeSRPPPdRPЬRЬT PЬSSP~TRkPRdSPSRݬSdRSP ^ЬRЬSRQaPP" QPPFPQ RQPPPcPЭcQPЬPЬQ Ra CMUSNMP.SAVqK I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1(~I#PRaݬQPb<ЬTЬSdPPEPPPPRRS4cPcRPxPPP QcUPQUcDPPcPЬQЬSЬ RQTRR xRPPRTQPcPPTQPPcQP^ЬRЬTЬWЬVRSU S&PSRRSPPPdERSPPPdЭTfT:ff/RxRQcPʏPQPRTRPRT<R(RP<P(PR~PgWUPPxPfSP@^ЬXЬY ZЬWT@VxW~Vݬ2fPxPQxPPPQQVWZ08ݬ ݬQPQQݬQPQPЭQSQPPbQP^ЬRTЬUЬVЬScRW~0RPR1&WRXXcݼ ݬSR6PR1TPPBqUVT~SR}9UVT~SRO%U~VT~SR^T~SRnPRWRPXPPP0WPPRPpublic ^ЬR,XԭDPRWZ~˟W~PV1<Z~~V*PU1 ݬݬ UPR1RiPR CMUSNMP.SAVqK I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.EXE;1(ڣ&1RhPR1RMPR1 C~R0PT1Z~0RRTPSRݬ4ݬ0X~(ݬ$S|PRaSRPPP0TKPSDURPPP~V,PU%VRPPPόW?PVPWRPЬPЬRRQ{RPPR PRPPЬPЬRRQ{RPRPPPRRPЬPì QQPPjP@@8Pphh<lTt|D t , J #@MULTINET_SOCKET_LIBRARYLIBRTLVAXCRTLFORRTLMTHRTLSMGSHRJJJJ%,J CMUSNMP.SAV K I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OBJ;1^/*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OBJ;1+, K ./ 4 -I0D123KPWO56|ē7ƺ ē8<9FRQٓGHJ4SNMPGETV1.0 6-SEP-1990 11:50GNU CC V1.22X$CODESID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATE MAIN C$MAIN_ARGSINIT_MIBPRINTFEXITBZEROSTRLENSNMP_SYNCH_SETUP SNMP_OPENSNMP_PDU_CREATE READ_OBJIDSNMP_ADD_NULL_VARSNMP_SYNCH_RESPONSEPRINT_VARIABLESNMP_ERRSTRING PRINT_OBJID SNMP_FIX_PDU SNMP_FREE_PDU SNMP_CLOSE SOCKET_ERRNOVMSERRNO VAXC$ERRNOERRNOSTDERRSTDOUTSTDINPinvalid option: -%c usage: snmpget gateway-name community-name object-identifier [object-identifier ...] Couldn't open snmp Invalid object identifier: %s Error in packet. Reason: %s This name doesn't exist: No Response from %s An error occurred, Quitting  PPT^ЬWЬSVTU,PRRWN4PBcP`-$=PdDP2LPBcP~ϨXP CMUSNMP.SAV K I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OBJ;1_PaPVePBcVkPToPBcT uPBcEUWRPVPTPUPσPPP$RRPVTTPPԭRPRPPWPPP~P~PPTSSUDP\R@XXRC/PP3PCC<PCPXRTRPUSVPTTWePP1lPTPՠ vPРDR1PRݢݢPbRP1PTPݠPPPPRbTPѠEPPbSTPРDRPTPS PbRSRPR PݢݢPPP񚏠~TPPT1:PPP#PVϮ)P0P 2P϶6P=PT CPTNPWWPRP SNMP_CLOSEIP SNMP_FREE_PDU8PPRINTF+PPRINTFP SNMP_FIX_PDUPPRINTFP PRINT_OBJIDPPRINTFPSNMP_ERRSTRINGPPRINT_VARIABLE`PSNMP_SYNCH_RESPONSEMPSNMP_ADD_NULL_VAR>PPRINTF*P READ_OBJIDPSNMP_PDU_CREATEPEXITPPRINTFP SNMP_OPENPSNMP_SYNCH_SETUPPSTRLENPBZEROPEXITPPRINTFZPPRINTF'PINIT_MIB P C$MAIN_ARGSEPP CMUSNMP.SAV K I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OBJ;1.SNMPGETRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrRS synch_statewaiting  status @reqid `pdu RRSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_len RS T Ssnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables T R S snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic snmp_dump_packet,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno*#$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes CMUSNMP.SAV K I/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OBJ;1 _NOSHR$$errno& $$PsectAttributes_NOSHR$$stderr T& $$PsectAttributes_NOSHR$$stdout T% $$PsectAttributes_NOSHR$$stdin TvSO {岒 ;DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.C;3   mainargcVargvV session  TssV  TpduV  TTresponse  TvarsV TargV gatewayVO " communityV countV% current_nameV names3/ \name*&@@?X name_lengthstatusV (  ;~ eR  rNN  CMUSNMP.SAVOI/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OPT;20z/*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGET.OPT;2+,O./ 40<-I0@123KPWO56|757_758ͼ<9FRQٓGHJSNMPGET[-.SNMPLIB]LIBSNMP/LIB0[--.SOCKET_LIBRARY]MULTINET_SOCKET_LIBRARY/SHAREGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE1*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGETNEXT.C;2+,P./ 4f J-I0@123KPWO56R747o8g}9FRQٓGHJ/*B * snmpgetnext.c - send snmp GETNEXT requests to a network entity. * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University) All Rights ReservedFPermission to use, copy, modify, and distribute this software and its Adocumentation for any purpose and without fee is hereby granted, Fprovided that the above copyright notice appear in all copies and that@both that copyright notice and this permission notic  CMUSNMP.SAVPI1[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGETNEXT.C;2fje appear in 9supporting documentation, and that the name of CMU not beBused in advertising or publicity pertaining to distribution of the6software without specific, written prior permission. DCMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGHALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLCCMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORCANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,FWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************/#include #include #include #include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "snmp_api.h"#include "snmp_client.h"extern int errno;int snmp_dump_packet = 0;main(argc, argv) int argc; char *argv[];{% struct snmp_session session, *ss;$ struct snmp_pdu *pdu, *response; struct variable_list *vars; int arg; char *gateway = NULL; char *community = NULL; int count, current_name = 0; char *names[128]; oid name[MAX_NAME_LEN]; int name_length; int status; init_mib(); /*D * usage: snmpgetnext gateway-name community-name object-id-list */$ for(arg = 1; arg < argc; arg++){ if (argv[arg][0] == '-'){ switch(argv[arg][1]){ case 'd':! CMUSNMP.SAVPI1[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGETNEXT.C;2f snmp_dump_packet++; break; default:4 printf("invalid option: -%c\n", argv[arg][1]); break; } continue; } if (gateway == NULL){ gateway = argv[arg]; } else if (community == NULL){ community = argv[arg]; } else {' names[current_name++] = argv[arg]; } }5 if (!(gateway && community && current_name > 0)){f printf("usage: snmpgetnext gateway-name community-name object-identifier [object-identifier ...]\n"); exit(1); }9 bzero((char *)&session, sizeof(struct snmp_session)); session.peername = gateway;, session.community = (u_char *)community;6 session.community_len = strlen((char *)community);+ session.retries = SNMP_DEFAULT_RETRIES;+ session.timeout = SNMP_DEFAULT_TIMEOUT;! session.authenticator = NULL; snmp_synch_setup(&session); ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); }+ pdu = snmp_pdu_create(GETNEXT_REQ_MSG);2 for(count = 0; count < current_name; count++){ name_length = MAX_NAME_LEN;4 if (!read_objid(names[count], name, &name_length)){= printf("Invalid object identifier: %s\n", names[count]); } + snmp_add_null_var(pdu, name, name_length); }5 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){, if (response->errstat == SNMP_ERR_NOERROR){F for(vars = response->variables; vars; vars = vars->next_variable)6 print_variable(vars->name, v" CMUSNMP.SAVPI1[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPGETNEXT.C;2fSars->name_length, vars); } else {3 if (response->errstat == SNMP_ERR_NOSUCHNAME){3 printf("You have reached the end of the MIB.\n"); } else {N printf("Error in packet.\nReason: %s\n", snmp_errstring(response->errstat));0 if (response->errstat == SNMP_ERR_NOSUCHNAME){* printf("This name doesn't exist: ");U for(count = 1, vars = response->variables; vars && count != response->errindex;' vars = vars->next_variable, count++) ; if (vars). print_objid(vars->name, vars->name_length); printf("\n"); } } }' } else if (status == STAT_TIMEOUT){* printf("No Response from %s\n", gateway);* } else { /* status == STAT_ERROR */) printf("An error occurred, Quitting\n"); } if (response) snmp_free_pdu(response); snmp_close(ss);}3*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPNETSTAT.DIR;1+,Q./ 4-I0123 KPWO56@o78 9FRQٓGHJI# CMUSNMP.SAVQI3[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPNETSTAT.DIR;1 $M$AKEFILE.RIF.CSIF.OBJaINET.CUINET.OBJaMAIN.CWMAIN.HXMAIN.OBJaMAKE.COMZROUTE.C[ ROUTE.OBJaSNMPNETSTAT.EXEvK SNMPNETSTAT.OPT^;*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]$M$AKEFILE.;2+,R. / 4E H-Q0@123KPWO 56 &7 'o8 ғ9FRQٓGHJ#=# Copyright (c) 1987 Regents of the University of California.# All rights reserved.#A# Redistribution and use in source and binary forms are permittedA# provided that the above copyright notice and this paragraph are:# duplicated in all such forms and that any documentation,<# advertising materials, and other materials related to suchB# distribution and use acknowledge that the software was developed=# by the University of California, Berkeley. The name of theC# University may not be $ CMUSNMP.SAVRQ;[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]$M$AKEFILE.;2E used to endorse or promote products derived?# from this software without specific prior written permission.@# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR@# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIEDE# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.#&# @(#)Makefile 5.10 (Berkeley) 9/20/88#CFLAGS= -O -I../../snmplibLIBS= ../../snmplib/libsnmp.a!SRCS= inet.c if.c main.c route.c OBJS= inet.o if.o main.o route.oall: snmpnetstatsnmpnetstat: ${OBJS} ${LIBS}& ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS}clean: rm -f ${OBJS} core snmpnetstatcleandir: clean rm -f ${MAN} tags .dependdepend: ${SRCS} mkdep ${CFLAGS} ${SRCS} lint: ${SRCS} lint ${CFLAGS} ${SRCS} tags: ${SRCS} ctags ${SRCS}install: cp snmpnetstat ../../bin4*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4+,S./ 4Q><-Q0@123KPWO56a8WV77o8_~9FRQٓGHJ% CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4Q</***********************************************************- Copyright 1989 by Carnegie Mellon University All Rights ReservedEPermission to use, copy, modify, and distribute this software and its@documentation for any purpose and without fee is hereby granted,Fprovided that the above copyright notice appear in all copies and that?both that copyright notice and this permission notice appear in9supporting documentation, and that the name of CMU not beBused in advertising or publicity pertaining to distribution of the4software without specific, written prior permission.DCMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGHALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLCCMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORCANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,FWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************//*C * Copyright (c) 1983,1988 Regents of the University of California. * All rights reserved. *B * Redistribution and use in source and binary forms are permittedF * provided that this notice is preserved and that due credit is givenJ * to the University of California at Berkeley. The name of the UniversityC * may not be used to endorse or promote products derived from thisD * software without specific pri& CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4QDNor written permission. This software= * is provided ``as is'' without express or implied warranty. */#include #include #include #include #include #include "main.h"#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "snmp_api.h"#include "snmp_client.h"#include "mib.h" #define YES 1 #define NO 0extern int nflag;extern char *interface;%extern char *routename(), *netname();$extern struct snmp_session *Session;,extern struct variable_list *getvarbyname();5oid oid_ifname[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 2, 1};Dstatic oid oid_ifinucastpkts[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1};9static oid oid_cfg_nnets[] = {1, 3, 6, 1, 2, 1, 2, 1, 0};#define IFNAME 2#define IFMTU 4#define IFOPERSTATUS 8#define INUCASTPKTS 11#define INNUCASTPKTS 12#define INERRORS 14#define OUTUCASTPKTS 17#define OUTNUCASTPKTS 18#define OUTERRORS 20/*1 * Print a description of the network interfaces. */intpr(interval) int interval;{0 oid varname[MAX_NAME_LEN], *instance, *ifentry; int varname_len; int ifnum, cfg_nnets; struct variable_list *var; char name[32]; int mtu;8 int ipkts, ierrs, opkts, oerrs, operstatus, collisions; if (interval) {$ sidewaysintpr((unsigned)interval); return; }D printf("%-11.11s %-5.5s %-11.11s %-15.15s %8.8s %5.5s %8.8s %5.5s",8 "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs", "Opkts", "Oerrs"); putchar('' CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4Q\n');Q var = getvarbyname(Session, oid_cfg_nnets, sizeof(oid_cfg_nnets) / sizeof(oid)); if (var)# cfg_nnets = *var->val.integer; else return;@ bcopy((char *)oid_ifname, (char *)varname, sizeof(oid_ifname));0 varname_len = sizeof(oid_ifname) / sizeof(oid); ifentry = varname + 9; instance = varname + 10;/ for (ifnum = 1; ifnum <= cfg_nnets; ifnum++) { register char *cp; char *index(); *name = mtu = 0;> ipkts = ierrs = opkts = oerrs = operstatus = collisions = 0; *instance = ifnum; *ifentry = IFNAME;4 var = getvarbyname(Session, varname, varname_len); if (var){9 bcopy((char *)var->val.string, name, var->val_len); name[var->val_len] = 0; } *ifentry = IFMTU;4 var = getvarbyname(Session, varname, varname_len); if (var) mtu = *var->val.integer; *ifentry = IFOPERSTATUS;4 var = getvarbyname(Session, varname, varname_len); if (var)% operstatus = *var->val.integer; *ifentry = INUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var) ipkts = *var->val.integer; *ifentry = INNUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var)! ipkts += *var->val.integer; *ifentry = INERRORS;4 var = getvarbyname(Session, varname, varname_len); if (var) ierrs = *var->val.integer; *ifentry = OUTUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var) opkts = *var->val.integer; *ifentry = OUTNUCASTPKTS;4 var = getvarbyname(S( CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4QW ession, varname, varname_len); if (var)! opkts += *var->val.integer; *ifentry = OUTERRORS;4 var = getvarbyname(Session, varname, varname_len); if (var) oerrs = *var->val.integer; name[15] = '\0'; if (interface != 0 &&# strcmp(name, interface) != 0) continue; cp = index(name, '\0');$ if (operstatus != MIB_IFSTATUS_UP) *cp++ = '*'; *cp = '\0';& printf("%-11.11s %-5d ", name, mtu); printf("%-11.11s ", "none"); printf("%-15.15s ", "none"); printf("%8d %5d %8d %5d %5d", ipkts, ierrs, opkts, oerrs, collisions); putchar('\n'); }}#define MAXIF 10struct iftot {) char ift_name[16]; /* interface name */" int ift_ip; /* input packets */! int ift_ie; /* input errors */# int ift_op; /* output packets */" int ift_oe; /* output errors */ int ift_co; /* collisions */} iftot[MAXIF];7u_char signalled; /* set if alarm goes off "early" *//*3 * Print a running summary of interface statistics.< * Repeat display every interval seconds, showing statisticsD * collected over that interval. Assumes that interval is non-zero.< * First line printed at top of screen is always cumulative. */sidewaysintpr(interval) unsigned interval;{# register struct iftot *ip, *total; register int line;@ struct iftot *lastif, *sum, *interesting, ifnow, *now = &ifnow; int oldmask; int catchalarm(); struct variable_list *var;0 oid varname[MAX_NAME_LEN], *instance, *ifentry; int varname_len;) CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4Qu  int ifnum, cfg_nnets; char *index(); lastif = iftot; sum = iftot + MAXIF - 1; total = sum - 1; interesting = iftot;Q var = getvarbyname(Session, oid_cfg_nnets, sizeof(oid_cfg_nnets) / sizeof(oid)); if (var)# cfg_nnets = *var->val.integer; else return;@ bcopy((char *)oid_ifname, (char *)varname, sizeof(oid_ifname));0 varname_len = sizeof(oid_ifname) / sizeof(oid);; for (ifnum = 1, ip = iftot; ifnum <= cfg_nnets; ifnum++) { char *cp; ip->ift_name[0] = '('; varname[10] = ifnum;4 var = getvarbyname(Session, varname, varname_len); if (var){E bcopy((char *)var->val.string, ip->ift_name + 1, var->val_len); }< if (interface && strcmp(ip->ift_name + 1, interface) == 0) interesting = ip; ip->ift_name[15] = '\0';! cp = index(ip->ift_name, '\0'); sprintf(cp, ")"); ip++; if (ip >= iftot + MAXIF - 2) break; } lastif = ip;#ifndef vax11c# (void)signal(SIGALRM, catchalarm); signalled = NO; (void)alarm(interval); #endif vax11cbanner:F printf(" input %-6.6s output ", interesting->ift_name); if (lastif - iftot > 0)* printf(" input (Total) output");- for (ip = iftot; ip < iftot + MAXIF; ip++) { ip->ift_ip = 0; ip->ift_ie = 0; ip->ift_op = 0; ip->ift_oe = 0; ip->ift_co = 0; } putchar('\n');) printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",1 "packets", "errs", "packets", "errs", "colls"); if (lastif - iftot > 0)* printf("%8.8s %5.5s %8.8s %5.5s %5.5s ",2 "pa* CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4Q$ckets", "errs", "packets", "errs", "colls"); putchar('\n'); fflush(stdout); line = 0;loop: sum->ift_ip = 0; sum->ift_ie = 0; sum->ift_op = 0; sum->ift_oe = 0; sum->ift_co = 0;N bcopy((char *)oid_ifinucastpkts, (char *)varname, sizeof(oid_ifinucastpkts));7 varname_len = sizeof(oid_ifinucastpkts) / sizeof(oid); ifentry = varname + 9; instance = varname + 10;P for (ifnum = 1, ip = iftot; ifnum <= cfg_nnets && ip < lastif; ip++, ifnum++) {# bzero((char *)now, sizeof(*now)); *instance = ifnum; *ifentry = INUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var)& now->ift_ip = *var->val.integer; *ifentry = INNUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var)' now->ift_ip += *var->val.integer; *ifentry = INERRORS;4 var = getvarbyname(Session, varname, varname_len); if (var)& now->ift_ie = *var->val.integer; *ifentry = OUTUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var)& now->ift_op = *var->val.integer; *ifentry = OUTNUCASTPKTS;4 var = getvarbyname(Session, varname, varname_len); if (var)' now->ift_op += *var->val.integer; *ifentry = OUTERRORS;4 var = getvarbyname(Session, varname, varname_len); if (var)& now->ift_oe = *var->val.integer; if (ip == interesting)! printf("%8d %5d %8d %5d %5d ", now->ift_ip - ip->ift_ip, now->ift_ie - ip->ift_ie, now->ift_op - ip->ift_op, now->ift_oe - ip->ift_oe, + CMUSNMP.SAVSQ4[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4QLnow->ift_co - ip->ift_co); ip->ift_ip = now->ift_ip; ip->ift_ie = now->ift_ie; ip->ift_op = now->ift_op; ip->ift_oe = now->ift_oe; ip->ift_co = now->ift_co; sum->ift_ip += ip->ift_ip; sum->ift_ie += ip->ift_ie; sum->ift_op += ip->ift_op; sum->ift_oe += ip->ift_oe; sum->ift_co += ip->ift_co; } if (lastif - iftot > 0) printf("%8d %5d %8d %5d %5d ", sum->ift_ip - total->ift_ip, sum->ift_ie - total->ift_ie, sum->ift_op - total->ift_op, sum->ift_oe - total->ift_oe, sum->ift_co - total->ift_co); *total = *sum; putchar('\n'); fflush(stdout); line++;#ifndef vax11c& oldmask = sigblock(sigmask(SIGALRM)); if (! signalled) { sigpause(0); } sigsetmask(oldmask); signalled = NO; (void)alarm(interval); #else vax11c sleep(interval); #endif vax11c if (line == 21) goto banner; goto loop; /*NOTREACHED*/}/*K * Called if an interval expires before sidewaysintpr has completed a loop.) * Sets a flag to not wait for the alarm.* */* catchalarm(){* signalled = YES;*}*, CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1A#6*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1+,a./ 4-Q0D123KPWO56FHē7fYIē8`n<9FRQٓGHJ/IFV1.0 6-SEP-1990 11:53GNU CC V1.22h$CODE COMMUNITYADDRESSREQIDSDSID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATENFLAG INTERFACESESSION_040000X OID_IFNAME INTPR  SIDEWAYSINTPRPRINTFSTDOUTFPUTC GETVARBYNAMEBCOPYSTRCMPINDEXhIFTOTSPRINTFFFLUSHhBZEROSLEEP ^ CATCHALARM SIGNALLEDSTDERRSTDIN($DATAPOerrsOpktsIerrsIpktsAddressNetworkMtuName%-11.11s %-5.5s %-11.11s %-15.15s %8.8s %5.5s %8.8s %5.5s%-11.11s %-5d none%-11.11s %-15.15s %8d %5d %8d %5d %5dPP^ЬPPPP?PAPCPEPGPKPOPOPPP PP P P PPRPв XRR- CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1ܺ-P URSSR\\XXX1NPўT`Y[`ZPWTVX\cUT}PPPRPݢYݢ PТPM`cUTPPPRPв [cUTPPPRPв Z cUTPPPRPв V cUTP PPRP VcUT"P)PPR.Pв TcUTAPHPPRMPв WcUT^PePPRjP WcUT{PPPRPв PoPPPYPPaP~YPZP*`[YϢPPRbϣPϤPbϘPϣPb~PWTVϘPbP  PXX1?P) input %-6.6s output input (Total) outputcollserrspackets%8.8s %5.5s %8.8s %5.5s %5.5s %8d %5d %8d %5d %5d PL^VPYDXXYP PPPPа [\P USPRS[x P(bSpU\P$PP(Pݠݠ 8P>PPAPPMPPQPRP~RdPϱhPPqP$RR}P[SPRYPϏPPÏYPP$PP$P PϔPPPR. CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1xPPPPԢԢԢԢԢ $RRPPP PqPsPtPkPlPpPPÏYPP$PP$PP>P@#PA'P8+P9/P=3P:P@P IPOPVPTԨԨԨԨԨ \RRP URTTRLLSPRS[19P\WRY1,P$VPSL dUWPPPPа  dUWPPPP dUW PPPPа dUW&P-PP1Pа dUWCPJPPNP dUW`PgPPkPа RP)wPâ ~â~â~â~â~PPЦЦЦЦЦ  $R[S1PÏYPP$PP$P.PXZê ~ê~ê~ê~ê~vP P($hX,P 5P;PBPTݬPPT1*ZP1]P^PgPbPKPSLEEP=PFFLUSH6P 0PFPUTC'P PPRINTFPPRINTFbP GETVARBYNAME[P EP GETVARBYNAME>P (P GETVARBYNAME!P  P GETVARBYNAMEP P GETVARBYNAMEP P GETVARBYNAME/ CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1 P PBZEROPzPBCOPYQPFFLUSHJP DPFPUTC;P 5PPRINTFPPRINTFPFPUTCP PhPPPRINTFPPRINTFlPSPRINTF_PINDEXHPSTRCMP9P 3PBCOPYP GETVARBYNAMEP PPBCOPYP GETVARBYNAMEP PPFPUTCP PPRINTFPINDEXPSTRCMPP P }P GETVARBYNAMEvP `P GETVARBYNAMEYP CP GETVARBYNAME<P $P GETVARBYNAMEP P GETVARBYNAMEP P GETVARBYNAMEP P GETVARBYNAMEP P GETVARBYNAMEvP PBCOPYP GETVARBYNAMExP (PBCOPYP GETVARBYNAMEP PFPUTCP PPRINTFPsP PPwP P P!P PPP  P  IFRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_0 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1 addrRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslenRS sockproto  sp_family sp_protocolRSsockaddr sa_familysa_data*&  R Slinger@l_onoff l_linger R Ssigstack@ ss_sp  ss_onstack R S sigcontext sc_onstack sc_mask @sc_sp `sc_pc sc_ps R Ssigvec` sv_handler  sv_mask@ sv_onstack R Smib_egpNeighEntry@ egpNeighState egpNeighAddrRSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrorsRSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPortRSmib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegsRSmib_icmp@ icmp1 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1InMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsRSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgeRSmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrRSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscardsO` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atIfIndex atPhysAdd2 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1 cress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr5*&   ifType @ifMtu`ifSpeed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknownProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLenRS mib_interface ifNumberRS mib_systemsysDescr*&  sysObjectID*&ObjIDLen sysUpTimeRS synch_statewaiting  status @reqid `pdu RRSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_lenRSTSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap3 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername՜  remote_port local_port authenticator callback callback_magic  R Siftot ift_name*& ift_ip ift_ie ift_op ift_oe ift_co!RS!T!S   oid_ifname*& oid_ifinucastpkts*&  oid_cfg_nnets*&  signalled iftot3/ T$h &$$PsectAttributes_NOSHR$$stderr T& $$PsectAttributes_NOSHR$$stdout T%$$PsectAttributes_NOSHR$$stdin T~ZVa8WV>BDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.C;4  Z intpr! intervalـvarname*&@@?\instance  ifentry $ varname_lenifnumX cfg_nnetsvar T `name*&4 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1k mtu ipkts Tierrsopkts Poerrs# operstatus W$0cpW  @ L  sidewaysintprintervalip\  T Xtotal  T Tlinelastif\  Tsum\  TP interesting  T ifnow  Tnow\  Tvar\ T\varnameRC*&@@?Linstance  ifentry\ $ varname_len\ifnum\" cfg_nnets\  $0cp | t` ` g R I5 CMUSNMP.SAVaQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]IF.OBJ;1o }  - ^ catchalarm  _addr s_6*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5+,U./ 4W<-Q0@123KPWO56 o|7wYo8*9FRQٓGHJ</***********************************************************- Copyright 1989 by Carnegie Mellon University All Rights ReservedEPermission to use, copy, modify, and distribute this software and its@documentation for any purpose and without fee is hereby granted,Fprovided that the above copyright notice appear in all copies and that?both that copyright notice and this permission notice appear in9supporting documentation, and that the name of CMU not beBused in advertising or publici6 CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wty pertaining to distribution of the4software without specific, written prior permission.DCMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGHALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLCCMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORCANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,FWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************//*C * Copyright (c) 1983,1988 Regents of the University of California. * All rights reserved. *B * Redistribution and use in source and binary forms are permittedF * provided that this notice is preserved and that due credit is givenJ * to the University of California at Berkeley. The name of the UniversityC * may not be used to endorse or promote products derived from thisD * software without specific prior written permission. This software= * is provided ``as is'' without express or implied warranty. */#include #include #include #include #include #include #include "main.h"#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "snmp_api.h"#include "snmp_client.h"#include "mib.h"extern int aflag;extern int nflag;extern char *plural();extern char *malloc();$extern struct 7 CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wsnmp_session *Session;,extern struct variable_list *getvarbyname();char *inetname();struct stat_table {/ int entry; /* entry number in table */E /* format string to printf(description, value, plural(value)); *// /* warning: the %d must be before the %s */ char description[80];};7static oid oid_ipstats[] = {1, 3, 6, 1, 2, 1, 4, 0, 0};"struct stat_table ip_stattab[] = {( {3, "%d total datagram%s received"},, {4, "%d datagram%s with header errors"},= {5, "%d datagram%s with an invalid destination address"},# {6, "%d datagram%s forwarded"},/ {7, "%d datagram%s with unknown protocol"},# {8, "%d datagram%s discarded"},# {9, "%d datagram%s delivered"},) {10, "%d output datagram request%s"},+ {11, "%d output datagram%s discarded"},( {12, "%d datagram%s with no route"},# {14, "%d fragment%s received"},& {15, "%d datagram%s reassembled"},$ {16, "%d reassembly failure%s"},% {17, "%d datagram%s fragmented"},' {18, "%d fragmentation failure%s"},! {19, "%d fragment%s created"}};8static oid oid_udpstats[] = {1, 3, 6, 1, 2, 1, 7, 0, 0};#struct stat_table udp_stattab[] = {( {1, "%d total datagram%s received"},) {2, "%d datagram%s to invalid port"},/ {3, "%d datagram%s dropped due to errors"},' {4, "%d output datagram request%s"}};8static oid oid_tcpstats[] = {1, 3, 6, 1, 2, 1, 6, 0, 0};#struct stat_table tcp_stattab[] = { {5, "%d active open%s"}, {6, "%d passive op8 CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wen%s"}, {7, "%d failed attempt%s"},1 {8, "%d reset%s of established connections"},/ {9, "%d current established connection%s"}," {10, "%d segment%s received"}, {11, "%d segment%s sent"},& {12, "%d segment%s retransmitted"}};9static oid oid_icmpstats[] = {1, 3, 6, 1, 2, 1, 5, 0, 0};$struct stat_table icmp_stattab[] = {' {1, "%d total message%s received"},. {2, "%d message%s dropped due to errors"},' {14, "%d ouput message request%s"},) {15, "%d output message%s discarded"}};(struct stat_table icmp_inhistogram[] = {' {3, "Destination unreachable: %d"}, {4, "Time Exceeded: %d"},! {5, "Parameter Problem: %d"}, {6, "Source Quench: %d"}, {7, "Redirect: %d"}, {8, "Echo Request: %d"}, {9, "Echo Reply: %d"}," {10, "Timestamp Request: %d"}, {11, "Timestamp Reply: %d"},% {12, "Address Mask Request: %d"},! {13, "Addrss Mask Reply:%d"},};)struct stat_table icmp_outhistogram[] = {( {16, "Destination unreachable: %d"}, {17, "Time Exceeded: %d"}," {18, "Parameter Problem: %d"}, {19, "Source Quench: %d"}, {20, "Redirect: %d"}, {21, "Echo Request: %d"}, {22, "Echo Reply: %d"}," {23, "Timestamp Request: %d"}, {24, "Timestamp Reply: %d"},% {25, "Address Mask Request: %d"},! {26, "Addrss Mask Reply:%d"},};struct tcpconn_entry { oid instance[10];! struct in_addr localAddress; int locAddrSet; u_short localPort; int 9 CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5W9 locPortSet;" struct in_addr remoteAddress; int remAddrSet; u_short remotePort; int remPortSet; int state; int stateSet; struct tcpconn_entry *next;};#define TCPCONN_STATE 1#define TCPCONN_LOCADDR 2#define TCPCONN_LOCPORT 3#define TCPCONN_REMADDR 4#define TCPCONN_REMPORT 5=static oid oid_tcpconntable[] = {1, 3, 6, 1, 2, 1, 6, 13, 1};#define ENTRY 9char *tcpstates[] = {/ "", "CLOSED", "LISTEN", "SYNSENT",; "SYNRECEIVED", "ESTABLISHED", "FINWAIT1", "FINWAIT2",8 "CLOSEWAIT", "LASTACK", "CLOSING", "TIMEWAIT"};#define TCP_NSTATES 11/*8 * Print a summary of connections related to an InternetJ * protocol (currently only TCP). For TCP, also give state of connection. */ protopr(){5 struct tcpconn_entry *tcpconn = NULL, *tp, *newp;( struct snmp_pdu *request, *response; struct variable_list *vp; oid *instance; int first, status;/ request = snmp_pdu_create(GETNEXT_REQ_MSG);W snmp_add_null_var(request, oid_tcpconntable, sizeof(oid_tcpconntable)/sizeof(oid)); while(1){; status = snmp_synch_response(Session, request, &response);F if (status != STAT_SUCCESS || response->errstat != SNMP_ERR_NOERROR){. fprintf(stderr, "SNMP request failed\n"); break; } vp = response->variables; if (vp->name_length != 20 ||Q bcmp((char *)vp->name, (char *)oid_tcpconntable, sizeof(oid_tcpconntable))){ break; }, request = snmp_pd: CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wu_create(GETNEXT_REQ_MSG);7 snmp_add_null_var(request, vp->name, vp->name_length); instance = vp->name + 10;. for(tp = tcpconn; tp != NULL; tp = tp->next){6 if (!bcmp((char *)instance, (char *)tp->instance, sizeof(tp->instance))) break; } if (tp == NULL){I newp = (struct tcpconn_entry *)malloc(sizeof(struct tcpconn_entry)); if (tcpconn == NULL){ tcpconn = newp; } else {4 for(tp = tcpconn; tp->next != NULL; tp = tp->next) ; tp->next = newp; } tp = newp;$ bzero((char *)tp, sizeof(*tp)); tp->next = NULL;I bcopy((char *)instance, (char *)tp->instance, sizeof(tp->instance)); }' if (vp->name[ENTRY] == TCPCONN_STATE){" tp->state = *vp->val.integer; tp->stateSet = 1; }) if (vp->name[ENTRY] == TCPCONN_LOCADDR){N bcopy((char *)vp->val.string, (char *)&tp->localAddress, sizeof(u_long)); tp->locAddrSet = 1; }) if (vp->name[ENTRY] == TCPCONN_LOCPORT){& tp->localPort = *vp->val.integer; tp->locPortSet = 1; }) if (vp->name[ENTRY] == TCPCONN_REMADDR){O bcopy((char *)vp->val.string, (char *)&tp->remoteAddress, sizeof(u_long)); tp->remAddrSet = 1; }) if (vp->name[ENTRY] == TCPCONN_REMPORT){' tp->remotePort = *vp->val.integer; tp->remPortSet = 1; } }< for(first = 1, tp = tcpconn; tp != NULL; tp = tp->next){% if (!(tp->stateSet && tp->locAddrSet= && tp->locPortSet && tp->remAddrSet && tp->remPortSet)){ printf("incomp; CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wwlete entry\n"); continue; }4 if (!aflag && tp->state == MIB_TCPCONNSTATE_LISTEN) continue; if (first){+ printf("Active Internet Connections"); if (aflag)! printf(" (including servers)"); putchar('\n');; printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n"," "Proto", "Recv-Q", "Send-Q",5 "Local Address", "Foreign Address", "(state)"); first = 0; }( printf("%-5.5s %6d %6d ", "tcp", 0, 0);4 inetprint(&tp->localAddress, tp->localPort, "tcp");6 inetprint(&tp->remoteAddress, tp->remotePort, "tcp");. if (tp->state < 1 || tp->state > TCP_NSTATES) printf(" %d", tp->state); else) printf(" %s", tcpstates[tp->state]); putchar('\n'); }}/*! * Dump UDP statistics structure. */ udp_stats(){) oid varname[MAX_NAME_LEN], *udpentry; int varname_len; struct variable_list *var; int count;( struct stat_table *sp = udp_stattab;G bcopy((char *)oid_udpstats, (char *)varname, sizeof(oid_udpstats));5 varname_len = sizeof(oid_udpstats) / sizeof(oid); udpentry = varname + 7; printf("udp:\n");= count = sizeof(udp_stattab) / sizeof (struct stat_table); while (count--){ *udpentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len); if (var){ putchar('\t');P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n'); } sp++; }}/*! * Dump TCP statistics structure. */ tcp_stats()< CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5W{{) oid varname[MAX_NAME_LEN], *tcpentry; int varname_len; struct variable_list *var; int count;( struct stat_table *sp = tcp_stattab;G bcopy((char *)oid_tcpstats, (char *)varname, sizeof(oid_tcpstats));5 varname_len = sizeof(oid_tcpstats) / sizeof(oid); tcpentry = varname + 7; printf("tcp:\n");= count = sizeof(tcp_stattab) / sizeof (struct stat_table); while (count--){ *tcpentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len); if (var){ putchar('\t');*P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n');r } sp++; }t},/* * Dump IP statistics structure. */n ip_stats(){t( oid varname[MAX_NAME_LEN], *ipentry; int varname_len; struct variable_list *var; int count;' struct stat_table *sp = ip_stattab;iE bcopy((char *)oid_ipstats, (char *)varname, sizeof(oid_ipstats));h4 varname_len = sizeof(oid_ipstats) / sizeof(oid); ipentry = varname + 7; printf("ip:\n");< count = sizeof(ip_stattab) / sizeof (struct stat_table); while (count--){ *ipentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len);N if (var){ putchar('\t'); P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n');  } sp++; }R}I/* * Dump ICMP statistics. */T icmp_stats(){T* oid varname[MAX_NAME_LEN], *icmpentry; int varname_len; struct varia= CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5WKble_list *var; int count, first;* struct stat_table *sp;I bcopy((char *)oid_icmpstats, (char *)varname, sizeof(oid_icmpstats));i6 varname_len = sizeof(oid_icmpstats) / sizeof(oid); icmpentry = varname + 7; printf("icmp:\n"); sp = icmp_stattab;> count = sizeof(icmp_stattab) / sizeof (struct stat_table); while (count--){ *icmpentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len);p if (var){ putchar('\t');P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n');t } sp++; }  sp = icmp_outhistogram;t first = 1;C count = sizeof(icmp_outhistogram) / sizeof (struct stat_table);i while (count--){ *icmpentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len);p$ if (var && *var->val.integer != 0){ if (first){" printf("\tOutput Histogram:\n"); first = 0; } printf("\t\t");P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n');  } sp++; }a sp = icmp_inhistogram; first = 1;B count = sizeof(icmp_inhistogram) / sizeof (struct stat_table); while (count--){ *icmpentry = sp->entry;3 var = getvarbyname(Session, varname, varname_len);f$ if (var && *var->val.integer != 0){ if (first){! printf("\tInput Histogram:\n"); first = 0; } printf("\t\t");P printf(sp->description, *var->val.integer, plural((int)*var->val.integer)); putchar('\n')> CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5W;5 } sp++; }t}n/*9 * Pretty print an Internet address (net address + port).d< * If the nflag was specified, use numbers instead of names. */ inetprint(in, port, proto) register struct in_addr *in;} u_short port; char *proto;m{q struct servent *sp = 0; char line[80], *cp, *index(); int width;d+ sprintf(line, "%.*s.", 16, inetname(*in));n cp = index(line, '\0'); if (!nflag && port)' sp = getservbyport((int)port, proto);% if (sp || port == 0)g- sprintf(cp, "%.8s", sp ? sp->s_name : "*");n elsee sprintf(cp, "%d", port); width = 22;' printf(" %-*.*s", width, width, line);,} /*0 * Construct an Internet address representation.' * If the nflag has been supplied, give,2 * numeric value, otherwise try for symbolic name. */ char * inetname(in) struct in_addr in;4{% register char *cp;u static char line[50]; struct hostent *hp; struct netent *np;,( static char domain[MAXHOSTNAMELEN + 1]; static int first = 1; if (first && !nflag) { first = 0;1 if (gethostname(domain, MAXHOSTNAMELEN) == 0 && (cp = index(domain, '.')))! (void) strcpy(domain, cp + 1);c else domain[0] = 0;g } cp = 0;) if (!nflag && in.s_addr != INADDR_ANY) {1 u_long net = inet_netof(in); u_long lna = inet_lnaof(in); if (lna == INADDR_ANY) {# np = getnetbyaddr(net, AF_INET);] if (np) cp = np->n_name; }v if (cp == 0) {9 hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET);s if (hp) {( if ((cp = index(hp->h_? CMUSNMP.SAVUQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.C;5Wrname, '.')) && !strcmp(cp + 1, domain)) *cp = 0;] cp = hp->h_name; } }h } if (in.s_addr == INADDR_ANY)d strcpy(line, "*"); else if (cp)  strcpy(line, cp);c else {  in.s_addr = ntohl(in.s_addr);#define C(x) ((x) & 0xff),2 sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24),8 C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); } return (line); }}8*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.OBJ;1+,a.2/ 42.-Q0D123KPWO356fAXē7DHYē8 5<9FRQٓGHJ1INETV1.0 6-SEP-1990 11:53GNU CC V1.22 $CODEs$UNINITIALIZED_DATA COMMUNITYADDRESSREQIDSDSID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATEAFLAGNFLAGSESSION_040000X@ IP_STATTABP UDP_STATTAB TCP_STATTABP ICMP_STATTABICMP_INHISTOGRAMICMP_OUTHISTOGRAM0 TCPSTATES >|PROTOPRSNMP_PDU_CREATESNMP_ADD@ CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.OBJ;12 _NULL_VARSNMP_SYNCH_RESPONSESTDERRFPRINTFBCMPMALLOCBZEROBCOPYPRINTFSTDOUTFPUTC  INETPRINT  UDP_STATS GETVARBYNAMEPLURAL | TCP_STATS IP_STATS  ICMP_STATS H INETNAMESPRINTFINDEX GETSERVBYPORT GETHOSTNAMESTRCPYs INET_NETOF INET_LNAOF GETNETBYADDR GETHOSTBYADDRSTRCMPNTOHLSTDIN^$DATAPCLOSEDLISTENSYNSENTSYNRECEIVEDESTABLISHEDFINWAIT1FINWAIT2CLOSEWAITLASTACKCLOSINGTIMEWAITdPSNMP request failed incomplete entry Active Internet Connections (including servers)(state)Foreign AddressLocal AddressSend-QRecv-QProto%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s tcp%-5.5s %6d %6d %d %s>P|^V~PPPU UdPUoPvPP zPЭPՠPPPP1*PЭPРDRѢ1PݢPP1P~PPUݢݢUPTVSPSTPPPУ8SPSEP< PVPPVPVSգ8 PУ8Sգ8&PP8PS