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&PP8PSprotopr tcpconnC $TtpC $TnewpC $T requestC "Tresponse "TvpC !T! instanceC firstC/statusC\ >  inetprint in  T proto portM CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.OBJ;12)9sp9 T ٰline*&PPOcp9 width9P  udp_stats-ـvarname*&@@?! udpentrys $ varname_lensvars !Tcountssps Td"| tcp_stats-ـvarname*&@@?! tcpentry $ varname_lenvar !Tcountsp Tcip_stats,ـvarname*&@@? ipentry$ $ varname_len$var$ !Tcount$sp$ Te icmp_statsUـvarname*&N CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]INET.OBJ;12,@@?" icmpentry $ varname_lenvar !Tcountfirstsp TrHinetname in  TcpJ  hpJ  TnpJ  T $0net lna lc LLs`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsRSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetrO CMUSNMP.SAVWQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5RY6*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5+,W./ 4R|<-Q0@123KPWO56[]7 |o8j;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 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 OFP CMUSNMP.SAVWQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5Ro 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. */ #ifndef lintchar copyright[] =D"@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n";#endif not lint#include #include #include #include #include #include #include #include #include #include "asn1.h"#include "snmp.h"#include "snmp_api.h"/* internet protocols */extern int protopr();>extern int tcp_stats(), udp_stats(), ip_stats(), icmp_stats();(#define NULLPROTOX ((struct protox *) 0)struct protox {2 u_char pr_wanted; /* 1 if wanted, 0 otherwise */; int (*pr_cblocks)(); /* control blocks printing routine */6 int (*pr_stats)(); /* statistics printing routine */& char *pr_name; /* well-known name */} protox[] = {% { 1, protopr, tcp_stats, "tcp" }, { 1, 0, udp_stats, "udp" }, { 1, 0, Q CMUSNMP.SAVWQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5R8 ip_stats, "ip" }," { 1, 0, icmp_stats, "icmp" }, { 0, 0, 0, 0 }}; int aflag; int iflag; int nflag; int pflag; int rflag; int sflag; int interval;char *interface; int unit;Rchar usage[] = "host community [ -ainrs ] [-p proto] [-I interface] [ interval ]";int debug = 0;extern char *malloc();struct snmp_session *Session;int snmp_dump_packet = 0;int print_errors = 0;main(argc, argv) int argc; char *argv[];{ char *cp, *name; char *host; register struct protoent *p;? register struct protox *tp; /* for printing cblocks & stats */+ struct protox *name2protox(); /* for -p */ char *community; struct snmp_session session; name = argv[0]; argc--, argv++; if (argc) { host = *argv++; argc--; } if (argc) {! community = *argv++; argc--; } else goto use;$ while (argc > 0 && **argv == '-') {# for (cp = &argv[0][1]; *cp; cp++) switch(*cp) { case 'a': aflag++; break; case 'i': iflag++; break; case 'n': nflag++; break; case 'r': rflag++; break; case 's': sflag++; break; case 'p': argv++; argc--; if (argc == 0) goto use;1 if ((tp = name2protox(*argv)) == NULLPROTOX) {? fprintf(stderr, "%s: unknown or uninstrumented protocol\n", *argv); exit(10); } pflag++; break; case 'I': iflag++;$ if (*(interface = cp + 1) == 0) {# if ((interface = argv[1]) == 0) breR CMUSNMP.SAVWQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5R ak; argv++; argc--; }+ for (cp = interface; isalpha(*cp); cp++) ; unit = atoi(cp); break; default:use:) printf("usage: %s %s\n", name, usage); exit(1); } argv++, argc--; }' if (argc > 0 && isdigit(argv[0][0])) { interval = atoi(argv[0]); if (interval <= 0) goto use; argv++, argc--; iflag++; }6 bzero((char *)&session, sizeof(struct snmp_session)); session.peername = host;) session.community = (u_char *)community;3 session.community_len = strlen((char *)community);( session.retries = SNMP_DEFAULT_RETRIES; session.timeout = 10000000L; session.authenticator = NULL; snmp_synch_setup(&session); Session = snmp_open(&session); if (Session == NULL){$ printf("Couldn't open snmp\n"); exit(-1); } if (pflag) { if (tp->pr_stats) (*tp->pr_stats)(); else1 printf("%s: no stats routine\n", tp->pr_name); exit(1); } /*0 * Keep file descriptors open to avoid overhead0 * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); if (iflag) { intpr(interval); exit(1); } if (rflag) { if (sflag) rt_stats(); else routepr(); exit(1); } setprotoent(1); setservent(1); while (p = getprotoent()) {& for (tp = protox; tp->pr_name; tp++)+ if (strcmp(tp->pr_name, p->p_name) == 0) break;- if (tp->pr_name == 0 || tp->pr_wanted == 0) continue; if (sflag) { if (tp->pr_stats) (*tp->pr_stats)(); } elS CMUSNMP.SAVWQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5R se if (tp->pr_cblocks) (*tp->pr_cblocks)(); } endprotoent(); exit(1);}char * plural(n) int n;{ return (n != 1 ? "s" : "");}/*3 * Find the protox for the given "well-known" name. */struct protox *knownname(name) char *name;{ struct protox *tp;% for (tp = protox; tp->pr_name; tp++)% if (strcmp(tp->pr_name, name) == 0) return(tp); return(NULLPROTOX);}/*) * Find the protox corresponding to name. */struct protox *name2protox(name) char *name;{ struct protox *tp;, char **alias; /* alias from p->aliases */ struct protoent *p; /*C * Try to find the name in the list of "well-known" names. If that> * fails, check if name is an alias for an Internet protocol. */ if (tp = knownname(name)) return(tp);5 setprotoent(1); /* make protocol lookup cheaper */ while (p = getprotoent()) {( /* assert: name not same as p->name */- for (alias = p->p_aliases; *alias; alias++)# if (strcmp(name, *alias) == 0) { endprotoent();! return(knownname(p->p_name)); } } endprotoent(); return(NULLPROTOX);}T CMUSNMP.SAVXQ6[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.H;3"2G6*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.H;3+,X./ 4"-Q0@123KPWO56b7`ҋo8ƃ_ 9FRQٓGHJ#ifndef MAXHOSTNAMELEN#define MAXHOSTNAMELEN 64#endifextern char *community;"extern struct sockaddr_in address;extern int reqid;extern int sd;8*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1+,a./ 4X-Q0D123KPWO56f%cē7&3cē8 f<9FRQٓGHJ1MAINV1.0 6-SEP-1990 11:53GNU CC V1.22@$CODEX COPYRIGHT_CTYPE_ C$V_CTYPEDEFS SNMP_ERRNOSNMP_DUMP_PACKETAPROTOXPROTOPR TCP_STATS UDP_STATSIP_STATS ICMP_STATSAUSAGEDEBUG PRINT_ERRORS zMAIN C$MAIN_ARGSAFLAGIFLAGNFLAGRFLAGSFLAG  NAME2PROTOXSTDERRFPRINTFEXITPFLAG INTERFACEU CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1ATOIUNITPRINTFINTERVALBZEROSTRLENSNMP_SYNCH_SETUP SNMP_OPENSESSION_040000X SETHOSTENT SETNETENTINTPRRT_STATSROUTEPR SETPROTOENT SETSERVENTSTRCMP GETPROTOENT ENDPROTOENT PLURAL  KNOWNNAMESTDOUTSTDIN SOCKET_ERRNO3VMSERRNO VAXC$ERRNOERRNOPP PtcpudpipicmpP%s: unknown or uninstrumented protocol usage: %s %s Couldn't open snmp %s: no stats routine zPP$^ЬRЂVUPЂXUU1:PЂW1\P-1ZPbS1BPcPPI*1PP1"P(P1+P1P14P:P1=PCP1FPRU1PPbϋWPPT\PbϸbPhPoP xP~PuPPPPP`PТPPPSPRUPSPQPScPPPA`PSPPPPV]PPPSc1PRU1PU, PbQaPPP PQ)PP0P2P8P$RRGPXWWXPPЏԭRtPR}PPPV CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1 PPP~PP"PդPPݤ ϯPPPPPPPPPPP!PP P PPPP'P0PI2PTդ >Pbݤ JPPNP Tդ VPդ  [Pd_PeP gPդlP rPդwPPPRPPPsPѬPPPPPPP ЬSRբ PSݢ PPPRP Rբ PPPЬTTPPPP,PУRb$PbTPPPPc"PRb*P1PPS6P=PPPPPPPPPPPPPPPPPPPPPPPPPPPYPPPPPPPPbPPPP Pk PPPPtP}8P ENDPROTOENT,P GETPROTOENTP ENDPROTOENT PSTRCMPP SETPROTOENTPW CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1*STRCMPPEXITP ENDPROTOENT}P GETPROTOENT`P EPSTRCMP+P SETSERVENT"P SETPROTOENTPEXITPROUTEPRPRT_STATSP P PEXITPINTPRPP P SETNETENTP SETHOSTENTPEXITPPRINTFPPEXITPPRINTFPxP SNMP_OPENoPSNMP_SYNCH_SETUPSPSTRLENBPBZERO3P +P$PATOIPEXITPPRINTFPPATOIPPPPP yPsPEXITjPFPRINTFcP>P 5P ,P #P P }P C$MAIN_ARGSP C$V_CTYPEDEFSP3PPPPPPhost community [ -ainrs ] [-p proto] [-I interface] [ interval ]PPP@(#) Copyright (c) 1983 Regents of the University of California. All rights reserved. 0P,P ICMP_STATS#PPIP_STATSPP? UDP_STATS P P TCP_STATSPPROTOPR MAINRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimervalX CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1 it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocol R Ssockaddr sa_familysa_data*&  R Slinger@l_onoff l_linger R S_iobufp _cnt _ptr  @_base  `_flag h_file R Sprotoent` p_name  p_aliases @p_protoRSservent s_name  s_aliases  @s_port`s_proto RSnetent n_name  n_aliases @ n_addrtype `n_net n_addresses  TRShostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protos  h_addresses  TRS sockaddr_in sin_familysin_portY CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1 sin_addr R@sin_zero*&RSTSin_addr s_addrRSprotoxh pr_wanted pr_cblocks (pr_stats Hpr_name RSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_lenRSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magicRSTS  copyright*&XXW protox3/T A usage*&AA@ debugsnmp_dump_packet print_errorsSession T unit interface intervZ CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1"cal  sflag  rflag pflag  nflag  iflag  aflag&$$PsectAttributes_NOSHR$$stderr  T&$$PsectAttributes_NOSHR$$stdout  T%$$PsectAttributes_NOSHR$$stdin  T,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno*#$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errno\X[]|DDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.C;5  __ctype__dummyz zmainargcargv cp name host p  Ttp T" community csession T  ]z " name2protoxname? tp? Talias? p?  Tw r5[ CMUSNMP.SAVaQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAIN.OBJ;1 N^ plural nR, knownnameename tp T   #2zPPݤ ϯPPPPPPPPPPP!PP P PPPP'P0PI2PTդ >Pbݤ JPPNP Tդ VPդ  [Pd_P8*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAKE.COM;6+,Z. / 4H <-Q0@123KPWO 56U7o8 . 9FRQٓGHJ\ CMUSNMP.SAVZQ8[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]MAKE.COM;6H r$!!$! Compile and link SNMP programs$!-$ If P1 .Eqs. "VMSINSTAL" Then Goto VMSinstal$ SAVE_VERIFY='F$VERIFY(0)$ Set Symbol/Scope=NoGlobalH$ GCC := GCC/DEBUG/DEFINE=("""vax11c""","""unix""")/INCLUDE=[--.SNMPLIB]>$ If "''LINKFLAGS'" .Eqs. "" Then LINKFLAGS = "/NOTRACE/NOMAP"$-$ CALL MAKE IF.OBJ "GCC IF" IF.C MAIN.H3$ CALL MAKE INET.OBJ "GCC INET" INET.C MAIN.H,$ CALL MAKE MAIN.OBJ "GCC MAIN" MAIN.C5$ CALL MAKE ROUTE.OBJ "GCC ROUTE" ROUTE.C MAIN.HB$ CALL MAKE SNMPNETSTAT.EXE "LINK''LINKFLAGS' SNMPNETSTAT/OPT" -% "IF.OBJ INET.OBJ MAIN.OBJ ROUTE.OBJ"$ 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.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7SÏ7*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7+,[./ 4S4<-Q0@123KPWO56ԣP7o8Jp9FRQٓ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 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^ CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7Sge 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 #define LOOPBACKNET 127#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 nflag;0extern char *routename(), *netname(), *plural();extern char *malloc();$extern struct snmp_session *Session;,extern struct variable_list *getvarbyname();extern int print_errors;struct route_entry { oid instance[4]; struct in_addr destination; int set_destination; struct in_addr gateway; int set_gateway; int interface; int set_interface; int type; int set_type; int proto; int set_proto; char ifname[64]; int set_name;};_ CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7S#define RTDEST 1#define RTIFINDEX 2#define RTNEXTHOP 7#define RTTYPE 8#define RTPROTO 98static oid oid_rttable[] = {1, 3, 6, 1, 2, 1, 4, 21, 1};:static oid oid_rtdest[] = {1, 3, 6, 1, 2, 1, 4, 21, 1, 1};=static oid oid_rtifindex[] = {1, 3, 6, 1, 2, 1, 4, 21, 1, 2};=static oid oid_rtnexthop[] = {1, 3, 6, 1, 2, 1, 4, 21, 1, 7};:static oid oid_rttype[] = {1, 3, 6, 1, 2, 1, 4, 21, 1, 8};;static oid oid_rtproto[] = {1, 3, 6, 1, 2, 1, 4, 21, 1, 9};:static oid oid_ifdescr[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 2};;static oid oid_ipnoroutes[] = {1, 3, 6, 1, 2, 1, 4, 12, 0};/* * Print routing tables. */ routepr(){( struct route_entry route, *rp = &route;% struct snmp_pdu *request, *response; struct variable_list *vp; char name[16], *flags; oid *instance, type; int toloopback, status; char ch; printf("Routing tables\n");) printf("%-16.16s %-18.18s %-6.6s %s\n", "Destination", "Gateway", "Flags", "Interface");, request = snmp_pdu_create(GETNEXT_REQ_MSG);H snmp_add_null_var(request, oid_rtdest, sizeof(oid_rtdest)/sizeof(oid));N snmp_add_null_var(request, oid_rtifindex, sizeof(oid_rtifindex)/sizeof(oid));N snmp_add_null_var(request, oid_rtnexthop, sizeof(oid_rtnexthop)/sizeof(oid));H snmp_add_null_var(request, oid_rttype, sizeof(oid_rttype)/sizeof(oid));J snmp_add_null_var(request, oid_rtproto, sizeof(oid_rtproto)/sizeof(oid)); while(request){? status = snmp_synch_response(Session, request, &response);J if (status ` CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7S != STAT_SUCCESS || response->errstat != SNMP_ERR_NOERROR){+ fprintf(stderr, "SNMP request failed\n"); break; } instance = NULL; request = NULL; rp->set_destination = 0; rp->set_interface = 0; rp->set_gateway = 0; rp->set_type = 0; rp->set_proto = 0;? for(vp = response->variables; vp; vp = vp->next_variable){ if (vp->name_length != 14 ||H bcmp((char *)vp->name, (char *)oid_rttable, sizeof(oid_rttable))){@ continue; /* if it isn't in this subtree, just continue */ } if (instance != NULL){ oid *ip, *op; int count; ip = instance; op = vp->name + 10;) for(count = 0; count < 4; count++){ if (*ip++ != *op++) break; } if (count < 4)1 continue; /* not the right instance, ignore */ } else { instance = vp->name + 10; } /*E * At this point, this variable is known to be in the routing table@ * subtree, and is of the right instance for this transaction. */ if (request == NULL)1 request = snmp_pdu_create(GETNEXT_REQ_MSG);8 snmp_add_null_var(request, vp->name, vp->name_length); type = vp->name[9]; switch ((char)type){ case RTDEST:K bcopy((char *)vp->val.string, (char *)&rp->destination, sizeof(u_long)); rp->set_destination = 1; break; case RTIFINDEX:$ rp->interface = *vp->val.integer; rp->set_interface = 1; break; case RTNEXTHOP:G bcopy((char *)vp->val.string, (chara CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7S *)&rp->gateway, sizeof(u_long)); rp->set_gateway = 1; break; case RTTYPE: rp->type = *vp->val.integer; rp->set_type = 1; break; case RTPROTO: rp->proto = *vp->val.integer; rp->set_proto = 1; break; } }1 if (!(rp->set_destination && rp->set_gateway) && rp->set_type && rp->set_interface)){ snmp_free_pdu(request); request = 0; continue; }7 toloopback = *(char *)&rp->gateway == LOOPBACKNET; printf("%-16.16s ",- (rp->destination.s_addr == 0) ? "default" : (toloopback) ?= routename(rp->destination) : netname(rp->destination, 0L));1 printf("%-18.18s ", routename(rp->gateway)); flags = name;* *flags++ = 'U'; /* route is in use */1 /* this !toloopback shouldnt be necessary */; if (!toloopback && rp->type == MIB_IPROUTETYPE_REMOTE) *flags++ = 'G'; if (toloopback) *flags++ = 'H';, if (rp->proto == MIB_IPROUTEPROTO_ICMP) *flags++ = 'D'; /* redirect */ *flags = '\0'; printf("%-6.6s ", name);+ get_ifname(rp->ifname, rp->interface);- ch = rp->ifname[strlen(rp->ifname) - 1];+ ch = '5'; /* force the if statement */ if (isdigit(ch))! printf(" %.32s\n", rp->ifname); else2 printf(" %.32s%d\n", rp->ifname, rp->interface); }}struct iflist { int index; char name[64]; struct iflist *next;} *Iflist = NULL;get_ifname(name, index) char *name; int index;{$ struct sb CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7Snmp_pdu *pdu, *response; struct variable_list *vp; struct iflist *ip; oid varname[32]; int status;( for(ip = Iflist; ip; ip = ip->next){ if (ip->index == index) break; } if (ip){ strcpy(name, ip->name); return; }8 ip = (struct iflist *)malloc(sizeof(struct iflist)); ip->next = Iflist; Iflist = ip; ip->index = index;' pdu = snmp_pdu_create(GET_REQ_MSG);E bcopy((char *)oid_ifdescr, (char *)varname, sizeof(oid_ifdescr)); varname[10] = (oid)index;I snmp_add_null_var(pdu, varname, sizeof(oid_ifdescr)/sizeof(oid) + 1);: status = snmp_synch_response(Session, pdu, &response);I if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR){ vp = response->variables;6 bcopy((char *)vp->val.string, ip->name, vp->val_len); ip->name[vp->val_len] = '\0'; } else {" sprintf(ip->name, "if%d", index); } strcpy(name, ip->name);}char * routename(in) struct in_addr in;{ register char *cp;& static char line[MAXHOSTNAMELEN + 1]; struct hostent *hp;( static char domain[MAXHOSTNAMELEN + 1]; static int first = 1; char *index(); if (first) { first = 0;1 if (gethostname(domain, MAXHOSTNAMELEN) == 0 && (cp = index(domain, '.')))! (void) strcpy(domain, cp + 1); else domain[0] = 0; } cp = 0; if (!nflag) {; hp = _gethostbyaddr((char *)&in, sizeof (struct in_addr), AF_INET); if (hp) {' if ((cp = index(hp->h_name, '.')) &&! !stc CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7S8|rcmp(cp + 1, domain)) { static char Temp[256]; strcpy(Temp,hp->h_name); cp = index(Temp,'.'); *cp = 0; cp = Temp; } else cp = hp->h_name; } } if (cp)& strncpy(line, cp, sizeof(line) - 1); else {#define C(x) ((x) & 0xff) in.s_addr = ntohl(in.s_addr);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);}/*9 * Return the name of the network whose address is given.D * The address is assumed to be that of a net or subnet, not a host. */char *netname(in, mask) struct in_addr in; u_long mask;{ char *cp = 0;& static char line[MAXHOSTNAMELEN + 1];) struct netent *np = 0, *_getnetbyaddr(); u_long net; register i; int subnetshift; i = ntohl(in.s_addr); if (!nflag && i) { if (mask == 0) { if (IN_CLASSA(i)) { mask = IN_CLASSA_NET; subnetshift = 8; } else if (IN_CLASSB(i)) { mask = IN_CLASSB_NET; subnetshift = 8; } else { mask = IN_CLASSC_NET; subnetshift = 4; } /*3 * If there are more bits than the standard mask, * would suggest, subnets must be in use.3 * Guess at the subnet mask, assuming reasonable * width subnet fields. */ while (i &~ mask)% mask = (long)mask >> subnetshift; } net = i & mask; while ((mask & 1) == 0) mask >>= 1, net >>= 1;# np = _getnetbyaddr(net, AF_INET); if (np) cp = np->n_name; }d CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7Sp if (cp)& strncpy(line, cp, sizeof(line) - 1); else if ((i & 0xffffff) == 0)" sprintf(line, "%u", C(i >> 24)); else if ((i & 0xffff) == 0)2 sprintf(line, "%u.%u", C(i >> 24) , C(i >> 16)); else if ((i & 0xff) == 0)? sprintf(line, "%u.%u.%u", C(i >> 24), C(i >> 16), C(i >> 8));t else * sprintf(line, "%u.%u.%u.%u", C(i >> 24), C(i >> 16), C(i >> 8), C(i)); return (line);s}n/* * Print routing statisticsm */i rt_stats(){e struct variable_list *var;  printf("routing:\n");S var = getvarbyname(Session, oid_ipnoroutes, sizeof(oid_ipnoroutes) / sizeof(oid));. if (var){5 printf("\t%u destination%s found unreachable\n",U5 *var->val.integer, plural((int)*var->val.integer));N } else {E7 printf("\tCouldn't get ipOutNoRoutes variable\n");N }}I/*= * Request a variable with a GET REQUEST message on the givenT? * session. The session must have been opened as a synchronousT@ * session (synch_setup_session()). If the variable is found, a= * pointer to a struct variable_list object will be returned.*B * Otherwise, NULL is returned. The caller must free the returned* * variable_list object when done with it. */struct variable_list *getvarbyname(sp, name, len)s struct snmp_session *sp; oid *name; int len;{i( struct snmp_pdu *request, *response;* struct variable_list *var = NULL, *vp; int status; + request = snmp_pdu_create(GET_REQ_MSG);n* snmp_add_null_var(request, name, len);9 status = snmp_synch_respe CMUSNMP.SAV[Q7[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7Ssonse(sp, request, &response);o if (status == STAT_SUCCESS){, if (response->errstat == SNMP_ERR_NOERROR){C for(var = response->variables; var; var = var->next_variable){eK if (var->name_length == len && !bcmp(name, var->name, len * sizeof(oid))) " break; /* found our match */ } if (var != NULL){ /*@ * Now unlink this var from pdu chain so it doesn't get freed." * The caller will free the var. */"" if (response->variables == var){/ response->variables = var->next_variable;n } else {@ for(vp = response->variables; vp; vp = vp->next_variable){! if (vp->next_variable == var){p. vp->next_variable = var->next_variable; break;; } }_ }  } } }n if (response)o snmp_free_pdu(response);e return var; }_9*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1+,a.#/ 4#!z-Q0D123KPWO$56Epē7Gpē8 <9FRQٓGHJf CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#^2ROUTEV1.0 6-SEP-1990 11:54GNU CC V1.22h$CODE$UNINITIALIZED_DATA_CTYPE_ C$V_CTYPEDEFS COMMUNITYADDRESSREQIDSDSID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATENFLAGSESSION_040000X PRINT_ERRORS ROUTEPRPRINTFSNMP_PDU_CREATESNMP_ADD_NULL_VARSNMP_SYNCH_RESPONSESTDERRvFPRINTFBCMPBCOPY SNMP_FREE_PDU B ROUTENAME NETNAME ` GET_IFNAMESTRLENIFLIST_020000XMALLOCSPRINTFSTRCPY GETHOSTNAMEINDEX_GETHOSTBYADDRSTRCMPSTRNCPYNTOHL _GETNETBYADDR p RT_STATS < GETVARBYNAMEPLURALSTDOUTSTDIN$DATAPP P PRouting tables InterfaceFlagsGatewayDestination%-16.16s %-18.18s %-6.6s %s SNMP request failed default%-16.16s %-18.18s %-6.6s %.32s %.32s%d Px^TSPPRbUP[P]PaPiPb~PPU UPRb Ub Ub Ub UbU1$5P0WxUEPLPP PPxPՠZP^PdPkP1nPVUԤ ԤԤԤ$Ԥ,xPРDS1Pѣ1PݣPP1PVPVRPQPQg CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#PQ1PPVUP~PPUݣݣUPУPPPIPݣ 'P 4-Pг )8Pݣ GPMPг $ XPг (,cS1&iPդ nPդ sPդ$xPդ}PUPU1PPPPPSդPPPPS PݤϐP P~ݤPPϵPPRbݤlPPϧPb|PUS PѤ PGSPHѤ(PD`|{PPRbݤW;%PW.P4P 7PWX=PbBPݤWRKPRPU1YPZPif%d`P^ЬWЬUT wPdU|PФDTPT1PH~PPTDTUd~PPRSSPVfU SRPRPPP#PЭPՠPРDRݢݢ fТPDPU;P)PW5P6P%u.%u.%u.%uBPGLP@~cPP&gP.vPPR{PPPRPePPPSRP.cPTdPR<PPP(PcP.dPRbRPcRRP횏@~Rh CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#GPOPݬ%PPˏ~PPˏP~ЬQQPˏP~ЬQQ~]PjPP%u%u.%u%u.%u.%uPЬRTݬPPSPtPSpPRDPS PЏRQ.Pˏ?SPP PЏRQP2RQPQPxPRRRSPPRPPSP PRRPPRPPPPP`TTP횏@~T,P1/PS!8PxSPˏP~)IPVP1YPS.bPxSPˏP~xSPˏP~PP1PS:PxSPˏP~xSPˏP~xSPˏP~ϷPP@PˏS~xSPˏP~xSPˏP~xSPˏP~0PPProuting: %u destination%s found unreachable Couldn't get ipOutNoRoutes variable pP uP{PSc P)PPRPݲ PPݲ |Pc PPPP<^ЬUЬ TS~PPRTURPRݬPP]PЭPՠTPРDS!PxTRѣTPRݣUPP"PcS'PS)+PЭPѠDS5PcD;PЭPРDPEP`SJPc`OP`PTPխ YPݭcPSPPP)P] P] P]P]P4PIPT^P SNMP_FREE_PDUPBCMPi CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#4 PSNMP_SYNCH_RESPONSEPSNMP_ADD_NULL_VARPSNMP_PDU_CREATEPPRINTFPPLURALP vPPRINTFPSPRINTFPSPRINTFPSPRINTFQPSPRINTF'PSTRNCPY P _GETNETBYADDRP PNTOHLePSPRINTF PNTOHLPSTRNCPYPSTRCPYPSTRCMPPINDEXP_GETHOSTBYADDRP PSTRCPYqPINDEX^P GETHOSTNAME0PSTRCPY$PSPRINTFPSNMP_SYNCH_RESPONSEP PSNMP_ADD_NULL_VARPBCOPYPSNMP_PDU_CREATEPMALLOCMPPRINTF/P5)PSTRLENPPRINTFPPRINTFP SNMP_FREE_PDUBPBCOPY"PBCOPYPSNMP_ADD_NULL_VARPSNMP_PDU_CREATEPBCMPfPFPRINTF_PGPSNMP_SYNCH_RESPONSE@P PSNMP_ADD_NULL_VARPSNMP_PDU_CREATEPPRINTFP C$V_CTYPEDEFSPPPPPJP PkP^P PPPPPAPAPAjPAWPAMPEPPvPPoPP$PbPN P:P&PPPP vPbP NPj CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#4 :P&PPP ROUTERS_iobufp _cnt _ptr  @_base  `_flag h_fileRSprotoent` p_name  p_aliases @p_protoRSservent s_name  s_aliases  @s_port`s_proto RSnetent n_name  n_aliases @ n_addrtype `n_net n_addresses RRShostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protos  h_addresses RRS sockaddr_in sin_familysin_port sin_addr  R@sin_zero*& R S T Sin_addr s_addr R Smsghdrmsg_name  msg_namelen@msg_iov  R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocolRSTSTSsockaddr sa_familysa_data*&k CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#  RSlinger@l_onoff l_lingerRS route_entryinstance*&@ destination  T`set_destinationgateway  T set_gateway interface set_interface type set_type @proto` set_proto ifname*&@@?set_nameRSmib_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@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampRel CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#ۡps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosPicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsRSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgeRSmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrRSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atIfIndex atPhysAddress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescrІ*&   ifType @ifMtu`ifSm CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#F8peed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknownProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLenRS mib_interface ifNumberRS mib_systemsysDescr*&  sysObjectID*&ObjIDLen sysUpTimeRS synch_stateSwaiting  status @reqid `pdu R R Sval integer  string  objid !R!S 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_portn CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1# local_port authenticator callback callback_magic $R$Siflist@ index name*&@@? next $T%R S%T%S  oid_rttable*&  oid_rtdest*& & oid_rtifindex*& : oid_rtnexthop*& N oid_rttype*& b oid_rtproto*& v oid_ifdescr*& oid_ipnoroutes*&  Iflist $T&$$PsectAttributes_NOSHR$$stderr T&$$PsectAttributes_NOSHR$$stdout T%$$PsectAttributes_NOSHR$$stdin T]YԣP4EDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.C;7  __ctype__dummyroutepr ٌroute TrpX T requestX "Txresponse "TvpX !T |name*&flagsX ! instao CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1#KnceX # toloopbackXstatusX $0ip op count| a  a6B routename in  TcpDq hpDq T $0&Bnetname in  Tmaskcp np Tneti$ subnetshiftyS` get_ifnamewnamen4 indexn4pdun4 "Tټresponse "Tvpn4 !Tipn4 $Tvarname*& p CMUSNMP.SAVaQ9[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]ROUTE.OBJ;1# statusn4r  |1prt_statss5varr !T3J getvarbynamenX sp #Tnamef lenf requestf "Tresponse "Tvarf !Tvpf !Tstatusf  " O @ egpOutMsgs` egpOutErrorsRSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPortRSmib_tcptcpRtoAlgorithm tcq CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12 9?*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;1+,vK .2/ 422-Q0D123 KPWO356H')ɓ7y')ɓ8O 9FRQٓGHJ0DX0205(f$)I^v- SNMPNETSTATV1.0if$)ɓ04-00 !/ 0 ?0!MULTINET_SOCKET_LIBRARY_001!  LIBRTL_001 ! VAXCRTL_001@!d FORRTL_001y! MTHRTL_001!f SMGSHR_001    r CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12|>>>>@(#) Copyright (c) 1983 Regents of the University of California. All rights reserved. ====>4>Destination unreachable: %dTime Exceeded: %dParameter Problem: %dSource Quench: %dRedirect: %dEcho Request: %d Echo Reply: %d Timestamp Request: %d Timestamp Reply: %d Address Mask Request: %d Addrss Mask Reply:%dDestination unreachable: %dTime Exceedes CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12Jd: %dParameter Problem: %dSource Quench: %dRedirect: %dEcho Request: %dEcho Reply: %dTimestamp Request: %dTimestamp Reply: %dAddress Mask Request: %dAddrss Mask Reply:%d%d total message%s received%d message%s dropped due to errors%d ouput message request%s%d output message%s discardedt CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12F %d total datagram%s received%d datagram%s with header errors%d datagram%s with an invalid destination address%d datagram%s forwarded%d datagram%s with unknown protocol%d datagram%s discarded %d datagram%s delivered %d output datagram request%s %d output datagram%s discarded %d datagram%s with no route%d fragment%s received%d datagram%s reassembled%d reassembly failure%s%d datagram%s fragmented%d fragmentation failure%s%d fragment%s created$'-@' -u CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12R (-T)-h#i#p#w#########%d active open%s%d passive open%s%d failed attempt%s%d reset%s of established connections %d current established connection%s %d segment%s received %d segment%s sent %d segment%s retransmitted%d total datagram%s received%d datagram%s to invalid port%d datagram%s dropped due to errors%d output datagram request%shost community [ -ainrs ] [-p proto] [-I interface] [ interval ]v CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;125OerrsOpktsIerrsIpktsAddressNetworkMtuName%-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 %5dP^ЬPP?ACEGKOOP B"B  B /PRв XRRA URSSR\\XXX1T`Y[`ZPWTVX\cUTrPRݢYݢ $AТPM`cUTAPRв [cUTi$PRв Z cUTLPRв V cUT/PR VcUTPRв TcUTPRв WcUTPR WcUTtPRв PoaYYX@Pa~Y!=Z*`[YϢ9@RbϣϤbϘϣb~PWTVϘb @ ?XX1?) input %-6.6s output input (Total) outputcollserrspackets%8.8s %5.5s %8.8s %5.5s %5.5s %8d %5d %8d %5d %5d L^VYDXXYP H`Pа [\> USRS[x(bSpU\Pݠݠ >PP>PRP~Rt;ϱP>$RR[SRYPϏu>ÏYP$PP$P ϔV>R9PԢԢԢԢԢ $RRP1> >qstklp>ÏYP$PP$P>@A89=== ===TԨԨԨԨԨ \RR== URTTRLLSRS[19\WRY1,$V<SL dUWe Pа  dUWHP dw CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12kUW+Pа dUWPа dUWP dUWPа RP)â ~â~â~â~â~h<ЦЦЦЦЦ  $R[S1ÏYP$PP$P.XZê ~ê~ê~ê~ê~v;($hX; ;;;Tݬ;T1*1CLOSEDLISTENSYNSENTSYNRECEIVEDESTABLISHEDFINWAIT1FINWAIT2CLOSEWAITLASTACKCLOSINGTIMEWAITSNMP 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|^V~PU UU]P ЭPՠ:91*ЭPРDRѢ1Xݢ9P1~pPUݢݢUTVSSTW9PУ8SSE<x9VPVVSգ8 У8Sգ8P8PS -&~#hS fSRRU1xRPPQQWP QPBP<`~`SURSPﷲ~~xPP~~ݬ  ^ЬTЬUЬVTRSV& RPRTRPPPeѭVPTRPPPebS xSQPPQS׭ѭSRPЬTЬV WЬRR>м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 RaPRaݬQPb<ЬTЬSdPPEPPPPRRS cc PcRPxPPP 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ԭlPRWZ~˟W~PV1<Z~~V*PU1 ݬݬ UPR1RiPR1RhPR1RMPR1 C~R0PT1Z~0RRTPSRݬ4ݬ0X~(ݬ$S|PRaSRPPP0TKPSDURPPP~V,PU%VRPPPόW?PVPWRP<ЬQRaRQPPPЬPЬRRQ{RPPR PRPPЬPЬRRQ{RPRPPPRRPЬPì QQPPjP CMUSNMP.SAVvK Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.EXE;12.0@@,@8Pphh8 `0p |LLDt8 , t \ !@MULTINET_SOCKET_LIBRARYLIBRTLVAXCRTLFORRTLMTHRTLSMGSHR$](]]]]-] ]?*[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.OPT;2+,^./ 41<-Q0@123KPWO56`z57 {58 )<9FRQٓGHJ CMUSNMP.SAV^Q?[MULTINET_PLUS.MULTINET.SNMP.APPS.SNMPNETSTAT]SNMPNETSTAT.OPT;21mIF,INET,MAIN,ROUTE[--.SNMPLIB]LIBSNMP/LIB1[---.SOCKET_LIBRARY]MULTINET_SOCKET_LIBRARY/SHAREGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE0*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3+,_./ 4c<-I0@123KPWO56s O71To8}9FRQٓGHJ/*= * snmpstatus.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 in9suppor CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3cting 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******************************************************************/#include #include #include #include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "snmp_client.h"#include "snmp_api.h"#include "mib.h"int snmp_dump_packet = 0;3oid objid_sysDescr[] = {1, 3, 6, 1, 2, 1, 1, 1, 0};9int length_sysDescr = sizeof(objid_sysDescr)/sizeof(oid);4oid objid_sysUpTime[] = {1, 3, 6, 1, 2, 1, 1, 3, 0};;int length_sysUpTime = sizeof(objid_sysUpTime)/sizeof(oid);:oid objid_ifOperStatus[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 8};Aint length_ifOperStatus = sizeof(objid_ifOperStatus)/sizeof(oid);<oid objid_ifInUCastPkts[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 11};Cint length_ifInUCastPkts = sizeof(objid_ifInUCastPkts)/sizeof(oid);=oid objid_ifInNUCastPkts[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 12};Eint length_ifInNUCastPkts = sizeof(objid_ifInNUCastPkts)/siz CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3c eof(oid);=oid objid_ifOutUCastPkts[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 17};Eint length_ifOutUCastPkts = sizeof(objid_ifOutUCastPkts)/sizeof(oid);>oid objid_ifOutNUCastPkts[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 18};Gint length_ifOutNUCastPkts = sizeof(objid_ifOutNUCastPkts)/sizeof(oid);7oid objid_ipInReceives[] = {1, 3, 6, 1, 2, 1, 4, 3, 0};Aint length_ipInReceives = sizeof(objid_ipInReceives)/sizeof(oid);9oid objid_ipOutRequests[] = {1, 3, 6, 1, 2, 1, 4, 10, 0};Cint length_ipOutRequests = sizeof(objid_ipOutRequests)/sizeof(oid);char *uptime_string(timeticks, buf) register u_long timeticks; char *buf;{& int seconds, minutes, hours, days; timeticks /= 100;& days = timeticks / (60 * 60 * 24); timeticks %= (60 * 60 * 24);" hours = timeticks / (60 * 60); timeticks %= (60 * 60); minutes = timeticks / 60; seconds = timeticks % 60; if (days == 0){7 sprintf(buf, "%d:%02d:%02d", hours, minutes, seconds); } else if (days == 1) {E sprintf(buf, "%d day, %d:%02d:%02d", days, hours, minutes, seconds); } else {F sprintf(buf, "%d days, %d:%02d:%02d", days, hours, minutes, seconds); } return buf;}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; char name[256]; char buf[64]; int good_var, index; CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3cG int status, count;< u_long ipackets = 0, opackets = 0, down_interfaces = 0; u_long ipin = 0, ipout = 0; u_long uptime = 0; /*6 * usage: snmpstatus 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 {A printf("usage: snmpstatus gateway-name [community-name]\n"); exit(1); } } if (!(gateway)){= printf("usage: snmpstatus gateway-name [community-name]\n"); exit(1); }9 bzero((char *)&session, sizeof(struct snmp_session)); session.peername = gateway;, session.community = (u_char *)community; if (community == NULL){4 session.community_len = SNMP_DEFAULT_COMMUNITY_LEN; } else {+ session.community_len = strlen(community); } session.retries = 4; session.timeout = 500000;! session.authenticator = NULL; snmp_synch_setup(&session); ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); }4 strcpy(name, "No System Description Available");' pdu = snmp_pdu_create(GET_REQ_MSG);< snmp_add_null_var(pdu, objid_sysDescr, length_sysDescr);> snmp_add_null_var(pdu, obj CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3c4 id_sysUpTime, length_sysUpTime);D snmp_add_null_var(pdu, objid_ipInReceives, length_ipInReceives);F snmp_add_null_var(pdu, objid_ipOutRequests, length_ipOutRequests);retry:5 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){, if (response->errstat == SNMP_ERR_NOERROR){G for(vars = response->variables; vars; vars = vars->next_variable){- if (vars->name_length == length_sysDescr &&P !bcmp((char *)objid_sysDescr, (char*)vars->name, sizeof(objid_sysDescr))){8 bcopy((char *)vars->val.string, name, vars->val_len); name[vars->val_len] = '\0'; }. if (vars->name_length == length_sysUpTime &&R !bcmp((char *)objid_sysUpTime, (char*)vars->name, sizeof(objid_sysUpTime))){ uptime = *vars->val.integer; }1 if (vars->name_length == length_ipInReceives &&X !bcmp((char *)objid_ipInReceives, (char*)vars->name, sizeof(objid_ipInReceives))){ ipin = *vars->val.integer; }2 if (vars->name_length == length_ipOutRequests &&Z !bcmp((char *)objid_ipOutRequests, (char*)vars->name, sizeof(objid_ipOutRequests))){ ipout = *vars->val.integer; } } } 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 CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3c4->name_length); printf("\n"); }= if ((pdu = snmp_fix_pdu(response, GET_REQ_MSG)) != NULL) goto retry; }' } else if (status == STAT_TIMEOUT){* printf("No Response from %s\n", gateway); exit(1);' } else { /* status == STAT_ERROR */) printf("An error occurred, Quitting\n"); exit(2); }N printf("[%s]=>[%s] Up: %s\n", inet_ntoa(response->address.sin_addr), name, uptime_string(uptime, buf)); if (response) snmp_free_pdu(response);+ pdu = snmp_pdu_create(GETNEXT_REQ_MSG);D snmp_add_null_var(pdu, objid_ifOperStatus, length_ifOperStatus);F snmp_add_null_var(pdu, objid_ifInUCastPkts, length_ifInUCastPkts);H snmp_add_null_var(pdu, objid_ifInNUCastPkts, length_ifInNUCastPkts);H snmp_add_null_var(pdu, objid_ifOutUCastPkts, length_ifOutUCastPkts);J snmp_add_null_var(pdu, objid_ifOutNUCastPkts, length_ifOutNUCastPkts); good_var = 5; while(good_var == 5){ good_var = 0;2 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){0 if (response->errstat == SNMP_ERR_NOERROR){) pdu = snmp_pdu_create(GETNEXT_REQ_MSG); index = 0;D for(vars = response->variables; vars; vars = vars->next_variable){C if (index == 0 && vars->name_length >= length_ifOperStatus &&8 !bcmp((char *)objid_ifOperStatus, (char *)vars->name, sizeof(objid_ifOperStatus))){1 if (*vars->val.integer != MIB_IFSTATUS_UP) down_interfaces++;= snmp_add_null_var(pdu, vars->name, vars->name_l CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3cength); good_var++;K } else if (index == 1 && vars->name_length >= length_ifInUCastPkts &&9 !bcmp((char *)objid_ifInUCastPkts, (char *)vars->name,! sizeof(objid_ifInUCastPkts))){& ipackets += *vars->val.integer;= snmp_add_null_var(pdu, vars->name, vars->name_length); good_var++;L } else if (index == 2 && vars->name_length >= length_ifInNUCastPkts &&: !bcmp((char *)objid_ifInNUCastPkts, (char *)vars->name," sizeof(objid_ifInNUCastPkts))){& ipackets += *vars->val.integer;= snmp_add_null_var(pdu, vars->name, vars->name_length); good_var++;L } else if (index == 3 && vars->name_length >= length_ifOutUCastPkts &&: !bcmp((char *)objid_ifOutUCastPkts, (char *)vars->name," sizeof(objid_ifOutUCastPkts))){& opackets += *vars->val.integer;= snmp_add_null_var(pdu, vars->name, vars->name_length); good_var++;M } else if (index == 4 && vars->name_length >= length_ifOutNUCastPkts &&; !bcmp((char *)objid_ifOutNUCastPkts, (char *)vars->name,# sizeof(objid_ifOutNUCastPkts))){& opackets += *vars->val.integer;= snmp_add_null_var(pdu, vars->name, vars->name_length); good_var++; } index++; } } 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; CMUSNMP.SAV_I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3c-' 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); }c printf("Recv/Trans packets: Interfaces: %d/%d | IP: %d/%d\n", ipackets, opackets, ipin, ipout); if (down_interfaces > 0){a6 printf("%d interfaces are down!\n", down_interfaces); } #ifdef vax11c* exit(1); #endif vax11c*}*******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 in9suppor2*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1+,rK .-/ 4-,-I0D123 KPWO.56 g)ɓ7`)ɓ8 B 9FRQٓGHJ CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-0DX0205()IR* SNMPSTATUSV1.0)ɓ04-00%) * ?0!MULTINET_SOCKET_LIBRARY_001!  LIBRTL_001 ! VAXCRTL_001@!d FORRTL_001y! MTHRTL_001!f SMGSHR_001 404=4P4/383d3333    .iso.org.dod.internet.mgmt.mib       ! !!!(!7! =! I!O!R![! `! j!r!  CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-!`z! !!!! !!!%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02dЬW8IRd~ݬbPTݏQTbPV>ISݏQTcPT<~TbPU<~TcPT[%s] Up: %s Recv/Trans packets: Interfaces: %d/%d | IP: %d/%d %d interfaces are down! Hΐ^ЬUЬTXSWVY͔͐ZRRUYBdP`-$d=BdP~fJH(XBdXSBdSZ)HHURX> HH$GXSԭ SGPЏ ԭRR (R)P[ G~GG~#PUU$RbvUbYOUbLRUb͘U[&P1S͘Pՠ1РDR1gѢ0ݢ FPݢݢ FТPM CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-lѢݢcFPв ZѢݢ?FPв ͔ѢݢFPв ͐bR1N1͘Pݠu'P9FRb͘PѠEbQ͘PРDR͘PQ bRQRR ݢݢTϲE~͘ $PU1*PXωE ϏEE͜ZP͘Pݠ*EPvuE͘ ͘t3~!PULU!Rb0UbUbUbUbS͘U[g$P1͘Pՠ1~B!PUT͘PРDR1}T.Ѣ$ݢfGDPѲ 1Y1T&ѢpݢDP WyT&ѢAݢCP WNT Ѣ&ݢCP%T5Ѣ+ݢCP VݢݢU STbR11͘Pݠ$P=CRb͘PѠ_AbQ͘PРDR͘PQ bRQRR ݢݢ !PXGC :C͘ ͘91S1'͔͐VW CRbY Y=bB%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02d<ЬUǏdPǏQPSSQďQQQPQǏQTTPďPPQPR>~SRP~2R>Rx>УQQ~ݣ RP~ Wrong Type (should be Timeticks): Timeticks: (%d) %s ^ЬRЬS C#R>R>~SRP~Ϛݳ DPݳ R=Wrong Type (should be INTEGER): INTEGER: %dINTEGER: %s(%d) ЬRЬSЬ PQ 3R=Ro=~SRP~Ѡ РQ`PPQݳ RJ=ݳ QR7=Wrong Type (should be Gauge): Gauge: %lu ЬRЬS B#R<R<~SRP~mݳ R<Wrong Type (should be Counter): Counter: %lu ЬRЬS A#R}<Rd<~SRP~ݳ RW<Network Address: %02X<ЬSЬRS(<S<PSТ TТURRU+~S;S;PSPRP:URWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%d ЬSЬR @#S;Sp;~RSP~Т P~~~`~SS;INTEGER (0..65535): %lu ЬRЬS $>R;R;~SRP~ϛݳ R:Wrong Type (should be NULL):  CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1- NULL ЬRЬS "R:R:~SRP~5R:Variable has bad typeݬm:ЬRЬQ PPBfݬ QR_QRUTQRDIQR>QRZ3QR(QRQRQRϘRmib.txtMIBFILEMULTINET:SNMP_MIB.TXTCouldn't find mib file 3RbP 8P PbPP888ЬR1Ϣ0 h (08@HPX`PϮ8N8F8>(86ϸ8.ϼ8&B8 88d8ϲ8b{ТRЬTbRSTQDQPQPTcPPPB`UR Ѣ,THТRR>c.caURUU ωPТ,TТRR T65Pff55߰Tc.PVWbPfffP%s ^P.RPݬݬHRh5ЬQvP.QPݬ ݬName: %s |^Ь VGU.RUݬݬPURTT4ScPRYcRP!KcP@T4P CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-STT4ե8ݥ4V8ݥ4V64 ^ЬTЬWV.RVݬ ݬ,PVRUTB4ScPRcRP!cPT3PUUT 4T3PTզ8 ݦ4WT8 ݦ4WTwMT3 ^ЬSЬRPPݬ ݬzՠ8 ݠ4RS8 ݠ4RS$ ^Ь SPRRPݬݬ5ՠ8 ݠ4SR8ݠ4SϘ23%d.|ЬTЬUЬ SЬRVS8V[ѦcЩR1ѢLݨ VݦXP7RSѩScЩRbScbbRݣ S?bR8ѦѦѦ Ѧݨ VݦXVϮjZ1I^ЬVЬUЬ WЬXTSԭԭROTТQaPPfPfxaPPeա,SСP$խխѠ  Ѡ}`PbRSTP~׭@B­­ѭ@B֭ѭ@Bխԭԭhѭg ѭ}gh^T~9V1zЦUЦWRЧS1PT TETѣ1*ѣ1 ѣ0ݥ ݣ У PݠURccbݣ 4ST1<֣ ݣ UϩPϯ jJRR6M~Ϟ RPPPPRPP υ Rʟv ~) ݣ ~g5P E } Ǐ@BPPď@BPP}SRcS1T T TfV1ЬTR"SBc1  PBc P Bc BcPT`RPRR  Pݬ ݬݬ2 PR -&~#hS  CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-%fSRRU1xRPPQQWP QPBúP<`~`SURSPﷹ~~xPP~~ݬ  ^ЬTЬUЬVTRSV& RPRTRPPPeѭVPTRPPPebS xSQPPQS׭ѭSRPЬTЬV WЬRR>мSЏQQURxSSUSPPQRRW~VT%PTfRPRfҏQQSPPPPxSSRRTP<^ЬSЬTЬUSR RPRSRPPPdѭePݭݬRЭeSRPPPdRPЬRЬT PЬSSP~TRkPRdSPSRݬVSdRSP ^ЬRЬSRQaPP" QPPFPQ RQPPPcPЭcQPЬPЬQ RaPRaݬQPb<ЬTЬSdPPEPPPPRRScoPcRPxPPP 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ԭPRWZ~˟W~PV1<Z~~V*PU1 ݬݬ UPR1RiPR1RhPR1RMPR1 C~R0PT1Z~0RRTPSRݬ4ݬ0X~(ݬ$S|PRaSRPPP0TKPSDURPPP~V,PU%VRPPPόW?PVPWRPЬPЬRRQ{RPPR PRPPЬPЬRRQ{RPRPPPRRPЬPì QQPPjP@@8Pphh<lTt| Dt , P %@MULTINET_SOCKET_LIBRARYLIBRTLVAXCRTL CMUSNMP.SAVrK I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.EXE;1-H+FORRTLMTHRTLSMGSHRPPPPK ,#P2*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1+,%K ./ 4-I0D123KPWO56>ē7gē8 u<9FRQٓGHJ7 SNMPSTATUSV1.0 6-SEP-1990 11:51GNU CC V1.22$CODESIDSNMP_SYNCH_STATE SNMP_ERRNOSNMP_DUMP_PACKETOBJID_SYSDESCR_010000XLENGTH_SYSDESCR_010000XOBJID_SYSUPTIME_820000XLENGTH_SYSUPTIME_820000XOBJID_IFOPERSTATUS_022000XLENGTH_IFOPERSTATUS_022000XOBJID_IFINUCASTPKTS_885000XLENGTH_IFINUCASTPKTS_885000XOBJID_IFINNUCASTPKTS_88B000XLENGTH_IFINNUCAS CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;18TPKTS_88B000XOBJID_IFOUTUCASTPKTS_889000XLENGTH_IFOUTUCASTPKTS_889000XOBJID_IFOUTNUCASTPKTS_883100XLENGTH_IFOUTNUCASTPKTS_883100XOBJID_IPINRECEIVES_082000XLENGTH_IPINRECEIVES_082000XOBJID_IPOUTREQUESTS_084000XLENGTH_IPOUTREQUESTS_084000X 8 UPTIME_STRINGUDIVUREMSPRINTFM *MAIN C$MAIN_ARGSPRINTFEXITBZEROSTRLENSNMP_SYNCH_SETUP SNMP_OPENSTRCPYSNMP_PDU_CREATESNMP_ADD_NULL_VARSNMP_SYNCH_RESPONSEBCMPBCOPYSNMP_ERRSTRING PRINT_OBJID SNMP_FIX_PDU INET_NTOA SNMP_FREE_PDUSTDERRSTDOUTSTDINP%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02d8PЬWDPRd~ݬbPTݏQTbPVfPSݏQTcPT<~TbPU<~TcPT[%s] Up: %s Recv/Trans packets: Interfaces: %d/%d | IP: %d/%d %d interfaces are down! *P2Pמΐ^ЬUЬTXSWVY͔͐ZRRUY[PBdP`-$dPdkP=sPBdP~fPP(PX CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1PBdXPSPBdSPZPPPURPXP>PPP$PXSPԭ PSPPЏ ԭRRPRPP[P "P)P~3P7PBP~MPPUUdPRbUbUbUb͘U[PP1SP͘Pՠ1PРDR1gPѢ0PݢPPPݢݢ PТPMѢ PݢPP!Pв ZѢ/PݢAPPEPв ͔ѢUPݢgPPkPв ͐bR1NyP1|P͘PݠPPPPRb͘PѠEPPbQ͘PРDRP͘PQ PbRQRPR PݢݢPϲPP񚏠~͘PPU1P*PP PXωPP PϏP%P.P͜Z9PP͘PݠNPPvTP[P͘ aP͘lP~wPPUUPRbUbUbUbUbS͘U[PP1P͘Pՠ1P~P CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1>KPUT͘PРDR1}PT.PѢ$'Pݢ9PP=PѲ 1FPY1KPT&PPѢZPݢlPPpP WyvPT&{PѢPݢPPP WNPT PѢPݢPP%PT5PѢ+PݢPPP VݢݢUPSTbR1 P1 P͘PݠPP="P(PRb͘PѠ_7PA;PbQ͘PРDRLP͘PQ WPbRQR`PR dPݢݢqP!uPwPP|PXPP PPP͘ P͘PS1'P͔͐VWPPRbY PY=PbPPEXITPPRINTFP SNMP_FREE_PDUPPRINTFPPRINTFlP PRINT_OBJID#PPRINTFPSNMP_ERRSTRINGPSNMP_ADD_NULL_VARPBCMPPBCMPPBCMPgPBCMP4PBCMPPSNMP_PDU_CREATEPSNMP_SYNCH_RESPONSEPSNMP_ADD_NULL_VARrPSNMP_PDU_CREATEgP SNMP_FREE_PDUVPPRINTFIP INET_NTOA)PEXIT PPRINTFPPRINTFP SNMP_FIX_PDUPPRINTFP PRINT_OBJIDPPRINTFPSNMP_ERRSTRINGbPBCMP<PBCMPPBCMPPBCOPYP CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1G BCMPPSNMP_SYNCH_RESPONSE_PSNMP_ADD_NULL_VARHPSNMP_PDU_CREATE=PSTRCPY.PEXIT$PPRINTFP SNMP_OPEN PSNMP_SYNCH_SETUPPSTRLENPBZEROPEXITPPRINTFPEXITPPRINTFPPRINTF-P C$MAIN_ARGSPSPRINTFPSPRINTFaPUREM?PUDIVPPPPP ~P`P SP -P  P PPPPP PP P P {P [PNP5P(PPPPPPPPzPoPiPWPQPlPP P P PP PP PP  P  P  P  P  PP PP PP SNMPSTATUSRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*& CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1uRSTSin_addr s_addrRS synch_statewaiting  status @reqid `pdu RRSmib_egpNeighEntry@ egpNeighState egpNeighAddrRSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrors R Smib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagrams R Smib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPort R Smib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegs R Smib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoReps CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;14icmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskReps R Smib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgeRSmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrRSmib_ip` ipForwarding ipDefaultTTL@ ipInReceivesA` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atIfIndex atPhysAddress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr*&   ifType @ifMtu`ifSpeed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknown CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1LProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLenRS mib_interface ifNumberRS mib_systemsysDescr*&  sysObjectID*&ObjIDLen sysUpTimeRSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_lenRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic RSTSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables Tsnmp_dump_packetobjid_sysDescr*& length_sysDescrobjid_sysUpTime*& length_sysUpTime objid_ifOperStatus*&  CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1*  length_ifOperStatus objid_ifInUCastPkts*&  length_ifInUCastPkts objid_ifInNUCastPkts*& length_ifInNUCastPktsobjid_ifOutUCastPkts*& length_ifOutUCastPktsobjid_ifOutNUCastPkts*& length_ifOutNUCastPktsobjid_ipInReceives*& length_ipInReceivesobjid_ipOutRequests*& length_ipOutRequests&$$PsectAttributes_NOSHR$$stderr T&$$PsectAttributes_NOSHR$$stdout T%$$PsectAttributes_NOSHR$$stdin TVRs O>DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.C;3  !8 uptime_string timeticksbuf>  seconds> minutes>hours>days>m ;8 *maińargc?argv? session Tss? Tpdu? CMUSNMP.SAV%K I2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OBJ;1^ T٘response Tvars? Targ? gateway? " community?  name*& ٜbuf*&@@?! good_var?index?status?count?! ipackets?! opacketsA?(down_interfaces? ٔipin ِipoutuptime? II i q< #* PP PP  CMUSNMP.SAVbI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OPT;40ay2*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPSTATUS.OPT;4+,b./ 40<-I0@123KPWO56ɹ757&758 F<9FRQٓGHJ SNMPSTATUS[-.SNMPLIB]LIBSNMP/LIB0[--.SOCKET_LIBRARY]MULTINET_SOCKET_LIBRARY/SHAREGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE.*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;2+,c./ 4U-I0@123KPWO56@ʭ7`o8j#}9FRQٓGHJ/*7 * snmptest.c - send snmp 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 notice appear i CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21Un 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 #include #include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "snmp_api.h"#include "snmp_client.h"extern int errno;int command = GET_REQ_MSG;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, *vp; int arg, ret; char *gateway = NULL; char *community = NULL; int status, count; init_mib(); /*2 * usage: snmptest gateway-name community-name */$ for(arg = 1; arg < argc; arg++){ if (argv[arg][0] == '-'){ switch(argv[arg][1]){ case 'd': snmp_dump_packet++; break; defa CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21Uult: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 {= printf("usage: snmptest gateway-name community-name\n"); exit(1); } } if (community == NULL). community = "public"; /* default to public */! if (!(gateway && community)){9 printf("usage: snmptest gateway-name community-name\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); } while(1){ vars = NULL; for(ret = 1; ret != 0;){G vp = (struct variable_list *)malloc(sizeof(struct variable_list)); vp->next_variable = NULL; vp->name = NULL; vp->val.string = NULL;, while((ret = input_variable(vp)) == -1) ; if (ret == 1){ /* add it to the list */ if (vars == NULL){ /* if first variable */% pdu = snmp_pdu_create(command); pdu->variables = vp; } else { vars->next_variable = vp; } vars = vp; } else {' /* free the last (un CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21U]used) variable */ if (vp->name) free((char *)vp->name); if (vp->val.string)# free((char *)vp->val.string); free((char *)vp); } }2 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){ switch(response->command){ case GET_REQ_MSG:& printf("Received GET REQUEST "); break; case GETNEXT_REQ_MSG:* printf("Received GETNEXT REQUEST "); break; case GET_RSP_MSG:' printf("Received GET RESPONSE "); break; case SET_REQ_MSG:& printf("Received SET REQUEST "); break; case TRP_REQ_MSG:' printf("Received TRAP REQUEST "); break; }@ printf("from %s\n", inet_ntoa(response->address.sin_addr));: printf("requestid 0x%x errstat 0x%x errindex 0x%x\n",: response->reqid, response->errstat, response->errindex);0 if (response->errstat == SNMP_ERR_NOERROR){C for(vars = response->variables; vars; vars = vars->next_variable): print_variable(vars->name, vars->name_length, vars); } else {N printf("Error in packet.\nReason: %s\n", snmp_errstring(response->errstat));0 if (response->errstat == SNMP_ERR_NOSUCHNAME){U for(count = 1, vars = response->variables; vars && count != response->errindex;' vars = vars->next_variable, count++) ; if (vars){' printf("This name doesn't exist: ");. print_objid(vars->name, vars->name_length); } printf("\n"); } }$ } else if (status == STAT_TIMEOUT){. p CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21U rintf("No Response from %s\n", gateway);' } else { /* status == STAT_ERROR */- printf("An error occurred, Quitting\n"); } if (response) snmp_free_pdu(response); }}intascii_to_binary(cp, bufp) u_char *cp; u_char *bufp;{ int subidentifier; u_char *bp = bufp; for(; *cp != '\0'; cp++){ if (isspace(*cp)) continue; if (!isdigit(*cp)){ printf("Input error\n"); return -1; } subidentifier = atoi(cp); if (subidentifier > 255){G printf("subidentifier %d is too large ( > 255)\n", subidentifier); return -1; } *bp++ = (u_char)subidentifier; while(isdigit(*cp)) cp++; cp--; } return bp - bufp;}input_variable(vp) struct variable_list *vp;{! u_char buf[256], value[256];/ printf("Please enter the variable name: "); fflush(stdout); gets(buf); if (*buf == 0){ vp->name_length = 0; return 0; } if (*buf == '$'){ switch(buf[1]){ case 'G': command = GET_REQ_MSG;* printf("Request type is GET REQUEST\n"); break; case 'N': command = GETNEXT_REQ_MSG;. printf("Request type is GETNEXT REQUEST\n"); break; case 'S': command = SET_REQ_MSG;* printf("Request type is SET REQUEST\n"); break; case 'D': if (snmp_dump_packet){ snmp_dump_packet = 0;) printf("Turned packet dump off\n"); } else { snmp_dump_packet = 1;( printf("Turned packet dump on\n"); }  CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21Udpbreak; case 'Q':! printf("Quitting, Goodbye\n"); exit(0); break; default: printf("Bad command\n"); } return -1; }# vp->name_length = MAX_NAME_LEN;2 if (!read_objid(buf, value, &vp->name_length)) return -1;< vp->name = (oid *)malloc(vp->name_length * sizeof(oid));J bcopy((char *)value, (char *)vp->name, vp->name_length * sizeof(oid)); if (command == SET_REQ_MSG){2 printf("Please enter variable type [i|s|n|o]: "); fflush(stdout); gets(buf); switch(*buf){ case 'i': vp->type = INTEGER; break; case 's': vp->type = STRING; break; case 'n': vp->type = NULLOBJ; break; case 'o': vp->type = OBJID; break; default:H printf("bad type \"%c\", use \"i\", \"s\", \"n\", or \"o\".\n", *buf); return -1; }4 printf("Please enter new value: "); fflush(stdout); gets(buf); switch(vp->type){ case INTEGER:1 vp->val.integer = (long *)malloc(sizeof(long));! *(vp->val.integer) = atoi(buf); vp->val_len = sizeof(long); break; case STRING:, vp->val_len = ascii_to_binary(buf, value);1 vp->val.string = (u_char *)malloc(vp->val_len);< bcopy((char *)value, (char *)vp->val.string, vp->val_len); break; case NULLOBJ: vp->val_len = 0; vp->val.string = NULL; break; case OBJID: vp->val_len = MAX_NAME_LEN;;' read_objid(buf, value, &vp->val_len); vp->val_len *= sizeof(oid);- vp->val.objid = (oid *)malloc(vp->val_len);; bcopy((char *)value, (ch CMUSNMP.SAVcI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTEST.C;21UUar *)vp->val.objid, vp->val_len); break; default: printf("Internal error\n"); break; }+ } else { /* some form of get message */ vp->type = NULLOBJ; vp->val_len = 0; } return 1;}.*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;2+,d./ 4o-I0@123KPWO56@7`)o8j}9FRQٓGHJ/*4 * snmptrap.c - send snmp traps to a network entity. * */</***********************************************************- Copyright 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 notice appear in 9suppor CMUSNMP.SAVdI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;21oting 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 #include #include #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;A#define NUM_NETWORKS 16 /* max number of interfaces to check */5oid objid_enterprise[] = {1, 3, 6, 1, 4, 1, 3, 1, 1};3oid objid_sysdescr[] = {1, 3, 6, 1, 2, 1, 1, 1, 0};struct nlist nl[] = { { "_boottime" }, { "" }};int snmp_input(){}#ifndef IFF_LOOPBACK#define IFF_LOOPBACK 0#endif#define LOOPBACK 0x7f000001u_long get_myaddr(){ int sd; struct ifconf ifc;2 struct ifreq conf[NUM_NE CMUSNMP.SAVdI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;21oJDTWORKS], *ifrp, ifreq; struct sockaddr_in *in_addr; int count;A int interfaces; /* number of interfaces returned by ioctl */2 if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 0; ifc.ifc_len = sizeof(conf); ifc.ifc_buf = (caddr_t)conf;2 if (ioctl(sd, SIOCGIFCONF, (char *)&ifc) < 0){ close(sd); return 0; } ifrp = ifc.ifc_req;4 interfaces = ifc.ifc_len / sizeof(struct ifreq);8 for(count = 0; count < interfaces; count++, ifrp++){ ifreq = *ifrp;1 if (ioctl(sd, SIOCGIFFLAGS, (char *)&ifreq) < 0) continue;1 in_addr = (struct sockaddr_in *)&ifrp->ifr_addr; if ((ifreq.ifr_flags & IFF_UP)' && (ifreq.ifr_flags & IFF_RUNNING)) && !(ifreq.ifr_flags & IFF_LOOPBACK). && in_addr->sin_addr.s_addr != LOOPBACK){ close(sd);" return in_addr->sin_addr.s_addr; } } close(sd); return 0;}/*% * Returns uptime in centiseconds(!). */long uptime(){' struct timeval boottime, now, diff; int kmem;* if ((kmem = open("/dev/kmem", 0)) < 0) return 0; nlist("/vmunix", nl); if (nl[0].n_type == 0){ close(kmem); return 0; } , lseek(kmem, (long)nl[0].n_value, L_SET);, read(kmem, &boottime, sizeof(boottime)); close(kmem); gettimeofday(&now, 0); now.tv_sec--; now.tv_usec += 1000000L;/ diff.tv_sec = now.tv_sec - boottime.tv_sec;2 diff.tv_usec = now.tv_usec - boottime.tv_usec;! if (diff.tv_usec > 1000000L){ diff.tv_usec -= CMUSNMP.SAVdI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;21o 1000000L; diff.tv_sec++; }: return ((diff.tv_sec * 100) + (diff.tv_usec / 10000));}u_long parse_address(address) char *address;{ u_long addr; struct sockaddr_in saddr; struct hostent *hp;* if ((addr = inet_addr(address)) != -1) return addr; hp = gethostbyname(address); if (hp == NULL){0 fprintf(stderr, "unknown host: %s\n", address); return 0; } else {B bcopy((char *)hp->h_addr, (char *)&saddr.sin_addr, hp->h_length); return saddr.sin_addr.s_addr; }}main(argc, argv) int argc; char *argv[];{% struct snmp_session session, *ss; struct snmp_pdu *pdu; struct variable_list *vars; int arg; char *gateway = NULL; char *community = NULL;L char *trap = NULL, *specific = NULL, *description = NULL, *agent = NULL; /*o * usage: snmptrap gateway-name community-name trap-type specific-type device-description [ -a agent-addr ] */$ for(arg = 1; arg < argc; arg++){ if (argv[arg][0] == '-'){ switch(argv[arg][1]){ case 'a': agent = argv[++arg]; break; 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 if (trap == NULL){ trap = argv[arg]; } else if (specific == NULL){ specific = argv[arg]; CMUSNMP.SAVdI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;21o } else { description = argv[arg]; } }D if (!(gateway && community && trap && specific && description)){i printf("usage: snmptrap host community trap-type specific-type device-description [ -a agent-addr ]\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;" session.callback = snmp_input;" session.callback_magic = NULL;) session.remote_port = SNMP_TRAP_PORT; ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); }' pdu = snmp_pdu_create(TRP_REQ_MSG);> pdu->enterprise = (oid *)malloc(sizeof(objid_enterprise));W bcopy((char *)objid_enterprise, (char *)pdu->enterprise, sizeof(objid_enterprise));D pdu->enterprise_length = sizeof(objid_enterprise) / sizeof(oid); if (agent != NULL)8 pdu->agent_addr.sin_addr.s_addr = parse_address(agent); else0 pdu->agent_addr.sin_addr.s_addr = get_myaddr(); pdu->trap_type = atoi(trap);( pdu->specific_type = atoi(specific); pdu->time = uptime();Y pdu->variables = vars = (struct variable_list *)malloc(sizeof(struct variable_list)); vars->next_variable = NULL;7 vars->name = (oid *)malloc(sizeof(objid_sysdescr));N bcopy((char *)objid_sysd CMUSNMP.SAVdI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAP.C;21oHescr, (char *)vars->name, sizeof(objid_sysdescr));= vars->name_length = sizeof(objid_sysdescr) / sizeof(oid); vars->type = ASN_OCTET_STR;A vars->val.string = (u_char *)malloc(strlen(description) + 1);2 strcpy((char *)vars->val.string, description);( vars->val_len = strlen(description); if (snmp_send(ss, pdu)== 0){ printf("error\n"); } snmp_close(ss);}/*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAPD.C;2+,e./ 4^ -I0@123KPWO56@7o8~9FRQٓGHJ/*+ * snmptrapd.c - receive and log snmp traps * */</***********************************************************- Copyright 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 notice appear in 9supporting doc CMUSNMP.SAVeI/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAPD.C;2^8umentation, 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 #include #include #include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "snmp_api.h"#include "snmp_client.h"#ifndef BSD4_3typedef long fd_mask;<#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */K#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))L#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))L#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))3#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))#endifextern int errno;int snmp_dump_packet = 0;int Print = 0;char *trap_description(trap) int trap;{ switch(trap){ case SNMP_TRAP_COLDSTART: return "Cold Start"; cas CMUSNMP.SAVeI/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAPD.C;2^?e SNMP_TRAP_WARMSTART: return "Warm Start"; case SNMP_TRAP_LINKDOWN: return "Link Down"; case SNMP_TRAP_LINKUP: return "Link Up"; case SNMP_TRAP_AUTHFAIL:% return "Authentication Failure"; case SNMP_TRAP_EGPNEIGHBORLOSS: return "EGP Neighbor Loss";# case SNMP_TRAP_ENTERPRISESPECIFIC:" return "Enterprise Specific"; default: return "Unknown Type"; }}char *uptime_string(timeticks, buf) register u_long timeticks; char *buf;{& int seconds, minutes, hours, days; timeticks /= 100;& days = timeticks / (60 * 60 * 24); timeticks %= (60 * 60 * 24);" hours = timeticks / (60 * 60); timeticks %= (60 * 60); minutes = timeticks / 60; seconds = timeticks % 60; if (days == 0){7 sprintf(buf, "%d:%02d:%02d", hours, minutes, seconds); } else if (days == 1) {E sprintf(buf, "%d day, %d:%02d:%02d", days, hours, minutes, seconds); } else {F sprintf(buf, "%d days, %d:%02d:%02d", days, hours, minutes, seconds); } return buf;}.int snmp_input(op, session, reqid, pdu, magic) int op;! struct snmp_session *session; int reqid; struct snmp_pdu *pdu; void *magic;{ char buf[64];? if (op == RECEIVED_MESSAGE && pdu->command == TRP_REQ_MSG){ if (Print){Q printf("%s: %s Trap (%d) Uptime: %s\n", inet_ntoa(pdu->agent_addr.sin_addr),W trap_description(pdu->trap_type), pdu->specific_type, uptime_string(pdu->time, buf)); } els CMUSNMP.SAVeI/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAPD.C;2^Ye {^ syslog(LOG_WARNING, "%s: %s Trap (%d) Uptime: %s\n", inet_ntoa(pdu->agent_addr.sin_addr),W trap_description(pdu->trap_type), pdu->specific_type, uptime_string(pdu->time, buf)); } } else if (op == TIMED_OUT){- printf("Timeout: This shouldn't happen!\n"); }}main(argc, argv) int argc; char *argv[];{% struct snmp_session session, *ss; int arg; int count, numfds, block; fd_set fdset;! struct timeval timeout, *tvp; init_syslog(); /* * usage: snmptrapd [-p] */$ for(arg = 1; arg < argc; arg++){ if (argv[arg][0] == '-'){ switch(argv[arg][1]){ case 'd': snmp_dump_packet++; break; case 'p': Print++; break; default:4 printf("invalid option: -%c\n", argv[arg][1]);) printf("Usage: snmptrapd [-p ]\n"); break; } continue; } }9 bzero((char *)&session, sizeof(struct snmp_session)); session.peername = NULL; session.community = NULL; session.community_len = 0;+ session.retries = SNMP_DEFAULT_RETRIES;+ session.timeout = SNMP_DEFAULT_TIMEOUT;! session.authenticator = NULL;" session.callback = snmp_input;" session.callback_magic = NULL;( session.local_port = SNMP_TRAP_PORT; ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); } while(1){ numfds = 0; FD_ZERO(&fdset); block = 1; tvp = &timeout; timerclear(tvp);0 CMUSNMP.SAVeI/[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPTRAPD.C;2^ snmp_select_info(&numfds, &fdset, tvp, &block); if (block == 1), tvp = NULL; /* block without timeout */+ count = select(numfds, &fdset, 0, 0, tvp); if (count > 0){ snmp_read(&fdset); } else switch(count){ case 0: snmp_timeout(); break; case -1: if (errno == EINTR){ continue; } else { perror("select"); } return -1; default:( printf("select returned %d\n", count); return -1; } }}init_syslog(){/*M * These definitions handle 4.2 systems without additional syslog facilities. */#ifndef LOG_CONS7#define LOG_CONS 0 /* Don't bother if not defined... */#endif#ifndef LOG_LOCAL0#define LOG_LOCAL0 0#endif /*M * All messages will be logged to the local0 facility and will be sent to* * the console if syslog doesn't work. *// openlog("snmptrapd", LOG_CONS, LOG_LOCAL0);+ syslog(LOG_INFO, "Starting snmptrapd");}.*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.C;3+,f./ 4W <-I0@123KPWO56O7vo8l*~9FRQٓGHJ CMUSNMP.SAVfI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.C;32W(Q/*R * snmpwalk.c - send snmp GETNEXT requests to a network entity, walking a subtree. * */</***********************************************************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 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"%oid objid_mib[] = {1, 3, 6, 1, 2, 1};int snmp_dump_packet = 0;main(argc, argv) int argc; char *argv[ CMUSNMP.SAVfI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.C;3C;2W];{% struct snmp_session session, *ss;$ struct snmp_pdu *pdu, *response; struct variable_list *vars; int arg; char *gateway = NULL; char *community = NULL; int gotroot = 0; oid name[32]; int name_length; oid root[MAX_NAME_LEN]; int rootlen, count; int running; int status; init_mib(); /*> * usage: snmpwalk gateway-name community-name [object-id] */$ 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 { rootlen = MAX_NAME_LEN;0 if (read_objid(argv[arg], root, &rootlen)){ gotroot = 1; } else {7 printf("Invalid object identifier: %s\n", argv[arg]); } } } if (gotroot == 0){; bcopy((char *)objid_mib, (char *)root, sizeof(objid_mib));+ rootlen = sizeof(objid_mib) / sizeof(oid); gotroot = 1; }1 if (!(gateway && community && gotroot == 1)){K printf("usage: snmpwalk gateway-name community-name 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);+  CMUSNMP.SAVfI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.C;3C;2W= 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); }= bcopy((char *)root, (char *)name, rootlen * sizeof(oid)); name_length = rootlen; running = 1; while(running){ running = 0;( pdu = snmp_pdu_create(GETNEXT_REQ_MSG);+ snmp_add_null_var(pdu, name, name_length);2 status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS){0 if (response->errstat == SNMP_ERR_NOERROR){D for(vars = response->variables; vars; vars = vars->next_variable){W if (vars->name_length < rootlen || bcmp(root, vars->name, rootlen * sizeof(oid)))+ continue; /* not part of this subtree */: print_variable(vars->name, vars->name_length, vars);O bcopy((char *)vars->name, (char *)name, vars->name_length * sizeof(oid));& name_length = vars->name_length;< running = 1; /* restart so we can get next variable */ } } else {0 if (response->errstat == SNMP_ERR_NOSUCHNAME){ printf("End of MIB.\n"); } else {R printf("Error in packet.\nReason: %s\n", snmp_errstring(response->errstat));4 if (response->errstat == SNMP_ERR_NOSUCHNAME){= printf("The request for this object identifier failed: ");R for(count = 1, vars = response->variables; vars && count != response->errindex;+ vars = vars->next_variable, cou CMUSNMP.SAVfI.[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.C;3C;2Wt nt++) ; if (vars)2 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); #ifdef vax11c exit(1); #endif vax11c}0*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1+,sK .(/ 4()-I0D123 KPWO)56- )ɓ7BU )ɓ8g. 9FRQٓGHJ0DX0205( )ILSNMPWALKV1.0`1 )ɓ04-00#& ' ?0!MULTINET_SOCKET_LIBRARY_001!  LIBRTL_001 ! VAXCRTL_001@!d FORRTL_001y! MTHRTL_001!f SMGSHR_001 CMUSNMP.SAVsK I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1R;1(c ...0.--D-p---.iso.org.dod.internet.mgmt.mib       )/2; @ JR Z dkry invalid option: -%c Invalid object identifier: %s usage: snmpwalk gateway-name community-name object-identifier Couldn't open snmp End of MIB. Error in packet. Reason: %s The request for this object identifier failed: No Response from %s An error occurred, Quitting E^ЬWЬSVTU^ RRWmBcP`-d6QBcP~ϜR>~SRP~2R>R>УQQ~ݣ RP~ Wrong Type (should be Timeticks): Timeticks: (%d) %s ^ЬRЬS C#R,>R'>~SRP~Ϛݳ DPݳ R=Wrong Type (should be INTEGER): INTEGER: %dINTEGER: %s(%d) ЬRЬSЬ PQ 3R=R=~SRP~Ѡ РQ`PPQݳ RZ=ݳ QRG=Wrong Type (should be Gauge): Gauge: %lu ЬRЬS B#R<R<~SRP~mݳ R<Wrong Type (should be Counter): Counter: %lu ЬRЬS A#R<R<~SRP~ݳ Rg<Network Address: %02X<ЬSЬRS8<S3<PSТ TТURRU+~S<S <PSPRP:URWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%d ЬSЬR @#S;S;~RSP~Т P~~~`~Sc;INTEGER (0..65535): %lu ЬRЬS $>R-;R(;~SRP~ϛݳ R;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 3RbP 9P PbPP888 CMUSNMP.SAVsK I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1.C;4( ЬR1Ϣ0 h (08@HPX`PϮ8N8F8>(86ϸ8.ϼ8&B8 88d8ϲ8b{ТRЬTRSTQDQPQPTcPPPB`UR Ѣ,THТRR>c.caURUU ωPТ,TТRR T"65Pff65߰Tc.PVWbPfffP%s ^P.RPݬݬHR5ЬQrP.QPݬ ݬName: %s |^Ь VCU.RUݬݬPURTT5ScPRcRP!cPT4PTT4ե8ݥ4V8ݥ4V64 ^ЬTЬWV.RVݬ ݬ,PVRUTf4ScPRcRP!cPT3PUUT4T4PTզ8 ݦ4WT8 ݦ4WTwMT3 ^ЬSЬRPPݬ ݬzՠ8 ݠ4RS8 ݠ4RS$ ^Ь SPRRPݬݬ5ՠ8 ݠ4SR8ݠ4SϘV3%d.|ЬTЬUЬ SЬRVS8RbSP1ϘP2b1ݠ ݰ P~<~fPԥԭ<~KPR)PFϬ>OS]P'?PCW^PSP ЬS SRcSբ ݢ + R S ЬRPQѡR QSc SѣR P c`SPcSSdУP` `УPՠ CMUSNMP.SAVsK I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1.C;4( ݠݣУP` ` УPݠAݣfRbSb мSЏQQURxSSUSPPQRRW~VT%PTfRPRfҏQQSPPPPxSSRRTP<^ЬSЬTЬUSR RPRSRPPPdѭePݭݬRЭeSRPPPdRPЬRЬT PЬSSP~TRkPRdSPSRݬ CMUSNMP.SAVsK I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1.OBJ;1(F#~SdRSP ^ЬRЬSRQaPP" QPPFPQ RQPPPcPЭcQPЬPЬQ RaPRaݬQPb<ЬTЬSdPPEPPPPRRScPcRPxPPP 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ݬb2fPxPQxPPPQQVWZ08ݬ ݬQPQQݬQPQPЭQSQPPbQP^ЬRTЬUЬVЬScRW~0RPR1&WRXXcݼ ݬSR6PR1TPPBqUVT~SR}9UVT~SRO%U~VT~SR^T~SRnPRWRPXPPP0WPPRPpublic ^ЬR,XԭPRWZ~ CMUSNMP.SAVsK I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.EXE;1.OBJ;1(8&˟W~PV1<Z~~V*PU1 ݬݬ UPR1RiPR1RhPR1RMPR1 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.SAV9K I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1.OBJ;1.0*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1+,9K ./ 4 H-I0D123KPWO561ē7&tē8<9FRQٓGHJ5SNMPWALKV1.0 6-SEP-1990 11:51GNU CC V1.22$CODESID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATE OBJID_MIB MAIN C$MAIN_ARGSINIT_MIB READ_OBJIDPRINTFBCOPYEXITBZEROSTRLENSNMP_SYNCH_SETUP SNMP_OPENSNMP_PDU_CREATESNMP_ADD_NULL_VARSNMP_SYNCH_RESPONSEBCMPPRINT_VARIABLESNMP_ERRSTRING PRINT_OBJIDN SNMP_FREE_PDU SNMP_CLOSESTDERRSTDOUTSTDINPinvalid option: -%c Invalid object identifier: %s usage: snmpwalk gateway-name community-name object-identifier Couldn't open snmp End of MIB. Error in packet. Reason: %s The request for this object identifier failed: No Response from %s An error occurred, Quitting PP^ЬWЬSVTU8PRRWm@PBcP`-IPdPPQXPBcP~ϜdP<fPVjPBcV9pPTt CMUSNMP.SAV9K I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1.OBJ;1PBcT/zP蚏@BcPPPUPBcsPPWRPUP PUV PTPUPWPPP$RRPVTT PPԭR%PR.PPU3P<7P>P~HPx~\PTS~nPPRTRPRUPP1PPՠYPРDR1PѢ@Px~ݢPP(PRݢݢPx~ݢPТTSbRP1PPѠPπP1 PPݠPPuP%PRbPѠ_4Py8PbQPРDRIPPQ TPbRQR]PR aPݢݢnPorPtPPyPVdPP PlPP PPS1PUPPPEXITP SNMP_CLOSEP SNMP_FREE_PDUPPRINTFPPRINTFiP PRINT_OBJID PPRINTFPSNMP_ERRSTRINGPBCOPYPPRINT_VARIABLEPBCMPPSNMP_SYNCH_RESPONSEzPSNMP_ADD_NULL_VARiPSNMP_PDU_CREATEWPBCOPYCPEXIT9PPRINTF)P SNMP_OPEN PSNMP_SYNCH_SETUPPSTRLENPBZEROPEXITP CMUSNMP.SAV9K I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1.OBJ;1eXPRINTFPBCOPYPPRINTFP READ_OBJID3PINIT_MIBP C$MAIN_ARGSPQPPPSNMPWALKRS_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  objid_mib*& CMUSNMP.SAV9K I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1.OBJ;1 snmp_dump_packet&$$PsectAttributes_NOSHR$$stderr T&$$PsectAttributes_NOSHR$$stdout T%$$PsectAttributes_NOSHR$$stdin TwTPO  ~ CMUSNMP.SAV9K I0[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OBJ;1.OBJ;1\+ *0*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK.OPT;3+,i./ 40<-I0@123KPWO56757`758I<9FRQٓGHJSNMPWALK[-.SNMPLIB]LIBSNMP/LIB0[--.SOCKET_LIBRARY]MULTINET_SOCKET_LIBRARY/SHAREGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE2*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4+,j./ 4h <-I0@123KPWO56E#T7io8*P~9FRQٓGHJ CMUSNMP.SAVjI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4BJ;1hV/*R * snmpwalk.c - send snmp GETNEXT requests to a network entity, walking a subtree.1 * This uses the asynchronous interface directly. * */</***********************************************************- 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******************************************************************/#include #include #include #include #include #include #include #include #include #include #include "snmp.h"#include "snmp_impl.h" CMUSNMP.SAVjI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4.C;5h#include "asn1.h"#include "snmp_api.h"#include "snmp_client.h"typedef int fd_set;)#define FD_SET(n, p) (*(p) |= (1 << (n)))*#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))*#define FD_ISSET(n, p) (*(p) & (1 << (n)))#define FD_ZERO(p) (*(p) = 0)#define select net_select%oid objid_mib[] = {1, 3, 6, 1, 2, 1};extern int errno;int snmp_dump_packet = 0;struct state { oid name[MAX_NAME_LEN]; int name_length; oid root[MAX_NAME_LEN]; int rootlen; int running; int waiting; } state_info;*snmp_input(op, session, reqid, pdu, magic) int op;! struct snmp_session *session; int reqid; struct snmp_pdu *pdu; void *magic;{ struct variable_list *vars;0 struct state *state = (struct state *)magic; int count; state->waiting = 0; state->running = 0;? if (op == RECEIVED_MESSAGE && pdu->command == GET_RSP_MSG){' if (pdu->errstat == SNMP_ERR_NOERROR){B for(vars = pdu->variables; vars; vars = vars->next_variable){h if (vars->name_length < state->rootlen || bcmp(state->root, vars->name, state->rootlen * sizeof(oid))). continue; /* not part of this subtree */6 print_variable(vars->name, vars->name_length, vars);R bcopy((char *)vars->name, (char *)state->name, vars->name_length * sizeof(oid));) state->name_length = vars->name_length;? state->running = 1; /* restart so we can get next variable */ } } else {. if (pdu->errstat == SNMP_ERR_NOSUCHNAME){ printf("End of MIB.\ CMUSNMP.SAVjI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4.C;5h?n"); } else {I printf("Error in packet.\nReason: %s\n", snmp_errstring(pdu->errstat));+ if (pdu->errstat == SNMP_ERR_NOSUCHNAME){@ printf("The request for this object identifier failed: ");K for(count = 1, vars = pdu->variables; vars && count != pdu->errindex;' vars = vars->next_variable, count++) ; if (vars). print_objid(vars->name, vars->name_length); printf("\n"); } } } } else if (op == TIMED_OUT){4 /* We don't restart on timeout so main will exit */ printf("Timed Out\n"); } return 1;}main(argc, argv) int argc; char *argv[];{% struct snmp_session session, *ss; struct snmp_pdu *pdu; int arg; char *gateway = NULL; char *community = NULL;* int count, numfds, gotroot = 0, block; fd_set fdset;! struct timeval timeout, *tvp;& struct state *state = &state_info; init_mib(); /*> * usage: snmpwalk gateway-name community-name [object-id] */$ 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 {# state->rootlen = MAX_NAME_LEN;> if (read_objid(argv[arg], state->root, &state->rootlen)){ gotroot =  CMUSNMP.SAVjI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4.C;5h1 1; } else {7 printf("Invalid object identifier: %s\n", argv[arg]); } } } if (gotroot == 0){B bcopy((char *)objid_mib, (char *)state->root, sizeof(objid_mib));2 state->rootlen = sizeof(objid_mib) / sizeof(oid); gotroot = 1; }1 if (!(gateway && community && gotroot == 1)){K printf("usage: snmpwalk gateway-name community-name object-identifier\n"); exit(1); } 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;" session.callback = snmp_input;+ session.callback_magic = (void *)state;/ session.remote_port = SNMP_DEFAULT_REMPORT; ss = snmp_open(&session); if (ss == NULL){ printf("Couldn't open snmp\n"); exit(-1); } state->running = 1; state->waiting = 0;R bcopy((char *)state->root, (char *)state->name, state->rootlen * sizeof(oid));( state->name_length = state->rootlen; while(state->running){ if (!state->waiting){, pdu = snmp_pdu_create(GETNEXT_REQ_MSG);= snmp_add_null_var(pdu, state->name, state->name_length);" if (snmp_send(ss, pdu) == 0){ snmp_free_pdu(pdu); state->running = 0; } } state->waiting = 1; numfds = 0; FD_ZERO(&fdset); block = 1; tvp = &timeout; timerclear(tvp);0 snmp_select_info(&numfds, &fdset, tvp, &block); if (b CMUSNMP.SAVjI2[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4.C;5h lock == 1), tvp = NULL; /* block without timeout */+ count = select(numfds, &fdset, 0, 0, tvp); if (count > 0){ snmp_read(&fdset); } else switch(count){ case 0: snmp_timeout(); break; case -1: if (errno == EINTR){ continue; } else { perror("select"); } default:( printf("select returned %d\n", count); } } #ifdef vax11c exit(1); #endif vax11c}4*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1+,tK .-/ 4-+-I0D123 KPWO.56 )ɓ7)ɓ8S 9FRQٓGHJ0DX0205(:)IP SNMPWALK_ASYV1.0:)ɓ04-00$( ) ?0!MULTINET_SOCKET_LIBRARY_001!  LIBRTL_001 ! VAXCRTL_001@!d FORRTL_001y! MTHRTL_001!f SMGSHR_001 CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1;5-# `3p3}33o2x22223.iso.org.dod.internet.mgmt.mib    ! 0 ; F P a h w  }                 CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1;5-.End of MIB. Error in packet. Reason: %s The request for this object identifier failed: Timed Out ЬQЬTЬPPS Q1Ѥ1դ[ФDR1ѢCx~ݢÄGP+Rݢݢ+x~SݢGТÀbRrѤ_ݤ**PGRbѤFbPФDRP bRPRR ݢݢL Q jGPinvalid option: -%c Invalid object identifier: %s usage: snmpwalk gateway-name community-name object-identifier Couldn't open snmp selectselect returned %d F8^ЬXЬTWUVmS RRXmBdP`-d/QBdP~ ݳ QR>Wrong Type (should be Gauge): Gauge: %lu ЬRЬS B#Rk>Rj>~SRP~mݳ RE>Wrong Type (should be Counter): Counter: %lu ЬRЬS A#R=R=~SRP~ݳ R=Network Address: %02X<ЬSЬRS=S=PSТ TТURRU+~Sz=Sy=PSPRP:URWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%d ЬSЬR @#S=S=~RSP~Т P~~~`~S<INTEGE CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1;5-O R (0..65535): %lu ЬRЬS $>R<R<~SRP~ϛݳ Rs<Wrong Type (should be NULL): NULL ЬRЬS "R2<R1<~SRP~5R<Variable has bad typeݬ;ЬRЬQ PPBfݬ QR_QRUTQRDIQR>QRZ3QR(QRQRQRϘRmib.txtMIBFILEMULTINET:SNMP_MIB.TXTCouldn't find mib file RbPx:P PbPlfPSMf:3:>:,ЬR1Ϣ0 h (08@HPX`PϮ8N8F8>(86ϸ8.ϼ8&B8 88d8ϲ8b{ТRЬT"RSTQDQPQPTcPPPB`UR Ѣ,THТRR>c.caURUU ωPТ,TТRR T7c7Pffw7D7߰Tc.PVWbPfffP%s ^P.RPݬݬHR7ЬQP.QPݬ ݬNa CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1;5-me: %s |^Ь VU.RUݬݬPURTT6ScPRcRP! cPT6PTTX6ե8ݥ4V8ݥ4V6#6 ^ЬTЬWV.RVݬ ݬ,PVRUT5ScPRacRP!ScPHT[5PUUT5T5PTզ8 ݦ4WT8 ݦ4WTwMTF5 ^ЬSЬR;PPݬ ݬzՠ8 ݠ4RS8 ݠ4RS$ ^Ь SPRRPݬݬ5ՠ8 ݠ4SR8ݠ4SϘ4%d.|ЬTЬUЬ SЬRVS8 PWH~WYԧDЬԧЩDRVѩVbRVR1TdPSSDSRUeբfx~dPx~PݢeKbRVVfUePcPSSR_Tdբx~ePx~Pݢdբ ݢbP ݢPݢ cXbVX WPWPselect<^ЬRЬ USRݬF PeR^Pc1Tԭԭ잭RԢbRTѭRR CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1BJ;1-H~~Tݭ$PPSPPTg ѥ? V PS1A S PS1%vݥ$ݥ  VPS1, S PS18 S PS1< Su PS1@ SY PS1 T1TS$RR;VSPPT< T~ R PSO THTSV$PPSPPTg Th VzPS VSPPgPPTPTS$VSPTPgPWrong version: %d Continuing anyway bad type returned (%x) |^ЬVЬUЬ TTzPT1%|XRb{vbզTPT1T PT1&ѥBT- PT1T PT11@$$T PT1x$~P x$~P:,T PTm8T PTS<Tj PT9@TP PTT PT 01PեDPSSDPcPScԣ ԣ@ TXPTx~{PRx~R2R< P2PPPB"7"""""""""""""""""""""""""""""""""""""""""""""""""""""""""1P ݣ 1ݣP P \@RR ^ xPPP>P ݣPR ~lT!լ11PNo remote IP address specified Error building packet %02X sendto<^ЬU CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1BJ;1-q ST< vPѠUРT`PT _Pѣѣѣ ѣ/գѣԣѣ8ԣ3գ$" P P$գ@ԣ@գ.դPS $SUϺP1lJRR 6M$~ϬRPPPPRPP ϓ Rʟτp~S~ $dlPTPѣѣ ѣS$PQФaQS УХ } Ǐ@BPPď@BPP}УP ЬSУDR1բ ݢuբ  ݢ fRPbRPWRգ  ݣ DS;recvfromreceived %d bytes from %s: Mangled packet ^Ь[Z1ЪQxaPkP1ЪXQY~<~$i)PWW kRt`'PWRRRW4M$~ϜRPPPPRPP σqWR̟vbH~/PV(fԦԦDԦ Ԧ$W$VXmP5V[ѦcЩR1ѢLݨ VݦXP7RSѩScЩRbScbbRݣ S?bR8ѦѦѦ Ѧݨ VݦXVϮjZ1I^ЬVЬUЬ WЬXTSԭԭROTТQaPPfPfxaPPeա,SСP$խխѠ  Ѡ}`PbRSTP~Y ׭@B­­ѭ@B֭ѭ@Bխԭԭhѭg ѭ}gh^T~ V1zЦUЦWRЧS1PT T Tѣ1*ѣ1 ѣ0ݥ ݣ У PݠURccbݣ 4ST1<֣  CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1BJ;1-@"# ݣ UϩPϯ  ^JRR6M~Ϟ RPPPPRPP υs Rʟvb ~ ݣ ~g]P E } Ǐ@BPPď@BPP}SRcS1T T TfV1^ЬTЬUЬVTRSV& RPRTRPPPeѭVPTRPPPebS xSQPPQS׭ѭSRPЬTЬV WЬRR>мSЏQQURxSSUSPPQRRW~VT%PTfRPRfҏQQSPPPPxSSRRTP<^ЬSЬTЬUSR RPRSRPPPdѭePݭݬR6 ЭeSRPPPdRPЬRЬT PЬSSP~TRkPRdSPSRݬ SdRSP ^ЬRЬSRQaPP" QPPFPQ RQPPPcPЭcQPЬPЬQ RaPRaݬQPb<ЬTЬSdPPEPPPPRRS< cPcRPxPPP 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ԭLPRWZ~˟W~PV1<Z~~V*PU1 ݬݬ UPR1RiPR1RhPR1RMPR1 C~R0PT1Z~0RRTPSRݬ4ݬ0X~(ݬ$S|PRaSRPPP0TKPSDURPPP~V,PU%VRPPPόW?PVPWRPЬPЬRRQ{RPPR PRPPЬPЬRRQ{RPRPPPRRPЬPì QQPPjP CMUSNMP.SAVtK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.EXE;1BJ;1-yQ)@@ h8Pph<lTt|D4  t , N $@MULTINET_SOCKET_LIBRARYLIBRTLVAXCRTLFORRTLMTHRTLSMGSHRNNNNNM+"4*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1+,TK ./ 4-I0D123KPWO56F"ē7{R#ē8`#<9FRQٓGHJ CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;1_;9 SNMPWALK_ASYV1.0 6-SEP-1990 11:52GNU CC V1.22T$CODE_CTYPE_ C$V_CTYPEDEFSSID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATE OBJID_MIB r SNMP_INPUTBCMPPRINT_VARIABLEBCOPYSNMP_ERRSTRINGPRINTF PRINT_OBJID MAIN C$MAIN_ARGS STATE_INFOINIT_MIB READ_OBJIDEXITSTRLEN SNMP_OPENSNMP_PDU_CREATESNMP_ADD_NULL_VAR SNMP_SEND SNMP_FREE_PDUSNMP_SELECT_INFO NET_SELECT SNMP_READ SNMP_TIMEOUTERRNOPERROR SOCKET_ERRNOVMSERRNO VAXC$ERRNOSTDERRSTDOUTSTDINPP P PEnd of MIB. Error in packet. Reason: %s The request for this object identifier failed: Timed Out rPЬQЬTЬPPS Q1PѤ1Pդ[PФDR1PѢCPx~ݢÄPP+PRݢݢPx~SݢPТÀbRPrPѤP P_ PݤPPP"PRbѤF,P0PbPФDR<PP BPbRPRKPR OPݢݢ\P`P bPQ gPkPrPPinvalid option: -%c Invalid object identifier: %s usage: snmpwalk gateway-name community-name object-identifier Couldn't open snmp selectselect returned %d  CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;17P P8^ЬXЬTWUV7PS?PRRXmGPBdP`-PPdWPQ_PBdP~ kP<mPWqPBdW9wPU{PBdU/P蚏@ÄBdPPPVPBdPPXRPVP ÄPVW PUPVPPPPWUUPPԭZPS+PPU0Pϵ4P;P~EP x~SÄaPÀ1qPT 9{P~PPRÀSRPRUPP PRP ԭԭȞRԢbRTPѭPRR~~TݭPPR PTP8PяRPRPP!P$P'P+P2PR8P?P1-HPQPLPEXIT:PPRINTF-PPERRORPP SNMP_TIMEOUTP SNMP_READP NET_SELECTPSNMP_SELECT_INFOP SNMP_FREE_PDUP SNMP_SENDPSNMP_ADD_NULL_VARPSNMP_PDU_CREATE\PBCOPY@PEXIT6PPRINTF&P SNMP_OPENPSTRLENPEXITPPRINTFPBCOPYPPRINTFP READ_OBJID:PINIT_MIB2PP C$MAIN_ARGSmPPRINT CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;1FWP PRINT_OBJIDPPRINTFPSNMP_ERRSTRINGPBCOPYPPRINT_VARIABLEPBCMPP C$V_CTYPEDEFSPXPPP SNMPWALK_ASYRS_iobufp _cnt _ptr  @_base  `_flag h_fileRSprotoent` p_name  p_aliases @p_protoRSservent s_name  s_aliases  @s_port`s_proto RSnetent n_name  n_aliases @ n_addrtype `n_net n_addresses RRShostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protos  h_addresses RRS sockaddr_in sin_familysin_port sin_addr  R@sin_zero*& R S T Sin_addr s_addr R Smsghdrmsg_name  msg_namelen@msg_iov  R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocolRST CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;1D STSsockaddr sa_familysa_data*& RSlinger@l_onoff l_lingerRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRS 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 trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator cal CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;1- lback callback_magic RSstate name*&@@? name_length root*&@@? rootlen@running`waitingR STS  objid_mib*&snmp_dump_packet state_info T, %$$PsectAttributes_NOSHR$$socket_errno( !$$PsectAttributes_NOSHR$$vmserrno* #$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errno& $$PsectAttributes_NOSHR$$stderr T& $$PsectAttributes_NOSHR$$stdoutN T%$$PsectAttributes_NOSHR$$stdin TXTE#T @DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.C;4  __ctype__dummyrr snmp_inputJsession T  reqidopupduu Tmagicu varsu Tstateu Tcountu @r N mainargc+Pargv CMUSNMP.SAVTK I4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OBJ;1BJ;1K+P session Tss+P Tpdu+P Targ+P gateway+P " community+P count+P numfds gotroot+P block fdsettimeout Ttvp+P Tstate+P T <<ECATESNMP_ADD_NULL_VAR SNMP_SEND 4*[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OPT;3+,m./ 40<-I0@123KPWO56`W857 *858 <9FRQٓGHJ CMUSNMP.SAVmI4[MULTINET_PLUS.MULTINET.SNMP.APPS]SNMPWALK_ASY.OPT;3BJ;10 SNMPWALK_ASY[-.SNMPLIB]LIBSNMP/LIB0[--.SOCKET_LIBRARY]MULTINET_SOCKET_LIBRARY/SHAREGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE&*[MULTINET_PLUS.MULTINET.SNMP]BIN.DIR;1+,r./ 4-E0123 KPWO56@h7 8@ 9FRQٓGHDJI'*[MULTINET_PLUS.MULTINET.SNMP]MAKE.COM;3+,s./ 4V-E0123KPWO56l3*;7o8 9FRQٓGHDJ CMUSNMP.SAVsE'[MULTINET_PLUS.MULTINET.SNMP]MAKE.COM;3ETSTAT]MAIN.C;57$ SET DEF [.SNMPLIB] $ @MAKE 'p1'$ SET DEF [-.APPS] $ @MAKE 'p1' $ SET DEF [-]&*[MULTINET_PLUS.MULTINET.SNMP]MAN.DIR;1+,t./ 4-E0123 KPWO56,C7X8 9FRQٓGHDJI SNMPGET.1u SNMPGETNEXT.1v SNMPNETSTAT.1w SNMPSTATUS.1x SNMPTEST.1y SNMPTRAP.1z SNMPTRAPD.1{ SNMPWALK.1| SNMP_API.3} VARIABLES.5~,*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGET.1;2+,u./ 4_-t0@123KPWO567$2o8 ғ9FRQٓGHJ CMUSNMP.SAVut,[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGET.1;2T]MAIN.C;5_k@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/!.TH SNMPGET 1 "17 September 1989".UC 4.SH NAMEEsnmpget - communicates with a network entity using SNMP GET Requests. .SH SYNOPSIS7snmpget host community variable-name [variable-name]....SH DESCRIPTIONESnmpget is an SNMP application that uses the GET Request to query forDinformation on a network e CMUSNMP.SAVut,[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGET.1;2T]MAIN.C;5_@gntity. One or more fully qualified object:identifiers may be given as arguments on the command line.6Each variable name is given in the format specified in.IR variables (5)..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PP For example.PPM.I snmpget netdev-kbox.cc.cmu.edu public system.sysdescr.0 system.sysUpTime.0.PP7will retrieve the variables sysDescr.0 and sysUpTime.0:.PP.I Name: system.sysDescr.0.br,.I OCTET STRING- (ascii): Kinetics FastPath2.PP.I Name: system.sysUpTime.0.br.I Timeticks: (2270351) 6:18:23.PPJIf the network entity has an error processing the request packet, an errorPpacket will be returned and a message will be shown, helping to pinpoint in whatMway the request was malformed. If there were other variables in the request,4the request will be resent without the bad variable..PP_Adding a "-d" to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"*variables(5), RFC 1065, RFC 1066, RFC 1067 CMUSNMP.SAVvt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGETNEXT.1;2IN.C;5_'0*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGETNEXT.1;2+,v./ 4_-t0@123KPWO56@m7fAo8&ғ9FRQٓGHJ@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGL CMUSNMP.SAVvt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGETNEXT.1;2IN.C;5_IGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/%.TH SNMPGETNEXT 1 "17 September 1989".UC 4.SH NAMENsnmpgetnext - communicates with a network entity using SNMP GET NEXT Requests. .SH SYNOPSIS;snmpgetnext host community variable-name [variable-name]....SH DESCRIPTIONJSnmpget is an SNMP application that uses the GET NEXT Request to query for4information on a network entity. One or more object:identifiers may be given as arguments on the command line.6Each variable name is given in the format specified in.IR variables (5).PFor each one, the variable that is lexicographicly "next" in the remote entity'sMIB will be returned..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PP For example.PPM.I snmpgetnext netdev-kbox.cc.cmu.edu public system.sysdescr system.sysUpTime.PP7will retrieve the variables sysDescr.0 and sysUpTime.0:.PP.I Name: system.sysDescr.0.br,.I OCTET STRING- (ascii): Kinetics FastPath2.PP.I Name: system.sysUpTime.0.br.I Timeticks: (2270351) 6:18:23.PPJIf the network entity has an error processing the request packet, an errorQmessage will be shown, helping to pinpoint in what way the request was malformed..PP_Adding a "-d"  CMUSNMP.SAVvt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPGETNEXT.1;2IN.H;3_to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"*variables(5), RFC 1065, RFC 1066, RFC 10670*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2+,w./ 4O-t0@123KPWO56e7Po8i*ғ9FRQٓGHJ@.\* /***********************************************************1.\" Copyright 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that CMUSNMP.SAVwt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2IN.OBJ;1O& the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/C.\" Copyright (c) 1983 The Regents of the University of California..\" All rights reserved..\"C.\" Redistribution and use in source and binary forms are permittedC.\" 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 suchD.\" distribution and use acknowledge that the software was developed?.\" by the University of California, Berkeley. The name of theE.\" University may not be used to endorse or promote products derivedA.\" from this software without specific prior written permission.B.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS ORB.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIEDG.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A  CMUSNMP.SAVwt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2IN.OBJ;1OtPARTICULAR PURPOSE..\"(.\" @(#)netstat.1 6.8 (Berkeley) 9/20/88.\"&.TH SNMPNETSTAT 1 "September 17, 1989".UC 5.SH NAME-snmpnetstat \- show network status using SNMP .SH SYNOPSIS.B snmpnetstat.I host community[ .B \-an].br.B snmpnetstat.I host community[ .B \-inrs].br.B snmpnetstat.I host community[ .B \-n] [.B \-I .I interface] .I interval.br.B snmpnetstat.I host community[ .B \-p .I protocol].SH DESCRIPTIONThe.I snmpnetstat Ccommand symbolically displays the values of various network-relatedCinformation retrieved from a remote system using the SNMP protocol.%There are a number of output formats,7depending on the options for the information presented.@The first form of the command displays a list of active sockets.<The second form presents the values of other network-related-information according to the option selected.Using the third form, with an .I interval specified,.I snmpnetstat:will continuously display the information regarding packet-traffic on the configured network interfaces.=The fourth form displays statistics about the named protocol..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PP'The options have the following meaning:.TP.B \-aWith the default display,7show the state of all sockets; normally sock CMUSNMP.SAVwt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2IN.OBJ;1OUets used byserver processes are not shown..TP.B \-i(Show the state of all of the interfaces..TP.BI \-I " interface"+Show information only about this interface; used with an .I intervalas described below..TP.B \-n,Show network addresses as numbers (normally .I snmpnetstat1interprets addresses and attempts to display themsymbolically).8This option may be used with any of the display formats..TP.BI \-p " protocol"Show statistics about .IR protocol ,Jwhich is either a well-known name for a protocol or an alias for it. Some2protocol names and aliases are listed in the file .IR /etc/protocols .IA null response typically means that there are no interesting numbers to report.The program will complain if .I protocol7is unknown or if there is no statistics routine for it..TP.B \-sShow per-protocol statistics..TP.B \-rShow the routing tables.When.B \-s1is also present, show routing statistics instead..PP8The default display, for active sockets, shows the localand remote addresses, protocol,'and the internal state of the protocol.AAddress formats are of the form ``host.port'' or ``network.port''Gif a socket's address specifies a network but no specific host address.DWhen known the host and network addresses are displayed symbolicallyaccording to the data bases .I /etc/hostsand.IR /etc/networks ,Brespectively. If a symbolic name for an address is unknown, or ifthe .B \-nBoption is specified, the address is prin CMUSNMP.SAVwt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2IN.OBJ;1OM ted numerically, accordingto the address family.For more information regarding the Internet ``dot format,'' refer to .IR inet (3N). Unspecified,7or ``wildcard'', addresses and ports appear as ``*''. .PP4The interface display provides a table of cumulativeAstatistics regarding packets transferred, errors, and collisions.&The network addresses of the interface?and the maximum transmission unit (``mtu'') are also displayed..PP<The routing table display indicates the available routes andCtheir status. Each route consists of a destination host or networkBand a gateway to use in forwarding packets. The flags field shows;the state of the route (``U'' if ``up''), whether the routeBis to a gateway (``G''), whether the route was created dynamically>by a redirect (``D''), and whether the route has been modified:by a redirect (``M''). Direct routes are created for each%interface attached to the local host;Othe gateway field for such entries shows the address of the outgoing interface.)The interface entry indicates the network!interface utilized for the route..PPWhen .I snmpnetstatis invoked with an .I interval>argument, it displays a running count of statistics related to/network interfaces. This display consists of a column for the primary interfaceand a column summarizinginformation for all interfaces.EThe primary interface may be replaced with another interface with the.I \-Ioption.IThe first line of each screen of information contains a summar CMUSNMP.SAVwt0[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPNETSTAT.1;2IN.OBJ;1Oy since theAsystem was last rebooted. Subsequent lines of output show values(accumulated over the preceding interval. .SH SEE ALSO iostat(1), vmstat(1), hosts(5), networks(5), protocols(5), services(5),RFC1067.SH BUGS$The notion of errors is ill-defined./*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPSTATUS.1;2+,x./ 4_-t0@123KPWO56`ܹ7 do8 ?>ғ9FRQٓGHJ@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, an CMUSNMP.SAVxt/[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPSTATUS.1;2AIN.OBJ;1_6d that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/$.TH SNMPSTATUS 1 "17 September 1989".UC 4.SH NAMECsnmpstatus - Retrieves important information from a network entity. .SH SYNOPSISsnmpstatus host [community].SH DESCRIPTIONBSnmpstatus is an SNMP application that retrieves several important!statistics from a network entity..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system.AIf this argument is not given, the community name will default to .I "public"..PPThe information returned is:.PPThe IP address of the entity..br#A textual description of the entity.I (sysDescr.0).brThe uptime of the entity.I (sysUpTime.0).br-The sum of received packets on all interface CMUSNMP.SAVxt/[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPSTATUS.1;2AIN.OBJ;1_s'.I (ifInUCastPkts.* + ifInNUCastPkts.*).br0The sum of transmitted packets on all interfaces).I (ifOutUCastPkts.* + ifOutNUCastPkts.*).brThe number of IP input packets.I (ipInReceives.0).brThe number of IP output packets.I (ipOutRequests.0).PP For example.PP+.I snmpstatus netdev-kbox.cc.cmu.edu public.PP-will produce output similar to the following:.PP:.I [128.2.56.220]=>[Kinetics FastPath2] Up: 1 day, 4:43:31.br'.I IF recv/trans packets 262874/39867 |$.I IP recv/trans packets 31603/15805.PPQSnmpstatus also checks the operational status of all interfaces (ifOperStatus.*),Uand if it finds any that are not running, it will report in a manner similar to this:.PP.I 2 interfaces are down!The.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityTspecifies the community name for the transaction with the remote system. If none is%given, the community name defaults to .I "public"..PPJIf the network entity has an error processing the request packet, an errorTpacket will be returned and a message will be shown, helping to pinpoint in what wayWthe request was malformed. Snmpstatus will attempt to reform it's request to eliminateWthe malformed variable, but this variable will then be missing from the displayed data..PP_Adding a "-d" to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"RFC 1065, RFC 1066, RFC 1067 CMUSNMP.SAVyt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTEST.1;2]MAKE.COM;6ka-*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTEST.1;2+,y./ 4kp-t0@123KPWO56\7`so8`Mғ9FRQٓGHJ@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGL CMUSNMP.SAVyt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTEST.1;2]ROUTE.C;7kIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/".TH SNMPTEST 1 "17 September 1989".UC 4.SH NAMEFsnmptest - communicates with a network entity using SNMP GET Requests. .SH SYNOPSISsnmptest host community.SH DESCRIPTIONCSnmptest is a flexible SNMP application that can monitor and manage information on a network entity..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PP*After invoking the program, a command line>interpreter proceeds to accept commands. It will prompt with:.PP".I Please enter the variable name:.PPEAt this point you can enter one or more variable names, one per line.RA blank line is a command to send a request for each of the variables (in a singleTpacket) to the remote entity. Each variable name is given in the format specified in.IR variables (5). For example.PP(.I snmpget netdev-kbox.cc.cmu.edu public.br4.I Please enter the variable name: system.sysdescr.0.br#.I Please enter the variable name: .PPPWill return some information about the request and reply packets, as well as the information:.PP.I Name: system.sysDescr.0.br,.I OCTET STRING- (ascii): Kinetics FastPath2.PPXUpon startup, the program defaults to sending a GE CMUSNMP.SAVyt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTEST.1;2]ROUTE.C;7km T Request packet. This can be changed_to a GET NEXT Request or a SET Request by typing the commands "$N" or "$S" repectively. Typing*"$G" will go back to the GET Request mode..PPJThe command "$D" will toggle the dumping of each sent and received packet..PPkWhen in the "SET Request" mode, more information is requested by the prompt for each variable. The prompt:.PP'.I Please enter variable type [i|s|n]: .PP`requests the type of the variable be entered. Type "i" for an integer, "s" for an octet string,and "n" for a null value..br+At this point a value will be prompted for:.PP.I Please enter new value: .PP\If this is an integer value, just type the integer (in decimal). If it is a string, type in^white-space seperated decimal numbers, one per byte of the string. Again type a blank line at4the prompt for the variable name to send the packet..PP=At the variable name line, typing "$Q" will quit the program..PP_Adding a "-d" to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"*variables(5), RFC 1065, RFC 1066, RFC 1067 CMUSNMP.SAVzt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAP.1;2]ROUTE.C;7Z-*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAP.1;2+,z./ 4Z-t0@123KPWO56Ǻ7o8\ғ9FRQٓGHJ@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGL CMUSNMP.SAVzt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAP.1;2]ROUTE.C;7Z;IGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/".TH SNMPTRAP 1 "17 September 1989".UC 4.SH NAME/snmptrap - Send an SNMP TRAP message to a host. .SH SYNOPSISTsnmptrap host community trap-type specific-type device-description [ -a agent-addr ].SH DESCRIPTIONLsnmptrap is an SNMP application that forms and sends an SNMP TRAP message toa host..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PPThe .I trap-typeand.I specific-type>are integers that specify the type of trap message being sent..PPThe.I device-descriptionTis a textual description of the device sending this trap, to be used as the value ofLa system.sysDescr.0 variable sent in the variable list of this trap message.The optional argument.I -a agent-addrZcan be used to change the address from which the trap reports it is being sent. Otherwise#the sending host's address is used..PP For example.PP).I snmptrap nic.andrew.cmu.edu public 0 0.I 'SUN 3/60: SUNOS4.0'.PP5will send a Cold Start trap to the specified machine..PPThe defined trap types are:.TP.B 0:coldStart \- signifies that the sending protocol entity is@reinitializing itself such that the agent's configuration or CMUSNMP.SAVzt-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAP.1;2]ROUTE.C;7Z the.protocol entity implementation may be altered..TP.B 1:warmStart \- signifies that the sending protocol entity isCreinitializing itself such that neither the agent configuration nor.the protocol entity implementation is altered..TP.B 26linkDown \- signifies that the sending protocol entityErecognizes a failure in one of the communication links represented inthe agent's configuration..TP.B 34linkUp \- signifies that the sending protocol entityArecognizes that one of the communication links represented in the"agent's configuration has come up..TP.B 4<authenticationFailure \- signifies that the sending protocolBentity is the addressee of a protocol message that is not properlyDauthenticated. While implementations of the SNMP must be capable ofBgenerating this trap, they must also be capable of suppressing the@emission of such traps via an implementation-specific mechanism..TP.B 5:egpNeighborLoss \- signifies that an EGP neighbor for whomDthe sending protocol entity was an EGP peer has been marked down and(the peer relationship no longer obtains..TP.B 69enterpriseSpecific \- signifies that the sending protocolCentity recognizes that some enterprise-specific event has occurred.<The specific-trap field identifies the particular trap which occurred..PPXAdding a "-d" to the argument list will cause the application to dump the output packet..PP.SH "SEE ALSO"RFC 1065, RFC 1066, RFC 1067 CMUSNMP.SAV{t.[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAPD.1;2ROUTE.C;7_b.*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAPD.1;2+,{./ 4_-t0@123KPWO56 17Eo8lғ9FRQٓGHJ@.\* /***********************************************************1.\" Copyright 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE CMUSNMP.SAV{t.[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPTRAPD.1;2ROUTE.C;7_t OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/#.TH SNMPTRAPD 1 "17 SEPTEMBER 1989".UC 4.SH NAME/snmptrapd - Receive and log snmp trap messages. .SH SYNOPSISsnmptrapd [ -p ].SH DESCRIPTION Snmptrapd@is an SNMP application that receives and logs snmp trap messages6sent to the SNMP-TRAP port (162) on the local machine..PPIf the.B -poption is given, .I snmptrapdGwill print it's messages to the standard output. Otherwise it will use.IR syslog (8)Sto log messages. These syslog messages are sent with the level of LOG_WARNING, andNare if available (usually on 4.3 systems) are sent to the LOG_LOCAL0 facility..PP!The log messages are of the form:.br2.I Sep 17 22:39:52 suffern snmptrapd: 128.2.13.41:.I Cold Start Trap (0) Uptime:.I 8 days, 0:35:46.PP .I Snmptrapd7must be run as root so that UDP port 162 can be opened..PP_Adding a "-d" to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"5syslog(8), variables(5), RFC 1065, RFC 1066, RFC 1067 CMUSNMP.SAV|t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPWALK.1;2]ROUTE.C;7_-*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPWALK.1;2+,|./ 4_X-t0@123KPWO56`<7 o8 H{ғ9FRQٓGHJ@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGL CMUSNMP.SAV|t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPWALK.1;2]ROUTE.C;7_7IGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/".TH SNMPWALK 1 "17 September 1989".UC 4.SH NAMEKsnmpwalk - communicates with a network entity using SNMP GET Next Requests. .SH SYNOPSIS'snmpwalk host community [variable-name].SH DESCRIPTIONOSnmpwalk is an SNMP application that uses GET NEXT Requests to query for a tree&of information about a network entity..PPThe.I host>specification may be either a host name or an internet addressspecified in "dot notation".PPThe .I communityHspecifies the community name for the transaction with the remote system..PP#A variable may also be given on theMcommand line. This variable specifies which portion of the object identifierMspace will be searched using GET NEXT Requests. All variables in the subtreeLbelow the given variable are queried and their values presented to the user.6Each variable name is given in the format specified in.IR variables (5)..PP\If the "variable-name" argument is not present, snmpwalk will search the whole Internet MIB..PP For example.PP0.I snmpwalk netdev-kbox.cc.cmu.edu public system.PPIwill retrieve the variables sysDescr.0 and sysObjectID.0 and sysUpTime.0:.PP.I Name: system.sysDescr.0.br,.I OCTET STRING- (ascii): Kinetics FastPath2.PP.I Name: system.sysObjectID.0.brR.I OBJECT IDENTIFIER: .iso.org.dod.internet.pri CMUSNMP.SAV|t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMPWALK.1;2]ROUTE.OBJ;1_U=vate.enterprises.CMU.sysID.CMU-KIP.PP.I Name: system.sysUpTime.0.br.I Timeticks: (2291082) 6:21:50.PPJIf the network entity has an error processing the request packet, an errorLpacket will be returned and a message will be shown, helping to pinpoint whythe request was malformed..PPQIf the tree search causes attempts to search beyond the end of the MIB, a messagewill be displayed:.PP.I End of MIB..PP_Adding a "-d" to the argument list will cause the application to dump input and output packets..PP.SH "SEE ALSO"*variables(5), RFC 1065, RFC 1066, RFC 1067-*[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2+,}./ 4|-t0@123KPWO567@^o8@ғ9FRQٓGHJ CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1| )@.\* /***********************************************************1.\" Copyright 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/.TH SNMP_API 3 "Sept 17, 1989".UC 5.SH NAME|snmp_open, snmp_close, snmp_send, snmp_read, snmp_free_pdu, snmp_select_info, snmp_timeout \- send and receive SNMP messages .SH SYNOPSIS.B "#include .br.B "#include .br.B "#include .br.B #include """snmp.h"".b CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1|r.B #include """snmp_impl.h"".br.B #include """asn1.h"".br.B #include """snmp_api.c"".PP.B "extern int snmp_errno;.PP+.B "struct snmp_session *snmp_open(session).br!.B "struct snmp_session *session;.PP.B "int snmp_close(session).br!.B "struct snmp_session *session;.PP.B "int snmp_send(session, pdu).br!.B "struct snmp_session *session;.br.B "struct snmp_pdu *pdu;.PP.B "void snmp_read(fdset).br.B "fd_set *fdset;.PP7.B "int snmp_select_info(numfds, fdset, timeout, block).br.B "int *numfds;.br.B "fd_set *fdset;.br.B "struct timeval *timeout;.br.B "int *block;.PP.B "void snmp_timeout().PP.B "void snmp_free_pdu(pdu).br.B "struct snmp_pdu *pdu;.PP.SH DESCRIPTION.I Snmp_open, snmp_close,and .I snmp_send2each take as input a pointer to an object with the"following structure. In addition, .I snmp_open8also returns a pointer to an object with this structure.BThis structure contains information for a set of transactions that-will share similar transport characteristics..RS.PP.nf#typedef struct sockaddr_in ipaddr;struct snmp_session {> u_char *community; /* community for outgoing requests. */; int community_len; /* Length of community name. */< int retries; /* Number of retries before timeout. */X long timeout; /* Number of uS until first timeout, then exponential backoff */M char *peername; /* Domain name or dotted IP address of defaul CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1|@t peer */6 u_short remote_port;/* UDP port number of peer. */P u_short local_port; /* My UDP port number, 0 for default, picked randomly */H /* Authentication function or NULL if null authentication is used */ u_char *(*authenticator)();E int (*callback)(); /* Function to interpret incoming data */K /* Pointer to data that the callback function may consider important */ void *callback_magic;};/*Y * Set fields in session and pdu to the following to get a default or unconfigured value. */E#define SNMP_DEFAULT_COMMUNITY_LEN 0/* for default community name */##define SNMP_DEFAULT_RETRIES -1##define SNMP_DEFAULT_TIMEOUT -1"#define SNMP_DEFAULT_REMPORT 0 #define SNMP_DEFAULT_REQID 0##define SNMP_DEFAULT_ERRSTAT -1$#define SNMP_DEFAULT_ERRINDEX -1"#define SNMP_DEFAULT_ADDRESS 0&#define SNMP_DEFAULT_PEERNAME NULL(#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0#define SNMP_DEFAULT_TIME 0/*4 * This routine must be supplied by the application: *? * u_char *authenticator(pdu, length, community, community_len)8 * u_char *pdu; The rest of the PDU to be authenticatedE * int *length; The length of the PDU (updated by the authenticator)? * u_char *community; The community name to authenticate under.6 * int community_len The length of the community name. *C * Returns the authenticated pdu, or NULL if authentication failed.K * If null authentication is used, the authenticator in snmp_session can be * s CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1|% et to NULL(0). *//*4 * This routine must be supplied by the application: *6 * int callback(operation, session, reqid, pdu, magic) * int operation;D * struct snmp_session *session; The session authenticated under.; * int reqid; The request id of this pdu (0 for TRAP)1 * struct snmp_pdu *pdu; The pdu information.9 * void *magic A link to the data for this routine. *G * Returns 1 if request was successful, 0 if it should be kept pending.I * Any data in the pdu must be copied because it will be freed elsewhere. * Operations are defined below: */#define RECEIVED_MESSAGE 1#define TIMED_OUT 2.ft R.ad.fi.RE.PP .I Snmp_sendand.I snmp_free_pdu2each take as input a pointer to an object with thefollowing structure.@This structure contains information that describes a transaction,that will be performed over an open session..RS.PP.nfstruct snmp_pdu {* ipaddr address; /* Address of peer */+ int command; /* Type of this PDU */# u_long reqid; /* Request id */' u_long errstat; /* Error status */' u_long errindex; /* Error index */ /* Trap information */( oid *enterprise;/* System OID */ int enterprise_length;? ipaddr agent_addr; /* address of object generating trap */& int trap_type; /* trap type *// int specific_type; /* specific type */ u_long time; /* Uptime */$ struct variable_list *variables;};struct variable_list {H stru CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1|y ct variable_list *next_variable; /* NULL for last variable */7 oid *name; /* Object identifier of variable */; int name_length; /* number of subid's in name */. u_char type; /* ASN type of variable */# union { /* value of variable */ long *integer; u_char *string; oid *objid; } val; int val_len;};.ft R.ad.fi.RE.PP.I Snmp_read, snmp_select_info,and.I snmp_timeout'provide an interface for the use of the.IR select (2)?system call so that SNMP transactions can occur asynchronously..PP.I Snmp_select_info7is given the information that would have been passed to .I selectSin the absence of SNMP. For example, this might include window update information.SThis information is modified so that SNMP will get the service it requires from thecall to .I select. In this case,.I numfds, fdset,and .I timeoutcorrespond to the.I nfds, readfds,and .I timeout arguments to .I select,orespectively. The only exception is that timeout must always point to an allocated (but perhaps uninitialized).I struct timeval.If .I timeoutwould have been passed as NULL,.I blockis set to true, and .I timeoutAis treated as undefined. This same rule applies upon return from.I snmp_select_info..PP After calling.I snmp_select_info, select7is called with the returned data. When select returns, .I snmp_readis called with the .I fd_set returned from .I select.+This will read all SNMP socket CMUSNMP.SAV}t-[MULTINET_PLUS.MULTINET.SNMP.MAN]SNMP_API.3;2]ROUTE.OBJ;1|Vs with input.If .I select times out,.I snmp_timeout=should be called to see if the timeout was intended for SNMP..SH DIAGNOSTICS.PPError return status from .I snmp_open)is indicated by return of a null pointer.Error return status from .I snmp_closeand .I snmp_sendBis indicated by return of 0. A successful status will return a 1.The external integer.IR snmp_errno:may then be checked to see what type of error has occurred.PP.IR snmp_errnocan have the following values:.RS..IP SNMPERR_GENERR \w'SNMPERR_BAD_LOCPORT'u+2nA generic error occurred.3.IP SNMPERR_BAD_LOCPORT \w'SNMPERR_BAD_LOCPORT'u+2n2The local port was bad because it had already been#allocated or permission was denied.3.IP SNMPERR_BAD_ADDRESS \w'SNMPERR_BAD_LOCPORT'u+2n/The host name or address given was not useable.3.IP SNMPERR_BAD_SESSION \w'SNMPERR_BAD_SESSION'u+2n#The specified session was not open..RE.SH "SEE ALSO"select(2), snmp_api.h.*[MULTINET_PLUS.MULTINET.SNMP.MAN]VARIABLES.5;2+,~./ 4`~-t0@123KPWO567 o8ʶғ9FRQٓGHJ CMUSNMP.SAV~t.[MULTINET_PLUS.MULTINET.SNMP.MAN]VARIABLES.5;2ROUTE.OBJ;1`@.\* /***********************************************************7.\" Copyright 1988, 1989 by Carnegie Mellon University.\" -.\" All Rights Reserved.\" J.\" Permission to use, copy, modify, and distribute this software and its E.\" documentation for any purpose and without fee is hereby granted, J.\" provided that the above copyright notice appear in all copies and thatD.\" both that copyright notice and this permission notice appear in =.\" supporting documentation, and that the name of CMU not beF.\" used in advertising or publicity pertaining to distribution of the:.\" software without specific, written prior permission. .\" H.\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGL.\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLG.\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORG.\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,J.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,G.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE.G.\" ******************************************************************/#.TH VARIABLES 5 "17 September 1989".UC 4.SH NAMEB variables - Format of specifying variable names to SNMP tools. .SH SYNOPSIS system.sysdescr.0.SH DESCRIPTIONJVariable names are in the format of Object Identifiers (ASN.1). There are[several methods of representation. Each variable name is g CMUSNMP.SAV~t.[MULTINET_PLUS.MULTINET.SNMP.MAN]VARIABLES.5;2ROUTE.OBJ;1`9iven in the format of A.B.C.D...,Hwhere A, B, C, and D are subidentifiers in one of two forms of notation.OEach subidentifier may be encoded as a decimal integer, or a symbol as found in=the RFC1066 MIB. The case of the symbols is not significant..brHIf there is no leading "." in the variable name, the name will be formedMas if having been preceded with "iso.org.dod.internet.mgmt.mib.". A "." mustMbe placed before the first variable if the user is to fully specify the name. For example:.PP,.I 1.1.0 system.sysDescr.0 and 1.sysDescr.0.PP/all refer to the same variable name. Likewise:.PP`.I .1.3.6.1.2.1.1.1.0 .iso.org.dod.internet.mgmt.mib.system.sysdescr.0 .1.3.6.1.2.1.1.sysdescr.0.PP$All refer to the same variable name..PPDThe description of the variables in the MIB is given in a file named .I "mib.txt"Gin the current directory or in a file named in the environment variable.I "MIBFILE" or in.I "/etc/mib.txt".]These files are searched in the above order. The files are in the ASN.1 notation and use the^OBJECT TYPE macro defined in RFC 1065. Most of the file describing the RFC 1066 MIB is pulledout of RFC 1066 without change..SH "SEE ALSO"0RFC 1065, RFC 1066, RFC 1067, ISO IS 8824(ASN.1).SH BUGSThe parser of the .I "mib.txt"`file is not expected to handle bizarre (although correct) interpretations of the ASN.1 notation. CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]ROUTE.OBJ;1MU֫&*[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2+,.U/ 4MUM-E0@123KPWOV56`7@-o86I9FRQٓGHDJM mgmt OBJECT IDENTIFIER ::= { iso org(3) dod(6) internet(1) mgmt(2) }= mib OBJECT IDENTIFIER ::= { mgmt 1 }3 directory OBJECT IDENTIFIER ::= { internet 1 }7 experimental OBJECT IDENTIFIER ::= { internet 3 }3 private OBJECT IDENTIFIER ::= { internet 4 }3 enterprises OBJECT IDENTIFIER ::= { private 1 }< system OBJECT IDENTIFIER ::= { mib 1 }< interfaces OBJECT IDENTIFIER ::= { mib 2 }< at OBJECT IDENTIFIER ::= { mib 3 }< ip OBJECT IDENTIFIER ::= { mib 4 }< icmp OBJECT IDENTIFIER ::= { mib 5 }< tcp OBJECT IDENTIFIER ::= { mib 6 }< udp OBJECT IDENTIFIER ::= { mib 7 }< egp OBJECT IDENTIFIER ::= { mib 8 }! -- object types% -- the System group& sysDescr OBJECT-TYPE. SYNTAX OCTE CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]ROUTE.OBJ;1MUK2T STRING+ ACCESS read-only+ STATUS mandatory* ::= { system 1 }) sysObjectID OBJECT-TYPE3 SYNTAX OBJECT IDENTIFIER+ ACCESS read-only+ STATUS mandatory* ::= { system 2 }' sysUpTime OBJECT-TYPE+ SYNTAX TimeTicks+ ACCESS read-only+ STATUS mandatory* ::= { system 3 }) -- the Interfaces group& ifNumber OBJECT-TYPE) SYNTAX INTEGER+ ACCESS read-only+ STATUS mandatory. ::= { interfaces 1 }) -- the Interfaces table% ifTable OBJECT-TYPE5 SYNTAX SEQUENCE OF IfEntry, ACCESS read-write+ STATUS mandatory. ::= { interfaces 2 }% ifEntry OBJECT-TYPE) SYNTAX IfEntry, ACCESS read-write+ STATUS mandatory+ ::= { ifTable 1 }( IfEntry ::= SEQUENCE { ifIndex" INTEGER, ifDescr'  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUp OCTET STRING, ifType" INTEGER, ifMtu" INTEGER, ifSpeed Gauge,# ifPhysAddress' OCTET STRING,# ifAdminStatus" INTEGER," ifOperStatus" INTEGER," ifLastChange$ TimeTicks, ifInOctets" Counter,# ifInUcastPkts" Counter,$ ifInNUcastPkts" Counter," ifInDiscards" Counter, ifInErrors" Counter,' ifInUnknownProtos" Counter,! ifOutOctets" Counter,$ ifOutUcastPkts" Counter,% ifOutNUcastPkts" Counter,# ifOutDiscards" Counter,! ifOutErrors" Counter, ifOutQLen Gauge }% ifIndex OBJECT-TYPE) SYNTAX INTEGER+  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUw ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 1 }% ifDescr OBJECT-TYPE. SYNTAX OCTET STRING+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 2 }$ ifType OBJECT-TYPE+ SYNTAX INTEGER {H other(1), -- none of the following1 regular1822(2),- hdh1822(3),- ddn-x25(4),0 rfc877-x25(5),5 ethernet-csmacd(6),5 iso88023-csmacd(7),7 iso88024-tokenBus(8),8 iso88025-tokenRing(9),3 iso88026-man(10),. starLan(11),5 proteon-10MBit(12),5 proteon-80MBit(13),3 hyperchannel(14),+ fddi(15),+ lapb(16),+ sdlc(17),1 t1-carrier(18),+ cept(19),0 basicIsdn(20),2 primaryIsdn(21 CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUI ),H -- proprietary serial< propPointToPointSerial(22) }+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 3 }# ifMtu OBJECT-TYPE) SYNTAX INTEGER+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 4 }% ifSpeed OBJECT-TYPE' SYNTAX Gauge+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 5 }+ ifPhysAddress OBJECT-TYPE. SYNTAX OCTET STRING+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 6 }+ ifAdminStatus OBJECT-TYPE+ SYNTAX INTEGER {H up(1), -- ready to pass packets* down(2),D testing(3) -- in some test mode# }, ACCESS read-write+ STATUS mandatory+ ::= { ifEntry 7 }* ifOperStatus OBJECT-TYPE+ SYNTAX INTEGER  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU{H up(1), -- ready to pass packets* down(2),D testing(3) -- in some test mode# }+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 8 }* ifLastChange OBJECT-TYPE+ SYNTAX TimeTicks+ ACCESS read-only+ STATUS mandatory+ ::= { ifEntry 9 }( ifInOctets OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 10 }+ ifInUcastPkts OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory- ::= { ifEntry 11 }, ifInNUcastPkts OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 12 }* ifInDiscards OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 13 }( if CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUInErrors OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 14 }/ ifInUnknownProtos OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 15 }) ifOutOctets OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 16 }, ifOutUcastPkts OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 17 }- ifOutNUcastPkts OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 18 }+ ifOutDiscards OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 19 }) ifOutErrors OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandator  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUxy, ::= { ifEntry 20 }' ifOutQLen OBJECT-TYPE' SYNTAX Gauge+ ACCESS read-only+ STATUS mandatory, ::= { ifEntry 21 }2 -- the Address Translation group% atTable OBJECT-TYPE5 SYNTAX SEQUENCE OF AtEntry, ACCESS read-write+ STATUS mandatory& ::= { at 1 }% atEntry OBJECT-TYPE) SYNTAX AtEntry, ACCESS read-write+ STATUS mandatory+ ::= { atTable 1 }( AtEntry ::= SEQUENCE { atIfIndex" INTEGER,# atPhysAddress' OCTET STRING," atNetAddress( NetworkAddress }' atIfIndex OBJECT-TYPE) SYNTAX INTEGER, ACCESS read-write+ STATUS mandatory+ ::= { atEntry 1 }+ atPhysAddress OBJECT-TYPE. SYNTAX OCTET STRING, ACCESS read-write+ STATUS mandatory+ ::= { atEntry 2 }  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU* atNetAddress OBJECT-TYPE0 SYNTAX NetworkAddress, ACCESS read-write+ STATUS mandatory+ ::= { atEntry 3 }! -- the IP group* ipForwarding OBJECT-TYPE+ SYNTAX INTEGER {@ gateway(1), -- entity forwards datagramsH host(2) -- entity does NOT forward datagrams# }+ ACCESS read-only+ STATUS mandatory& ::= { ip 1 }* ipDefaultTTL OBJECT-TYPE) SYNTAX INTEGER, ACCESS read-write+ STATUS mandatory& ::= { ip 2 }* ipInReceives OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 3 }+ ipInHdrErrors OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 4 }, ipInAddrErrors OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory&   CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUAn ::= { ip 5 }- ipForwDatagrams OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 6 }/ ipInUnknownProtos OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 7 }* ipInDiscards OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 8 }* ipInDelivers OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory& ::= { ip 9 }+ ipOutRequests OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 10 }+ ipOutDiscards OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 11 }+ ipOutNoRoutes OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+   CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUb STATUS mandatory' ::= { ip 12 }, ipReasmTimeout OBJECT-TYPE) SYNTAX INTEGER+ ACCESS read-only+ STATUS mandatory' ::= { ip 13 }* ipReasmReqds OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 14 }( ipReasmOKs OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 15 }* ipReasmFails OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 16 }' ipFragOKs OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 17 }) ipFragFails OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory' ::= { ip 18 }+ ipFragCreates OBJECT-TYPE) SYNTAX Counter+ ACCESS  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU ! read-only + STATUS mandatory ' ::= { ip 19 } + -- the IP Interface table ) ipAddrTable OBJECT-TYPE 9 SYNTAX SEQUENCE OF IpAddrEntry + ACCESS read-onlyt+ STATUS mandatory ' ::= { ip 20 }y) ipAddrEntry OBJECT-TYPE - SYNTAX IpAddrEntry{+ ACCESS read-only + STATUS mandatoryp/ ::= { ipAddrTable 1 } , IpAddrEntry ::= SEQUENCE {! ipAdEntAddrO$ IpAddress,$ ipAdEntIfIndex" INTEGER,$ ipAdEntNetMask$ IpAddress,& ipAdEntBcastAddr! INTEGERr } ) ipAdEntAddr OBJECT-TYPE + SYNTAX IpAddress + ACCESS read-only + STATUS mandatory 0 ::= { ipAddrEntry 1 }, ipAdEntIfIndex OBJECT-TYPE) SYNTAX INTEGER + ACCESS read-only + STATUS mandatory 0 ::= { ipAddrEntry 2 }, ipAdEntNetMask OBJECT-TYPE+  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU$ SYNTAX IpAddress + ACCESS read-only + STATUS mandatory 0 ::= { ipAddrEntry 3 }. ipAdEntBcastAddr OBJECT-TYPE) SYNTAX INTEGERC+ ACCESS read-onlyT+ STATUS mandatory:/ ::= { ipAddrEntry 4 }t) -- the IP Routing tableB, ipRoutingTable OBJECT-TYPE: SYNTAX SEQUENCE OF IpRouteEntry, ACCESS read-write+ STATUS mandatoryc' ::= { ip 21 }T* ipRouteEntry OBJECT-TYPE. SYNTAX IpRouteEntry, ACCESS read-write+ STATUS mandatory 2 ::= { ipRoutingTable 1 }- IpRouteEntry ::= SEQUENCE { ! ipRouteDest $ IpAddress,$ ipRouteIfIndex" INTEGER,$ ipRouteMetric1" INTEGER,$ ipRouteMetric2" INTEGER,$ ipRouteMetric3" INTEGER,$ ipRouteMetric4" INTEGER,$ ipRouteNextHop$ IpAddress,! ipRouteType "  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU3' INTEGER," ipRouteProto" INTEGER, ipRouteAge! INTEGER  }n) ipRouteDest OBJECT-TYPE,+ SYNTAX IpAddress , ACCESS read-write+ STATUS mandatoryn0 ::= { ipRouteEntry 1 }- ipRouteIfIndex OBJECT-TYPE ) SYNTAX INTEGER , ACCESS read-write+ STATUS mandatory 0 ::= { ipRouteEntry 2 }, ipRouteMetric1 OBJECT-TYPE) SYNTAX INTEGER, ACCESS read-write+ STATUS mandatory 0 ::= { ipRouteEntry 3 }, ipRouteMetric2 OBJECT-TYPE) SYNTAX INTEGERT, ACCESS read-write+ STATUS mandatoryS0 ::= { ipRouteEntry 4 }, ipRouteMetric3 OBJECT-TYPE) SYNTAX INTEGER , ACCESS read-write+ STATUS mandatoryd0 ::= { ipRouteEntry 5 }, ipRouteMetric4 OBJECT-TYPE) SYNTAX INTEGER , ACCESS read-write+ ST CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUQ*ATUS mandatory 0 ::= { ipRouteEntry 6 }, ipRouteNextHop OBJECT-TYPE+ SYNTAX IpAddress , ACCESS read-write+ STATUS mandatory 0 ::= { ipRouteEntry 7 }) ipRouteType OBJECT-TYPE4+ SYNTAX INTEGER { C other(1), -- none of the following6B invalid(2), -- an invalidated route? -- route to directly E direct(3), -- connected (sub-)networkeB -- route to a non-localF remote(4), -- host/network/sub-network } , ACCESS read-write+ STATUS mandatory 0 ::= { ipRouteEntry 8 }* ipRouteProto OBJECT-TYPE+ SYNTAX INTEGER {rB other(1), -- none of the followingE -- non-protocol informationC= -- e.g., manuallyA local(2), -- configured entriesf> -- set via a networkB netmgmt(3), -- management protocol?  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUR- -- obtained via ICMP,= icmp(4), -- e.g., Redirect > -- the following areF -- gateway routing protocols# egp(5), # ggp(6), % hello(7), # rip(8),o% is-is(9), & es-is(10),* ciscoIgrp(11),* bbnSpfIgp(12),$ oigp(13) } + ACCESS read-only + STATUS mandatory 0 ::= { ipRouteEntry 9 }( ipRouteAge OBJECT-TYPE) SYNTAX INTEGER , ACCESS read-write+ STATUS mandatory 1 ::= { ipRouteEntry 10 } # -- the ICMP group ( icmpInMsgs OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatorye( ::= { icmp 1 }* icmpInErrors OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory( ::= { icmp 2 }0 icmpInDestUnreachs OBJECT-TYPE)  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU"0 SYNTAX Counter+ ACCESS read-only+ STATUS mandatory ( ::= { icmp 3 }- icmpInTimeExcds OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ( ::= { icmp 4 }- icmpInParmProbs OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only+ STATUS mandatoryE( ::= { icmp 5 }. icmpInSrcQuenchs OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only}+ STATUS mandatoryE( ::= { icmp 6 }- icmpInRedirects OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only}+ STATUS mandatory( ::= { icmp 7 }) icmpInEchos OBJECT-TYPE) SYNTAX Counterr+ ACCESS read-only4+ STATUS mandatoryE( ::= { icmp 8 }, icmpInEchoReps OBJECT-TYPE) SYNTAX Counter + ACCESS read-onlyf+ STATUS mandatoryB( ::= { icmp 9 CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MUk3 }. icmpInTimestamps OBJECT-TYPE) SYNTAX Counter + ACCESS read-onlyf+ STATUS mandatorys) ::= { icmp 10 }T1 icmpInTimestampReps OBJECT-TYPEo) SYNTAX Counterd+ ACCESS read-onlyr+ STATUS mandatoryB) ::= { icmp 11 }X- icmpInAddrMasks OBJECT-TYPEd) SYNTAX Countera+ ACCESS read-onlyn+ STATUS mandatoryB) ::= { icmp 12 }X0 icmpInAddrMaskReps OBJECT-TYPE) SYNTAX Counterd+ ACCESS read-onlyr+ STATUS mandatoryT) ::= { icmp 13 }o) icmpOutMsgs OBJECT-TYPEd) SYNTAX Countera+ ACCESS read-onlyn+ STATUS mandatoryT) ::= { icmp 14 }a+ icmpOutErrors OBJECT-TYPEl) SYNTAX Countert+ ACCESS read-only + STATUS mandatorys) ::= { icmp 15 }B1 icmpOutDestUnreachs OBJECT-TYPEE) SYNTAX CounterE+ ACCESS read-onlyT+  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.EXE;1MU6 STATUS mandatory ) ::= { icmp 16 }T. icmpOutTimeExcds OBJECT-TYPE) SYNTAX Counteri+ ACCESS read-onlyr+ STATUS mandatory ) ::= { icmp 17 }E. icmpOutParmProbs OBJECT-TYPE) SYNTAX Counter + ACCESS read-onlyC+ STATUS mandatorye) ::= { icmp 18 }s/ icmpOutSrcQuenchs OBJECT-TYPEe) SYNTAX CounterY+ ACCESS read-onlyE+ STATUS mandatoryT) ::= { icmp 19 }:. icmpOutRedirects OBJECT-TYPE) SYNTAX CounterY+ ACCESS read-only + STATUS mandatory ) ::= { icmp 20 } * icmpOutEchos OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ) ::= { icmp 21 } - icmpOutEchoReps OBJECT-TYPE ) SYNTAX Counterw+ ACCESS read-only + STATUS mandatorya) ::= { icmp 22 } / icmpOutTimestamps OBJECT-TYPEf)  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2NETSTAT]SNMPNETSTAT.OPT;2MU 9 SYNTAX Counter + ACCESS read-only + STATUS mandatory ) ::= { icmp 23 } 2 icmpOutTimestampReps OBJECT-TYPE) SYNTAX Counter+ ACCESS read-only+ STATUS mandatory) ::= { icmp 24 } . icmpOutAddrMasks OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ) ::= { icmp 25 } 1 icmpOutAddrMaskReps OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ) ::= { icmp 26 }p" -- the TCP group- tcpRtoAlgorithm OBJECT-TYPE + SYNTAX INTEGER { ? other(1), -- none of the following}8 constant(2), -- a constant rtoB rsre(3), -- MIL-STD-1778, Appendix BG vanj(4) -- Van Jacobson's algorithm [11] # } + ACCESS read-only + STATUS mandatory ' ::= { tcp 1 } ' tcpRtoMin OBJECT-TYPE) SYNTAX INTEGER +  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MU< ACCESS read-only + STATUS mandatory ' ::= { tcp 2 } ' tcpRtoMax OBJECT-TYPE) SYNTAX INTEGER + ACCESS read-only + STATUS mandatory ' ::= { tcp 3 } ( tcpMaxConn OBJECT-TYPE) SYNTAX INTEGER + ACCESS read-only + STATUS mandatory ' ::= { tcp 4 }, tcpActiveOpens OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { tcp 5 }- tcpPassiveOpens OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { tcp 6 } - tcpAttemptFails OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { tcp 7 } , tcpEstabResets OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { tcp 8 } * tcpCurrEstab OBJECT-TYPE'  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MU&?SYNTAX Gauge + ACCESS read-only + STATUS mandatory ' ::= { tcp 9 } ' tcpInSegs OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ( ::= { tcp 10 }( tcpOutSegs OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ( ::= { tcp 11 }, tcpRetransSegs OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ( ::= { tcp 12 }. -- the TCP connections table* tcpConnTable OBJECT-TYPE: SYNTAX SEQUENCE OF TcpConnEntry+ ACCESS read-onlyC+ STATUS mandatoryT( ::= { tcp 13 }* tcpConnEntry OBJECT-TYPE. SYNTAX TcpConnEntry+ ACCESS read-onlyY+ STATUS mandatory 0 ::= { tcpConnTable 1 }- TcpConnEntry ::= SEQUENCE { " tcpConnState" INTEGER,) tcpConnLocalAddress $  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MUB IpAddress,& tcpConnLocalPort- INTEGER (0..65535),d' tcpConnRemAddressn$ IpAddress,$ tcpConnRemPort, INTEGER (0..65535) } * tcpConnState OBJECT-TYPE+ SYNTAX INTEGER {d0 closed(1),0 listen(2),1 synSent(3),5 synReceived(4), 5 established(5), 2 finWait1(6),2 finWait2(7),3 closeWait(8), 1 lastAck(9),l2 closing(10),2 timeWait(11)# }-+ ACCESS read-onlyr+ STATUS mandatoryo0 ::= { tcpConnEntry 1 }1 tcpConnLocalAddress OBJECT-TYPE+ SYNTAX IpAddressE+ ACCESS read-only+ STATUS mandatory0 ::= { tcpConnEntry 2 }. tcpConnLocalPort OBJECT-TYPE4 SYNTAX INTEGER (0..65535)+ ACCESS read-only +  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MU E STATUS mandatoryt0 ::= { tcpConnEntry 3 }/ tcpConnRemAddress OBJECT-TYPE + SYNTAX IpAddress + ACCESS read-only + STATUS mandatory 0 ::= { tcpConnEntry 4 }, tcpConnRemPort OBJECT-TYPE4 SYNTAX INTEGER (0..65535)+ ACCESS read-only + STATUS mandatory 0 ::= { tcpConnEntry 5 }" -- the UDP group, udpInDatagrams OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatoryi' ::= { udp 1 } ( udpNoPorts OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatoryp' ::= { udp 2 } ) udpInErrors OBJECT-TYPE ) SYNTAX Counter + ACCESS read-onlyE+ STATUS mandatory ' ::= { udp 3 } - udpOutDatagrams OBJECT-TYPE ) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { udp 4 } " -- t CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MU.Hhe EGP group' egpInMsgs OBJECT-TYPEe) SYNTAX Counterr+ ACCESS read-onlyt+ STATUS mandatoryJ' ::= { egp 1 }T) egpInErrors OBJECT-TYPES) SYNTAX CounterT+ ACCESS read-only + STATUS mandatoryt' ::= { egp 2 } ( egpOutMsgs OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { egp 3 } * egpOutErrors OBJECT-TYPE) SYNTAX Counter + ACCESS read-only + STATUS mandatory ' ::= { egp 4 }E+ -- the EGP Neighbor table + egpNeighTable OBJECT-TYPE ; SYNTAX SEQUENCE OF EgpNeighEntry + ACCESS read-only + STATUS mandatory ' ::= { egp 5 } + egpNeighEntry OBJECT-TYPE / SYNTAX EgpNeighEntry + ACCESS read-only + STATUS mandatory 1 ::= { egpNeighTable 1 } . EgpNeighEntry ::= SEQUENCE {# egpNeighStatei"  CMUSNMP.SAVE&[MULTINET_PLUS.MULTINET.SNMP]MIB.TXT;2STATUS.C;3MUK INTEGER," egpNeighAddr# IpAddress  }i+ egpNeighState OBJECT-TYPE + SYNTAX INTEGER {t. idle(1),5 acquisition(2), . down(3),, up(4),. cease(5)# } + ACCESS read-only + STATUS mandatory 1 ::= { egpNeighEntry 1 }* egpNeighAddr OBJECT-TYPE+ SYNTAX IpAddress + ACCESS read-only + STATUS mandatoryc1 ::= { egpNeighEntry 2 } / cmu OBJECT IDENTIFIER ::= { enterprises 3 } + systems OBJECT IDENTIFIER ::= { cmu 1 }c( mibs OBJECT IDENTIFIER ::= { cmu 2 }/ cmuSNMP OBJECT IDENTIFIER ::= { systems 1 } . cmuKip OBJECT IDENTIFIER ::= { systems 2 }1 cmuRouter OBJECT IDENTIFIER ::= { systems 3 }ong areF -- gateway routing protocols# egp(5), # ggp(6), % hello(7), # rip(8),o% is-is(9), & es-is(10),* ciscoIgrp(11),*  CMUSNMP.SAVE*[MULTINET_PLUS.MULTINET.SNMP]SNMPLIB.DIR;1US.C;3**[MULTINET_PLUS.MULTINET.SNMP]SNMPLIB.DIR;1+,./ 4-E0123 KPWO56 `7p8+ 9FRQٓGHDJI $M$AKEFILE.ASN1.CASN1.HASN1.OBJJ DEVICE_TRANSLATION.C "DEVICE_TRANSLATION.OBJK  LIBSNMP.OLB KMAKE.COM[MIB.CMIB.HMIB.OBJJ PARSE.CPARSE.H PARSE.OBJJ SNMP.CSNMP.HSNMP.OBJJ  SNMP_AGENT.CSNMP_AGENT.OBJJ SNMP_AGENT.OPT SNMP_AGENT.ORIG SNMP_API.C SNMP_API.H SNMP_API.OBJJ SNMP_AUTH.C SNMP_AUTH.OBJJ  SNMP_CLIENT.C SNMP_CLIENT.HSNMP_CLIENT.OBJJ SNMP_IMPL.H SNMP_VARS.C SNMP_VARS.H  CMUSNMP.SAVE*[MULTINET_PLUS.MULTINET.SNMP]SNMPLIB.DIR;1US.EXE;14  SNMP_VARS.OBJK SNMP_VAR_ARP.CSNMP_VAR_ARP.OBJ K+ SNMP_VAR_MULTINET.C"SNMP_VAR_MULTINET.OBJK SNMP_VAR_ROUTE.CSNMP_VAR_ROUTE.OBJK VMSIO.C VMSIO.OBJK!2*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]$M$AKEFILE.;2+,. / 4G -0@123KPWO 56`7`=o8`ߌғ9FRQٓGHJ## Makefile for snmplib#TARG= libsnmp.aGCSRCS= snmp_client.c snmp.c snmp_auth.c asn1.c mib.c parse.c snmp_api.cFOBJS= snmp_client.o snmp.o snmp_auth.o asn1.o mib.o parse.o snmp_api.o CFLAGS=-O all: $(TARG)libsnmp.a: ${OBJS} ar r libsnmp.a ${OBJS} ranlib libsnmp.alint: lint -nhx $(CSRCS)clean: rm -f ${OBJS} ${TARG}asn1.o: ./asn1.hmib.o: ./asn1.hmib.o: ./snmp_impl.hmib.o: ./snmp_api.hmib.o: ./parse.hparse.o: ./parse.hsnmp.o: ./asn1.hsnmp.o: ./ CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]$M$AKEFILE.;2G vsnmp.hsnmp.o: ./snmp_impl.hsnmp.o: ./mib.hsnmp.o: ./snmp_vars.hsnmp_api.o: ./asn1.hsnmp_api.o: ./snmp.hsnmp_api.o: ./snmp_impl.hsnmp_api.o: ./snmp_api.hsnmp_auth.o: ./asn1.hsnmp_auth.o: ./snmp.hsnmp_auth.o: ./snmp_impl.hsnmp_client.o: ./asn1.hsnmp_client.o: ./snmp.hsnmp_client.o: ./snmp_impl.hsnmp_client.o: ./snmp_api.hsnmp_client.o: ./snmp_client.h-*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2+,.-/ 4c-&d-0@123KPWO.56`7o89FRQٓGHJ/*& * Abstract Syntax Notation One, ASN.1, * As defined in ISO/IS 8824 and ISO/IS 8825E * This implements a subset of the above International Standards that# * is sufficient to implement SNMP. *J * Encodes abstract data types into a machine independent stream of bytes. * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University) All Rights ReservedFPermission to use, copy, modify, and distribute this sof CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-Etware 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 notice 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******************************************************************/#ifdef KINETICS#include "gw.h"#endif)#if (defined(unix) && !defined(KINETICS))#include #include #endif#include "asn1.h" #ifndef NULL#define NULL 0#endif#define ERROR(x)/*7 * asn_parse_int - pulls a long out of an ASN int type.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes& * following the end of this object. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error.  CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-# */u_char *4asn_parse_int(data, datalength, type, intp, intsize)D register u_char *data; /* IN - pointer to start of object */T register int *datalength;/* IN/OUT - number of valid bytes left in buffer */5 u_char *type; /* OUT - asn type of object */E long *intp; /* IN/OUT - pointer to start of output buffer */: int intsize; /* IN - size of output buffer */{/*0 * ASN.1 integer ::= 0x02 asnlength byte {byte}* */! register u_char *bufp = data; u_long asn_length; register long value = 0;" if (intsize != sizeof (long)){ ERROR("not long"); return NULL; } *type = *bufp++;/ bufp = asn_parse_length(bufp, &asn_length); if (bufp == NULL){ ERROR("bad length"); return NULL; }2 if (asn_length + (bufp - data) > *datalength){ ERROR("overflow of message"); return NULL; } if (asn_length > intsize){. ERROR("I don't support such large integers"); return NULL; }3 *datalength -= (int)asn_length + (bufp - data); if (*bufp & 0x80)& value = -1; /* integer is negative */ while(asn_length--) value = (value << 8) | *bufp++; *intp = value; return bufp;}/*> * asn_build_int - builds an ASN object containing an integer.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes& * following the end of this object. *4 * Returns a pointer to the first byte pa! CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-Ost the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */u_char *4asn_build_int(data, datalength, type, intp, intsize)G register u_char *data; /* IN - pointer to start of output buffer */S register int *datalength;/* IN/OUT - number of valid bytes left in buffer */2 u_char type; /* IN - asn type of object */F register long *intp; /* IN - pointer to start of long integer */8 register int intsize; /* IN - size of *intp */{/*0 * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ register long integer; register u_long mask;! if (intsize != sizeof (long)) return NULL; integer = *intp; /*c * Truncate "unnecessary" bytes off of the most significant end of this 2's complement integer.a * There should be no sequence of 9 consecutive 1's or 0's at the most significant end of the * integer. */3 mask = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);4 /* mask is 0xFF800000 on a big-endian machine */R while((((integer & mask) == 0) || ((integer & mask) == mask)) && intsize > 1){ intsize--; integer <<= 8; }= data = asn_build_header(data, datalength, type, intsize); if (data == NULL) return NULL; if (*datalength < intsize) return NULL; *datalength -= intsize;, mask = 0xFF << (8 * (sizeof(long) - 1));4 /* mask is 0xFF000000 on a big-endian machine */ while(intsize--){B *data++ = (u_char)((integer & mask) >> (8 * (si" CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c- zeof(long) - 1))); integer <<= 8; } return data;}/*L * asn_parse_string - pulls an octet string out of an ASN octet string type.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * following the beginning of the next object. *- * "string" is filled with the octet string. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */u_char *;asn_parse_string(data, datalength, type, string, strlength)? u_char *data; /* IN - pointer to start of object */W register int *datalength; /* IN/OUT - number of valid bytes left in buffer */8 u_char *type; /* OUT - asn type of object */L u_char *string; /* IN/OUT - pointer to start of output buffer */H register int *strlength; /* IN/OUT - size of output buffer */{/*1 * ASN.1 octet string ::= primstring | cmpdstring- * primstring ::= 0x04 asnlength byte {byte}*1 * cmpdstring ::= 0x24 asnlength string {string}*0 * This doesn't yet support the compound string. */! register u_char *bufp = data; u_long asn_length; *type = *bufp++;/ bufp = asn_parse_length(bufp, &asn_length); if (bufp == NULL) return NULL;2 if (asn_length + (bufp - data) > *datalength){ ERROR("overflow of message"); return NULL; }! if (asn_length > *strlength){, ERROR("# CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-<I don't support such long strings"); return NULL; }9 bcopy((char *)bufp, (char *)string, (int)asn_length);! *strlength = (int)asn_length;3 *datalength -= (int)asn_length + (bufp - data); return bufp + asn_length;}/*T * asn_build_string - Builds an ASN octet string object containing the input string.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * following the beginning of the next object. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */u_char *;asn_build_string(data, datalength, type, string, strlength)? u_char *data; /* IN - pointer to start of object */W register int *datalength; /* IN/OUT - number of valid bytes left in buffer */6 u_char type; /* IN - ASN type of string */G u_char *string; /* IN - pointer to start of input buffer */B register int strlength; /* IN - size of input buffer */{/*1 * ASN.1 octet string ::= primstring | cmpdstring- * primstring ::= 0x04 asnlength byte {byte}*1 * cmpdstring ::= 0x24 asnlength string {string}*/ * This code will never send a compound string. */? data = asn_build_header(data, datalength, type, strlength); if (data == NULL) return NULL; if (*datalength < strlength) return NULL;3 bcopy((char *)string, (char *)data, strlength)$ CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-Q0; *datalength -= strlength; return data + strlength;}/*I * asn_parse_header - interprets the ID and length of the current object.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * in this object following the id and length. *G * Returns a pointer to the first byte of the contents of this object. * Returns NULL on any error. */u_char *(asn_parse_header(data, datalength, type); u_char *data; /* IN - pointer to start of object */L int *datalength;/* IN/OUT - number of valid bytes left in buffer */4 u_char *type; /* OUT - ASN type of object */{! register u_char *bufp = data; register header_len; u_long asn_length;F /* this only works on data types < 30, i.e. no extension octets */ if (IS_EXTENSION_ID(*bufp)){! ERROR("can't process ID >= 30"); return NULL; } *type = *bufp;3 bufp = asn_parse_length(bufp + 1, &asn_length); if (bufp == NULL) return NULL; header_len = bufp - data;/ if (header_len + asn_length > *datalength){ ERROR("asn length too long"); return NULL; }" *datalength = (int)asn_length; return bufp;}/*H * asn_build_header - builds an ASN header for an object with the ID and * length specified.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * in % CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-̩this object following the id and length. *A * This only works on data types < 30, i.e. no extension octets.! * The maximum length is 0xFFFF; *G * Returns a pointer to the first byte of the contents of this object. * Returns NULL on any error. */u_char *0asn_build_header(data, datalength, type, length)@ register u_char *data; /* IN - pointer to start of object */L int *datalength;/* IN/OUT - number of valid bytes left in buffer */2 u_char type; /* IN - ASN type of object */0 int length; /* IN - length of object */{ if (*datalength < 1) return NULL; *data++ = type; (*datalength)--;6 return asn_build_length(data, datalength, length); }/*B * asn_parse_length - interprets the length of the current object.< * On exit, length contains the value of this length field. *9 * Returns a pointer to the first byte after this length- * field (aka: the start of the data field). * Returns NULL on any error. */u_char *asn_parse_length(data, length)> u_char *data; /* IN - pointer to start of length field */6 u_long *length; /* OUT - value of length field */{' register u_char lengthbyte = *data;# if (lengthbyte & ASN_LONG_LEN){0 lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */ if (lengthbyte == 0){2 ERROR("We don't support indefinite lengths"); return NULL; } if (lengthbyte > sizeof(long)){6 ERROR("we can't support data lengths that long"); return NULL; }: bcopy((ch& CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-hCar *)data + 1, (char *)length, (int)lengthbyte); *length = ntohl(*length);3 *length >>= (8 * ((sizeof *length) - lengthbyte)); return data + lengthbyte + 1;" } else { /* short asnlength */ *length = (long)lengthbyte; return data + 1; }}u_char **asn_build_length(data, datalength, length)@ register u_char *data; /* IN - pointer to start of object */L int *datalength;/* IN/OUT - number of valid bytes left in buffer */7 register int length; /* IN - length of object */{! u_char *start_data = data;$ /* no indefinite lengths sent */ if (length < 0x80){ *data++ = (u_char)length; } else if (length <= 0xFF){) *data++ = (u_char)(0x01 | ASN_LONG_LEN); *data++ = (u_char)length;* } else { /* 0xFF < length <= 0xFFFF */) *data++ = (u_char)(0x02 | ASN_LONG_LEN);* *data++ = (u_char)((length >> 8) & 0xFF);# *data++ = (u_char)(length & 0xFF); }+ if (*datalength < (data - start_data)){ ERROR("build_length"); return NULL; }' *datalength -= (data - start_data); return data;}/*V * asn_parse_objid - pulls an object indentifier out of an ASN object identifier type.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * following the beginning of the next object. *1 * "objid" is filled with the object identifier. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start ' CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-of the next object). * Returns NULL on any error. */u_char *;asn_parse_objid(data, datalength, type, objid, objidlength)? u_char *data; /* IN - pointer to start of object */P int *datalength; /* IN/OUT - number of valid bytes left in buffer */8 u_char *type; /* OUT - ASN type of object */I oid *objid; /* IN/OUT - pointer to start of output buffer */I int *objidlength; /* IN/OUT - number of sub-id's in objid */{/*@ * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*, * subidentifier ::= {leadingbyte}* lastbyte * leadingbyte ::= 1 7bitvalue * lastbyte ::= 0 7bitvalue */! register u_char *bufp = data;# register oid *oidp = objid + 1;" register u_long subidentifier; register long length; u_long asn_length; *type = *bufp++;/ bufp = asn_parse_length(bufp, &asn_length); if (bufp == NULL) return NULL;2 if (asn_length + (bufp - data) > *datalength){ ERROR("overflow of message"); return NULL; }3 *datalength -= (int)asn_length + (bufp - data); length = asn_length;? (*objidlength)--; /* account for expansion of first byte *// while (length > 0 && (*objidlength)-- > 0){ subidentifier = 0;- do { /* shift and add in low order 7 bits */J subidentifier = (subidentifier << 7) + (*(u_char *)bufp & ~ASN_BIT8); length--;K } while (*(u_char *)bufp++ & ASN_BIT8); /* last byte has high bit clear */ if (subidentifier > MAX_SUBID( CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-Z){% ERROR("subidentifier too long"); return NULL; } *oidp++ = (oid)subidentifier; } /*H * The first two subidentifiers are encoded into the first component* * with the value (X * 40) + Y, where:1 * X is the value of the first subidentifier.3 * Y is the value of the second subidentifier. */% subidentifier = (u_long)objid[1];, objid[1] = (u_char)(subidentifier % 40);9 objid[0] = (u_char)((subidentifier - objid[1]) / 40);' *objidlength = (int)(oidp - objid); return bufp;}/*X * asn_build_objid - Builds an ASN object identifier object containing the input string.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * following the beginning of the next object. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */u_char *;asn_build_objid(data, datalength, type, objid, objidlength)D register u_char *data; /* IN - pointer to start of object */P int *datalength; /* IN/OUT - number of valid bytes left in buffer */6 u_char type; /* IN - ASN type of object */D oid *objid; /* IN - pointer to start of input buffer */C int objidlength; /* IN - number of sub-id's in objid */{/*@ * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*, * subidentifier ::= {leadingbyte}* ) CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-Y lastbyte * leadingbyte ::= 1 7bitvalue * lastbyte ::= 0 7bitvalue */ u_char buf[MAX_OID_LEN]; u_char *bp = buf; oid objbuf[MAX_OID_LEN]; oid *op = objbuf; register int asnlength;* register u_long subid, mask, testmask; register int bits, testbits;D bcopy((char *)objid, (char *)objbuf, objidlength * sizeof(oid));4 /* transform size in bytes to size in subid's */F /* encode the first two components into the first subidentifier */! op[1] = op[1] + (op[0] * 40);c op++;t objidlength--; while(objidlength-- > 0){O subid = *op++; * mask = 0x7F; /* handle subid == 0 case */ bits = 0;2 /* testmask *MUST* !!!! be of an unsigned type */R for(testmask = 0x7F, testbits = 0; testmask != 0; testmask <<= 7, testbits += 7){1 if (subid & testmask){ /* if any bits set */* mask = testmask; bits = testbits; } } /* mask can't be zero here */+ for(;mask != 0x7F; mask >>= 7, bits -= 7){,1 *bp++ = ((subid & mask) >> bits) | ASN_BIT8;  } *bp++ = subid & mask; }  asnlength = bp - buf;e? data = asn_build_header(data, datalength, type, asnlength);e if (data == NULL)o return NULL;a if (*datalength < asnlength) return NULL;d0 bcopy((char *)buf, (char *)data, asnlength); *datalength -= asnlength;p return data + asnlength;}/*0 * asn_parse_null - Interprets an ASN null type.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is r* CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-)#eturned as the number of valid bytes0 * following the beginning of the next object. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */Ou_char *&asn_parse_null(data, datalength, type)? u_char *data; /* IN - pointer to start of object */*P int *datalength; /* IN/OUT - number of valid bytes left in buffer */8 u_char *type; /* OUT - ASN type of object */{u/* * ASN.1 null ::= 0x05 0x00e */h# register u_char *bufp = data;i u_long asn_length; *type = *bufp++;/ bufp = asn_parse_length(bufp, &asn_length);  if (bufp == NULL)e return NULL;h if (asn_length != 0){v ERROR("Malformed NULL");" return NULL;, }r! *datalength -= (bufp - data);s return bufp + asn_length;s}j/*. * asn_build_null - Builds an ASN null object.H * On entry, datalength is input as the number of valid bytes followingB * "data". On exit, it is returned as the number of valid bytes0 * following the beginning of the next object. *4 * Returns a pointer to the first byte past the end8 * of this object (i.e. the start of the next object). * Returns NULL on any error. */;u_char *&asn_build_null(data, datalength, type)? u_char *data; /* IN - pointer to start of object */ P int *datalength; /* IN/OUT - number of valid bytes left in buffer */6 u_char type; /* IN - ASN type of object */{ /*+ CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.C;2EXE;1c-`& * ASN.1 null ::= 0x05 0x00; */ 7 return asn_build_header(data, datalength, type, 0);l}) ERROR("not long"); return NULL; } *type = *bufp++;/ bufp = asn_parse_length(bufp, &asn_length); if (bufp == NULL){ ERROR("bad length"); return NULL; }2 if (asn_length + (bufp - data) > *datalength){ ERROR("overflow of message"); return NULL; } if (asn_length > intsize){. ERROR("I don't support such large integers"); return NULL; }3 *dat-*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.H;2+,./ 4O-0@123KPWO56`8v7U)o8`? 9FRQٓGHJ/*6 * Definitions for Abstract Syntax Notation One, ASN.1, * As defined in ISO/IS 8824 and ISO/IS 8825 * * */</***********************************************************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 copy, CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.H;2OBJ;1Og#right notice and this permission notice 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******************************************************************/#ifndef EIGHTBIT_SUBIDStypedef u_short oid;#define MAX_SUBID 0xFFFF#elsetypedef u_char oid;#define MAX_SUBID 0xFF#endifF#define MAX_OID_LEN 64 /* max length in bytes of an encoded oid */#define ASN_BOOLEAN (0x01)#define ASN_INTEGER (0x02)#define ASN_BIT_STR (0x03) #define ASN_OCTET_STR (0x04)#define ASN_NULL (0x05) #define ASN_OBJECT_ID (0x06)#define ASN_SEQUENCE (0x10)#define ASN_SET (0x11) #define ASN_UNIVERSAL (0x00)"#define ASN_APPLICATION (0x40)#define ASN_CONTEXT (0x80)#define ASN_PRIVATE (0xC0) #define ASN_PRIMITIVE (0x00)"#define ASN_CONSTRUCTOR (0x20)#define ASN_LONG_LEN (0x80)"#define ASN_EXTENSION_ID (0x1F)#define ASN_BIT8 (0x80)7#d- CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.H;2OBJ;1Oefine IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)O#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)u_char *asn_parse_int();u_char *asn_build_int();u_char *asn_parse_string();u_char *asn_build_string();u_char *asn_parse_header();u_char *asn_build_header();u_char *asn_parse_length();u_char *asn_build_length();u_char *asn_parse_objid();u_char *asn_build_objid();u_char *asn_parse_null();u_char *asn_build_null();/*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.OBJ;1+,J./ 4 -0D123KPWO56:ē7f8;ē8f 9FRQٓGHJ1ASN1V1.0 6-SEP-1990 11:45GNU CC V1.22y$CODE ASN_PARSE_INT <ASN_PARSE_LENGTH z ASN_BUILD_INT ASN_BUILD_HEADER <ASN_PARSE_STRINGBCOPY `ASN_BUILD_STRING  ASN_PARSE_HEADER rASN_BUILD_LENGTHNTOHL ASN_PARSE_OBJIDUREMUDIV ASN_BUILD_OBJID n ASN_PARSE_NULL ASN_BUILD_NULLPP^ЬTЬUЬVTRSV&P򐂼 R. CMUSNMP.SAVJ/[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]ASN1.OBJ;1J;1S=)PPR.PTRPPPe;PѭVAPPTRPPPebUPS ZPxSQPPQS׭ѭrPSRPzPЬTЬV WЬRR>PмSЏQQUPRxSSUSPPPQPRPRW~VT%PPTPfRPPRfҏQPQSPPPPxSSRRPTPP<^ЬSЬTЬUSR R PPR%PSRPPPd2Pѭe8PPݭݬRJPЭeSRPPPdRP`PЬRЬT PЬSSP~TRkPPRPdSPPSRݬPSdRSPP ^ЬRЬSRQaPP"P𐁼 QPPFPPQ PRQPPPcPPЭcQPPЬPЬQ RaPPRaݬQPbPP<ЬTЬSdPPE%PP+PP0PPPRRSDPcMPPcRPxPPP QcUPQUcDPPcPrPЬQЬSЬ RQTRPRP P萏xRPPRTQPcPPPTQPPcQPP^ЬRЬTЬWЬVRSU S&PPSRPRSPPPdEPRSPPPdЭTfT:Pff/PRxRQcPʏPQPRT:PRCPPRTMP<R(R\PP<P(PR~qPPgWUPzPPxPfSPP@^ЬXЬY ZЬWT@VxW~VݬP2fPxPQxPPPQQVWZP#include #include /*@ * Open the DEVICE_NAMES.TRANSLATION file and cache the contents */!static char *Data, *Current_Data; static Init_Device_Names_Cache(){ struct FAB Fab; struct RAB Rab; register char *cp; register int Space, Offset; register int n; /* * Open the file: */ bzero(&Fab, sizeof(Fab)); Fab.fab$b_bid = FAB$C_BID; Fab.fab$b_bln = sizeof(Fab); Fab.fab$b_fac = FAB$M_GET;5 Fab.fab$l_fna = "MULTINET:DEVICE_NAMES.TRANSLATION";' Fab.fab$b_fns = strlen(Fab.fab$l_fna); bzero(&Rab, sizeof(Rab)); Rab.rab$b_bid = RAB$C_BID; Rab.rab$b_bln = sizeof(Rab); Rab.rab$l_fab = &Fab; Rab.rab$l_rop = RAB$M_RAH; Rab.rab$b_mbc = 8; Rab.rab$b_mbf = 2; if (!(sys$open(&Fab) & 1)) { /*5 * File not found (just remember it as being empty) */ } sys$connect(&Rab); /* * Read and save the data */ Offset = 0; Space = 500; cp = (char *)malloc(Space); if (cp == 0) { printf("Out of memory"); sys$close(&Fab); } for (;;) { if ((Space - Offset) < 250) { Space += Space;# cp = (char *)realloc(cp, Space); if (cp == 0) { printf("Out of Memory"); sys$close(&Fab); } } /*) * Read another line and add "\n" to it */ Rab.rab$l_ubf = cp + Offset; Rab.rab$l_rbf = Rab.rab$l_ubf;! Rab.rab$w_usz = Space - Offset; Rab.rab$w_rsz = Rab.rab$w_usz;" if (!(sys$get(&Rab) & 1)) break; n = Rab.rab$w_rsz; if (n == 0) continue4 CMUSNMP.SAV<[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]DEVICE_TRANSLATION.C;13@; cp[Offset + n] = '\n'; n++; /* * Lowercaseify it */ Offset += n; } /*1 * Done: Add a 0 character to terminate the data */ cp[Offset] = 0; sys$close(&Fab); Current_Data = Data = cp;}static Rewind_File(){ Current_Data = Data;}/* * Read a line from the file */#static char *get_line(Buffer, Size) char *Buffer;register int Size;{ register char *cp,*cp1; /* * Get the Data pointers */ cp = Current_Data; cp1 = Buffer; /* * Check for EOF */ if (*cp == 0) return(0); /*8 * Move data up to (and including) newline or until EOF */ while(Size > 1) { /* * Check for EOF */ if (*cp == 0) { /* * EOF */ Current_Data = cp; return(Buffer); } /*$ * Move data and check for newline */ if (*cp == '\n') { /* * Newline, return the line */ *cp1 = 0; Current_Data = cp + 1; return(Buffer); } *cp1++ = *cp++; Size--; } /*4 * Overflowed the buffer, skip the rest of the data */ while(*cp) if (*cp++ == '\n') break; /* * Return the line */ *cp1 = 0; Current_Data = cp; return(Buffer);}2char *Lookup_Device_Annotation(Device, Annotation)char *Device, *Annotation;{ static int init=1; static char Buffer[256]; char SearchBuf[256]; if (init) { Init_Device_Names_Cache(); init=0; } else { Rewind_File(); } if (Annotation) { strcpy(SearchBuf,"#");" 5 CMUSNMP.SAV<[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]DEVICE_TRANSLATION.C;13@Ph strcat(SearchBuf,Annotation); strcat(SearchBuf," "); strcat(SearchBuf,Device); strcat(SearchBuf," ");* } else { /* else return device name */ strcpy(SearchBuf,Device); strcat(SearchBuf," "); }+ while (get_line(Buffer, sizeof(Buffer))) {@ if (strncasecmp(Buffer,SearchBuf,strlen(SearchBuf)) == 0) {% return(&Buffer[strlen(SearchBuf)]); } }, /* Lop off the unit number and try again */! Device[strlen(Device)-1] = '\0'; if (Annotation) { strcpy(SearchBuf,"#");" strcat(SearchBuf,Annotation); strcat(SearchBuf," "); strcat(SearchBuf,Device); strcat(SearchBuf," ");* } else { /* else return device name */ strcpy(SearchBuf,Device); strcat(SearchBuf," "); } Rewind_File();+ while (get_line(Buffer, sizeof(Buffer))) {@ if (strncasecmp(Buffer,SearchBuf,strlen(SearchBuf)) == 0) {% return(&Buffer[strlen(SearchBuf)]); } } return(0);}=*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]DEVICE_TRANSLATION.OBJ;1+,K ./ 4-0D123KPWO56 ē7Piē8 f 9FRQٓGHJ6 CMUSNMP.SAVK =[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]DEVICE_TRANSLATION.OBJ;1?DEVICE_TRANSLATIONV1.0 6-SEP-1990 11:50GNU CC V1.22`$CODE$UNINITIALIZED_DATA_CTYPE_ C$V_CTYPEDEFSBZEROSTRLENSYS$OPEN SYS$CONNECTMALLOCPRINTF SYS$CLOSEREALLOCSYS$GET <LOOKUP_DEVICE_ANNOTATIO_001804XSTRCPYSTRCAT STRNCASECMP$DATAPP PMULTINET:DEVICE_NAMES.TRANSLATIONOut of memoryOut of MemoryHP<l^P~UU_PRbPƞsPܟxPPǐP䚏D~lSSblDmU<pUPSPT<SSPPRPRPPUPTSPP(PSSSRPPR P,PPPRTPPPTSPPPlBPPEP CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13F:SNMP_SYNCH_INPUTSNMP_SYNCH_RESPONSESNMP_SYNCH_SETUP6 SNMP_TIMEOUTA SPRINT_OBJIDA SPRINT_VALUEASPRINT_VARIABLESRANDOM ? CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13ۣ @ CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13 A CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13wB CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.D CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13E CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13eF CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13{ !G CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13\!"#$H CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13mb$%&'I CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13'()*J CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13EFILE.;2*+,-K CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;134-./0L CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;134o012M CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;134-341 TēV1.01ASN1V1.0 6-SEP-1990 11:45GNU CC V1.22y$CODE ASN_PARSE_INT <ASN_PARSE_LENGTH z ASN_BUILD_INT ASN_BUILD_HEADER <ASN_PARSE_STRINGBCOPY `ASN_BUILD_STRING  ASN_PARSE_HEADER rASN_BUILD_LENGTHNTOHL ASN_PARSE_OBJIDUREMUDIV ASN_BUILD_OBJID n ASN_PARSE_NULL ASN_BUILD_NULL5PP^ЬTЬUЬVTRSV&P򐂼 R)PPR.PTRPPPe;PѭVAPPTRPPPebUPS ZPxSQPPQS׭ѭrPSRPzPЬTЬV WЬRR>PмSЏQQUPRxSSUSPPPQPRPRW~VT%PPTPfRPPRfҏQPQSPPPPxSSRRPTPP<^ЬSЬTЬUSR R PPR%PSRPPPd2P6ѭe8PPݭݬRJPЭeSRPPPdRP`PЬRЬT PЬSSP~TRkPPRPdSPPSRݬPSdRSPP ^ЬRЬSRQaPP"P𐁼 QPPFPPQ PRQPPPcPPЭcQPPЬPЬQ RaPPRaݬQPbPP<ЬTЬSdPPE%PP+PP0PPPRRSDPcMPPcRPxPPP QcUPQUcDPPcPrPЬQЬN CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;134V67SЬ RQTRPRP P萏xRPPRTQPcPPPTQPPcQPP^ЬRЬTЬWЬVRSU S&PPSRPRSPPPdEPRSPPPdЭTfT:Pff/PRxRQcPʏPQPRT:PRCPPRTMP<R(R\PP<P(PR~qPPgWUPzPPxPfSPP@^ЬXЬY ZЬWT@VxW~VݬP2fPxPQxPPPQQVWZPengthHrasn_build_lengthdata # datalength length# start_data  P?asn_parse_objid type data # datalength objid $ objidlength bufp oidp & subidentifierlength( asn_length Q CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;134?@asn_build_objid objid datal # datalengthl typel $ objidlengthl buf*&@@?bpl  @objbuf*&@@?Aopl " asnlengthlsubidlmaskl! testmasklbitsl! testbitsl   nasn_parse_nullB type data{ # datalength{ bufp{  asn_lengthW8asn_build_null] data  datalength type ww1 ēV1.00MIBV1.0 6-SEP-1R CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13J;1LBC990 11:46GNU CC V1.22$CODE_CTYPE_ C$V_CTYPEDEFSSID SNMP_ERRNOSNMP_DUMP_PACKETSPRINTFSTRLEN SPRINT_OBJID RFC1066_MIB_707000XRFC1066_MIB_TEXT_0E0E00X INIT_MIBREAD_MIB MIB_400000XGETENVSTDERRFPRINTFEXIT T | READ_OBJID T  PRINT_OBJID | GET_SYMBOLPRINTF |PRINT_VARIABLEBCMP hSPRINT_VARIABLEDSTRCAT $ SPRINT_VALUE j PRINT_VALUESTRCPYSTDOUTSTDINPP P%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02dBP<ЬUǏdPǏQPSSQďQQQPQǏQTTPďPPQPPݚ~~~~~~~d~oaPUiPS cUuPRbPUT~~~~~~~d~WPU cUbPUTVVPP~_PUPUPPUVVPeP|ЬRЬSЬ UTTUEPPVcPPPF`PPPP.S0TPxPQxPPQPPTPP/5P UT<PbWrong Type (should be OCTET STRING): OCTET STRING- (hex): OCTET STRING- (S CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13J;1KEFascii): PЬTЬW #PPTPTP~WTP~PUЧ SRR,PPVcPPQFaPP PFaPUSRPѧ PUU'PQPTPT&Pݧݧ TP~5P%7PB;PTDPTMPݧݧ TP~φ\PWrong Type (should be Opaque): OPAQUE - (hex): P ЬRЬS D#PPRPRGP~SRP~PPRPRPݣݣ RP~@PWrong Type (should be OBJECT IDENTIFIER): OBJECT IDENTIFIER: (P ЬRЬS #8P;PRDPRMP~SRP~2ZP^PRgPRpPУQQ~ݣ RP~ PWrong Type (should be Timeticks): Timeticks: (%d) %sP ^ЬRЬS C#PPRPRP~SRP~ϚPݳ HDPPݳ PRPWrong Type (should be INTEGER): INTEGER: %dINTEGER: %s(%d)NP ЬRЬSЬ PQ 3dPgPRpPRyP~SRP~PѠ PРQP`PPPQPݳ PRPPݳ QPRPWrong Type (should be Gauge): Gauge: %luP ЬRЬS B#PPR PRP~SRP~mPݳ &PT CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13J;1HIR/PWrong Type (should be Counter): Counter: %lu^P ЬRЬS A#oPrPR{PRP~SRP~Pݳ PRPNetwork Address: %02XP<ЬSЬRPSPSPPSТ TТURRU+P~PSPSPPSPRPP:UR՗PWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%dRP ЬSЬR @#cPfPSJoPSxP~RSP~PТ P~~~`~PSPINTEGER (0..65535): %luP ЬRЬS $P>PRPRP~SRP~ϛPݳ PRPWrong Type (should be NULL): NULL&P ЬRЬS "6P9PRBPRKP~SRP~5WP[PRdPVariable has bad type|PPݬPPЬRЬQ PPBKf* Pݬ QR6 P_8 PQRUA PTC PQRDL PIN PQRW P>Y PQRZb P3d PQRm P(o PQRx Pz PQR P PQRϘ P PR P Pmib.txtMIBFILEMULTINET:SNMP_MIB.TXTCouldn't find mib file  P PU CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13J;1@KL PRbP P P P PP  PPbP P P P P PP! P' P) P, P2 P9 PB PH PL PN PЬR1Y PϢ0 Pv PϮz P8N~ P P8F P P8> P( P86 Pϸ P8. Pϼ P8& PB P8M P  P8 P P8 Pd P8 Pϲ P8b{ PТR P PЬTRSTQ PDQPQPTcPPPB` PUR  PѢ,TH PТR PR> Pc. Pc PaUR P򞭀UU ω PP P PТ,T PТR PR  PV CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13J;1NO P PT P P P PPff P P! P( P* PTc.2 PPVWbD PPfI PffP%s T P^a PP.RPݬݬH| PR P P PЬQ PP.QPݬ ݬ PName: %s  P|^Ь V PU.RUݬݬ PPURTT PScPRcRP!PPcPTPP!PTT)P0Pե89Pݥ4V8HPݥ4V6VP^PeP hP^ЬTЬW}PV.RVݬ ݬ,PPVRUTPScPRcRP!PcPTPPPUUPTPTPPTզ8 Pݦ4WT8  Pݦ4WTwPMPT"P$P ^ЬSЬRQ9PPPݬ ݬzJPՠ8 OPݠ4RS8 \Pݠ4RS$hPjP ^Ь S{PPRRPݬݬ5Pՠ8 Pݠ4SR8Pݠ4SPϘPP%d.P|ЬTЬUЬ SЬRVS8P(P08.Pݬ ݬQCPPQHPNPQݬQaPPQfPPЭQSQPPbQP~P^ЬRTЬUЬVЬScRW~0RPPR1&PWRXXcݼ ݬSRPPR1PTPPBqkPUVT~SR}P9PUVT~SRP%PU~VT~SRPPT~SRPPRPWRPXPPP0WPPPPRPpublicP ^ЬR,XԭPl CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1PPRWZ~PW$PPV1<,P욏Z~~V@PPU1 HPݬݬ U\PPR1dPRwPPR1PRPPR1PRPPR1P C~RPPT1P뚏Z~0RRTPPSRݬ4ݬ0X~(ݬ$S|PPRaPSRPPP0TPPSD$PURPPP~V>PPU%CPVRPPPόWPWcPPVhPPWRPPPPPPPPPPPPPPPPPPPP P P PPPPPPPPPP!P#P%P'P)P+P-P/P1P3P5P7P9P;P=P?PAPCPEPGPIPKPMPOPQPSPUPWPYP[P]P_PaPcPePgP^PSNMP_AUTH_BUILD9PASN_BUILD_HEADERPASN_BUILD_HEADERPASN_BUILD_HEADERP ASN_BUILD_INTP ASN_BUILD_INTP ASN_BUILD_INTrPASN_BUILD_STRINGWPASN_BUILD_OBJID;PASN_BUILD_HEADERPSNMP_AUTH_m CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1gqBUILDPSTRLENPASN_BUILD_HEADERPASN_BUILD_NULLPASN_BUILD_OBJIDPASN_BUILD_STRINGxP ASN_BUILD_INTPASN_BUILD_OBJIDPASN_BUILD_HEADER\PASN_PARSE_HEADER>PASN_PARSE_OBJIDPASN_PARSE_HEADER SNMPRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrRSvariable name*&namelen type magic aclfindVar RSmib_egpNeighEntry@ egpNeighState egpNeighAddrRSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrorsRSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPort R Smib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegs R Smib_icmp@ icmpInMsgs icmpIn CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1ÛnErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskReps R Smib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAge R Smib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddr R Smib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atIfIndex atPhysAddress*o CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1^& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr*&   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 sysUpTimeSO8;DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2  snmp_parse_var_opbvar_name  var_name_len  var_val_type  var_val_len var_val data | # listlength |  var_op_type var_op_len% var_op_start |  5p CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1~~snmp_build_var_opvar_name  var_name_len data % var_val_type$ var_val_len var_val # listlength dummyLen" headerLen dataPtr   lsnmp_build_trap length sysOid  sysOidLen myAddrtrapType specificType  time$varName ( varNameLen 0varLen 4varVal ! out_datao  varTypeoversion sidLendummyLen! out_autho# # out_headero  out_pduo & out_varHeadero $ out_varlisto  out_endo  q CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1?Bww1ēV1.05SNMP_APIV1.0 6-SEP-1990 11:47GNU CC V1.22$CODESID SNMP_ERRNOSNMP_DUMP_PACKET DEFAULT_ENTERPRISESESSIONS_080000X REQID_010000X API_ERRORS GETTIMEOFDAYSRANDOMRANDOM < SNMP_OPENMALLOCBZEROBCOPYSTRLENSTRCPY NET_SOCKET SOCKET_PERROR  SNMP_CLOSESTDERRFPRINTF INET_ADDR GETHOSTBYNAME GETSERVBYNAMEHTONSNET_BINDEXIT SNMP_FREE_PDUFREE NET_CLOSESNMP_BUILD_VAR_OPASN_BUILD_HEADER ASN_BUILD_INTASN_BUILD_OBJIDASN_BUILD_STRINGSNMP_AUTH_BUILDSNMP_AUTH_PARSEASN_PARSE_HEADER ASN_PARSE_INTASN_PARSE_OBJIDASN_PARSE_STRINGSNMP_PARSE_VAR_OP < SNMP_SENDPRINTF NET_SENDTO L  SNMP_READ NET_RECVFROM INET_NTOA SNMP_SELECT_INFO  SNMP_TIMEOUTSTDOUTSTDINPUnknown sessionUnknown hostInvalid local portUnknown Error>P>PЬPPMPP VP@PbPPdP^~uPͭ~PPPpublicsocketCouldn't abort session: %s. Exiting unknown host: %s udpsnmpbindP<^ЬSPjP PTdPRdPUUU P$dr CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;1P$PS:PТSbRգ#QPݣ[P럠dPRݣRpPRգyPݣPPRݣRc$PPPPPPPRݣRPPRcѣPѣ PЏ@B ԥ~PPRCPϢPPSϙ PP1`P!PP|#P)P0P165PReգ1@PݣJPPP WPbaPݣkPPKoPݣNvP|PPRbSPP1PϘPPPPb1Pݠ ݰP PPPPPPP~P<~PPPԥԭ<~PPR+PPF/PϬ3P:PS]GPP'KPVPPC\PbPiPrPPSPzP ЬS PSRcSբ Pݢ + PRPSPP ЬRPQѡR PQSc PSPѣR PP Pc`PSPcSPSdPУP` P`PУPՠ Pݠ PݣPУP` $P`-PУPݠA9PݣBPRbSb MPPs CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;131BJ;11P\P^ЬXЬUЬ VЬWg VSХDR*P ݢ ݢ ~ݢSPPS1PbRPVST< T0 $PPS1PTSVP$PPSPPTg ѥ?P VPPS1AP S-PPS1%5Pv<Pݥ$ݥ  VQPPS1YP, SmPPS1uP8 SPPS1P< SPPS1P@ SPPS1P T1PTS$RRPVSPPT< T~ RPPSO P THPTSVPמ$PPSPPTg Th VHPPS MPVSPPgPPTZPPTS$mPVSPTPgPWrong version: %d Continuing anyway bad type returned (%x) P|^ЬVЬUЬ TTPPT1P%P|PPPRb{PPbզPTPT16PTFPPT1&NPѥB^PTsPPT1{PTPPT1P1P䚏@$$TPPT1Px$~PP x$~PP,TPPTmP8TPPTS!P<T6PPT9;P@t CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;133BJ;1=TPPPTUPTePPT jP01tPPեD}PPPSSDPPPcPScԣ ԣ@ TPPTPx~PPRx~RPR< P2PPPB~ P1 P PP ݣ  P1 Pݣ PP P  P\ Pߚ@RR  PxPPP PP ݣPR( P* P ~l2 P8 P? Pլ11G PPNo remote IP address specified Error building packet %02X sendto P<^ЬUЬST< P PѠU PРT P`P PT  PPѣ Pѣ Pѣ  Pѣ/ Pգ Pѣ Pԣѣ8& Pԣ3+ Pգ$"4 P = PP PR P$գ@[ Pԣ@գ.c Pդh Pl Pr Py PPS P $SUϺ PP P P P P1 P PJ PRR 6 PM$~Ϭ P PRP PPPPRPP  Pϓ P P Ru CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C;5} Pτ P P~ PS~ $d0 PP4 PT8 P? PPѣS Pѣ ] PѣSg P$p PPQФaQS УХ } Ǐ@BPPď@BPP}УP P ЬSУDR1 Pբ  Pݢ Pբ   Pݢ  PRPbRP PR Pգ   Pݣ  PS Precvfromreceived %d bytes from %s: Mangled packet L P^Ь[Z1c PЪQxaPkP1s PЪXQY~<~$i PPWW  Pk P P P P` P PPWR P PRRW4 PM$~Ϝ P PRP PPPPRPP PσP PWRPvPPH~%PPV(fԦԦDԦ Ԧ$W$VXmIPPMPQPWP^PV[ePѦcpPЩR1yPѢLPݨ VݦXP7PRSѩSPcPЩRPbSPcbPbRPݣ PSP?PbRP8PѦPѦPѦ PѦPݨ VݦXVϮPjZ1IPP^ЬVЬUЬ WЬXTSԭԭRODPTТQaPPfSPPfxaPPeա,bPSСP$jPխv CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C;5oPխtPѠ {P }PѠP}`PPbRPSPTP~P׭@B­­ѭ@BP֭ѭ@BPխPԭԭhPѭg PPѭP}ghPP^T~PV1z#PЦUЦWRЧS1P6PT :PTCPTѣLP1*QPѣ1 [Pѣ0bPݥ ݣ У PݠUR{PcPcbݣ 4PST1P<֣ ݣ UϩPPPϯPPPPJPRR6PM~ϞPPRPPPPPRPP PυP PRPvPP~'Pݣ ~g?PP CPEGPNP} Ǐ@BPPď@BPP}SRcS1PT PTPTfV1P P P" P P7 P P" P" P" P" P" P" P" P"" P"$ P"& P"( P"* P", P". P"0 P"2 P"4 P"6 P"8 P": P"< P"> P"@ P"B P"D P"F P"H P"J P"L P"N P"P P"R P"T P"V P"X P"Z P"\ P"^ P"` P"b P"d P"f P"h w CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C;5DP"j P"l P"n P"p P"r P"t P"v P"x P"z P"| P"~ P" P" P" P P P P PPFREEIP SOCKET_PERROR:P NET_SENDTO"P GETTIMEOFDAYPPRINTFPPRINTFPPRINTFPPFPRINTFP>PFREEP GETTIMEOFDAYP GETTIMEOFDAYPFREEYPFPRINTFRP PMALLOCPPRINTFPPRINTF PPRINTF PPRINTF P INET_NTOA P P SOCKET_PERROR P NET_RECVFROM PFREE PFREE PFREE PFREE PFREEk PMALLOC: P SOCKET_PERROR+ P NET_SENDTO P GETTIMEOFDAY PPRINTF PPRINTF PPRINTF P PFPRINTF P PBCOPYt PFPRINTFm PM PBCOPY8 PMALLOC: PFPRINTF3 P# PBCOPY PMALLOC PASN_PARSE_OBJID PASN_PARSE_STRING PMALLOC P ASN_PARSE_INT PMALLOCPBCOPYPMALLOCPSNMP_PARSE_VAR_OPPMALLOCPMALLOC`PASN_PARSE_HEADERKP ASN_PARSE_INT1P ASN_PARSE_INTP ASN_PARSE_INTPASN_PARSE_STRINGPBCOPYPMALLOCPASN_PARSE_OBJIDP ASN_PARSE_INTnP ASN_PARSE_INTAPASN_PARSE_HEADERPPFPRINTFPPSNMP_x CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C;5uAUTH_PARSEhPBCOPYCPSNMP_AUTH_BUILDPBCOPYPASN_BUILD_HEADERPBCOPYP ASN_BUILD_INTP ASN_BUILD_INTP ASN_BUILD_INThPASN_BUILD_STRINGLPASN_BUILD_OBJID(P ASN_BUILD_INT P ASN_BUILD_INTPBCOPYPASN_BUILD_HEADERPSNMP_BUILD_VAR_OP=PFREE(P NET_CLOSEPFREEPFREEPFREEPFREEmPEXITdPFPRINTF]P5P SOCKET_PERROR&PNET_BINDPHTONSPHTONSP GETSERVBYNAMEPBCOPYP}PFPRINTFwPfP GETHOSTBYNAMEEP INET_ADDR+PFPRINTF$PP SOCKET_PERRORP NET_SOCKETPBCOPYPMALLOCPSTRLEN~PMALLOCkPSTRCPYVPSTRLEN5PBCOPYPBZEROPMALLOCPRANDOM}PSRANDOMpP GETTIMEOFDAYP<PX PA P{ PF P P P P POPPPPLP<PPPPPGP?PPPXPPPPPP P0PPPSNMP_APIRS_iobufp _cnt _ptr y CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13C;5 @_base  `_flag h_fileRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRSprotoent` p_name  p_aliases @p_proto R Sservent s_name  s_aliases  @s_port`s_proto  R Snetent n_name  n_aliases @ n_addrtype `n_net n_addresses  R R Shostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protos  h_addresses  RRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslenRS sockproto  sp_family sp_protocolR ST STSsockaddr sa_familysa_datz CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13H;3a*& RSlinger@l_onoff l_lingerRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrRSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_lenRSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic RS session_list` next T session T@internal RRS request_list  next_request T request_id@retries`timeout time T expire T pdu { CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1R/TRSTS snmp_internal_session sd addr Trequests TRSTS default_enterprise*& Sessions T Reqid snmp_errno api_errors3/&$$PsectAttributes_NOSHR$$stderr T&t $$PsectAttributes_NOSHR$$stdout T% $$PsectAttributes_NOSHR$$stdin TWS=M;?DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5  > api_errstring1'snmp_errnumberB j>&d init_snmp tv T4 snmp_open sessionx Tslpx Tispx Tcpx sdx addr me Thpx  Tservpx  T   snmp_close sessionZ| CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1# TslpZ ToslpZ Tzfree_request_listhrp Torp T@*  snmp_free_pdupdu   Tvp   Tovp   T   \ snmp_build sessionsw Tpdusw Tpacketsw # out_lengthsw  $buf*&cpsw vpsw T  length zero.$ totallengthswY  O} CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1Z snmp_parse length sessionI  TpduI  TdataI  msg_type typevar_val version len fourـ community*&community_lengthvpI  T objid*&@@?opI      snmp_send session   Tpdu   Tslp   Tisp   T $packet*&  lengthrp   T tv T  $0count  J ~ CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1P ?  ^  o 6,L  snmp_readfdsetW  slpW  TspW  TispW  T $packet*& from TlengthW  fromlengthpduW  TrpW  TorpW  T  $0count `S       snmp_select_infonumfds1 fdset1  timeout1 Tblock1 CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1  slp1 Tisp1 Trp1 T now Tpearliest Tactive1! requests1U , # snmp_timeoutslp  Tsp  Tisp  Trp  Torp  Tfreeme  T now T $0 packet*&n length tv T $0countJ2    i~3 eww1f1!ēV1.06 SNMP_AUTHV1.0 6-SEP-1990 11:48GNU CC V1.22 CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1$CODESID SNMP_AUTH_PARSEASN_PARSE_HEADER ASN_PARSE_INTASN_PARSE_STRING b SNMP_AUTH_BUILDASN_BUILD_HEADER ASN_BUILD_INTASN_BUILD_STRINGPP^ЬPЬRЬ TЬSRP#PP3'P0--PݬRP@PPDPSTRPVPPZPPDbP ЬQЬRЬScP0RQPPQ.PݬRQPPQPcݬ RQPPQPPQPPASN_BUILD_STRINGP ASN_BUILD_INTPASN_BUILD_HEADERLQPASN_PARSE_STRING;P ASN_PARSE_INTPASN_PARSE_HEADER SNMP_AUTHRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrXT޶@DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2  lsnmp_auth_parseversion dataa lengtha sida slena  type~ 0bbsnmp_auth_build sid version  messagelendata CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13OBJ;1S length slen P^^ww1";ēV1.08 SNMP_CLIENTV1.0 6-SEP-1990 11:48GNU CC V1.22$CODESID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATE SNMP_PDU_CREATEMALLOCBZERO :SNMP_ADD_NULL_VARBCOPY SNMP_SYNCH_INPUT  SNMP_FIX_PDU SNMP_FREE_PDU <SNMP_SYNCH_RESPONSE SNMP_SENDSNMP_SELECT_INFO NET_SELECT SNMP_READERRNO SOCKET_PERROR SNMP_TIMEOUT SNMP_SYNCH_SETUP ERROR_STRING SNMP_ERRSTRING SOCKET_ERRNOVMSERRNO VAXC$ERRNOSTDERRSTDOUTSTDINPPH~ PPRH~RPЬԢ Ԣ$ԢDRP:PЬRЬ TբDIPRPPSSD[PТDSccPcScjPsPPcPScxTRRPPRPݬPT ԣ ԣPЬPЬRЬWѬ PPgP1PѢ1PH~PUePTT H~TRPVfԤDТDR1 PePSSDSRfբ^&Px~ePx~PݢfCAPIPUePcbRPSSRbPTdբkPx~ePx~ CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13COM;6Pݢdբ PݢPP ݢPݢ PcbPԧ PPPPPЬYXѩ1%Pթ1Pթ1PH~PPWH~WYPԧDЬԧЩDRVѩV PbRVR1-P5PTdPSSDSRLPUeբfUPx~dPx~PݢeKpPbRVVf{PPUePcPSSRPTdբPx~ePx~Pݢdբ PݢPP ݢPݢ PcXbPVPX PWPPWPselectP<^ЬRЬ UPSRݬ&PP-P/PeR:PPc1FP؞Tԭԭ잭RԢbRTnPѭtPRR~~TݭPP PTP.PяPPPPRPPPP1|PPcPУ ePPЬPPP No ErrorResponse message would have been too large.There is no such variable name in this MIB.The value given has the wrong type or lengthThis variable is read onlyA general failure occuredPUnknown ErrorPЬPP PP P@PPPPP SNMP_TIMEOUTP SOCKET_PERRORPP SNMP_READP NET_SELECTiPSNMP_SELECT_INFO5P SNMP_FREE_PDU(P CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7!P SNMP_SENDPP SNMP_FREE_PDUPBCOPYPMALLOCPBCOPY~PMALLOCGPBCOPY0PMALLOCPBCOPYPMALLOCPBCOPYPMALLOC]PBCOPYDPMALLOCPBCOPYPMALLOCPBCOPYPMALLOCnPMALLOCMPMALLOCPBZEROPMALLOCPPPPu PHPPP SNMP_CLIENTRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRS sockaddr_in sin_familysin_port sin_addr  R@sin_zero*& R S T Sin_addr s_addr R S synch_statewaiting  status @reqid `pdu  R R Sval integer  string  objid  CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7~RS variable_list next_variable T name @ name_length `type hval  Tval_lenR STSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic  error_string3/snmp_synch_state  T,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno * #$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errno& $$PsectAttributes_NOSHR$$stderr T& $$PsectAttributes_NOSHR$$stdout T% $$PsectAttributes_NOSHR$$stdin TZV/MBDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3  6snmp_pdu_createEcommandpdu9 Td 9: CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7O:snmp_add_null_var name pduD T$ name_lengthDvarsD Tepsnmp_synch_input@session T  reqid magic oppdu Tvar Tnewvar Tstate  T snmp_fix_pdu6commandpdu Tvar Tnewvar Tnewpdu TindexcopiedHsnmp_synch_responsec ss Tpdu T! response CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7G Tstate  T numfdscount fdsettimeout Ttvp T block  snmp_synch_setup9 session T5 snmp_errstring* errstat,   ww1 &sēV1.02VMSIOV1.0 6-SEP-1990 11:50GNU CC V1.22$CODE $UNINITIALIZED_DATANETWORK_IO_302000XMALLOCERRNOBZERO X NET_SOCKETSOCKET SOCKET_CLOSE NET_CLOSEFREE NET_BINDBIND NET_SENDTOSENDTO NET_RECVFROMRECVFROM $ NET_SELECTSYS$QIO SOCKET_ERRNOVMSERRNO SYS$SETIMR SYS$HIBERw SYS$CANTIM SYS$CANCELSYS$WAKE SRANDOMSRAND RANDOMRAND VAXC$ERRNOPPЬTRPSBc1P PPBc #P *PP Bc:PBcPT`RPRR LPSPPXPݬ ݬݬjPPRPDPRRUQKPxRPfPDTP~~~dPR0jPBqPP1<`~~ PPPPPPPURPS1Pc1PTTcRxQxPPQQRRPϭP~PPPPPPTPPPP PPPP&P~!P(P*PS.P4P 6P=P?PEPfSRRU1OPxRPPQQWP \PQcPPfPBmPP<`~xPzPSURPSPPP~~PPxPPP~~PPݬPPPPRANDPSRANDPSYS$WAKEPPSYS$WAKEPsP SYS$CANCELhP^P@P8P SYS$HIBER/P#P SYS$CANTIMPP P SYS$HIBERPPPPP SYS$SETIMRPP CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7P~PSYS$QIOlP_P?P9PPRECVFROMPPSENDTOPPBINDPPFREEP SOCKET_CLOSEP~Pi SOCKET_CLOSEePSOCKETNP5PBZERO%PPMALLOC P VMSIORS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocol R Ssockaddr sa_familysa_data*&  R Slinger@l_onoff l_linger R S Network_IOPChannel IOSB*& RS T S Timeout_OccuredReadyfds Dummy_Buffer Network_IO62  T  CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7v%,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno*#$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errnoUQ\yYĒ =DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.C;19  Fill_In_Network_ION ChannelVfdV  %EXX net_socketAddress_Family Type Protocol_FamilyfdZ ChannelZD0 net_close%fd;,net_bind$ fd sa  size+  net_sendtoK fd buf  len flags to tolen-( net_recvfromO fd buf  len flags fromfromlen+($ net_select writefds exceptfdswidth5 readfds5  timeout5 Ti5Status5)Original_Readfds5% Number_ CMUSNMP.SAVK3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]LIBSNMP.OLB;13.C;7Ready5 Delta_Time*&K  `select_read_wakeup  fdW select_timeout_wakeup  =  |srandom x: random  ww0*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MAKE.COM;91+,. / 4 <-0@123KPWO 56@+Ғ7~o8D$ 9FRQٓGHJ CMUSNMP.SAV0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MAKE.COM;91UTE.C;7 Yy$!$! Compile and link SNMPLIB$!-$ If P1 .Eqs. "VMSINSTAL" Then Goto VMSinstal$ SAVE_VERIFY='F$VERIFY(0)$ Set Symbol/Scope=NoGlobalA$ GCC := GCC/DEBUG/DEFINE=("""vax11c""","""unix""",MASTER_SERVER)>$ If "''LINKFLAGS'" .Eqs. "" Then LINKFLAGS = "/NOTRACE/NOMAP"$3$ CALL MAKE ASN1.OBJ "GCC ASN1" ASN1.C ASN1.HO$ CALL MAKE MIB.OBJ "GCC MIB" MIB.C ASN1.H SNMP_IMPL.H SNMP_API.H PARSE.H6$ CALL MAKE PARSE.OBJ "GCC PARSE" PARSE.C PARSE.HX$ CALL MAKE SNMP.OBJ "GCC SNMP" SNMP.C ASN1.H SNMP.H SNMP_IMPL.H MIB.H SNMP_VARS.Hf$ CALL MAKE SNMP_AGENT.OBJ "GCC SNMP_AGENT" SNMP_AGENT.C ASN1.H SNMP.H SNMP_IMPL.H MIB.H SNMP_VARS.H[$ CALL MAKE SNMP_API.OBJ "GCC SNMP_API" SNMP_API.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_API.HR$ CALL MAKE SNMP_AUTH.OBJ "GCC SNMP_AUTH" SNMP_AUTH.C ASN1.H SNMP.H SNMP_IMPL.Ho$ CALL MAKE SNMP_CLIENT.OBJ "GCC SNMP_CLIENT" SNMP_CLIENT.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_API.H SNMP_CLIENT.Hd$ CALL MAKE SNMP_VARS.OBJ "GCC SNMP_VARS" SNMP_VARS.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_VARS.H MIB.Hj$ CALL MAKE SNMP_VAR_ARP.OBJ "GCC SNMP_VAR_ARP" SNMP_VAR_ARP.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_VARS.H MIB.Hy$ CALL MAKE SNMP_VAR_MULTINET.OBJ "GCC SNMP_VAR_MULTINET" SNMP_VAR_MULTINET.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_VARS.H MIB.Hp$ CALL MAKE SNMP_VAR_ROUTE.OBJ "GCC SNMP_VAR_ROUTE" SNMP_VAR_ROUTE.C ASN1.H SNMP.H SNMP_IMPL.H SNMP_VARS.H MIB.HP$ CALL MAKE DEVICE_TRANSLATION.OBJ "GCC DEVICE_TRANSLATION" DEVICE_TRANSLATION.C.$ CALL MAKE VMSIO.OBJ "GCC VMSIO" VMSIO.C CMUSNMP.SAV0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MAKE.COM;91UTE.OBJ;1 t$ CALL MAKE LIBSNMP.OLB "LIBRARY/CREATE LIBSNMP.OLB ASN1,MIB,PARSE,SNMP,SNMP_API,SNMP_AUTH,SNMP_CLIENT,VMSIO" -_ "ASN1.OBJ MIB.OBJ PARSE.OBJ SNMP.OBJ SNMP_API.OBJ SNMP_AUTH.OBJ SNMP_CLIENT.OBJ VMSIO.OBJ"$!CALL MAKE SNMP_AGENT.EXE "LINK''LINKFLAGS' SNMP_AGENT/OPT" SNMP_AGENT.OBJ LIBSNMP.OLB SNMP_VARS.OBJ DEVICE_TRANSLATION.OBJ SNMP_VAR_ROUTE.OBJ$ 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.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s( ,*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4+,.(/ 4s(&"<-0@123KPWO)56lvYĒ7 o8j%9FRQٓGHJ</***********************************************************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 TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMA CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s(QNCE OF THIS SOFTWARE.C******************************************************************/#include #include #include #include #include #include "asn1.h"#include "snmp_impl.h"#include "snmp_api.h"#include "parse.h"static void sprint_by_type();(static set_functions(), parse_subtree();static int lc_cmp(); static char *uptimeString(timeticks, buf) register long timeticks; char *buf;{& int seconds, minutes, hours, days; timeticks /= 100;& days = timeticks / (60 * 60 * 24); timeticks %= (60 * 60 * 24);" hours = timeticks / (60 * 60); timeticks %= (60 * 60); minutes = timeticks / 60; seconds = timeticks % 60; if (days == 0){7 sprintf(buf, "%d:%02d:%02d", hours, minutes, seconds); } else if (days == 1) {E sprintf(buf, "%d day, %d:%02d:%02d", days, hours, minutes, seconds); } else {F sprintf(buf, "%d days, %d:%02d:%02d", days, hours, minutes, seconds); } return buf;}%static sprint_hexstring(buf, cp, len) char *buf; u_char *cp; int len;{ for(; len >= 16; len -= 16){r sprintf(buf, "%02X %02X %02X %02X %02X %02X %02X %02X ", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); buf += strlen(buf); cp += 8;s sprintf(buf, "%02X %02X %02X %02X %02X %02X %02X %02X\n", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); buf += strlen(buf); cp += 8; } for(; len > 0; len CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s(--){ sprintf(buf, "%02X ", *cp++); buf += strlen(buf); } *buf = '\0';}'static sprint_asciistring(buf, cp, len) char *buf; u_char *cp; int len;{ int x; for(x = 0; x < len; x++){ if (isprint(*cp)){ *buf++ = *cp++; } else { *buf++ = '.'; cp++; } if ((x % 48) == 47) *buf++ = '\n'; } *buf = '\0';} #ifdef UNUSEDint%read_rawobjid(input, output, out_len) char *input; oid *output; int *out_len;{ char buf[12], *cp; oid *op = output; int subid; while(*input != '\0'){ if (!isdigit(*input)) break; cp = buf; while(isdigit(*input)) *cp++ = *input++; *cp = '\0'; subid = atoi(buf); if(subid > MAX_SUBID){< fprintf(stderr, "sub-identifier too large: %s\n", buf); return 0; } if((*out_len)-- <= 0){5 fprintf(stderr, "object identifier too long\n"); return 0; } *op++ = subid; if(*input++ != '.') break; } *out_len = op - output; if (*out_len == 0) return 0; return 1;}#endif /* UNUSED */ static voidsprint_octet_string(buf, var) char *buf; struct variable_list *var;{ int hex, x; u_char *cp;$ if (var->type != ASN_OCTET_STR){7 sprintf(buf, "Wrong Type (should be OCTET STRING): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; } hex = 0;B for(cp = var->val.string, x = 0; x < var CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s( ->val_len; x++, cp++){% if (!(isprint(*cp) || isspace(*cp))) hex = 1; } if (var->val_len <= 4)) hex = 1; /* not likely to be ascii */ if (hex){* sprintf(buf, "OCTET STRING- (hex):\t"); buf += strlen(buf);6 sprint_hexstring(buf, var->val.string, var->val_len); } else {* sprintf(buf, "OCTET STRING- (ascii):\t"); buf += strlen(buf);8 sprint_asciistring(buf, var->val.string, var->val_len); }} static voidsprint_opaque(buf, var) char *buf; struct variable_list *var;{ if (var->type != OPAQUE){1 sprintf(buf, "Wrong Type (should be Opaque): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }( sprintf(buf, "OPAQUE - (hex):\t"); buf += strlen(buf);9 sprint_hexstring(buf, var->val.string, var->val_len);} static void"sprint_object_identifier(buf, var) char *buf; struct variable_list *var;{$ if (var->type != ASN_OBJECT_ID){< sprintf(buf, "Wrong Type (should be OBJECT IDENTIFIER): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }) sprintf(buf, "OBJECT IDENTIFIER:\t"); buf += strlen(buf);K sprint_objid(buf, (oid *)(var->val.objid), var->val_len / sizeof(oid));} static voidsprint_timeticks(buf, var) char *buf; struct variable_list *var;{ char timebuf[32]; if (var->type != TIMETICKS){4 sprintf(buf, "Wrong Type (should be Timeticks): "); buf += strlen(buf);4 CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s(x sprint_by_type(buf, var, (struct enum_list *)NULL); return; }h sprintf(buf, "Timeticks: (%d) %s", *(var->val.integer), uptimeString(*(var->val.integer), timebuf));} static voidsprint_integer(buf, var, enums) char *buf; struct variable_list *var; struct enum_list *enums;{ char *enum_string = NULL;" if (var->type != ASN_INTEGER){2 sprintf(buf, "Wrong Type (should be INTEGER): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }& for (; enums; enums = enums->next)( if (enums->value == *var->val.integer){ enum_string = enums->label; break; } if (enum_string == NULL)0 sprintf(buf, "INTEGER: %d", *var->val.integer); elseA sprintf(buf, "INTEGER: %s(%d)", enum_string, *var->val.integer);} static voidsprint_gauge(buf, var) char *buf; struct variable_list *var;{ if (var->type != GAUGE){0 sprintf(buf, "Wrong Type (should be Gauge): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }2 sprintf(buf, "Gauge: %lu", *var->val.integer);} static voidsprint_counter(buf, var) char *buf; struct variable_list *var;{ if (var->type != COUNTER){2 sprintf(buf, "Wrong Type (should be Counter): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }4 sprintf(buf, "Counter: %lu", *var->val.integer);} static voidsprint_networkaddress(buf, var)  CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;42]ROUTE.OBJ;1s(b char *buf; struct variable_list *var;{ int x, len; u_char *cp;' sprintf(buf, "Network Address:\t"); buf += strlen(buf); cp = var->val.string; len = var->val_len; for(x = 0; x < len; x++){ sprintf(buf, "%02X", *cp++); buf += strlen(buf); if (x < (len - 1)) *buf++ = ':'; }} static voidsprint_ipaddress(buf, var) char *buf; struct variable_list *var;{ u_char *ip; if (var->type != IPADDRESS){4 sprintf(buf, "Wrong Type (should be Ipaddress): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; } ip = var->val.string;G sprintf(buf, "IpAddress:\t%d.%d.%d.%d",ip[0], ip[1], ip[2], ip[3]);} static voidsprint_unsigned_short(buf, var) char *buf; struct variable_list *var;{" if (var->type != ASN_INTEGER){2 sprintf(buf, "Wrong Type (should be INTEGER): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; }? sprintf(buf, "INTEGER (0..65535): %lu", *var->val.integer);} static voidsprint_null(buf, var) char *buf; struct variable_list *var;{ if (var->type != ASN_NULL){/ sprintf(buf, "Wrong Type (should be NULL): "); buf += strlen(buf);4 sprint_by_type(buf, var, (struct enum_list *)NULL); return; } sprintf(buf, "NULL");} static voidsprint_badtype(buf) char *buf;{* sprintf(buf, "Variable has bad type");} static voidspri CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4;2ROUTE.OBJ;1s(Dmnt_by_type(buf, var, enums) char *buf; struct variable_list *var; struct enum_list *enums;{ switch (var->type){ case ASN_INTEGER:% sprint_integer(buf, var, enums); break; case ASN_OCTET_STR:# sprint_octet_string(buf, var); break; case OPAQUE: sprint_opaque(buf, var); break; case ASN_OBJECT_ID:( sprint_object_identifier(buf, var); break; case TIMETICKS: sprint_timeticks(buf, var); break; case GAUGE: sprint_gauge(buf, var); break; case COUNTER: sprint_counter(buf, var); break; case IPADDRESS: sprint_ipaddress(buf, var); break; case ASN_NULL: sprint_null(buf, var); break; default: sprint_badtype(buf); break; }}struct tree *get_symbol();)oid RFC1066_MIB[] = { 1, 3, 6, 1, 2, 1 };Dunsigned char RFC1066_MIB_text[] = ".iso.org.dod.internet.mgmt.mib";struct tree *Mib; init_mib(){ char *file, *getenv(); Mib = read_mib("mib.txt"); if (!Mib){ file = getenv("MIBFILE"); if (file) Mib = read_mib(file); } if (!Mib)#ifndef vax11c Mib = read_mib("/etc/mib.txt"); #else vax11c) Mib = read_mib("MULTINET:SNMP_MIB.TXT"); #endif vax11c if (!Mib){- fprintf(stderr, "Couldn't find mib file\n"); exit(2); } set_functions(Mib);}staticset_functions(subtree) struct tree *subtree;{1 for(; subtree; subtree = subtree->next_peer){ switch(subtree- CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4;2ROUTE.OBJ;1s(a>type){* case TYPE_OBJID:*. subtree->printer = sprint_object_identifier; break; case TYPE_OCTETSTR:) subtree->printer = sprint_octet_string;i break; case TYPE_INTEGER:b$ subtree->printer = sprint_integer; break; case TYPE_NETADDR: + subtree->printer = sprint_networkaddress;o break; case TYPE_IPADDR:& subtree->printer = sprint_ipaddress; break; case TYPE_COUNTER:$ subtree->printer = sprint_counter; break; case TYPE_GAUGE:d" subtree->printer = sprint_gauge; break; case TYPE_TIMETICKS:t& subtree->printer = sprint_timeticks; break; case TYPE_OPAQUE:# subtree->printer = sprint_opaque;L break; case TYPE_NULL:! subtree->printer = sprint_null;A break; case TYPE_OTHER:, default:N$ subtree->printer = sprint_badtype; break; }$ set_functions(subtree->child_list); }T} #ifdef testingint snmp_dump_packet = 0; main(argc, argv) int argc; char *argv[];{U oid objid[64];" int objidlen = sizeof (objid); int count; struct variable variable;* init_mib(&Mib);> if (argc < 2)> print_subtree(Mib, 0); variable.type = ASN_INTEGER; variable.val.integer = 3;h variable.val_len = 4;( for (argc--; argc; argc--, argv++) { objidlen = sizeof (objid);e printf("read_objid(%s) = %d\n",8 argv[1], read_objid(argv[1], objid, &objidlen));* for(count = 0; count < objidlen; count++)! printf("%d.", objid[count]);  printf("\n" CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4T]ROUTE.OBJ;1s( );, print_variable(objid, objidlen, &variable); }a}=#endif testingstatic struct tree *find_rfc1066_mib(root) struct tree *root;{  oid *op = RFC1066_MIB; struct tree *tp; int len;A for(len = sizeof(RFC1066_MIB)/sizeof(oid); len; len--, op++){f( for(tp = root; tp; tp = tp->next_peer){ if (tp->subid == *op){= root = tp->child_list; break; } } if (tp == NULL) return NULL;  } return root;}s&int read_objid(input, output, out_len) char *input; oid *output;7 int *out_len; /* number of subid's in "output" */;{  struct tree *root = Mib; oid *op = output; int i; if (*input == '.') input++; else { root = find_rfc1066_mib(root);29 for (i = 0; i < sizeof (RFC1066_MIB)/sizeof(oid); i++) {; if ((*out_len)-- > 0) *output++ = RFC1066_MIB[i];% else {c2 fprintf(stderr, "object identifier too long\n"); return (0);t } } }8 if (root == NULL){5 fprintf(stderr, "Mib not initialized. Exiting.\n");t exit(1); } if ((*out_len =4 parse_subtree(root, input, output, out_len)) == 0) return (0); *out_len += output - op; return (1); }(static.parse_subtree(subtree, input, output, out_len) struct tree *subtree;* char *input; oid *output;+ int *out_len; /* number of subid's */{  char buf[128], *to = buf;E int subid = 0; struct tree *tp; /*K * No empty strings. Can happen if th CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4T]ROUTE.OBJ;1s(ere is a trailing '.' or two '.'s, * in a row, i.e. "..".p */  if ((*input == '\0') ||i (*input == '.')) return (0); if (isdigit(*input)) { /*i8 * Read the number, then try to find it in the subtree. */ while (isdigit(*input)) { subid *= 10;  subid += *input++ - '0';r }- for (tp = subtree; tp; tp = tp->next_peer) {* if (tp->subid == subid) goto found;e } tp = NULL;  }) else { /*; * Read the name into a buffer. */ while ((*input != '\0') &&  (*input != '.')) { *to++ = *input++; } *to = '\0'; /*! * Find the name in the subtree;t */- for (tp = subtree; tp; tp = tp->next_peer) {u' if (lc_cmp(tp->label, buf) == 0) {  subid = tp->subid; goto found;  } } /*A( * If we didn't find the entry, punt... */ if (tp == NULL) {< fprintf(stderr, "sub-identifier not found: %s\n", buf); return (0); } }found: if(subid > MAX_SUBID){8 fprintf(stderr, "sub-identifier too large: %s\n", buf); return (0); }a if ((*out_len)-- <= 0){ 1 fprintf(stderr, "object identifier too long\n"); return (0); } *output++ = subid; if (*input != '.') return (1); if ((*out_len =s@ parse_subtree(tp->child_list, ++input, output, out_len)) == 0) return (0); return (++*out_len);};print_objid(objid, objidlen) oid *objid;>4 int objidlen; /* number of subidentifiers */{p char buf[256];" struct tree * CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4T]SNMPNETSTAT.EXE;1s(حsubtree = Mib;4 *buf = '.'; /* this is a fully qualified name */2 get_symbol(objid, objidlen, subtree, buf + 1); printf("%s\n", buf);}("sprint_objid(buf, objid, objidlen) char *buf; oid *objid;P4 int objidlen; /* number of subidentifiers */{t" struct tree *subtree = Mib;4 *buf = '.'; /* this is a fully qualified name */2 get_symbol(objid, objidlen, subtree, buf + 1);}*)print_variable(objid, objidlen, variable) oid *objid;T int objidlen;D$ struct variable_list *variable;{r char buf[512], *cp;" struct tree *subtree = Mib;4 *buf = '.'; /* this is a fully qualified name */< subtree = get_symbol(objid, objidlen, subtree, buf + 1); cp = buf; a if ((strlen(buf) >= strlen((char *)RFC1066_MIB_text)) && !bcmp(buf, (char *)RFC1066_MIB_text,l$ strlen((char *)RFC1066_MIB_text))){$ cp += sizeof(RFC1066_MIB_text); }n printf("Name: %s\n", cp);T *buf = '\0'; if (subtree->printer)_4 (*subtree->printer)(buf, variable, subtree->enums); else {/ sprint_by_type(buf, variable, subtree->enums);n }  printf("%s\n", buf);}e/sprint_variable(buf, objid, objidlen, variable)b char *buf; oid *objid;  int objidlen;a$ struct variable_list *variable;{ char tempbuf[512], *cp;" struct tree *subtree = Mib;8 *tempbuf = '.'; /* this is a fully qualified name */@ subtree = get_symbol(objid, objidlen, subtree, tempbuf + 1); CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4T]SNMPNETSTAT.EXE;1s(-! cp = tempbuf; a if ((strlen(buf) >= strlen((char *)RFC1066_MIB_text)) && !bcmp(buf, (char *)RFC1066_MIB_text,i$ strlen((char *)RFC1066_MIB_text))){$ cp += sizeof(RFC1066_MIB_text); }I# sprintf(buf, "Name: %s\n", cp);  buf += strlen(buf);G if (subtree->printer)v4 (*subtree->printer)(buf, variable, subtree->enums); else {/ sprint_by_type(buf, variable, subtree->enums); }( strcat(buf, "\n");}n,sprint_value(buf, objid, objidlen, variable) char *buf; oid *objid;, int objidlen; $ struct variable_list *variable;{u char tempbuf[512];i" struct tree *subtree = Mib;< subtree = get_symbol(objid, objidlen, subtree, tempbuf); if (subtree->printer)=4 (*subtree->printer)(buf, variable, subtree->enums); else {/ sprint_by_type(buf, variable, subtree->enums);r }m}s&print_value(objid, objidlen, variable) oid *objid;* int objidlen;$ struct variable_list *variable;{, char tempbuf[512]; " struct tree *subtree = Mib;< subtree = get_symbol(objid, objidlen, subtree, tempbuf); if (subtree->printer)e8 (*subtree->printer)(tempbuf, variable, subtree->enums); else {3 sprint_by_type(tempbuf, variable, subtree->enums);) }f printf("%s\n", tempbuf);} struct tree * )get_symbol(objid, objidlen, subtree, buf)i oid *objid;  int objidlen;t struct tree *subtree; char *buf; {(' struct tree *return_tree = NU CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.C;4T]SNMPNETSTAT.EXE;1s(t$LL;W1 for(; subtree; subtree = subtree->next_peer){b if (*objid == subtree->subid){s! strcpy(buf, subtree->label); goto found; } }i /* subtree not found */s? while(objidlen--){ /* output rest of name, uninterpreted */ sprintf(buf, "%d.", *objid++); while(*buf) buf++;t }l0 *(buf - 1) = '\0'; /* remove trailing dot */ return NULL;found: if (objidlen > 1){ while(*buf) buf++;s *buf++ = '.'; *buf = '\0'; M return_tree = get_symbol(objid + 1, objidlen - 1, subtree->child_list, buf);" }> if (return_tree != NULL) return return_tree; else return subtree;}u static intlc_cmp(s1, s2) char *s1, *s2;{L char c1, c2; while(*s1 && *s2){ if (isupper(*s1)) c1 = tolower(*s1);t else, c1 = *s1; if (isupper(*s2)) c2 = tolower(*s2);t else" c2 = *s2; if (c1 != c2)% return ((c1 - c2) > 0 ? 1 : -1); s1++; s2++; }b if (*s1) return -1;t if (*s2) return 1; return 0;}  CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1O,*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2+,./ 4O-0@123KPWO56`e7@Mo8,E$ 9FRQٓGHJ/*6 * Definitions for the variables as defined in the MIB */</***********************************************************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 notice 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 CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1OE OR OTHER TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************/struct mib_system {5 char sysDescr[32]; /* textual description */= u_char sysObjectID[16];/* OBJECT IDENTIFIER of system */5 u_char ObjIDLen; /* length of sysObjectID */@ u_long sysUpTime; /* Uptime in 100/s of a second */ };struct mib_interface {4 long ifNumber; /* number of interfaces */};struct mib_ifEntry {6 long ifIndex; /* index of this interface */B char ifDescr[32]; /* english description of interface */4 long ifType; /* network type of device */< long ifMtu; /* size of largest packet in bytes */4 u_long ifSpeed; /* bandwidth in bits/sec */8 u_char ifPhysAddress[11]; /* interface's address */4 u_char PhysAddrLen; /* length of physAddr */< long ifAdminStatus; /* desired state of interface */< long ifOperStatus; /* current operational status */O u_long ifLastChange; /* value of sysUpTime when current state entered */H u_long ifInOctets; /* number of octets received on interface */E u_long ifInUcastPkts; /* number of unicast packets delivered */D u_long ifInNUcastPkts; /* number of broadcasts or multicasts */K u_long ifInDiscards; /* number of packets discarded with no error */E u_long ifInErrors; /* number of packets containing errors */L CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1OPI u_long ifInUnknownProtos; /* number of packets with unknown protocol */> u_long ifOutOctets; /* number of octets transmitted */@ u_long ifOutUcastPkts; /* number of unicast packets sent */G u_long ifOutNUcastPkts;/* number of broadcast or multicast pkts */K u_long ifOutDiscards; /* number of packets discarded with no error */H u_long ifOutErrors; /* number of pkts discarded with an error */B u_long ifOutQLen; /* number of packets in output queue */};struct mib_atEntry {C long atIfIndex; /* interface on which this entry maps */D u_char atPhysAddress[11]; /* physical address of destination */9 u_char PhysAddressLen; /* length of atPhysAddress */@ u_long atNetAddress; /* IP address of physical address */};struct mib_ip {9 long ipForwarding; /* 1 if gateway, 2 if host */G long ipDefaultTTL; /* default TTL for pkts originating here */L u_long ipInReceives; /* no. of IP packets received from interfaces */O u_long ipInHdrErrors; /* number of pkts discarded due to header errors */J u_long ipInAddrErrors; /* no. of pkts discarded due to bad address */N u_long ipForwDatagrams;/* number pf pkts forwarded through this entity */O u_long ipInUnknownProtos;/* no. of local-addressed pkts w/unknown proto */H u_long ipInDiscards; /* number of error-free packets discarded */N u_long ipInDelivers; /* number of datagrams delivered to upper level */L u_long ipOutRequests; /* CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1O number of IP datagrams originating locally */O u_long ipOutDiscards; /* number of error-free output IP pkts discarded */M u_long ipOutNoRoutes; /* number of IP pkts discarded due to no route */N long ipReasmTimeout; /* seconds fragment is held awaiting reassembly */L u_long ipReasmReqds; /* no. of fragments needing reassembly (here) */A u_long ipReasmOKs; /* number of fragments reassembled */E u_long ipReasmFails; /* number of failures in IP reassembly */D u_long ipFragOKs; /* number of datagrams fragmented here */G u_long ipFragFails; /* no. pkts unable to be fragmented here */E u_long ipFragCreates; /* number of IP fragments created here */};struct mib_ipAddrEntry {: u_long ipAdEntAddr; /* IP address of this entry */3 long ipAdEntIfIndex; /* IF for this entry */; u_long ipAdEntNetMask; /* subnet mask of this entry */< long ipAdEntBcastAddr;/* read the MIB for this one */};struct mib_ipRouteEntry {D u_long ipRouteDest; /* destination IP addr for this route */B long ipRouteIfIndex; /* index of local IF for this route */8 long ipRouteMetric1; /* Primary routing metric */: long ipRouteMetric2; /* Alternate routing metric */: long ipRouteMetric3; /* Alternate routing metric */: long ipRouteMetric4; /* Alternate routing metric */5 u_long ipRouteNextHop; /* IP addr of next hop */4 long ipRouteType; /* Type of this route */< long ipRoutePro CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1Oi: to; /* How this route was learned */J long ipRouteAge; /* No. of seconds since updating this route */};struct mib_icmp {= u_long icmpInMsgs; /* Total of ICMP msgs received */I u_long icmpInErrors; /* Total of ICMP msgs received with errors */ u_long icmpInDestUnreachs; u_long icmpInTimeExcds; u_long icmpInParmProbs; u_long icmpInSrcQuenchs; u_long icmpInRedirects; u_long icmpInEchos; u_long icmpInEchoReps; u_long icmpInTimestamps; u_long icmpInTimestampReps; u_long icmpInAddrMasks; u_long icmpInAddrMaskReps; u_long icmpOutMsgs; u_long icmpOutErrors; u_long icmpOutDestUnreachs; u_long icmpOutTimeExcds; u_long icmpOutParmProbs; u_long icmpOutSrcQuenchs; u_long icmpOutRedirects; u_long icmpOutEchos; u_long icmpOutEchoReps; u_long icmpOutTimestamps;! u_long icmpOutTimestampReps; u_long icmpOutAddrMasks; u_long icmpOutAddrMaskReps;};struct mib_tcp {C long tcpRtoAlgorithm; /* retransmission timeout algorithm */A long tcpRtoMin; /* minimum retransmission timeout (mS) */B long tcpRtoMax; /* maximum retransmission timeout (mS) */ ? long tcpMaxConn; /* maximum tcp connections possible */J u_long tcpActiveOpens; /* number of SYN-SENT -> CLOSED transitions */K u_long tcpPassiveOpens; /* number of SYN-RCVD -> LISTEN transitions */O u_long tcpAttemptFails;/*(SYN-SENT,SYN-RCVD)->CLO CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1OSED or SYN-RCVD->LISTEN*/D u_long tcpEstabResets; /* (ESTABLISHED,CLOSE-WAIT) -> CLOSED */I u_long tcpCurrEstab; /* number in ESTABLISHED or CLOSE-WAIT state */9 u_long tcpInSegs; /* number of segments received */6 u_long tcpOutSegs; /* number of segments sent */B u_long tcpRetransSegs; /* number of retransmitted segments */};struct mib_tcpConnEntry {8 long tcpConnState; /* State of this connection */J u_long tcpConnLocalAddress;/* local IP address for this connection */B long tcpConnLocalPort; /* local port for this connection */J u_long tcpConnRemAddress; /* remote IP address for this connection */A long tcpConnRemPort; /* remote port for this connection */};struct mib_udp {I u_long udpInDatagrams; /* No. of UDP datagrams delivered to users */O u_long udpNoPorts; /* No. of UDP datagrams to port with no listener */M u_long udpInErrors; /* No. of UDP datagrams unable to be delivered */L u_long udpOutDatagrams;/* No. of UDP datagrams sent from this entity */};struct mib_egp {C u_long egpInMsgs; /* No. of EGP msgs received without error */A u_long egpInErrors;/* No. of EGP msgs received with error */2 u_long egpOutMsgs; /* No. of EGP msgs sent */N u_long egpOutErrors;/* No. of (outgoing) EGP msgs dropped due to error */};struct mib_egpNeighEntry {L long egpNeighState; /* local EGP state with this entry's neighbor */E u_long egpNeighAddr; /* IP address of this en CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1Otry's neighbor */};#define MIB 1, 3, 6, 1, 2, 1#define MIB_IFTYPE_OTHER 1%#define MIB_IFTYPE_REGULAR1822 2!#define MIB_IFTYPE_HDH1822 3 #define MIB_IFTYPE_DDNX25 4##define MIB_IFTYPE_RFC877X25 5'#define MIB_IFTYPE_ETHERNETCSMACD 6'#define MIB_IFTYPE_ISO88023CSMACD 7)#define MIB_IFTYPE_ISO88024TOKENBUS 8*#define MIB_IFTYPE_ISO88025TOKENRING 9&#define MIB_IFTYPE_ISO88026MAN 10"#define MIB_IFTYPE_STARLAN 11'#define MIB_IFTYPE_PROTEON10MBIT 12'#define MIB_IFTYPE_PROTEON80MBIT 13'#define MIB_IFTYPE_HYPERCHANNEL 14 #define MIB_IFTYPE_FDDI 15 #define MIB_IFTYPE_LAPB 16 #define MIB_IFTYPE_SDLC 17$#define MIB_IFTYPE_T1CARRIER 18 #define MIB_IFTYPE_CEPT 19$#define MIB_IFTYPE_BASICISDN 20&#define MIB_IFTYPE_PRIMARYISDN 21.#define MIB_IFTYPE_PROPPOINTTOPOINTSERIAL 22#define MIB_IFSTATUS_UP 1#define MIB_IFSTATUS_DOWN 2#define MIB_IFSTATUS_TESTING 3#define MIB_FORWARD_GATEWAY 1#define MIB_FORWARD_HOST 2#define MIB_IPROUTETYPE_OTHER 1!#define MIB_IPROUTETYPE_INVALID 2 #define MIB_IPROUTETYPE_DIRECT 3 #define MIB_IPROUTETYPE_REMOTE 4$#define MIB_IPROUTEPROTO_OTHER 1$#define MIB_IPROUTEPROTO_LOCAL 2%#define MIB_IPROUTEPROTO_NETMGMT 3##define MIB_IPROUTEPROTO_ICMP 4"#define MIB_IPROUTEPROTO_EGP 5"#define MIB_IPROUTEPROTO_GGP 6$#define MIB_IPROUTEPROTO_HELLO 7"#define MIB_IPROUTEPROTO_RIP 8##define MIB_IPROUTEPROTO_I CMUSNMP.SAV,[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.H;2T]SNMPNETSTAT.EXE;1OPSIS 9$#define MIB_IPROUTEPROTO_ESIS 10&#define MIB_IPROUTEPROTO_CISCOIGRP 11&#define MIB_IPROUTEPROTO_BBNSPFIGP 12$#define MIB_IPROUTEPROTO_OIGP 13#define MIB_TCPRTOALG_OTHER 1 #define MIB_TCPRTOALG_CONSTANT 2#define MIB_TCPRTOALG_RSRE 3#define MIB_TCPRTOALG_VANJ 4"#define MIB_TCPCONNSTATE_CLOSED 1"#define MIB_TCPCONNSTATE_LISTEN 2"#define MIB_TCPCONNSTATE_SYNSENT 3&#define MIB_TCPCONNSTATE_SYNRECEIVED 4&#define MIB_TCPCONNSTATE_ESTABLISHED 5##define MIB_TCPCONNSTATE_FINWAIT1 6##define MIB_TCPCONNSTATE_FINWAIT2 7$#define MIB_TCPCONNSTATE_CLOSEWAIT 8"#define MIB_TCPCONNSTATE_LASTACK 9##define MIB_TCPCONNSTATE_CLOSING 10$#define MIB_TCPCONNSTATE_TIMEWAIT 11!#define MIB_EGPNEIGHSTATE_IDLE 1&#define MIB_EGPNEIGHSTATE_AQUISITION 2!#define MIB_EGPNEIGHSTATE_DOWN 3#define MIB_EGPNEIGHSTATE_UP 4"#define MIB_EGPNEIGHSTATE_CEASE 5.*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1+,J .-/ 4-+-0D123KPWO.56fIKē7&Kē8&v 9FRQٓGHJ CMUSNMP.SAVJ .[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1SNMPNETSTAT.EXE;1-(80MIBV1.0 6-SEP-1990 11:46GNU CC V1.22$CODE_CTYPE_ C$V_CTYPEDEFSSID SNMP_ERRNOSNMP_DUMP_PACKETSPRINTFSTRLEN SPRINT_OBJID RFC1066_MIB_707000XRFC1066_MIB_TEXT_0E0E00X INIT_MIBREAD_MIB MIB_400000XGETENVSTDERRFPRINTFEXIT T | READ_OBJID T  PRINT_OBJID | GET_SYMBOLPRINTF |PRINT_VARIABLEBCMP hSPRINT_VARIABLESTRCAT $ SPRINT_VALUE j PRINT_VALUESTRCPYSTDOUTSTDINPP P%d:%02d:%02d%d day, %d:%02d:%02d%d days, %d:%02d:%02dBP<ЬUǏdPǏQPSSQďQQQPQǏQTTPďPPQPPݚ~~~~~~~d~oaPUiPS cUuPRbPUT~~~~~~~d~WPU cUbPUTVVPP~_PUPUPPUVVPeP|ЬRЬSЬ UTTUEPPVcPPPF`PPPP.S0TPxPQxPPQPPTPP/5P UT<PbWrong Type (should be OCTET STRING): OCTET STRING- (hex): OCTET STR CMUSNMP.SAVJ .[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1SNMPNETSTAT.EXE;1-ING- (ascii): PЬTЬW #PPTPTP~WTP~PUЧ SRR,PPVcPPQFaPP PFaPUSRPѧ PUU'PQPTPT&Pݧݧ TP~5P%7PB;PTDPTMPݧݧ TP~φ\PWrong Type (should be Opaque): OPAQUE - (hex): P ЬRЬS D#PPRPRP~SRP~PPRPRPݣݣ RP~@PWrong Type (should be OBJECT IDENTIFIER): OBJECT IDENTIFIER: (P ЬRЬS #8P;PRDPRMP~SRP~2ZP^PRgPRpPУQQ~ݣ RP~ PWrong Type (should be Timeticks): Timeticks: (%d) %sP ^ЬRЬS C#PPRPRP~SRP~ϚPݳ DPPݳ PRPWrong Type (should be INTEGER): INTEGER: %dINTEGER: %s(%d)NP ЬRЬSЬ PQ 3dPgPRpPRyP~SRP~PѠ PРQP`PPPQPݳ PRPPݳ QPRPWrong Type (should be Gauge): Gauge: %luP ЬRЬS B#PPR PRP~SRP~mPݳ &PR/ CMUSNMP.SAVJ .[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1SNMPNETSTAT.EXE;1-cPWrong Type (should be Counter): Counter: %lu^P ЬRЬS A#oPrPR{PRP~SRP~Pݳ PRPNetwork Address: %02XP<ЬSЬRPSPSPPSТ TТURRU+P~PSPSPPSPRPP:UR՗PWrong Type (should be Ipaddress): IpAddress: %d.%d.%d.%dRP ЬSЬR @#cPfPSoPSxP~RSP~PТ P~~~`~PSPINTEGER (0..65535): %luP ЬRЬS $P>PRPRP~SRP~ϛPݳ PRPWrong Type (should be NULL): NULL&P ЬRЬS "6P9PRBPRKP~SRP~5WP[PRdPVariable has bad type|PPݬPPЬRЬQ PPBf* Pݬ QR6 P_8 PQRUA PTC PQRDL PIN PQRW P>Y PQRZb P3d PQRm P(o PQRx Pz PQR P PQRϘ P PR P Pmib.txtMIBFILEMULTINET:SNMP_MIB.TXTCouldn't find mib file  P P PRbP P CMUSNMP.SAVJ .[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1SNMPNETSTAT.EXE;1-4  P P PP  PPbP P P P P PP! P' P) P, P2 P9 PB PH PL PN PЬR1Y PϢ0 Pv PϮz P8N~ P P8F P P8> P( P86 Pϸ P8. Pϼ P8& PB P8 P  P8 P P8 Pd P8 Pϲ P8b{ PТR P PЬTRSTQ PDQPQPTcPPPB` PUR  PѢ,TH PТR PR> Pc. Pc PaUR P򞭀UU ω PP P PТ,T PТR PR  P P PT P  CMUSNMP.SAVJ .[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]MIB.OBJ;1SNMPNETSTAT.EXE;1-Z P P PPff P P! P( P* PTc.2 PPVWbD PPfI PffP%s T P^a PP.RPݬݬH| PR P P PЬQ PP.QPݬ ݬ PName: %s  P|^Ь V PU.RUݬݬ PPURTT PScPRcRP!PcPTPP!PTT)P0Pե89Pݥ4V8HPݥ4V6VP^PeP hP^ЬTЬW}PV.RVݬ ݬ,PPVRUTPScPRcRP!PcPTPPPUUPTPTPPTզ8 Pݦ4WT8  Pݦ4WTwPMPT"P$P ^ЬSЬR9PPPݬ ݬzJPՠ8 OPݠ4RS8 \Pݠ4RS$hPjP ^Ь S{PPRRPݬݬ5Pՠ8 Pݠ4SR8Pݠ4SPϘPP%d.P|ЬTЬUЬ SЬRVS8P#include #include "parse.h"!static do_subtree(), free_node();static int get_token();/*T * This is one element of an object identifier with either an integer subidentifier,& * or a textual string label, or both.D * The subid is -1 if not present, and label is NULL if not present. */struct subid { int subid; char *label;}; int Line = 1;/* types of tokens */#define CONTINUE -1#define LABEL 1#define SUBTREE 2#define SYNTAX 3#define OBJID 4#define OCTETSTR 5#define INTEGER 6#define NETADDR 7#define IPADDR 8#define COUNTER 9#define GAUGE 10#define TIMETICKS 11#define OPAQUE 12#define NUL 13#define SEQUENCE 14##define OF 15 /* SEQUENCE OF */#define OBJTYPE 16#define ACCESS 17#define READONLY 18#define READWRITE 19#d CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-efine WRITEONLY 20#define NOACCESS 21#define STATUS 22#define MANDATORY 23#define OPTIONAL 24#define OBSOLETE 25#define PUNCT 26#define EQUALS 27 struct tok { char *name; /* token name */) int len; /* length not counting nul */ int token; /* value */ int hash; /* hash of name */7 struct tok *next; /* pointer to next in hash table */};struct tok tokens[] = {1 { "obsolete", sizeof ("obsolete")-1, OBSOLETE },+ { "Opaque", sizeof ("Opaque")-1, OPAQUE },1 { "optional", sizeof ("optional")-1, OPTIONAL },4 { "mandatory", sizeof ("mandatory")-1, MANDATORY },= { "not-accessible", sizeof ("not-accessible")-1, NOACCESS },6 { "write-only", sizeof ("write-only")-1, WRITEONLY },6 { "read-write", sizeof ("read-write")-1, READWRITE },4 { "TimeTicks", sizeof ("TimeTicks")-1, TIMETICKS },> { "OBJECTIDENTIFIER", sizeof ("OBJECTIDENTIFIER")-1, OBJID }, /*4 * This CONTINUE appends the next word onto OBJECT,. * hopefully matching OBJECTIDENTIFIER above. */- { "OBJECT", sizeof ("OBJECT")-1, CONTINUE },< { "NetworkAddress", sizeof ("NetworkAddress")-1, NETADDR },( { "Gauge", sizeof ("Gauge")-1, GAUGE },7 { "OCTETSTRING", sizeof ("OCTETSTRING")-1, OCTETSTR },% { "OCTET", sizeof ("OCTET")-1, -1 }, { "OF", sizeof ("OF")-1, OF },1 { "SEQUENCE", sizeof ("SEQUENCE")-1, SEQUENCE },$ { "NULL", sizeof ("NULL")-1, NUL },1 { "IpAddress", sizeof ("IpAddress")-1, IPADDR },. { "INTEGER", sizeof ("INTEGER")-1, INTEGER },. { "Counter",  CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-Qsizeof ("Counter")-1, COUNTER },3 { "read-only", sizeof ("read-only")-1, READONLY },+ { "ACCESS", sizeof ("ACCESS")-1, ACCESS },+ { "STATUS", sizeof ("STATUS")-1, STATUS },+ { "SYNTAX", sizeof ("SYNTAX")-1, SYNTAX },6 { "OBJECT-TYPE", sizeof ("OBJECT-TYPE")-1, OBJTYPE }, { "{", sizeof ("{")-1, PUNCT }, { "}", sizeof ("}")-1, PUNCT },% { "::=", sizeof ("::=")-1, EQUALS }, { NULL }};#define HASHSIZE 32#define BUCKET(x) (x & 0x01F)struct tok *buckets[HASHSIZE];static hash_init(){ register struct tok *tp; register char *cp; register int h; register int b;$ for (tp = tokens; tp->name; tp++) {' for (h = 0, cp = tp->name; *cp; cp++) h += *cp; tp->hash = h; b = BUCKET(h); if (buckets[b]) tp->next = buckets[b]; buckets[b] = tp; }} static char * Malloc(num) unsigned num;{ char *cp; char *malloc();V /* this is to fix (what seems to be) a problem with the IBM RT C library malloc */ if (num < 16) num = 16; cp = malloc(num); return cp;}staticprint_error(string, token) char *string; char *token;{ if (token)H fprintf(stderr, "%s(%s): On or around line %d\n", string, token, Line); else= fprintf(stderr, "%s: On or around line %d\n", string, Line);} #ifdef TESTprint_subtree(tree, count) struct tree *tree; int count;{ struct tree *tp; int i; for(i = 0; i < count; i++) printf(" ");- printf("Children of %s:\n", tree CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-M] ->label); count++;7 for(tp = tree->child_list; tp; tp = tp->next_peer){ for(i = 0; i < count; i++) printf(" "); printf("%s\n", tp->label); }7 for(tp = tree->child_list; tp; tp = tp->next_peer){ print_subtree(tp, count); }}#endif /* TEST */static struct tree *build_tree(nodes) struct node *nodes;{ struct node *np; struct tree *tp; /* build root node */4 tp = (struct tree *)Malloc(sizeof(struct tree)); tp->parent = NULL; tp->next_peer = NULL; tp->child_list = NULL; tp->enums = NULL; strcpy(tp->label, "iso"); tp->subid = 1; tp->type = 0;' /* grow tree from this root node */ do_subtree(tp, &nodes); #ifdef TEST print_subtree(tp, 0);#endif /* TEST */B /* If any nodes are left, the tree is probably inconsistent */ if (nodes){I fprintf(stderr, "The mib description doesn't seem to be consistent.\n");L fprintf(stderr, "Some nodes couldn't be linked under the \"iso\" tree.\n");, fprintf(stderr, "these nodes are left:\n");# for(np = nodes; np; np = np->next)Q fprintf(stderr, "%s ::= { %s %d } (%d)\n", np->label, np->parent, np->subid, np->type); } return tp;}/*I * Find all the children of root in the list of nodes. Link them into the" * tree and out of the nodes list. */staticdo_subtree(root, nodes) struct tree *root; struct node **nodes;{ register struct tree *tp; struct tree *peer = NULL; CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V- register struct node *np;B struct node *oldnp = NULL, *child_list = NULL, *childp = NULL; tp = root; /*A * Search each of the nodes for one whose parent is root, and& * move each into a seperate list. */( for(np = *nodes; np; np = np->next){H if ((tp->label[0] == np->parent[0]) && !strcmp(tp->label, np->parent)){ if (child_list == NULL){= child_list = childp = np; /* first entry in child list */ } else { childp->next = np; childp = np; }. /* take this node out of the node list */ if (oldnp == NULL){1 *nodes = np->next; /* fix root of node list */ } else {5 oldnp->next = np->next; /* link around this node */ } } else { oldnp = np; } } if (childp)* childp->next = 0; /* re-terminate list */ /*F * Take each element in the child list and place it into the tree. */, for(np = child_list; np; np = np->next){1 tp = (struct tree *)Malloc(sizeof(struct tree)); tp->parent = root; tp->next_peer = NULL; tp->child_list = NULL; strcpy(tp->label, np->label); tp->subid = np->subid; switch(np->type){ case OBJID: tp->type = TYPE_OBJID; break; case OCTETSTR: tp->type = TYPE_OCTETSTR; break; case INTEGER: tp->type = TYPE_INTEGER; break; case NETADDR: tp->type = TYPE_IPADDR; break; case IPADDR: tp->type = TYPE_IPADDR; break; case COUNTER: tp->type = TYPE_COUNTER; break; case GAUGE: tp CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-t.->type = TYPE_GAUGE; break; case TIMETICKS: tp->type = TYPE_TIMETICKS; break; case OPAQUE: tp->type = TYPE_OPAQUE; break; case NUL: tp->type = TYPE_NULL; break; default: tp->type = TYPE_OTHER; break; } tp->enums = np->enums;4 np->enums = NULL; /* so we don't free them later */ if (root->child_list == NULL){ root->child_list = tp; } else { peer->next_peer = tp; } peer = tp;3 do_subtree(tp, nodes); /* recurse on this child */ }3 /* free all nodes that were copied into tree */ for(np = child_list; np;){ oldnp = np; np = np->next; free_node(oldnp); }}/* * Takes a list of the form: * { iso org(3) dod(6) 1 }= * and creates several nodes, one for each parent-child pair. * Returns NULL on error. */ static intgetoid(fp, oid, length) register FILE *fp;8 register struct subid *oid; /* an array of subids */1 int length; /* the length of the array */{ register int count; int type; char token[64], label[32]; register char *cp, *tp;0 if ((type = get_token(fp, token)) != PUNCT){ if (type == -1)1 print_error("Unexpected EOF", (char *)NULL); else& print_error("Unexpected", token); return NULL; } if (*token != '{'){" print_error("Unexpected", token); return NULL; }3 for(count = 0; count < length; count++, oid++){ oid->label = 0; oid->subid = -1;- if ((type = get_token(fp, token)) != LABEL){ CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V- if (type == -1){. print_error("Unexpected EOF", (char *)NULL); return NULL; }. else if (type == PUNCT && *token == '}'){ return count; } else {# print_error("Unexpected", token); return NULL; } } tp = token; if (!isdigit(*tp)){! /* this entry has a label */ cp = label; while(*tp && *tp != '(') *cp++ = *tp++; *cp = 0;2 cp = (char *)Malloc((unsigned)strlen(label)); strcpy(cp, label); oid->label = cp; if (*tp == '('){*G /* this entry has a label-integer pair in the form label(integer). */e cp = ++tp; while(*cp && *cp != ')') cp++; if (*cp == ')'), *cp = 0; else {> print_error("No terminating parenthesis", (char *)NULL); return NULL; }e oid->subid = atoi(tp); } } else {a9 /* this entry has just an integer sub-identifier */d oid->subid = atoi(tp);r } }r return count; }tstatic free_node(np) struct node *np;{b struct enum_list *ep, *tep;  ep = np->enums;t while(ep){ tep = ep; ep = ep->next;I free((char *)tep);S }E free((char *)np);I}U/* * Parse an entry of the form:+ * label OBJECT IDENTIFIER ::= { parent 2 } A * The "label OBJECT IDENTIFIER" portion has already been parsed.N * Returns 0 on error. */Gstatic struct node *parse_objectid(fp, name) FILE *fp;O char *name;E{ int type;A char token[64];F register int count;E$ register struct  CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-7subid *op, *nop; int length;* struct subid oid[16];* struct node *np, *root;* type = get_token(fp, token); if (type != EQUALS){" print_error("Bad format", token); return 0; }& if (length = getoid(fp, oid, 16)){8 np = root = (struct node *)Malloc(sizeof(struct node)); /*u8 * For each parent-child subid pair in the subid array,1 * create a node and link it into the node list.  */C for(count = 0, op = oid, nop=oid+1; count < (length - 2); count++, op++, nop++){H /* every node must have parent's name and child's name or number */: if (op->label && (nop->label || (nop->subid != -1))){ strcpy(np->parent, op->label); if (nop->label)f$ strcpy(np->label, nop->label); if (nop->subid != -1) np->subid = nop->subid;  np ->type = 0; np->enums = 0; /* set up next entry */f6 np->next = (struct node *)Malloc(sizeof(*np->next)); np = np->next; } } /*CJ * The above loop took care of all but the last pair. This pair is takenJ * care of here. The name for this node is taken from the label for this * entry.' * np still points to an unused entry. */ if (count == (length - 2)){ if (op->label){ strcpy(np->parent, op->label); strcpy(np->label, name); if (nop->subid != -1)t np->subid = nop->subid;; else@ print_error("Warning: This entry is pretty silly", token); } else { free_node(np); } } else {e5 print_error("Missing end of oid", (char *)NULL);z? f CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-Eree_node(np); /* the last node allocated wasn't used */1 return NULL;" } /* free the oid array */)9 for(count = 0, op = oid; count < length; count++, op++){b if (op->label) free(oid->label);o op->label = 0;R } return root;d } else {4 print_error("Bad object identifier", (char *)NULL); return 0; } }E/*@ * Parses an asn type. This structure is ignored by this parser. * Returns NULL on error.p */ static intparse_asntype(fp) FILE *fp;i{O int type;  char token[64];E type = get_token(fp, token); if (type != SEQUENCE){I print_error("Not a sequence", (char *)NULL); /* should we handle this */ return NULL;R }i1 while((type = get_token(fp, token)) != NULL){i if (type == -1) return NULL;z< if (type == PUNCT && (token[0] == '}' && token[1] == '\0')) return -1;U }z7 print_error("Premature end of file", (char *)NULL);s return NULL;}"/* * Parses an OBJECT TYPE macro.  * Returns 0 on error. */ustatic struct node *parse_objecttype(fp, name) register FILE *fp; char *name;z{  register int type; char token[64];  int count, length; struct subid oid[16];T char syntax[32]; int nexttype;e char nexttoken[64];T register struct node *np; " register struct enum_list *ep; register char *cp; register char *tp; type = get_token(fp, token); if (type != SYNTAX){2 print_error("Bad format for OBJECT TYPE", token); retur CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-Dn 0; }4 np = (struct node *)Malloc(sizeof(struct node)); np->next = 0;s np->enums = 0; type = get_token(fp, token);( nexttype = get_token(fp, nexttoken); np->type = type; switch(type){T case SEQUENCE:t strcpy(syntax, token);[ if (nexttype == OF){} strcat(syntax, " "); strcat(syntax, nexttoken);& nexttype = get_token(fp, nexttoken); strcat(syntax, " "); strcat(syntax, nexttoken);& nexttype = get_token(fp, nexttoken); } break; case INTEGER: strcpy(syntax, token);u if (nexttype == PUNCT &&o2 (nexttoken[0] == '{' && nexttoken[1] == '\0')) {1 /* if there is an enumeration list, parse it */n/ while((type = get_token(fp, token)) != NULL){  if (type == -1){ free_node(np);n return 0; } if (type == PUNCT &&) (token[0] == '}' && token[1] == '\0')); break;o if (type == 1){e$ /* this is an enumerated label */ if (np->enums == 0){ , ep = np->enums = (struct enum_list *)& Malloc(sizeof(struct enum_list)); } else {t& ep->next = (struct enum_list *)& Malloc(sizeof(struct enum_list)); ep = ep->next; } ep->next = 0;2 /* a reasonable approximation for the length */7 ep->label = (char *)Malloc((unsigned)strlen(token));t cp = ep->label; tp = token; while(*tp != '(') *cp++ = *tp++;n *cp = 0; & cp = ++tp; /* start of number */ while(*tp != ')') tp++;% *tp = 0; /* terminate number */t  CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-| ep->value = atoi(cp); } }  if (type == NULL){9 print_error("Premature end of file", (char *)NULL);  free_node(np); return 0;  }g& nexttype = get_token(fp, nexttoken);8 } else if (nexttype == LABEL && *nexttoken == '('){0 /* ignore the "constrained integer" for now */& nexttype = get_token(fp, nexttoken); } break; case OBJID: case OCTETSTR:c case NETADDR: case IPADDR:i case COUNTER: case GAUGE: case TIMETICKS: case OPAQUE:n case NUL: case LABEL: strcpy(syntax, token);e break;" default: & print_error("Bad syntax", token); free_node(np);% return 0; }e if (nexttype != ACCESS){, print_error("Should be ACCESS", nexttoken); free_node(np); return 0; }t type = get_token(fp, token);B if (type != READONLY && type != READWRITE && type != WRITEONLY && type != NOACCESS){+ print_error("Bad access type", nexttoken); free_node(np);r return 0; } type = get_token(fp, token); if (type != STATUS){( print_error("Should be STATUS", token); free_node(np);= return 0; }r type = get_token(fp, token);C if (type != MANDATORY && type != OPTIONAL && type != OBSOLETE){ " print_error("Bad status", token); free_node(np);n return 0; } type = get_token(fp, token); if (type != EQUALS){" print_error("Bad format", token); free_node(np);t return 0; }*! length = getoid(fp, oid, 16); $ if (length > 1 && length <= 16){. /* just tak CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-#e the last pair in the oid list */ if (oid[length - 2].label)o4 strncpy(np->parent, oid[length - 2].label, 32); strcpy(np->label, name);! if (oid[length - 1].subid != -1) ' np->subid = oid[length - 1].subid; elsedF print_error("Warning: This entry is pretty silly", (char *)NULL); } else {, print_error("No end to oid", (char *)NULL); free_node(np);n np = 0; }  /* free oid array */, for(count = 0; count < length; count++){ if (oid[count].label) free(oid[count].label); oid[count].label = 0; }i return np;}s/*J * Parses a mib file and returns a linked list of nodes found in the file. * Returns NULL on error._ */;static struct node * parse(fp) FILE *fp;P{C char token[64];  char name[32]; int type = 1;E" struct node *np, *root = NULL; hash_init(); while(type != NULL){ type = get_token(fp, token);D if (type != LABEL){ if (type == NULL){= return root; }. print_error(token, "is a reserved word"); return NULL;I } strncpy(name, token, 32); type = get_token(fp, token);Q if (type == OBJTYPE){ if (root == NULL){c /* first link in chain */U) np = root = parse_objecttype(fp, name);= if (np == NULL){< print_error("Bad parse of object type", (char *)NULL); return NULL; } } else {d( np->next = parse_objecttype(fp, name); if (np->next == NULL){; print_error("Bad parse of objecttype", (char *)NULL);  return NULL; }* CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-7H& } /* now find end of chain */ while(np->next) np = np->next; } else if (type == OBJID){ if (root == NULL){o /* first link in chain */*' np = root = parse_objectid(fp, name);o if (np == NULL){: print_error("Bad parse of object id", (char *)NULL); return NULL; }r } else {c& np->next = parse_objectid(fp, name); if (np->next == NULL){< print_error("Bad parse of object type", (char *)NULL); return NULL; }e } /* now find end of chain */ while(np->next) np = np->next; } else if (type == EQUALS){ type = parse_asntype(fp); } else if (type == NULL){ break;- } else {i/ print_error("Bad operator", (char *)NULL); return NULL;" } }, #ifdef TESTt{  struct enum_list *ep;k& for(np = root; np; np = np->next){D printf("%s ::= { %s %d } (%d)\n", np->label, np->parent, np->subid, np->type); if (np->enums){ printf("Enums: \n");(, for(ep = np->enums; ep; ep = ep->next){+ printf("%s(%d)\n", ep->label, ep->value);  } } };} #endif /* TEST */} return root;}=/*K * Parses a token from the file. The type of the token parsed is returned,c< * and the text is placed in the string pointed to by token. */i static intget_token(fp, token) register FILE *fp; register char *token;t{= static char last = ' ';  register int ch; register char *cp = token; register int hash = 0; register struct tok *tp; *c CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3XE;1V-)p = 0; ch = last; /* skip all white space */# while(isspace(ch) && ch != -1){  ch = getc(fp);l if (ch == '\n') Line++; }f if (ch == -1) return NULL;l /*T * Accumulate characters until white space is found. Then attempt to match thisS * token as a reserved word. If a match is found, return the type. Else it is  * a label.d */d do { if (!isspace(ch)){r hash += ch; *cp++ = ch; if (ch == '\n') Line++;d } else { last = ch;i *cp = '\0';: for (tp = buckets[BUCKET(hash)]; tp; tp = tp->next) {; if ((tp->hash == hash) && (strcmp(tp->name, token) == 0))U break;P } if (tp){r if (tp->token == CONTINUE) continue;  return (tp->token);I }- if (token[0] == '-' && token[1] == '-'){0 /* strip comment */c while ((ch = getc(fp)) != -1), if (ch == '\n'){ Line++; break;  }e if (ch == -1)n return NULL; last = ch; return get_token(fp, token); } return LABEL; }$ } while ((ch = getc(fp)) != -1); return NULL;}= struct tree *kread_mib(filename) char *filename;r{" FILE *fp;k struct node *nodes; struct tree *tree; struct node *parse();= fp = fopen(filename, "r"); if (fp == NULL) return NULL;- nodes = parse(fp); if (!nodes){1 fprintf(stderr, "Mib table is bad. Exiting\n");/ exit(1);t }p tree = build_tree(nodes);g fclose(fp); return CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.C;3BJ;1V-J, tree;} #ifdef TESTemain(argc, argv) int argc;d char *argv[];/{ FILE *fp;l struct node *nodes;s struct tree *tp; fp = fopen("mib.txt", "r");o if (fp == NULL){" fprintf(stderr, "open failed\n"); return 1; }  nodes = parse(fp); tp = build_tree(nodes);> print_subtree(tp, 0);t fclose(fp);>}t#endif /* TEST */l.*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.H;2+,./ 4Zh-0@123KPWO56W#7o8 9FRQٓGHJ</***********************************************************- Copyright 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 notice appear in 9supporting documentation, and that the name of CMU not beBused in advert CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.H;2BJ;1Z6ising 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******************************************************************//* * parse.h *//*< * A linked list of tag-value pairs for enumerated integers. */struct enum_list { struct enum_list *next; int value; char *label;};/* * A linked list of nodes. */ struct node { struct node *next;; char label[32]; /* This node's (unique) textual name */: int subid; /* This node's integer subidentifier */3 char parent[32];/* The parent's textual name */: int type; /* The type of object this represents */Z struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */};/*9 * A tree in the format of the tree structure of the MIB. */ struct tree {@ struct tree *child_list; /* list of children of this node */< struct tree *next_peer; /* Next node in list of peers */ struct tree *parent;3 char label[32]; /* This node's textual name */8 int subid; /* This CMUSNMP.SAV.[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.H;21J;1Z_ node's integer subidentifier */- int type; /* This node's object type */Z struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */8 void (*printer)(); /* Value printing function */};,/* non-aggregate types for tree end nodes */#define TYPE_OTHER 0#define TYPE_OBJID 1#define TYPE_OCTETSTR 2#define TYPE_INTEGER 3#define TYPE_NETADDR 4#define TYPE_IPADDR 5#define TYPE_COUNTER 6#define TYPE_GAUGE 7#define TYPE_TIMETICKS 8#define TYPE_OPAQUE 9#define TYPE_NULL 10struct tree *read_mib();0*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1+,J .#/ 4#!t-0D123KPWO$56+[ē79\ē8M! 9FRQٓGHJ CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1;1#$2PARSEV1.0 6-SEP-1990 11:46GNU CC V1.22<$CODE_CTYPE_ C$V_CTYPEDEFS LINE_800000XDTOKENSBUCKETSMALLOCSTDERRFPRINTFSTRCPYSTRCMPSTRLENATOIFREESTRCATSTRNCPYFGETC @ READ_MIBFOPENEXITFCLOSESTDOUTSTDIN$DATAPP P PobsoleteOpaqueoptionalmandatorynot-accessiblewrite-onlyread-writeTimeTicksOBJECTIDENTIFIEROBJECTNetworkAddressGaugeOCTETSTRINGOCTETOFSEQUENCENULLIpAddressINTEGERCounterread-onlyACCESSSTATUSSYNTAXOBJECT-TYPE{}::=PPSc;P PTRcQa PPPRa!PR ˏRP@d2P@dS@dScBPDPЬPPOPPP[P%s(%s): On or around line %d %s: On or around line %d PЬQЬPPPQPPPPQPPPisoThe mib description doesn't seem to be consistent. Some nodes couldn't be linked under the "iso" tree. these nodes are left: %s ::= { %s %d } (%d) pP <yPPSԣԣcԣ4JP P,ԣ0S_PլVP+PPPRbKPPbsPPbЬR"PݢHݢ$(kPPPbRPSPPЬWЬYXTVUWRiS CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1;1#a@P (1%P( 2PP 6PV:PSUSVBPSeSUTLPciQPcdVPSTcS^PUbPeVS1lP<sPPRWԢb PУ$,ϣH 6P03P0-P0'P0!P0P0P0P 0 P 0PԢ0УL4ԣLgPRgPRRXYRPcS1^PVSPSTcSTf PS$PUnexpected EOFUnexpectedNo terminating parenthesisZP^ЬXЬTЬ WXτvPP{PPP~P1PP1P{ PP1PUUW1P잭VԤdX7PP*PP P~NP1PP P}1PDPmP랭ScPPPbPR Pc(PcPbV$PP+PPRVR9PRc(3BPSSRIPb)NPRbTPb)YP~_P0dPPbSrPPdTWU12PUPP ЬSУLRPRPbRPPRPSPBad formatWarning: This entry is pretty sillyMissing end of oidBad object identifierP@^ЬSRRS PP%PR*P1#-P@RRS=PPX1EPP~NPPYYUVRTTSSW[ePդNjPգ oPc CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1;1#@xPݤ(PRbգ PݣbcPc$ԥHԥLP~ϒPPePUVTSVWPDPդ6Pݤ(PRbݬbcPc$,PϿPϔPPU} P P~P~PUiPPV@TVX,Pդ 1PD<PԤTXVFPYHPP~ϡPP?UPPNot a sequencePremature end of file~P^ЬRRhPP(P~P4PPPPPP} PPPR1PPP~PϽPPBad format for OBJECT TYPE Bad syntaxShould be ACCESSBad access typeShould be STATUSBad statusNo end to oidNP^ЬWRRWϔfPPSSnPRftPyPPP~ϿPPVfԦLWdPRbPSWbPRSHS 1jP UUPR1[PPUPRbTTUbTW PSc PUbTUbTWcPR1. P < PR1D P{1O P1X PR1_ PS1xk PSp P}w P1 PSl PզL  P ϴ PPL  P ϧ PPdPTdR PPϏ PPPQRP`( P`( PaQQP`) PP`) P`Q PPRW PPS1^ CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1;1#*( PS P~\ P1 PR1 P(* PW% PPR* P 8 P : P϶A P1D PR I PϱQ P1T PWϜ^ PPSSf PSk PSp PS u Pϖ} P_ PRRWn PPSS PRω PB PRRWQ PPSS PS  PS PRs P PRRW* PPSS PR Pϱ PVϜ PP@W` PPSSP PSK P~CmP4 P 4(! Pݬ. P~CmP8= P8$!E P~oK PDP PR P~X P7] PV"d PVRRSm P~BDP` w P` P~BDP`SR PVPis a reserved wordBad parse of object typeBad parse of objecttypeBad parse of object idBad operator P^ЬWT PVUVW PPSS" PS1) Pc- PV12 P VU? PVWϲH PPSS<P PTT PUW] PPTTR!e P~8k Pom PUWv PPb { P~; PY PbRb Pb PS< PT PUWj PPTTR! P~( P. PUWQ PPb  P~ P PbRb P! PS PS P~ Pϳ PPWϓ PPSS1 PTP P P CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1SLATION.C;13#A |ЬVЬTTSUdQ PR# PQ1' PV0 PPQQ 8 PˏQPB`L P1O PˏQP` PQUQQ 1n P1w PQcˏUP@ PR PѢ U PTb PP PТR PR PѢK PТPd-= P-7 P  PQ  P PV PPQQ PQ& PQ1PPVPPQQ11PPrMib table is bad. Exiting @P EPݬOPPSTPPSϚ^PPRcPfPlPsP|PRPPRSPRPPPP"P(P(P.P4P:P@PFPyPPPyPyP}PyPyPyPyPyPyPyPPFCLOSEwPEXITnPFPRINTFgPJPFOPEN PFGETC PFGETC PSTRCMP P+ PFGETC P: PSTRNCPY{ PFREE) PSTRCPY PSTRNCPY3 PSTRCPY PATOI PSTRLEN7 PSTRCPYPSTRCATPSTRCPY7PFREEPSTRCPYPSTRCPYPFREEPFREEmPATOI4PSTRCPYPSTRLENPSTRCPY-PSTRCMPPFPRINTFPPPPFP CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1SLATION.C;13#RINTFPPSTRCPYPFPRINTFPPFPRINTFPVPMALLOCPP C$V_CTYPEDEFS P Py Po PY P9 P PPPPPP P         PPPPPPPPP|PhPTP@P,PPPPPPtPmP\PRxPGdP<PP-<P#(PPP  PARSEPRS_iobufp _cnt _ptr  @_base  `_flag h_fileRSsubid@ subid label R CMUSNMP.SAVJ 0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]PARSE.OBJ;1SLATION.C;13#+XStree child_list T next_peer T @parent T `label*&  `subid type enums Rprinter RSnode next T label*&   subid @parent*&  @type `enums RRSTSTS enum_list` next T  valueS @label RStok name   len @token `hash next T Line tokens3/TDbuckets62 T &$$PsectAttributes_NOSHR$$stderr T&$$PsectAttributes_NOSHR$$stdoutN T%$$PsectAttributes_NOSHR$$stdin TTP(wYĒ,#include #ifndef NULL#define NULL 0#endif#endif#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "mib.h"#include "snmp_vars.h"u_char *_snmp_parse_var_op(data, var_name, var_name_len, var_val_type, var_val_len, var_val, listlength)E register u_char *data; /* IN - pointer to the start of object */< oid *var_name; /* OUT - object id of variable */? int *var_name_len; /* OUT - length of variable name */Y u_char *var_val_type; /* OUT - type of variable (int or octet string) (one byte) */: int *var_val_len; /* OUT - length of variable */P u_char **var_val; /* OUT - pointer to ASN1 encoded value of variable */T int *listlength; /* IN/OUT - number of valid bytes left in var_op_list */{ u_char var_op_type;& int var_op_len = *listlength;$ u_char *var_op_start = data;= data = asn_parse_header(data, &var_op_len, &var_op_type); if (data == NULL){ ERROR(""); return NULL; }@ if (var_op_type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)) return NU CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2OLB;13s"LL;T data = asn_parse_objid(data, &var_op_len, &var_op_type, var_name, var_name_len); if (data == NULL){ ERROR(""); return NULL; }O if (var_op_type != (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID)) return NULL;6 *var_val = data; /* save pointer to this object */. /* find out what type of object this is */= data = asn_parse_header(data, &var_op_len, var_val_type); if (data == NULL){ ERROR(""); return NULL; } *var_val_len = var_op_len; data += var_op_len;. *listlength -= (int)(data - var_op_start); return data;}u_char *_snmp_build_var_op(data, var_name, var_name_len, var_val_type, var_val_len, var_val, listlength)S register u_char *data; /* IN - pointer to the beginning of the output buffer */4 oid *var_name; /* IN - object id of variable */6 int *var_name_len; /* IN - length of object id */4 u_char var_val_type; /* IN - type of variable */3 int var_val_len; /* IN - length of variable */1 u_char *var_val; /* IN - value of variable */[ register int *listlength; /* IN/OUT - number of valid bytes left in output buffer */{! int dummyLen, headerLen; u_char *dataPtr; dummyLen = *listlength; dataPtr = data;Z data = asn_build_header(data, &dummyLen, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); if (data == NULL){ ERROR(""); return NULL; } headerLen = data - dataPtr; *listlength -= headerLen;, data = asn_build_objid CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2OLB;13 (data, listlength,= (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID), var_name, *var_name_len); if (data == NULL){ ERROR(""); return NULL; } switch(var_val_type){ case ASN_INTEGER: case GAUGE: case COUNTER: case TIMETICKS:9 data = asn_build_int(data, listlength, var_val_type,$ (long *)var_val, var_val_len); break; case ASN_OCTET_STR: case IPADDRESS: case OPAQUE:< data = asn_build_string(data, listlength, var_val_type, var_val, var_val_len); break; case ASN_OBJECT_ID:; data = asn_build_objid(data, listlength, var_val_type,1 (oid *)var_val, var_val_len / sizeof(oid)); break; case ASN_NULL:; data = asn_build_null(data, listlength, var_val_type); break; default: ERROR("wrong type"); return NULL; } if (data == NULL){ ERROR(""); return NULL; }, dummyLen = (data - dataPtr) - headerLen;j if (asn_build_header(dataPtr, &dummyLen, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), dummyLen) == NULL){ ERROR(""); return NULL; } return data;}intsnmp_build_trap(out_data, length, sysOid, sysOidLen, myAddr, trapType, specificType, time, varName, varNameLen, varType, varLen, varVal) register u_char *out_data; int length; oid *sysOid; int sysOidLen; u_long myAddr; int trapType; int specificType; u_long time; oid *varName; int varNameLen;  CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2OLB;13b u_char varType; int varLen; u_char *varVal;{% long version = SNMP_VERSION_1;& int sidLen = strlen("public"); int dummyLen;U u_char *out_auth, *out_header, *out_pdu, *out_varHeader, *out_varlist, *out_end; out_auth = out_data;_ out_header = snmp_auth_build(out_data, &length, (u_char *)"public", &sidLen, &version, 90); if (out_header == NULL){ ERROR("auth build failed"); return 0; }M out_pdu = asn_build_header(out_header, &length, (u_char)TRP_REQ_MSG, 90); if (out_pdu == NULL){ ERROR("header build failed"); return 0; }0 out_data = asn_build_objid(out_pdu, &length,: (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID), (oid *)sysOid, sysOidLen); if (out_data == NULL){" ERROR("build enterprise failed"); return 0; }2 out_data = asn_build_string(out_data, &length,: (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),% (u_char *)&myAddr, sizeof(myAddr)); if (out_data == NULL){" ERROR("build agent_addr failed"); return 0; }/ out_data = asn_build_int(out_data, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),' (long *)&trapType, sizeof(trapType)); if (out_data == NULL){! ERROR("build trap_type failed"); return 0; }/ out_data = asn_build_int(out_data, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),/ (long *)&specificType, sizeof(specificType)); if (out_data == NULL){$ ERROR("build specificType fai CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2OLB;13led"); return 0; }4 out_varHeader = asn_build_int(out_data, &length, (u_char)(TIMETICKS), (long *)&time, sizeof(time)); if (out_varHeader == NULL){ ERROR("build timestampfailed"); return 0; }j out_varlist = asn_build_header(out_varHeader, &length, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 90);e out_end = snmp_build_var_op(out_varlist, varName, &varNameLen, varType, varLen, varVal, &length); if (out_end == NULL){ ERROR("build varop failed"); return 0; }4 /* Now rebuild header with the actual lengths */% dummyLen = out_end - out_varlist;v if (asn_build_header(out_varHeader, &dummyLen, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), dummyLen) != out_varlist) return 0;! dummyLen = out_end - out_pdu;Z if (asn_build_header(out_header, &dummyLen, (u_char)TRP_REQ_MSG, dummyLen) != out_pdu) return 0;$ dummyLen = out_end - out_header;l if (snmp_auth_build(out_auth, &dummyLen, (u_char *)"public", &sidLen, &version, dummyLen) != out_header) return 0; return out_end - out_auth;} CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.H;2OLB;13HA-*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.H;2+,./ 4Ht-0@123KPWO567uWo8&# 9FRQٓGHJ/*E * Definitions for the Simple Network Management Protocol (RFC 1067). * * */</***********************************************************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 notice 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 CMUSNMP.SAV-[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.H;2OLB;13HM OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************/#define SNMP_PORT 161#define SNMP_TRAP_PORT 162#define SNMP_MAX_LEN 484#define SNMP_VERSION_1 0=#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)A#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)=#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)=#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)=#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)!#define SNMP_ERR_NOERROR (0x0)!#define SNMP_ERR_TOOBIG (0x1)!#define SNMP_ERR_NOSUCHNAME (0x2)!#define SNMP_ERR_BADVALUE (0x3)!#define SNMP_ERR_READONLY (0x4)!#define SNMP_ERR_GENERR (0x5)"#define SNMP_TRAP_COLDSTART (0x0)"#define SNMP_TRAP_WARMSTART (0x1)!#define SNMP_TRAP_LINKDOWN (0x2)#define SNMP_TRAP_LINKUP (0x3)!#define SNMP_TRAP_AUTHFAIL (0x4)'#define SNMP_TRAP_EGPNEIGHBORLOSS (0x5)*#define SNMP_TRAP_ENTERPRISESPECIFIC (0x6) CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13/*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1+,J ./ 4$-0D123KPWO56洖eē7ƻeē8{* 9FRQٓGHJ1SNMPV1.0 6-SEP-1990 11:46GNU CC V1.22p$CODESID SNMP_PARSE_VAR_OPASN_PARSE_HEADERASN_PARSE_OBJID ~SNMP_BUILD_VAR_OPASN_BUILD_HEADERASN_BUILD_OBJID ASN_BUILD_INTASN_BUILD_STRINGASN_BUILD_NULL SNMP_BUILD_TRAPSTRLENSNMP_AUTH_BUILDPP^ЬQЬRbQSQ#PPQ>(P08.Pݬ ݬQCPPQHPNPQݬQaPPQfPPЭQSQPPbQP~P^ЬRTЬUЬVЬScRW~0RPPR1&PWRXXcݼ ݬSRPPR1PTPPBqkPUVT~SR}P9PUVT~SRP%PU~VT~SRPPT~SRPPRPWRPXPPP0W CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13^PPPPRPpublicP ^ЬR,XԭPPPRWZ~PW$PPV1<,P욏Z~~V@PPU1 HPݬݬ U\PPR1dPRwPPR1PRPPR1PRPPR1P C~RPPT1P뚏Z~0RRTPPSRݬ4ݬ0X~(ݬ$S|PPRaPSRPPP0TPPSD$PURPPP~V>PPU%CPVRPPPόWPWcPPVhPPWRPPPPPPPPPPPPPPPPPPPP P P PPPPPPPPPP!P#P%P'P)P+P-P/P1P3P5P7P9P;P=P?PAPCPEPGPIPKPMPOPQPSPUPWPYP[P]P_PaPcPePgP^PSNMP_AUTH_BUILD9PASN_BUILD_HEADERPASN_BUILD_HEADERPASN_BUILD_HEADERP ASN_BUILD_INTP ASN_BUILD_INTP ASN_BUILD_INTrPASN_BUILD_STRINGW CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13kPASN_BUILD_OBJID;PASN_BUILD_HEADERPSNMP_AUTH_BUILDPSTRLENPASN_BUILD_HEADERPASN_BUILD_NULLPASN_BUILD_OBJIDPASN_BUILD_STRINGxP ASN_BUILD_INTPASN_BUILD_OBJIDPASN_BUILD_HEADER\PASN_PARSE_HEADER>PASN_PARSE_OBJIDPASN_PARSE_HEADER SNMPRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrRSvariable name*&namelen type magic aclfindVar RSmib_egpNeighEntry@ egpNeighState egpNeighAddrRSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrorsRSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPort R Smib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegs R S CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13 mib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskReps R Smib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAge R Smib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddr R Smib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atI CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13or fIndex atPhysAddress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr*&   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 sysUpTimeSO8;DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.C;2  snmp_parse_var_opbvar_name  var_name_len  var_val_type  var_val_len var_val data | # listlength |  var_op_type var_op_len% var_op_start |  5 CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13˘~~snmp_build_var_opvar_name  var_name_len data % var_val_type$ var_val_len var_val # listlength dummyLen" headerLen dataPtr   lsnmp_build_trap length sysOid  sysOidLen myAddrtrapType specificType  time$varName ( varNameLen 0varLen 4varVal ! out_datao  varTypeoversion sidLendummyLen! out_autho6# # out_headero  out_pduo & out_varHeadero $ out_varlisto  out_endo   CMUSNMP.SAVJ /[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP.OBJ;1B;13VQSQPPbQP~P^ЬRTЬUЬVЬScRW~0RPPR1&PWRXXcݼ ݬSRPPR1PTPPBqkPUVT~SR}P9PUVT~SRP%PU~VT~SRPPT~SRPPRPWRPXPPP0W4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17+,.-/ 4z-)<-0@123KPWO.56Y77zo8N9FRQٓGHJ/*1 * Simple Network Management Protocol (RFC 1067). * */</***********************************************************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 documen CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z-.tation, 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******************************************************************/#ifdef KINETICS#include "gw.h"#include "ab.h"#include "inet.h"#include "fp4/cmdmacro.h"#include "fp4/pbuf.h"#include "glob.h"#endif)#if (defined(unix) && !defined(KINETICS))#include #include #include #include #ifndef NULL#define NULL 0#endif#endif#include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "mib.h"#include "snmp_vars.h"void snmp_input();void snmp_trap();int create_identical();int parse_var_op_list();int snmp_access();char version_descr[];oid version_id[];int version_id_len; struct pbuf *definitelyGetBuf();#define NUM_COMMUNITIES 5&char *communities[NUM_COMMUNITIES] = { "public", "proxy", "private", "regional", "core"};5/* these can't be global in a multi-pr CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17FILE.;2z-ocess router */ u_char sid[SID_MAX_LEN + 1]; int sidlen; u_char *packet_end; int community; #ifdef vax11c#define perror socket_perror #endif vax11c #ifdef unix#ifndef MASTER_SERVERmain(){ unsigned short s; int n, len; char buf[2000], outbuf[2000]; struct sockaddr_in sin; struct servent *sp; /*> * Create an IP-family socket on which to listen for packets */$ s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { perror("socket"); exit(1); } /*A * Create a "sockaddr_in" structure which describes the port we? * want to listen to. Address INADDR_ANY means we will accept2 * connections to any of our local IP addresses. */ sin.sin_family = AF_INET;" sin.sin_addr.s_addr = INADDR_ANY; /*2 * Get the UDP port number of the "snmp" server. */# sp = getservbyname("snmp", "udp"); if (sp == NULL)% sin.sin_port = htons(SNMP_PORT); else sin.sin_port = sp->s_port; /* * Bind to that address... */* if (bind(s, &sin, sizeof (sin), 0) < 0) { perror("bind"); exit(1); } /* * Initialize variables */ init_snmp(); /*B * Now go into a loop, reading data from the network and sending * it right back... */A while ((n = recvfrom(s, buf, sizeof(buf), 0, &sin, &len)) > 0) {K if (snmp_parse(buf, n, outbuf, sizeof(outbuf), sin.sin_addr.s_addr)) {C sendto(s, outbuf, (int) packet_end - (int) outbuf, 0, &sin, len); } }}#endif MASTER_SERVER CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z- #endif unix#ifdef KINETICSvoid snmp_input(p) struct pbuf *p;{. struct ip *ip = (struct ip *)p->p_off;( int hlen = (int)ip->ip_hl << 2;! register struct udp *udp;H register u_char *data; /* pointer to the rest of the unread data */M int length; /* bytes of data left in msg after the "data" pointer */ struct pbuf *out_packet; register u_char *out_data; int out_length; u_short udp_src;$ extern struct mib_udp mib_udp;* udp = (struct udp *)(p->p_off + hlen);` if (ntohs(ip->ip_len) - hlen < sizeof(struct udp) || /* IP length < minimum UDP packet */O ntohs(udp->length) > ntohs(ip->ip_len) - hlen){ /* UDP length > IP data */< ERROR("dropped packet with bad length"); /* delete me */ return; /* drop packet */ }. data = (u_char *)udp + sizeof(struct udp);5 length = ntohs(udp->length) - sizeof(struct udp);T out_packet = definitelyGetBuf(); /* drop packets off input queue if necessary */X out_data = (u_char *)(out_packet->p_off + sizeof (struct ip) + sizeof (struct udp));C out_length = MAXDATA - sizeof(struct ip) - sizeof (struct udp); K_LEDON();M if (!snmp_parse(data, length, out_data, out_length, (u_long)ip->ip_src)){ K_PFREE(out_packet); K_LEDOFF(); return; } K_LEDOFF();A out_packet->p_len = packet_end - (u_char *)out_packet->p_off;\ setiphdr(out_packet, ip->ip_src); /* address to source of request packet (ntohl ??? ) */ udp_src  CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z-4 = ntohs(udp->src);A udp = (struct udp *)(out_packet->p_off + sizeof (struct ip)); udp->src = htons(SNMP_PORT); udp->dst = htons(udp_src);8 udp->length = out_packet->p_len - sizeof(struct ip);4 udp->checksum = 0; /* this should be computed */ mib_udp.udpOutDatagrams++; routeip(out_packet, 0, 0);}void+snmp_trap(destAddr, trapType, specificType) u_long destAddr; int trapType; int specificType;{ struct pbuf *out_packet; register u_char *out_data;! register struct udp *udp; int out_length;? static oid sysDescrOid[] = {1, 3, 6, 1, 2, 1, 1, 1, 0};T out_packet = definitelyGetBuf(); /* drop packets off input queue if necessary */X out_data = (u_char *)(out_packet->p_off + sizeof (struct ip) + sizeof (struct udp));C out_length = MAXDATA - sizeof(struct ip) - sizeof (struct udp); K_LEDON();Y out_packet->p_len = snmp_build_trap(out_data, out_length, version_id, version_id_len,k conf.ipaddr, trapType, specificType, TICKS2MS(tickclock)/10, sysDescrOid, sizeof(sysDescrOid)/sizeof(oid),@ ASN_OCTET_STR, strlen(version_descr), (u_char *)version_descr); if (out_packet->p_len == 0){ K_PFREE(out_packet); K_LEDOFF(); return; } K_LEDOFF();@ out_packet->p_len += sizeof(struct ip) + sizeof(struct udp);Z setiphdr(out_packet, destAddr); /* address to source of request packet (ntohl ??? ) */A udp = (struct udp *)(out_packet->p_off + sizeof (struct ip)); udp->s CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z-^rc = htons(SNMP_PORT);% udp->dst = htons(SNMP_TRAP_PORT);8 udp->length = out_packet->p_len - sizeof(struct ip);4 udp->checksum = 0; /* this should be computed */ mib_udp.udpOutDatagrams++; routeip(out_packet, 0, 0);}#endifint8snmp_parse(data, length, out_data, out_length, sourceip) register u_char *data; int length; register u_char *out_data; int out_length;7 u_long sourceip; /* possibly for authentication */{ u_char msg_type, type; long zero = 0;& long reqid, errstat, errindex;7 register u_char *out_auth, *out_header, *out_reqid;! u_char *startData = data;" int startLength = length; long version;& int header_shift, auth_shift; sidlen = SID_MAX_LEN;z data = snmp_auth_parse(data, &length, sid, &sidlen, &version); /* authenticates message and returns length if valid */ if (data == NULL){ ERROR("bad authentication"); /* send auth fail trap */ return 0; }# if (version != SNMP_VERSION_1){ ERROR("wrong version"); return NULL; }# community = get_community(sid); if (community == -1) return NULL;6 data = asn_parse_header(data, &length, &msg_type); if (data == NULL){ ERROR("bad header"); return 0; }[ if (msg_type != GET_REQ_MSG && msg_type != GETNEXT_REQ_MSG && msg_type != SET_REQ_MSG){ return 0; }P data = asn_parse_int(data, &length, &type, (u_long *)&reqid, sizeof(reqid)); if (data = CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z-q= NULL){ ERROR("bad parse of reqid"); return 0; }T data = asn_parse_int(data, &length, &type, (u_long *)&errstat, sizeof(errstat)); if (data == NULL){ ERROR("bad parse of errstat"); return 0; }V data = asn_parse_int(data, &length, &type, (u_long *)&errindex, sizeof(errindex)); if (data == NULL){ ERROR("bad parse of errindex"); return 0; } /*I * Now start cobbling together what is known about the output packet.N * The final lengths are not known now, so they will have to be recomputed * later. */ out_auth = out_data;P out_header = snmp_auth_build(out_auth, &out_length, sid, &sidlen, &zero, 0); if (out_header == NULL){! ERROR("snmp_auth_build failed"); return 0; }R out_reqid = asn_build_header(out_header, &out_length, (u_char)GET_RSP_MSG, 0); if (out_reqid == NULL){ ERROR(""); return 0; }A type = (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER);% /* return identical request id */\ out_data = asn_build_int(out_reqid, &out_length, type, (u_char *)&reqid, sizeof(reqid)); if (out_data == NULL){ ERROR("build reqid failed"); return 0; }/ /* assume that error status will be zero */Y out_data = asn_build_int(out_data, &out_length, type, (u_char *)&zero, sizeof(zero)); if (out_data == NULL){ ERROR("build errstat failed"); return 0; }. /* assume that error index will be zero */Y out_data = asn_build_int(out_data, &out_length,  CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z--type, (u_char *)&zero, sizeof(zero)); if (out_data == NULL){ ERROR("build errindex failed"); return 0; }\ errstat = parse_var_op_list(data, length, out_data, out_length, msg_type, &errindex, 0);@ if (msg_type == SET_REQ_MSG && errstat == SNMP_ERR_NOERROR){ /*P * SETS require 2 passes through the var_op_list. The first pass verifies thatP * all types, lengths, and values are valid, and the second does the set. Then2 * the identical GET RESPONSE packet is returned. */Y errstat = parse_var_op_list(data, length, out_data, out_length, msg_type, &errindex, 1);*@ if (create_identical(startData, out_auth, startLength, 0L, 0L)) return 1; return 0; }  switch((short)errstat){m case SNMP_ERR_NOERROR:f /*sL * Because of the assumption above that header lengths would be encodedT * in one byte, things need to be fixed, now that the actual lengths are known. */ header_shift = 0;) out_length = packet_end - out_reqid;r if (out_length >= 0x80){e header_shift++; if (out_length > 0xFF) header_shift++;d } auth_shift = 0;= out_length = (packet_end - out_auth) - 2 + header_shift;  if (out_length >= 0x80){S auth_shift++;G if (out_length > 0xFF) auth_shift++;  }$ if (auth_shift + header_shift){ /*F * Shift packet (from request id to end of packet) by the sum of the * necessary shift counts. */IL shift_array(out_reqid, packet_end - out_reqid, auth_shift + head CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z-Her_shift);+ /* Now adjust pointers into the packet */O* packet_end += auth_shift + header_shift;) out_reqid += auth_shift + header_shift;* out_header += auth_shift;N }6 /* re-encode the headers with the real lengths */ out_data = out_header;c) out_length = packet_end - out_reqid;dQ out_data = asn_build_header(out_data, &out_length, GET_RSP_MSG, out_length);< if (out_data != out_reqid){" ERROR("internal error: header"); return 0;  } out_data = out_auth;n( out_length = packet_end - out_auth;e out_data = snmp_auth_build(out_data, &out_length, sid, &sidlen, &zero, packet_end - out_header);a! if (out_data != out_header){l ERROR("internal error"); return 0;n } break;o case SNMP_ERR_NOSUCHNAME: case SNMP_ERR_TOOBIG: case SNMP_ERR_BADVALUE: case SNMP_ERR_READONLY: case SNMP_ERR_GENERR:O if (create_identical(startData, out_auth, startLength, errstat, errindex))r break; return 0; default:  return 0; }* return 1;s}S/*O * Parse_var_op_list goes through the list of variables and retrieves each one,iV * placing it's value in the output packet. If doSet is non-zero, the variable is setQ * with the value in the packet. If any error occurs, an error code is returned.0 */intcLparse_var_op_list(data, length, out_data, out_length, msgtype, index, doSet) register u_char *data; int length;= register u_char *out_data; int out_length;r u_char msgtype; CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17z- register long *index;t int doSet;{u u_char type;e# oid var_name[MAX_NAME_LEN];o& int var_name_len, var_val_len;- u_char var_val_type, *var_val, statType;r register u_char *statP;l int statLen; u_short acl; int rw, exact; int access_method;& u_char *headerP, *var_list_start; int dummyLen;i int header_shift;n if (msgtype == SET_REQ_MSG) rw = WRITE; else rw = READ;/# if (msgtype == GETNEXT_REQ_MSG)/ exact = FALSE;& else exact = TRUE;2 data = asn_parse_header(data, &length, &type); if (data == NULL){' ERROR("not enough space for varlist");g return PARSE_ERROR; }r: if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)){ ERROR("wrong type");, return PARSE_ERROR; }l headerP = out_data;md out_data = asn_build_header(out_data, &out_length, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); if (out_data == NULL){, ERROR("not enough space in output packet"); return BUILD_ERROR; } var_list_start = out_data; *index = 1;  while((int)length > 0){ ! /* parse the name, value pair */  var_name_len = MAX_NAME_LEN;tp data = snmp_parse_var_op(data, var_name, &var_name_len, &var_val_type, &var_val_len, &var_val, (int *)&length); if (data == NULL) return PARSE_ERROR;? /* now attempt to retrieve the variable on the local entity */r_ statP = getStatPtr(var_name, &var_name_len, &statType, &statLen, &acl, exact, &access_method);  i CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17;1z-h f (statP == NULL)d return SNMP_ERR_NOSUCHNAME;< /* Check if this user has access rights to this variable */' if (!snmp_access(acl, community, rw)){ $ ERROR("authentication failed");, return SNMP_ERR_NOSUCHNAME; /* bogus */ /* send_trap(); */a } if (msgtype == SET_REQ_MSG){tN /* see if the type and value is consistent with this entities variable */C if (!goodValue(var_val_type, var_val_len, statType, statLen)){k return SNMP_ERR_BADVALUE;r }+ /* actually do the set if necessary */a if (doSet)uB setVariable(var_val, var_val_type, var_val_len, statP, statLen); }O /* retrieve the value of the variable and place it into the outgoing packet */(h out_data = snmp_build_var_op(out_data, var_name, &var_name_len, statType, statLen, statP, &out_length); if (out_data == NULL){E return SNMP_ERR_TOOBIG; } (*index)++; }oI packet_end = out_data; /* save a pointer to the end of the packet */r /*K * Because of the assumption above that header lengths would be encoded S * in one byte, things need to be fixed, now that the actual lengths are known.  */t header_shift = 0; - out_length = packet_end - var_list_start;  if (out_length >= 0x80){ header_shift++; if (out_length > 0xFF). header_shift++; }i if (header_shift){H shift_array(var_list_start, packet_end - var_list_start, header_shift); packet_end += header_shift; var_list_start += header_shift; }u4 /* Now rebuild header wi CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17;1z- th the actual lengths */+ dummyLen = packet_end - var_list_start; j if (asn_build_header(headerP, &dummyLen, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), dummyLen) == NULL){/ return SNMP_ERR_TOOBIG; /* bogus error ???? */  }r *index = 0;a return SNMP_ERR_NOERROR;} /*M * create a packet identical to the input packet, except for the error statusiF * and the error index which are set according to the input variables.- * Returns 1 upon success and 0 upon failure.s */dintCcreate_identical(snmp_in, snmp_out, snmp_length, errstat, errindex)s u_char *snmp_in; u_char *snmp_out;S int snmp_length;( long errstat, errindex;({_ register u_char *data; u_char type; u_long dummy; " int length, headerLength;R register u_char *headerPtr, *reqidPtr, *errstatPtr, *errindexPtr, *varListPtr;: bcopy((char *)snmp_in, (char *)snmp_out, snmp_length); length = snmp_length;eQ headerPtr = snmp_auth_parse(snmp_out, &length, sid, &sidlen, (long *)&dummy);h if (headerPtr == NULL) return 0;F reqidPtr = asn_parse_header(headerPtr, &length, (u_char *)&dummy); if (reqidPtr == NULL) return 0; headerLength = length;` errstatPtr = asn_parse_int(reqidPtr, &length, &type, &dummy, sizeof dummy); /* request id */ if (errstatPtr == NULL) return 0;e errindexPtr = asn_parse_int(errstatPtr, &length, &type, &dummy, sizeof dummy); /* error status */u if (errindexPtr == NULL) return 0;d  CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17;1z-Qx#varListPtr = asn_parse_int(errindexPtr, &length, &type, &dummy, sizeof dummy); /* error index */ if (varListPtr == NULL) return 0;Q data = asn_build_header(headerPtr, &headerLength, GET_RSP_MSG, headerLength); if (data != reqidPtr)a return 0; length = snmp_length;A type = (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER);;X data = asn_build_int(errstatPtr, &length, type, (u_char *)&errstat, sizeof errstat); if (data != errindexPtr) return 0;[ data = asn_build_int(errindexPtr, &length, type, (u_char *)&errindex, sizeof errindex); if (data != varListPtr)o return 0;( packet_end = snmp_out + snmp_length; return 1;L}#ifdef KINETICSe struct pbuf *ldefinitelyGetBuf(){  register struct pbuf *p; K_PGET(PT_DATA, p); while(p == 0){ #ifdef notdef_ if (pq->pq_head != NULL){ K_PDEQ(SPLIMP, pq, p);_ if (p) K_PFREE(p);$ } else if (sendq->pq_head != NULL){ K_PDEQ(SPLIMP, sendq, p); if (p) K_PFREE(p);a }#endif K_PGET(PT_DATA, p); } return p; }#endifintnsnmp_access(acl, community, rw)( u_short acl; int community; int rw;{L /*J * Each group has 2 bits, the more significant one is for read access,4 * the less significant one is for write access. */ G community <<= 1; /* multiply by two two shift two bits at a time */ if (rw == READ){A return (acl & (2 << community)); /* return the correct bit */* } else {! return (acl & CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17;1z-`& (1 << community));l }o} inttget_community(sessionid) u_char *sessionid;{; int count;5 for(count = 0; count < NUM_COMMUNITIES; count++){z, if (!strcmp(communities[count], sessionid)) break;u }l! if (count == NUM_COMMUNITIES)_ return -1;u return count;e}&intg/goodValue(inType, inLen, actualType, actualLen)= u_char inType, actualType; int inLen, actualLen;{r int type;  if (inLen > actualLen) return FALSE;3 /* convert intype to internal representation */iz type = inType == ASN_INTEGER ? INTEGER : inType == ASN_OCTET_STR ? STRING : inType == ASN_OBJECT_ID ? OBJID : NULLOBJ; return (type == actualType);}m?setVariable(var_val, var_val_type, var_val_len, statP, statLen)o u_char *var_val;y u_char var_val_type;( int var_val_len; u_char *statP;u int statLen;{r int buffersize = 1000; switch(var_val_type){r case ASN_INTEGER: case COUNTER: case GAUGE: case TIMETICKS:R asn_parse_int(var_val, &buffersize, &var_val_type, (u_long *)statP, statLen); break;r case ASN_OCTET_STR: case IPADDRESS: case OPAQUE:eL asn_parse_string(var_val, &buffersize, &var_val_type, statP, &statLen); break;r case ASN_OBJECT_ID:K asn_parse_objid(var_val, &buffersize, &var_val_type, statP, &statLen);s break;t }l}y(shift_array(begin, length, shift_amount) u_char *begin; register int length;N int shift_amount; CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17;1z-a){e register u_char *old, *new;l if (shift_amount >= 0){g old = begin + length - 1; new = old + shift_amount; while(length--) *new-- = *old--;r } else { old = begin;  new = begin + shift_amount; while(length--) *new++ = *old++;a }t}a5*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;1+,J ./ 4-0D123KPWO56&j0rē7arē8 f 9FRQٓGHJ7 SNMP_AGENTV1.0 6-SEP-1990 11:47GNU CC V1.22$CODEASID VERSION_DESCR VERSION_ID COMMUNITIES $ SNMP_PARSESIDLENSNMP_AUTH_PARSE  GET_COMMUNITY COMMUNITYASN_PARSE_HEADER ASN_PARSE_INTSNMP_AUTH_BUILDASN_BUILD_HEADER ASN_BUILD_INT PARSE_VAR_OP_LIST CREATE_IDENTICAL PACKET_END f SHIFT_ARRAYSNMP_PARSE_VAR_OPGETSTATPTR_440000X CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;11<  SNMP_ACCESS <GOODVALUE_010000X ~SETVARIABLE_080000XSNMP_BUILD_VAR_OPBCOPYSTRCMPASN_PARSE_STRINGASN_PARSE_OBJIDVERSION_ID_LENPpublicproxyprivateregionalcore#P$P^ЬSЬ RԭSYЬZ@CPLPRPY^PPS1fPխ1nPtPϓyPPPP1gPSPPS1PPP P18PSPPS1PSPPS1PS PPS1PRX~!P'PX3PPU1;P~~UMPPT1UP~TnPPR1vPꚭ~RPPR1dPꚭ~RPPR1GP~WW~ݬRݬS:PVfP7PP3PW~ݬRݬSfP~~ZXYPP1 PP2PP1'PQT0PѬ<PQѬIPQSXUPPAѬfPSѬsPSSQR|PRTP~TPRPRTSUTPPPP~UPPRRT7PXPUP~PPXPPRRU1PPݭݭ1PP_^ЬTЬ SXЬ[X!PZ%PZ CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;11X.PY2PYTEPPTcJP0\QPS_~0SfPPSkPPSUkլ1}P՞{WV@{rvzWVTPPTPPgYkmqWVPPRPZPPPPP9 PP PP SNMP_AGENTRSprotoent` p_name  p_aliases @p_protoRSservent s_name  s_aliases  @s_port`s_proto RSnetent n_name  n_aliases @ n_addrtype `n_net n_addresses RRShostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protos  h_addresses RRS sockaddr_in sin_familysin_port CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;11N sin_addr R@sin_zero*& RS T Sin_addr s_addr R Smsghdrmsg_name  msg_namelen@msg_iov  R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocol RS TS T Ssockaddr sa_familysa_data*& RSlinger@l_onoff l_lingerRSvariable name*&namelen type magic aclfindVar RSmib_egpNeighEntry@ egpNeighState egpNeighAddrRSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrorsRSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPortRSmib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetran CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;15:sSegsRSmib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchsS`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsRSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteTypeP ipRouteProto  ipRouteAgeRSmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrRSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS m CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;15 ib_atEntry atIfIndex atPhysAddress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr*&   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 sysUpTimeR STS  communities3/ community packet_end  sidlenversion_id_len sid*&AA@ZVY7)BDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.C;17  $ snmp_parse length out_lengthsourceipdata1 ! out_data1 msg_type  CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;15ztype zero reqiderrstaterrindex! out_auth1 # out_header1 " out_reqid1 " startData1 $ startLength1 version% header_shift1# auth_shift1l $  get_community^" sessionid; count;0parse_var_op_list length out_length doSetdata ! out_data  msgtypeindex  typeـvar_name*&@@?{ var_name_lenv var_val_lenz var_val_typervar_vala qstatTypestatP mstatLen kaclrw exact g access_method_headerP 'var_list_start CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;154 cdummyLen% header_shiftG5create_identicalsnmp_in errstaterrindex! snmp_out $ snmp_lengthdata  type dummy length headerLength" headerPtr ! reqidPtr # errstatPtr $ errindexPtr # varListPtr pf shift_arraybegint lengtht% shift_amounttoldt newt E B snmp_access\  rwacl" community2*< goodValue inLen actualLeninTypeF|# ac CMUSNMP.SAVJ 5[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OBJ;15 tualTypeF|typeF|0B~ setVariable var_val_type var_val_lenstatLen var_vald statPd  buffersize   n+J*` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocol RS TS T Ssockaddr sa_familysa_data*&6*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OPT;13+,./ 4&<-0@123KPWO56g6~7@o8@fwғ9FRQٓGHJ CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.OPT;13&0 SNMP_AGENT%SNMP_VARS,SNMP_VAR_ROUTE,SNMP_VAR_ARPDEVICE_TRANSLATION LIBSNMP/LIB&MULTINET:MULTINET_SOCKET_LIBRARY/SHARE%MULTINET:MULTINET_VMS_SHAREABLE/SHARESYS$DISK:[---.LIB]LIB/LIBGNU_CC:[000000]GCCLIB/LIBSYS$SHARE:VAXCRTL/SHARE6*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1+,.-/ 4z-&~-0@123KPWO.567ao8!ғ9FRQٓGHJ/*1 * Simple Network Management Protocol (RFC 1067). * */</***********************************************************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 notice appear in 9su CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1z-|Wpporting 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******************************************************************/#ifdef KINETICS#include "gw.h"#include "ab.h"#include "inet.h"#include "fp4/cmdmacro.h"#include "fp4/pbuf.h"#include "glob.h"#endif)#if (defined(unix) && !defined(KINETICS))#include #include #ifndef NULL#define NULL 0#endif#endif#include "snmp.h"#include "snmp_impl.h"#include "asn1.h"#include "mib.h"#include "snmp_vars.h"void snmp_input();void snmp_trap();int create_identical();int parse_var_op_list();int snmp_access();char version_descr[];oid version_id[];int version_id_len; struct pbuf *definitelyGetBuf();#define NUM_COMMUNITIES 5&char *communities[NUM_COMMUNITIES] = { "public", "proxy", "private", "regional", "core"};5/* these can't be global in a multi-process router */ u_char CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1z-ؽ sid[SID_MAX_LEN + 1]; int sidlen; u_char *packet_end; int community;#ifdef KINETICSvoid snmp_input(p) struct pbuf *p;{. struct ip *ip = (struct ip *)p->p_off;( int hlen = (int)ip->ip_hl << 2;! register struct udp *udp;H register u_char *data; /* pointer to the rest of the unread data */M int length; /* bytes of data left in msg after the "data" pointer */ struct pbuf *out_packet; register u_char *out_data; int out_length; u_short udp_src;$ extern struct mib_udp mib_udp; * udp = (struct udp *)(p->p_off + hlen);` if (ntohs(ip->ip_len) - hlen < sizeof(struct udp) || /* IP length < minimum UDP packet */O ntohs(udp->length) > ntohs(ip->ip_len) - hlen){ /* UDP length > IP data */< ERROR("dropped packet with bad length"); /* delete me */ return; /* drop packet */ }. data = (u_char *)udp + sizeof(struct udp);5 length = ntohs(udp->length) - sizeof(struct udp);T out_packet = definitelyGetBuf(); /* drop packets off input queue if necessary */X out_data = (u_char *)(out_packet->p_off + sizeof (struct ip) + sizeof (struct udp));C out_length = MAXDATA - sizeof(struct ip) - sizeof (struct udp); K_LEDON();M if (!snmp_parse(data, length, out_data, out_length, (u_long)ip->ip_src)){ K_PFREE(out_packet); K_LEDOFF(); return; } K_LEDOFF();A out_packet->p_len = packet_end - (u_char *)out_packet->p_off;\ setiphdr(out_packet, i CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1z-E$p->ip_src); /* address to source of request packet (ntohl ??? ) */ udp_src = ntohs(udp->src);A udp = (struct udp *)(out_packet->p_off + sizeof (struct ip)); udp->src = htons(SNMP_PORT); udp->dst = htons(udp_src);8 udp->length = out_packet->p_len - sizeof(struct ip);4 udp->checksum = 0; /* this should be computed */ mib_udp.udpOutDatagrams++; routeip(out_packet, 0, 0);}void+snmp_trap(destAddr, trapType, specificType) u_long destAddr; int trapType; int specificType;{ struct pbuf *out_packet; register u_char *out_data;! register struct udp *udp; int out_length;? static oid sysDescrOid[] = {1, 3, 6, 1, 2, 1, 1, 1, 0}; T out_packet = definitelyGetBuf(); /* drop packets off input queue if necessary */X out_data = (u_char *)(out_packet->p_off + sizeof (struct ip) + sizeof (struct udp));C out_length = MAXDATA - sizeof(struct ip) - sizeof (struct udp); K_LEDON();Y out_packet->p_len = snmp_build_trap(out_data, out_length, version_id, version_id_len,k conf.ipaddr, trapType, specificType, TICKS2MS(tickclock)/10, sysDescrOid, sizeof(sysDescrOid)/sizeof(oid),@ ASN_OCTET_STR, strlen(version_descr), (u_char *)version_descr); if (out_packet->p_len == 0){ K_PFREE(out_packet); K_LEDOFF(); return; } K_LEDOFF();@ out_packet->p_len += sizeof(struct ip) + sizeof(struct udp);Z setiphdr(out_packet, destAddr); /* address to source of request packet (ntohl ???  CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1z-t ) */A udp = (struct udp *)(out_packet->p_off + sizeof (struct ip)); udp->src = htons(SNMP_PORT);% udp->dst = htons(SNMP_TRAP_PORT);8 udp->length = out_packet->p_len - sizeof(struct ip);4 udp->checksum = 0; /* this should be computed */ mib_udp.udpOutDatagrams++; routeip(out_packet, 0, 0);}#endifint8snmp_parse(data, length, out_data, out_length, sourceip) register u_char *data; int length; register u_char *out_data; int out_length;7 u_long sourceip; /* possibly for authentication */{ u_char msg_type, type; long zero = 0;& long reqid, errstat, errindex;7 register u_char *out_auth, *out_header, *out_reqid;! u_char *startData = data;" int startLength = length; long version;& int header_shift, auth_shift; sidlen = SID_MAX_LEN;z data = snmp_auth_parse(data, &length, sid, &sidlen, &version); /* authenticates message and returns length if valid */ if (data == NULL){ ERROR("bad authentication"); /* send auth fail trap */ return 0; }# if (version != SNMP_VERSION_1){ ERROR("wrong version"); return NULL; }# community = get_community(sid); if (community == -1) return NULL;6 data = asn_parse_header(data, &length, &msg_type); if (data == NULL){ ERROR("bad header"); return 0; }[ if (msg_type != GET_REQ_MSG && msg_type != GETNEXT_REQ_MSG && msg_type != SET_REQ_MSG){ return 0; }P data = a CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-Zsn_parse_int(data, &length, &type, (u_long *)&reqid, sizeof(reqid)); if (data == NULL){ ERROR("bad parse of reqid"); return 0; }T data = asn_parse_int(data, &length, &type, (u_long *)&errstat, sizeof(errstat)); if (data == NULL){ ERROR("bad parse of errstat"); return 0; }V data = asn_parse_int(data, &length, &type, (u_long *)&errindex, sizeof(errindex)); if (data == NULL){ ERROR("bad parse of errindex"); return 0; } /*I * Now start cobbling together what is known about the output packet.N * The final lengths are not known now, so they will have to be recomputed * later. */ out_auth = out_data;P out_header = snmp_auth_build(out_auth, &out_length, sid, &sidlen, &zero, 0); if (out_header == NULL){! ERROR("snmp_auth_build failed"); return 0; }R out_reqid = asn_build_header(out_header, &out_length, (u_char)GET_RSP_MSG, 0); if (out_reqid == NULL){ ERROR(""); return 0; }A type = (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER);% /* return identical request id */\ out_data = asn_build_int(out_reqid, &out_length, type, (u_char *)&reqid, sizeof(reqid)); if (out_data == NULL){ ERROR("build reqid failed"); return 0; }/ /* assume that error status will be zero */Y out_data = asn_build_int(out_data, &out_length, type, (u_char *)&zero, sizeof(zero)); if (out_data == NULL){ ERROR("build errstat failed"); return 0; }. /* assume th CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-)at error index will be zero */Y out_data = asn_build_int(out_data, &out_length, type, (u_char *)&zero, sizeof(zero)); if (out_data == NULL){ ERROR("build errindex failed"); return 0; }\ errstat = parse_var_op_list(data, length, out_data, out_length, msg_type, &errindex, 0);@ if (msg_type == SET_REQ_MSG && errstat == SNMP_ERR_NOERROR){ /*P * SETS require 2 passes through the var_op_list. The first pass verifies thatP * all types, lengths, and values are valid, and the second does the set. Then2 * the identical GET RESPONSE packet is returned. */Y errstat = parse_var_op_list(data, length, out_data, out_length, msg_type, &errindex, 1);@ if (create_identical(startData, out_auth, startLength, 0L, 0L)) return 1; return 0; } switch((short)errstat){ case SNMP_ERR_NOERROR: /*L * Because of the assumption above that header lengths would be encodedT * in one byte, things need to be fixed, now that the actual lengths are known. */ header_shift = 0;) out_length = packet_end - out_reqid; if (out_length >= 0x80){ header_shift++; if (out_length > 0xFF) header_shift++; } auth_shift = 0;= out_length = (packet_end - out_auth) - 2 + header_shift; if (out_length >= 0x80){ auth_shift++; if (out_length > 0xFF) auth_shift++; }$ if (auth_shift + header_shift){ /*F * Shift packet (from request id to end of packet) by the sum of the * necessary shift CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-) counts. */L shift_array(out_reqid, packet_end - out_reqid, auth_shift + header_shift);+ /* Now adjust pointers into the packet */* packet_end += auth_shift + header_shift;) out_reqid += auth_shift + header_shift; out_header += auth_shift; } 6 /* re-encode the headers with the real lengths */ out_data = out_header;) out_length = packet_end - out_reqid;Q out_data = asn_build_header(out_data, &out_length, GET_RSP_MSG, out_length); if (out_data != out_reqid){" ERROR("internal error: header"); return 0; } out_data = out_auth;( out_length = packet_end - out_auth;e out_data = snmp_auth_build(out_data, &out_length, sid, &sidlen, &zero, packet_end - out_header);! if (out_data != out_header){ ERROR("internal error"); return 0; } break; case SNMP_ERR_NOSUCHNAME: case SNMP_ERR_TOOBIG: case SNMP_ERR_BADVALUE: case SNMP_ERR_READONLY: case SNMP_ERR_GENERR:O if (create_identical(startData, out_auth, startLength, errstat, errindex)) break; return 0; default: return 0; } return 1;}/*O * Parse_var_op_list goes through the list of variables and retrieves each one,V * placing it's value in the output packet. If doSet is non-zero, the variable is setQ * with the value in the packet. If any error occurs, an error code is returned. */intLparse_var_op_list(data, length, out_data, out_length, msgtype, index, doSet) register u_char *data; int  CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-b% length; register u_char *out_data; int out_length; u_char msgtype; register long *index; int doSet;{ u_char type;# oid var_name[MAX_NAME_LEN];& int var_name_len, var_val_len;- u_char var_val_type, *var_val, statType; register u_char *statP; int statLen; u_short acl; int rw, exact; int access_method;& u_char *headerP, *var_list_start; int dummyLen; int header_shift; if (msgtype == SET_REQ_MSG) rw = WRITE; else rw = READ;# if (msgtype == GETNEXT_REQ_MSG) exact = FALSE; else exact = TRUE;2 data = asn_parse_header(data, &length, &type); if (data == NULL){' ERROR("not enough space for varlist"); return PARSE_ERROR; }: if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)){ ERROR("wrong type"); return PARSE_ERROR; } headerP = out_data;d out_data = asn_build_header(out_data, &out_length, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); if (out_data == NULL){0 ERROR("not enough space in output packet"); return BUILD_ERROR; } var_list_start = out_data; *index = 1; while((int)length > 0){! /* parse the name, value pair */ var_name_len = MAX_NAME_LEN;p data = snmp_parse_var_op(data, var_name, &var_name_len, &var_val_type, &var_val_len, &var_val, (int *)&length); if (data == NULL) return PARSE_ERROR;? /* now attempt to retrieve the variable on the local entity */_ statP CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z- = getStatPtr(var_name, &var_name_len, &statType, &statLen, &acl, exact, &access_method); if (statP == NULL) return SNMP_ERR_NOSUCHNAME;< /* Check if this user has access rights to this variable */' if (!snmp_access(acl, community, rw)){$ ERROR("authentication failed");, return SNMP_ERR_NOSUCHNAME; /* bogus */ /* send_trap(); */ } if (msgtype == SET_REQ_MSG){N /* see if the type and value is consistent with this entities variable */C if (!goodValue(var_val_type, var_val_len, statType, statLen)){ return SNMP_ERR_BADVALUE; }+ /* actually do the set if necessary */ if (doSet)B setVariable(var_val, var_val_type, var_val_len, statP, statLen); }O /* retrieve the value of the variable and place it into the outgoing packet */h out_data = snmp_build_var_op(out_data, var_name, &var_name_len, statType, statLen, statP, &out_length); if (out_data == NULL){ return SNMP_ERR_TOOBIG; } (*index)++; }I packet_end = out_data; /* save a pointer to the end of the packet */ /*K * Because of the assumption above that header lengths would be encodedS * in one byte, things need to be fixed, now that the actual lengths are known. */ header_shift = 0;- out_length = packet_end - var_list_start; if (out_length >= 0x80){ header_shift++; if (out_length > 0xFF) header_shift++; } if (header_shift){H shift_array(var_list_start, packet_end - var_list_start, header_shift); packet_ CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-[Vend += header_shift; var_list_start += header_shift; }4 /* Now rebuild header with the actual lengths */+ dummyLen = packet_end - var_list_start;j if (asn_build_header(headerP, &dummyLen, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), dummyLen) == NULL){/ return SNMP_ERR_TOOBIG; /* bogus error ???? */ } *index = 0; return SNMP_ERR_NOERROR;}/*M * create a packet identical to the input packet, except for the error statusF * and the error index which are set according to the input variables.- * Returns 1 upon success and 0 upon failure. */intCcreate_identical(snmp_in, snmp_out, snmp_length, errstat, errindex) u_char *snmp_in; u_char *snmp_out; int snmp_length; long errstat, errindex;{ register u_char *data; u_char type; u_long dummy;" int length, headerLength;R register u_char *headerPtr, *reqidPtr, *errstatPtr, *errindexPtr, *varListPtr;: bcopy((char *)snmp_in, (char *)snmp_out, snmp_length); length = snmp_length;Q headerPtr = snmp_auth_parse(snmp_out, &length, sid, &sidlen, (long *)&dummy); if (headerPtr == NULL) return 0;F reqidPtr = asn_parse_header(headerPtr, &length, (u_char *)&dummy); if (reqidPtr == NULL) return 0; headerLength = length;` errstatPtr = asn_parse_int(reqidPtr, &length, &type, &dummy, sizeof dummy); /* request id */ if (errstatPtr == NULL) return 0;e errindexPtr = asn_parse_int(errstatPtr, &length, &ty CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z- pe, &dummy, sizeof dummy); /* error status */ if (errindexPtr == NULL) return 0;d varListPtr = asn_parse_int(errindexPtr, &length, &type, &dummy, sizeof dummy); /* error index */ if (varListPtr == NULL) return 0;Q data = asn_build_header(headerPtr, &headerLength, GET_RSP_MSG, headerLength); if (data != reqidPtr) return 0; length = snmp_length;A type = (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER);X data = asn_build_int(errstatPtr, &length, type, (u_char *)&errstat, sizeof errstat); if (data != errindexPtr) return 0;[ data = asn_build_int(errindexPtr, &length, type, (u_char *)&errindex, sizeof errindex);l if (data != varListPtr) return 0;( packet_end = snmp_out + snmp_length; return 1;d}s#ifdef KINETICSr struct pbuf *udefinitelyGetBuf(){p register struct pbuf *p; K_PGET(PT_DATA, p);h while(p == 0){ #ifdef notdefa if (pq->pq_head != NULL){ K_PDEQ(SPLIMP, pq, p);e if (p) K_PFREE(p); $ } else if (sendq->pq_head != NULL){ K_PDEQ(SPLIMP, sendq, p); if (p) K_PFREE(p);p }#endif K_PGET(PT_DATA, p); }e return p;i}w#endifintrsnmp_access(acl, community, rw)A u_short acl;D int community;C int rw;{E /*J * Each group has 2 bits, the more significant one is for read access,4 * the less significant one is for write access. */HG community <<= 1; /* multiply by two two shift two bits at a time */N if (rw == READ){A CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-)# return (acl & (2 << community)); /* return the correct bit */T } else {! return (acl & (1 << community));* }*}*int*get_community(sessionid) u_char *sessionid;{K int count;5 for(count = 0; count < NUM_COMMUNITIES; count++){e, if (!strcmp(communities[count], sessionid)) break;h }d! if (count == NUM_COMMUNITIES)d return -1; return count;.}inte/goodValue(inType, inLen, actualType, actualLen)e u_char inType, actualType; int inLen, actualLen;{c int type; if (inLen > actualLen) return FALSE;3 /* convert intype to internal representation */ez type = inType == ASN_INTEGER ? INTEGER : inType == ASN_OCTET_STR ? STRING : inType == ASN_OBJECT_ID ? OBJID : NULLOBJ; return (type == actualType);}?setVariable(var_val, var_val_type, var_val_len, statP, statLen){ u_char *var_val;p u_char var_val_type;  int var_val_len; u_char *statP;b int statLen;{s int buffersize = 1000; switch(var_val_type){e case ASN_INTEGER: case COUNTER: case GAUGE: case TIMETICKS:R asn_parse_int(var_val, &buffersize, &var_val_type, (u_long *)statP, statLen); break;f case ASN_OCTET_STR: case IPADDRESS: case OPAQUE:tL asn_parse_string(var_val, &buffersize, &var_val_type, statP, &statLen); break;d case ASN_OBJECT_ID:K asn_parse_objid(var_val, &buffersize, &var_val_type, statP, &statLen);p break;p }} (shift_array(begin, length, s CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AGENT.ORIG;1;1z-&hift_amount) u_char *begin; register int length;i int shift_amount;{d register u_char *old, *new;n if (shift_amount >= 0){  old = begin + length - 1; new = old + shift_amount; while(length--) *new-- = *old--;h } else { old = begin;  new = begin + shift_amount; while(length--) *new++ = *old++;e }/}r1*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5+,.</ 4z<;<-0@123KPWO=56=M7o8*E9FRQٓ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 publici CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5131BJ;1z<=ty 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******************************************************************//*' * snmp_api.c - API for access to snmp. */#include #include #include #include #include #include #include #include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "snmp_api.h"#define PACKET_LENGTH 1500typedef int fd_set;)#define FD_SET(n, p) (*(p) |= (1 << (n)))*#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))*#define FD_ISSET(n, p) (*(p) & (1 << (n)))#define FD_ZERO(p) (*(p) = 0) #define perror socket_perror#define sendto net_sendto #define recvfrom net_recvfrom#define select net_select#define bind net_bind#define close net_close#define socket net_socket^void default_enterprise[] = {1, 3, 6, 1, 4, 1, 3, 1, 1}; /* enterprises.cmu.systems.cmuSNMP */$#define DEFAULT_COMMUNITY "public"#define DEFAULT_RETRIES 4$#define DEFAULT_ CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5131BJ;1z<bTIMEOUT 1000000L%#define DEFAULT_REMPORT SNMP_PORT.#define DEFAULT_ENTERPRISE default_enterprise#define DEFAULT_TIME 0/*< * Internal information about the state of the snmp session. */struct snmp_internal_session {< int sd; /* socket descriptor for this connection */1 ipaddr addr; /* address of connected peer */G struct request_list *requests;/* Info about outstanding requests */};/*C * A list of all the outstanding requests for a particular session. */struct request_list {& struct request_list *next_request;( u_long request_id; /* request id */, int retries; /* Number of retries */4 u_long timeout; /* length to wait for timeout */9 struct timeval time; /* Time this request was made */D struct timeval expire; /* time this request is due to expire */\ struct snmp_pdu *pdu; /* The pdu for this request (saved so it can be retransmitted */};/*$ * The list of active/open sessions. */struct session_list { struct session_list *next;! struct snmp_session *session;+ struct snmp_internal_session *internal;};%struct session_list *Sessions = NULL;u_long Reqid = 0;int snmp_errno = 0;char *api_errors[4] = { "Unknown session", "Unknown host", "Invalid local port", "Unknown Error"}; static char *api_errstring(snmp_errnumber) int snmp_errnumber;{S if (snmp_errnumber <= SNMPERR_BAD_SESSION && snmp_errnumber >= SNMPERR_GENERR){' return api_ CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5131BJ;1z<errors[snmp_errnumber + 4]; } else { return "Unknown Error"; }}/*0 * Gets initial request ID for all transactions. */static init_snmp(){ struct timeval tv;, gettimeofday(&tv, (struct timezone *)0);$ srandom(tv.tv_sec ^ tv.tv_usec); Reqid = random();}/*A * Sets up the session with the snmp_session information provided= * by the user. Then opens and binds the necessary UDP port.F * A handle to the created session is returned (this is different thanE * the pointer passed to snmp_open()). On any error, NULL is returned7 * and snmp_errno is set to the appropriate error code. */struct snmp_session *snmp_open(session)! struct snmp_session *session;{ struct session_list *slp;& struct snmp_internal_session *isp; u_char *cp; int sd; u_long addr; struct sockaddr_in me; struct hostent *hp; struct servent *servp; if (Reqid == 0) init_snmp();3 /* Copy session structure and link into list */E slp = (struct session_list *)malloc(sizeof(struct session_list));g slp->internal = isp = (struct snmp_internal_session *)malloc(sizeof(struct snmp_internal_session));= bzero((char *)isp, sizeof(struct snmp_internal_session));1 slp->internal->sd = -1; /* mark it not set */N slp->session = (struct snmp_session *)malloc(sizeof(struct snmp_session));N bcopy((char *)session, (char *)slp->session, sizeof(struct snmp_session)); session = slp->session; /* now lin CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5131BJ;1z<)1 k it in. */ slp->next = Sessions; Sessions = slp; /*N * session now points to the new structure that still contains pointers toO * data allocated elsewhere. Some of this data is copied to space malloc'd7 * here, and the pointer replaced with the new one. */# if (session->peername != NULL){@ cp = (u_char *)malloc((unsigned)strlen(session->peername) + 1);' strcpy((char *)cp, session->peername); session->peername = (char *)cp; }' /* Fill in defaults if necessary */> if (session->community_len != SNMP_DEFAULT_COMMUNITY_LEN){9 cp = (u_char *)malloc((unsigned)session->community_len);G bcopy((char *)session->community, (char *)cp, session->community_len); } else {4 session->community_len = strlen(DEFAULT_COMMUNITY);9 cp = (u_char *)malloc((unsigned)session->community_len);F bcopy((char *)DEFAULT_COMMUNITY, (char *)cp, session->community_len); }K session->community = cp; /* replace pointer with pointer to new data */1 if (session->retries == SNMP_DEFAULT_RETRIES)$ session->retries = DEFAULT_RETRIES;1 if (session->timeout == SNMP_DEFAULT_TIMEOUT)$ session->timeout = DEFAULT_TIMEOUT; isp->requests = NULL; /* Set up connections */( sd = socket(AF_INET, SOCK_DGRAM, 0); if (sd < 0){ perror("socket"); snmp_errno = SNMPERR_GENERR; if (!snmp_close(session)){Y fprintf(stderr, "Couldn't abort session: %s. Exiting\n", api_errstring(snmp_errno)); exit(1); } return 0; } CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5131BJ;1z< isp->sd = sd;4 if (session->peername != SNMP_DEFAULT_PEERNAME){2 if ((addr = inet_addr(session->peername)) != -1){S bcopy((char *)&addr, (char *)&isp->addr.sin_addr, sizeof(isp->addr.sin_addr)); } else {+ hp = gethostbyname(session->peername); if (hp == NULL){; fprintf(stderr, "unknown host: %s\n", session->peername);# snmp_errno = SNMPERR_BAD_ADDRESS; if (!snmp_close(session)){Z fprintf(stderr, "Couldn't abort session: %s. Exiting\n", api_errstring(snmp_errno)); exit(2); } return 0; } else {G bcopy((char *)hp->h_addr, (char *)&isp->addr.sin_addr, hp->h_length); } } isp->addr.sin_family = AF_INET;3 if (session->remote_port == SNMP_DEFAULT_REMPORT){* servp = getservbyname("snmp", "udp"); if (servp != NULL){% isp->addr.sin_port = servp->s_port; } else {( isp->addr.sin_port = htons(SNMP_PORT); } } else {6 isp->addr.sin_port = htons(session->remote_port); } } else {2 isp->addr.sin_addr.s_addr = SNMP_DEFAULT_ADDRESS; } me.sin_family = AF_INET;$ me.sin_addr.s_addr = INADDR_ANY;- me.sin_port = htons(session->local_port);; if (bind(sd, (struct sockaddr *)&me, sizeof(me)) != 0){ perror("bind");" snmp_errno = SNMPERR_BAD_LOCPORT; if (!snmp_close(session)){Y fprintf(stderr, "Couldn't abort session: %s. Exiting\n", api_errstring(snmp_errno)); exit(3); } return 0; } return session;}/*/ * Free each element in the input request  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5133BJ;1z<list. */staticfree_request_list(rp) struct request_list *rp;{ struct request_list *orp; while(rp){ orp = rp; rp = rp->next_request; if (orp->pdu != NULL) snmp_free_pdu(orp->pdu); free((char *)orp); }}/*F * Close the input session. Frees all data allocated for the session,F * dequeues any pending requests, and closes any sockets allocated for1 * the session. Returns 0 on error, 1 otherwise. */intsnmp_close(session)! struct snmp_session *session;{2 struct session_list *slp = NULL, *oslp = NULL;; if (Sessions->session == session){ /* If first entry */ slp = Sessions; Sessions = slp->next; } else {+ for(slp = Sessions; slp; slp = slp->next){" if (slp->session == session){6 if (oslp) /* if we found entry that points here */: oslp->next = slp->next; /* link around this entry */ break; } oslp = slp; } }C /* If we found the session, free all data associated with it */ if (slp){% if (slp->session->community != NULL)+ free((char *)slp->session->community);# if(slp->session->peername != NULL)* free((char *)slp->session->peername); free((char *)slp->session); if (slp->internal->sd != -1) close(slp->internal->sd);, free_request_list(slp->internal->requests); free((char *)slp->internal); free((char *)slp); } else {" snmp_errno = SNMPERR_BAD_SESSION; return 0; } return 1;}/*E * Takes a session and a pdu and seriali CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513C;5z<zes the ASN PDU into the areaL * pointed to by packet. out_length is the size of the data area available.K * Returns the length of the completed packet in out_length. If any errors; * occur, -1 is returned. If all goes well, 0 is returned. */ static int,snmp_build(session, pdu, packet, out_length)! struct snmp_session *session; struct snmp_pdu *pdu; register u_char *packet; int *out_length;{ u_char buf[PACKET_LENGTH]; register u_char *cp; struct variable_list *vp;* int length;* long zero = 0;* int totallength; length = *out_length;  cp = packet;9 for(vp = pdu->variables; vp; vp = vp->next_variable){hr cp = snmp_build_var_op(cp, vp->name, &vp->name_length, vp->type, vp->val_len, (u_char *)vp->val.string, &length); if (cp == NULL) return -1;n } totallength = cp - packet; length = PACKET_LENGTH;_ cp = asn_build_header(buf, &length, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), totallength);r if (cp == NULL)o return -1;t3 bcopy((char *)packet, (char *)cp, totallength);M totallength += cp - buf; length = *out_length;C% if (pdu->command != TRP_REQ_MSG){A /* request id */S$ cp = asn_build_int(packet, &length,; (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),A. (long *)&pdu->reqid, sizeof(pdu->reqid)); if (cp == NULL) return -1;O /* error status */E cp = asn_build_int(cp, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513C;5z<),/ (long *)&pdu->errstat, sizeof(pdu->errstat));* if (cp == NULL) return -1; /* error index */ cp = asn_build_int(cp, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),1 (long *)&pdu->errindex, sizeof(pdu->errindex));e if (cp == NULL) return -1;) } else { /* this is a trap message */c /* enterprise */c& cp = asn_build_objid(packet, &length,= (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),f5 (oid *)pdu->enterprise, pdu->enterprise_length);n if (cp == NULL) return -1;  /* agent-addr */)# cp = asn_build_string(cp, &length,(: (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),W (u_char *)&pdu->agent_addr.sin_addr.s_addr, sizeof(pdu->agent_addr.sin_addr.s_addr));  if (cp == NULL) return -1;  /* generic trap */ cp = asn_build_int(cp, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),3 (long *)&pdu->trap_type, sizeof(pdu->trap_type));N if (cp == NULL) return -1;R /* specific trap */ cp = asn_build_int(cp, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),; (long *)&pdu->specific_type, sizeof(pdu->specific_type));I if (cp == NULL) return -1;  /* timestamp */. cp = asn_build_int(cp, &length,8 (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),) (long *)&pdu->time, sizeof(pdu->time));o if (cp == NULL) return -1;t }r if (length < totallength)n return -1;0 bcopy((char *)buf, (char *)cp, totallength); totallength += cp - packet  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513C;5z<(;* length = PACKET_LENGTH; K cp = asn_build_header(buf, &length, (u_char)pdu->command, totallength); if (cp == NULL)/ return -1;e if (length < totallength)* return -1;i3 bcopy((char *)packet, (char *)cp, totallength);i totallength += cp - buf; length = *out_length; k cp = snmp_auth_build(packet, &length, session->community, &session->community_len, &zero, totallength);  if (cp == NULL) return -1;l4 if ((*out_length - (cp - packet)) < totallength) return -1;u0 bcopy((char *)buf, (char *)cp, totallength); totallength += cp - packet;l *out_length = totallength; return 0; }s/*L * Parses the packet recieved on the input session, and places the data intoK * the input pdu. length is the length of the input packet. If any errors@ * are encountered, -1 is returned. Otherwise, a 0 is returned. */r static int&snmp_parse(session, pdu, data, length)! struct snmp_session *session;_ struct snmp_pdu *pdu;) u_char *data; int length;]{ u_char msg_type;U u_char type;  u_char *var_val;  long version; int len, four; u_char community[128]; int community_length = 128;o struct variable_list *vp;;% oid objid[MAX_NAME_LEN], *op;; /* authenticates message and returns length if valid */hR data = snmp_auth_parse(data, &length, community, &community_length, &version); if (data == NULL)h return -1;c# if (version != SNMP_VERSION_1){i1 fprintf  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513C;5z<w(stderr, "Wrong version: %d\n", version);.( fprintf(stderr, "Continuing anyway\n"); }n if (session->authenticator){K data = session->authenticator(data, &length, community, community_length);s if (data == NULL) return 0; } 6 data = asn_parse_header(data, &length, &msg_type); if (data == NULL) return -1;d pdu->command = msg_type;% if (pdu->command != TRP_REQ_MSG){sU data = asn_parse_int(data, &length, &type, (long *)&pdu->reqid, sizeof(pdu->reqid));r if (data == NULL) return -1;sY data = asn_parse_int(data, &length, &type, (long *)&pdu->errstat, sizeof(pdu->errstat));c if (data == NULL) return -1;o[ data = asn_parse_int(data, &length, &type, (long *)&pdu->errindex, sizeof(pdu->errindex));n if (data == NULL) return -1;m } else {' pdu->enterprise_length = MAX_NAME_LEN;sN data = asn_parse_objid(data, &length, &type, objid, &pdu->enterprise_length); if (data == NULL) return -1;oG pdu->enterprise = (oid *)malloc(pdu->enterprise_length * sizeof(oid));nU bcopy((char *)objid, (char *)pdu->enterprise, pdu->enterprise_length * sizeof(oid));r four = 4;b data = asn_parse_string(data, &length, &type, (u_char *)&pdu->agent_addr.sin_addr.s_addr, &four); if (data == NULL) return -1;r] data = asn_parse_int(data, &length, &type, (long *)&pdu->trap_type, sizeof(pdu->trap_type));a if (data == NULL) return -1;me data = asn_parse_int(data, &length, &type, (long *)&pdu->specific_type, sizeof(pdu->specific_type));F if (dat  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513C;5z<c{ a == NULL) return -1; S data = asn_parse_int(data, &length, &type, (long *)&pdu->time, sizeof(pdu->time));n if (data == NULL) return -1;o }r2 data = asn_parse_header(data, &length, &type); if (data == NULL) return -1;m9 if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR))l return -1;s while((int)length > 0){o if (pdu->variables == NULL){cX pdu->variables = vp = (struct variable_list *)malloc(sizeof(struct variable_list)); } else {tV vp->next_variable = (struct variable_list *)malloc(sizeof(struct variable_list)); vp = vp->next_variable; } vp->next_variable = NULL; vp->val.string = NULL;i vp->name = NULL;E vp->name_length = MAX_NAME_LEN;l data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type, &vp->val_len, &var_val, (int *)&length); if (data == NULL) return -1; = op = (oid *)malloc((unsigned)vp->name_length * sizeof(oid));sA bcopy((char *)objid, (char *)op, vp->name_length * sizeof(oid)); vp->name = op; len = PACKET_LENGTH; switch((short)vp->type){  case ASN_INTEGER: case COUNTER: case GAUGE: case TIMETICKS:1 vp->val.integer = (long *)malloc(sizeof(long));s vp->val_len = sizeof(long);}\ asn_parse_int(var_val, &len, &vp->type, (long *)vp->val.integer, sizeof(vp->val.integer)); break; case ASN_OCTET_STR: case IPADDRESS: case OPAQUE:D; vp->val.string = (u_char *)malloc((unsigned)vp->val_len);CK asn_parse_string(var_val, &len, &vp->type, vp->val.string, &  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513H;3z<eH#vp->val_len);t break; case ASN_OBJECT_ID: vp->val_len = MAX_NAME_LEN;rA asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);d vp->val_len *= sizeof(oid);s7 vp->val.objid = (oid *)malloc((unsigned)vp->val_len);p; bcopy((char *)objid, (char *)vp->val.objid, vp->val_len);  break; case ASN_NULL:o break; default:s8 fprintf(stderr, "bad type returned (%x)\n", vp->type); break; } }r return 0;o}r/*H * Sends the input pdu on the session after calling snmp_build to createH * a serialized packet. If necessary, set some of the pdu data from theI * session defaults. Add a request corresponding to this pdu to the listt> * of outstanding requests on this session, then send the pdu.M * Returns the request id of the generated packet if applicable, otherwise 1.r * On any error, 0 is returned.x< * The pdu is freed by snmp_send() unless a failure occured. */ int snmp_send(session, pdu)! struct snmp_session *session;i struct snmp_pdu *pdu;{ struct session_list *slp;- struct snmp_internal_session *isp = NULL;r" u_char packet[PACKET_LENGTH]; int length = PACKET_LENGTH;e struct request_list *rp; struct timeval tv;. for(slp = Sessions; slp; slp = slp->next){ if (slp->session == session){ isp = slp->internal; break;d } }  if (isp == NULL){l" snmp_errno = SNMPERR_BAD_SESSION; return 0; }sF if (pdu->command == GET_REQ_MSG || pdu->command == GETNEXT_REQ_MSG@ || pd CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<&u->command == GET_RSP_MSG || pdu->command == SET_REQ_MSG){& if (pdu->reqid == SNMP_DEFAULT_REQID) pdu->reqid = ++Reqid;* if (pdu->errstat == SNMP_DEFAULT_ERRSTAT) pdu->errstat = 0;, if (pdu->errindex == SNMP_DEFAULT_ERRINDEX) pdu->errindex = 0;s } else { /* fill in trap defaults */= pdu->reqid = 1; /* give a bogus non-error reqid for traps */u? if (pdu->enterprise_length == SNMP_DEFAULT_ENTERPRISE_LENGTH){A pdu->enterprise = (oid *)malloc(sizeof(DEFAULT_ENTERPRISE));\ bcopy((char *)DEFAULT_ENTERPRISE, (char *)pdu->enterprise, sizeof(DEFAULT_ENTERPRISE));E pdu->enterprise_length = sizeof(DEFAULT_ENTERPRISE)/sizeof(oid);s }$ if (pdu->time == SNMP_DEFAULT_TIME) pdu->time = DEFAULT_TIME; }> if (pdu->address.sin_addr.s_addr == SNMP_DEFAULT_ADDRESS){8 if (isp->addr.sin_addr.s_addr != SNMP_DEFAULT_ADDRESS){L bcopy((char *)&isp->addr, (char *)&pdu->address, sizeof(pdu->address)); } else {n9 fprintf(stderr, "No remote IP address specified\n"); & snmp_errno = SNMPERR_BAD_ADDRESS; return 0; } } 7 if (snmp_build(session, pdu, packet, &length) < 0){f, fprintf(stderr, "Error building packet\n"); snmp_errno = SNMPERR_GENERR;d return 0; }, if (snmp_dump_packet){ int count;b) for(count = 0; count < length; count++){t$ printf("%02X ", packet[count]); if ((count % 16) == 15) printf("\n");; } printf("\n\n"); }, gettimeofday(&tv, (struct timezone *)0);p if (sendto(isp->sd, (c CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<D\)har *)packet, length, 0, (struct sockaddr *)&pdu->address, sizeof(pdu->address)) < 0){ perror("sendto"); snmp_errno = SNMPERR_GENERR; return 0; }ag if (pdu->command == GET_REQ_MSG || pdu->command == GETNEXT_REQ_MSG || pdu->command == SET_REQ_MSG){ " /* set up to expect a response */A rp = (struct request_list *)malloc(sizeof(struct request_list));l" rp->next_request = isp->requests; isp->requests = rp; rp->pdu = pdu;a rp->request_id = pdu->reqid;S rp->retries = 1;C rp->timeout = session->timeout; rp->time = tv;  tv.tv_usec += rp->timeout;t$ tv.tv_sec += tv.tv_usec / 1000000L; tv.tv_usec %= 1000000L; rp->expire = tv;g }  return pdu->reqid;}E/*: * Frees the pdu and any malloc'd data associated with it. */ voidsnmp_free_pdu(pdu) struct snmp_pdu *pdu;){# struct variable_list *vp, *ovp;> vp = pdu->variables; while(vp){ if (vp->name) free((char *)vp->name); if (vp->val.string)" free((char *)vp->val.string); ovp = vp; vp = vp->next_variable; free((char *)ovp);* }c if (pdu->enterprise) free((char *)pdu->enterprise);_ free((char *)pdu);}u/*> * Checks to see if any of the fd's set in the fdset belong to@ * snmp. Each socket with it's fd set has a packet read from itF * and snmp_parse is called on the packet received. The resulting pduF * is passed to the callback routine for that session. If the callbackF * routine returns successfully, the pdu and it's request are deleted. */tvo CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<,idsnmp_read(fdset) fd_set *fdset; {n struct session_list *slp;i struct snmp_session *sp;& struct snmp_internal_session *isp;! u_char packet[PACKET_LENGTH];r struct sockaddr_in from; int length, fromlength;  struct snmp_pdu *pdu;t" struct request_list *rp, *orp;. for(slp = Sessions; slp; slp = slp->next){) if (FD_ISSET(slp->internal->sd, fdset)){n sp = slp->session;o isp = slp->internal;c fromlength = sizeof from;i length = recvfrom(isp->sd, (char *)packet, PACKET_LENGTH, 0, (struct sockaddr *)&from, &fromlength);R if (length == -1) perror("recvfrom");s if (snmp_dump_packet){N int count;K printf("received %d bytes from %s:\n", length, inet_ntoa(from.sin_addr));U* for(count = 0; count < length; count++){% printf("%02X ", packet[count]);o if ((count % 16) == 15)  printf("\n"); }e printf("\n\n");n }> pdu = (struct snmp_pdu *)malloc(sizeof(struct snmp_pdu)); pdu->address = from; pdu->reqid = 0; pdu->variables = NULL;a pdu->enterprise = NULL; pdu->enterprise_length = 0;B if (snmp_parse(sp, pdu, packet, length) != SNMP_ERR_NOERROR){& fprintf(stderr, "Mangled packet\n"); snmp_free_pdu(pdu); return;  }& if (pdu->command == GET_RSP_MSG){5 for(rp = isp->requests; rp; rp = rp->next_request){ ( if (rp->request_id == pdu->reqid){U if (sp->callback(RECEIVED_MESSAGE, sp, pdu->reqid, pdu, sp->callback_magic) == 1){l* / CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<%/* successful, so delete request */ orp = rp;! if (isp->requests == orp){a /* first in list */ & isp->requests = orp->next_request; } else {k7 for(rp = isp->requests; rp; rp = rp->next_request){o% if (rp->next_request == orp){t? rp->next_request = orp->next_request; /* link around it */ break;h }  }r } snmp_free_pdu(orp->pdu);  free((char *)orp);uL break; /* there shouldn't be any more request with the same reqid */ } }h }N } else if (pdu->command == GET_REQ_MSG || pdu->command == GETNEXT_REQ_MSGE || pdu->command == TRP_REQ_MSG || pdu->command == SET_REQ_MSG){ J sp->callback(RECEIVED_MESSAGE, sp, pdu->reqid, pdu, sp->callback_magic); } snmp_free_pdu(pdu); } }m}a/*A * Returns info about what snmp requires from a select statement.g@ * numfds is the number of fds in the list that are significant.@ * All file descriptors opened for SNMP are OR'd into the fdset.A * If activity occurs on any of these file descriptors, snmp_readi1 * should be called with that file descriptor sett *H * The timeout is the latest time that SNMP can wait for a timeout. TheL * select should be done with the minimum time between timeout and any otherM * timeouts necessary. This should be checked upon each invocation of select.aJ * If a timeout is received, snmp_timeout should be called to check if the6 * timeout was for SNMP. (snmp_timeout is idempotent) *U * Block is 1 if CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<2 the select is requested to block indefinitely, rather than time out.eV * If block is input as 1, the timeout value will be treated as undefined, but it mustX * be available for setting in snmp_select_info. On return, if block is true, the value * of timeout will be undefined. *[ * snmp_select_info returns the number of open sockets. (i.e. The number of sessions open)n */&int /snmp_select_info(numfds, fdset, timeout, block)L int *numfds; fd_set *fdset;i struct timeval *timeout;U int *block; /* should the select block until input arrives (i.e. no input) */n{  struct session_list *slp;& struct snmp_internal_session *isp; struct request_list *rp;! struct timeval now, earliest;d! int active = 0, requests = 0;t timerclear(&earliest); /*B * For each request outstanding, add it's socket to the fdset,F * and if it is the earliest timeout to expire, mark it as lowest. */>. for(slp = Sessions; slp; slp = slp->next){ active++; isp = slp->internal; if ((isp->sd + 1) > *numfds)n *numfds = (isp->sd + 1);  FD_SET(isp->sd, fdset); if (isp->requests){: /* found another session with outstanding requests */ requests++;8 for(rp = isp->requests; rp; rp = rp->next_request){D if (!timerisset(&earliest) || timercmp(&rp->expire, &earliest, <)) earliest = rp->expire; } } }>@ if (requests == 0) /* if none are active, skip arithmetic */ return active;e /*C * Now find ou CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<o5t how much time until the earliest timeout. ThisaG * transforms earliest from an absolute time into a delta time, theL1 * time left until the select should timeout.v */e- gettimeofday(&now, (struct timezone *)0);(B earliest.tv_sec--; /* adjust time to make arithmetic easier */! earliest.tv_usec += 1000000L;" earliest.tv_sec -= now.tv_sec;$ earliest.tv_usec -= now.tv_usec;) while (earliest.tv_usec >= 1000000L){p earliest.tv_usec -= 1000000L; earliest.tv_sec += 1; }E if (earliest.tv_sec < 0){t earliest.tv_sec = 0;N earliest.tv_usec = 0; } L /* if it was blocking before or our delta time is less, reset timeout */8 if (*block == 1 || timercmp(&earliest, timeout, <)){ *timeout = earliest; *block = 0; }e return active;}e/*T * snmp_timeout should be called whenever the timeout from snmp_select_info expires,P * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensiveK * proposition). snmp_timeout checks to see if any of the sessions have anEO * outstanding request that has timed out. If it finds one (or more), and thateM * pdu has more retries available, a new packet is formed from the pdu and isdP * resent. If there are no more retries available, the callback for the session, * is used to alert the user of the timeout. */rvoidsnmp_timeout(){  struct session_list *slp;n struct snmp_session *sp;& struct snmp_internal_session *isp;2 struct request_list *rp, *orp, *freeme = CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513OBJ;1z<c8 NULL; struct timeval now;*- gettimeofday(&now, (struct timezone *)0);t /*D * For each request outstanding, check to see if it has expired. */t. for(slp = Sessions; slp; slp = slp->next){ sp = slp->session;d isp = slp->internal;e orp = NULL;4 for(rp = isp->requests; rp; rp = rp->next_request){\ if (freeme != NULL){ /* frees rp's after the for loop goes on to the next_request */ free((char *)freeme);p freeme = NULL; }) if (timercmp(&rp->expire, &now, <)){ /* this timer has expired */" if (rp->retries >= sp->retries){. /* No more chances, delete this entry */O sp->callback(TIMED_OUT, sp, rp->pdu->reqid, rp->pdu, sp->callback_magic);m if (orp == NULL){ $ isp->requests = rp->next_request; } else {( orp->next_request = rp->next_request; }d snmp_free_pdu(rp->pdu);L freeme = rp;, continue; /* don't update orp below */ } else {$ u_char packet[PACKET_LENGTH];! int length = PACKET_LENGTH;= struct timeval tv; /* retransmit this pdu */i rp->retries++; rp->timeout <<= 1;8 if (snmp_build(sp, rp->pdu, packet, &length) < 0){. fprintf(stderr, "Error building packet\n"); }E if (snmp_dump_packet){ int count;/+ for(count = 0; count < length; count++){ & printf("%02X ", packet[count]); if ((count % 16) == 15) printf("\n");E } printf("\n\n"); }i. gettimeofday(&tv, (struct timezone *)0);z  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;513COM;6z<r; if (sendto(isp->sd, (char *)packet, length, 0, (struct sockaddr *)&rp->pdu->address, sizeof(rp->pdu->address)) < 0){ perror("sendto"); }z rp->time = tv; tv.tv_usec += rp->timeout;) tv.tv_sec += tv.tv_usec / 1000000L;f tv.tv_usec %= 1000000L;= rp->expire = tv; }  } orp = rp; } if (freeme != NULL){{ free((char *)freeme); freeme = NULL;d } }f}uaddress)); } else {n9 fprintf(stderr, "No remote IP address specified\n1*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;2+,./ 4[-0@123KPWO5667o8X 9FRQٓGHJ</***********************************************************- Copyright 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 notice appear in 9supporting documentation, and that the name of CMU not beBused in advert CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[>ising 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******************************************************************//*' * snmp_api.h - API for access to snmp. */#typedef struct sockaddr_in ipaddr;struct snmp_session {> u_char *community; /* community for outgoing requests. */; int community_len; /* Length of community name. */< int retries; /* Number of retries before timeout. */X long timeout; /* Number of uS until first timeout, then exponential backoff */M char *peername; /* Domain name or dotted IP address of default peer */6 u_short remote_port;/* UDP port number of peer. */P u_short local_port; /* My UDP port number, 0 for default, picked randomly */H /* Authentication function or NULL if null authentication is used */" u_char *(*authenticator)();E int (*callback)(); /* Function to interpret incoming data */K /* Pointer to data that the callback function may consider important */ void *callback_magic;};/*Y CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[O * Set fields in session and pdu to the following to get a default or unconfigured value. */K#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */##define SNMP_DEFAULT_RETRIES -1##define SNMP_DEFAULT_TIMEOUT -1"#define SNMP_DEFAULT_REMPORT 0 #define SNMP_DEFAULT_REQID 0##define SNMP_DEFAULT_ERRSTAT -1$#define SNMP_DEFAULT_ERRINDEX -1"#define SNMP_DEFAULT_ADDRESS 0&#define SNMP_DEFAULT_PEERNAME NULL(#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0#define SNMP_DEFAULT_TIME 0extern int snmp_errno;/* Error return values */#define SNMPERR_GENERR -1C#define SNMPERR_BAD_LOCPORT -2 /* local port was already in use */#define SNMPERR_BAD_ADDRESS -3#define SNMPERR_BAD_SESSION -4#define SNMPERR_TOO_LONG -5struct snmp_pdu {* ipaddr address; /* Address of peer */+ int command; /* Type of this PDU */# u_long reqid; /* Request id */' u_long errstat; /* Error status */' u_long errindex; /* Error index */ /* Trap information */( oid *enterprise;/* System OID */ int enterprise_length;? ipaddr agent_addr; /* address of object generating trap */& int trap_type; /* trap type *// int specific_type; /* specific type */ u_long time; /* Uptime */$ struct variable_list *variables;};struct variable_list {H struct variable_list *next_variable; /* NULL for last variable */7 oid *name; /* Object identifier of variable */;  CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[int name_length; /* number of subid's in name */. u_char type; /* ASN type of variable */# union { /* value of variable */ long *integer; u_char *string; oid *objid; } val; int val_len;};/** * struct snmp_session *snmp_open(session) * struct snmp_session *session; * A * Sets up the session with the snmp_session information provided= * by the user. Then opens and binds the necessary UDP port.F * A handle to the created session is returned (this is different thanF * the pointer passed to snmp_open()). On any error, NULL is returned7 * and snmp_errno is set to the appropriate error code. */!struct snmp_session *snmp_open();/* * int snmp_close(session)$ * struct snmp_session *session; * F * Close the input session. Frees all data allocated for the session,F * dequeues any pending requests, and closes any sockets allocated for1 * the session. Returns 0 on error, 1 otherwise. */int snmp_close();/* * int snmp_send(session, pdu)$ * struct snmp_session *session; * struct snmp_pdu *pdu; * H * Sends the input pdu on the session after calling snmp_build to createH * a serialized packet. If necessary, set some of the pdu data from theI * session defaults. Add a request corresponding to this pdu to the list> * of outstanding requests on this session, then send the pdu.M * Returns the request id of the generated packet if applicable, otherwise 1. * On any error, 0 is returned.< * The pdu is freed by CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[V snmp_send() unless a failure occured. */int snmp_send();/* * void snmp_read(fdset) * fd_set *fdset; * > * Checks to see if any of the fd's set in the fdset belong to@ * snmp. Each socket with it's fd set has a packet read from itF * and snmp_parse is called on the packet received. The resulting pduG * is passed to the callback routine for that session. If the callbackF * routine returns successfully, the pdu and it's request are deleted. */void snmp_read();/* * void * snmp_free_pdu(pdu) * struct snmp_pdu *pdu; * : * Frees the pdu and any malloc'd data associated with it. */void snmp_free_pdu();/*6 * int snmp_select_info(numfds, fdset, timeout, block) * int *numfds; * fd_set *fdset; * struct timeval *timeout; * int *block; *A * Returns info about what snmp requires from a select statement.@ * numfds is the number of fds in the list that are significant.@ * All file descriptors opened for SNMP are OR'd into the fdset.A * If activity occurs on any of these file descriptors, snmp_read2 * should be called with that file descriptor set. *H * The timeout is the latest time that SNMP can wait for a timeout. TheL * select should be done with the minimum time between timeout and any otherN * timeouts necessary. This should be checked upon each invocation of select.J * If a timeout is received, snmp_timeout should be called to check if the6 * timeout was for SNMP. (snmp_timeout is idempotent) *U * Block is 1 if the s CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[elect is requested to block indefinitely, rather than time out.V * If block is input as 1, the timeout value will be treated as undefined, but it mustX * be available for setting in snmp_select_info. On return, if block is true, the value * of timeout will be undefined. *[ * snmp_select_info returns the number of open sockets. (i.e. The number of sessions open) */int snmp_select_info();/* * void snmp_timeout(); * T * snmp_timeout should be called whenever the timeout from snmp_select_info expires,P * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensiveK * proposition). snmp_timeout checks to see if any of the sessions have anO * outstanding request that has timed out. If it finds one (or more), and thatM * pdu has more retries available, a new packet is formed from the pdu and isP * resent. If there are no more retries available, the callback for the session, * is used to alert the user of the timeout. */void snmp_timeout();/*4 * This routine must be supplied by the application: *? * u_char *authenticator(pdu, length, community, community_len)8 * u_char *pdu; The rest of the PDU to be authenticatedE * int *length; The length of the PDU (updated by the authenticator)? * u_char *community; The community name to authenticate under.6 * int community_len The length of the community name. *C * Returns the authenticated pdu, or NULL if authentication failed.K * If null authentication is used, the authenticator in snmp_session CMUSNMP.SAV1[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.H;213.C;7[6% can be * set to NULL(0). *//*4 * This routine must be supplied by the application: *6 * int callback(operation, session, reqid, pdu, magic) * int operation;D * struct snmp_session *session; The session authenticated under.; * int reqid; The request id of this pdu (0 for TRAP)1 * struct snmp_pdu *pdu; The pdu information.9 * void *magic A link to the data for this routine. *G * Returns 1 if request was successful, 0 if it should be kept pending.I * Any data in the pdu must be copied because it will be freed elsewhere. * Operations are defined below: */#define RECEIVED_MESSAGE 1#define TIMED_OUT 2extern int snmp_dump_packet;3*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1+,J.-/ 4-- -0D123KPWO.56]gē7f8ē8fM 9FRQٓGHJ CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.C;7-5SNMP_APIV1.0 6-SEP-1990 11:47GNU CC V1.22$CODESID SNMP_ERRNOSNMP_DUMP_PACKET DEFAULT_ENTERPRISESESSIONS_080000X REQID_010000X API_ERRORS GETTIMEOFDAYSRANDOMRANDOM < SNMP_OPENMALLOCBZEROBCOPYSTRLENSTRCPY NET_SOCKET SOCKET_PERROR  SNMP_CLOSESTDERRFPRINTF INET_ADDR GETHOSTBYNAME GETSERVBYNAMEHTONSNET_BINDEXIT SNMP_FREE_PDUFREE NET_CLOSESNMP_BUILD_VAR_OPASN_BUILD_HEADER ASN_BUILD_INTASN_BUILD_OBJIDASN_BUILD_STRINGSNMP_AUTH_BUILDSNMP_AUTH_PARSEASN_PARSE_HEADER ASN_PARSE_INTASN_PARSE_OBJIDASN_PARSE_STRINGSNMP_PARSE_VAR_OP < SNMP_SENDPRINTF NET_SENDTO L  SNMP_READ NET_RECVFROM INET_NTOA SNMP_SELECT_INFO  SNMP_TIMEOUTSTDOUTSTDINPUnknown sessionUnknown hostInvalid local portUnknown Error>P>PЬPPMPP VP@PbPPdP^~uPͭ~PPPpublicsocketCouldn't abort session: %s. Exiting unknown host: %s udpsnmpbindP<^ЬSPjP PTdPRdPUUU P$dP$PS:PТSbRգ#QPݣ[P럠dPRݣRpPRգy CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.C;7-;PݣPPRݣRc$PPPPPPPRݣRPPRcѣPѣ PЏ@B ԥ~PPRCPϢPPSϙ PP1`P!PP|#P)P0P165PReգ1@PݣJPPP WPbaPݣkPPKoPݣNvP|PPRbSPP1PϘPPPPb1Pݠ ݰP PPPPPPP~P<~PPPԥԭ<~PPR+PPF/PϬ3P:PS]GPP'KPVPPC\PbPiPrPPSPzP ЬS PSRcSբ Pݢ + PRPSPP ЬRPQѡR PQSc PSPѣR PP Pc`PSPcSPSdPУP` P`PУPՠ Pݠ PݣPУP` $P`-PУPݠA9PݣBPRbSb MPPP\P^ЬXЬUЬ VЬWg VSХDR*P ݢ ݢ ~ݢSPPS1PbRPVST< CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.C;7-F T0 $PPS1PTSVP$PPSPPTg ѥ?P VPPS1AP S-PPS1%5Pv<Pݥ$ݥ  VQPPS1YP, SmPPS1uP8 SPPS1P< SPPS1P@ SPPS1P T1PTS$RRPVSPPT< T~ RPPSO P THPTSVPמ$PPSPPTg Th VHPPS MPVSPPgPPTZPPTS$mPVSPTPgPWrong version: %d Continuing anyway bad type returned (%x) P|^ЬVЬUЬ TTPPT1P%P|PPPRb{PPbզPTPT16PTFPPT1&NPѥB^PTsPPT1{PTPPT1P1P䚏@$$TPPT1Px$~PP x$~PP,TPPTmP8TPPTS!P<T6PPT9;P@TPPPTUPTePPT jP01tPPեD}PPPSSDP CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1- PPcPScԣ ԣ@ TPPTPx~PPRx~RPR< P2PPPB~ P1 P PP ݣ  P1 Pݣ PP P  P\ Pߚ@RR  PxPPP PP ݣPR( P* P ~l2 P8 P? Pլ11G PPNo remote IP address specified Error building packet %02X sendto P<^ЬUЬST< P PѠU PРT P`P PT  PPѣ Pѣ Pѣ  Pѣ/ Pգ Pѣ Pԣѣ8& Pԣ3+ Pգ$"4 P = PP PR P$գ@[ Pԣ@գ.c Pդh Pl Pr Py PPS P $SUϺ PP P P P P1 P PJ PRR 6 PM$~Ϭ P PRP PPPPRPP  Pϓ P P R Pτ P P~ PS~ $d0 PP4 PT8 P? PPѣS Pѣ ] P  CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-DZ ѣSg P$p PPQФaQS УХ } Ǐ@BPPď@BPP}УP P ЬSУDR1 Pբ  Pݢ Pբ   Pݢ  PRPbRP PR Pգ   Pݣ  PS Precvfromreceived %d bytes from %s: Mangled packet L P^Ь[Z1c PЪQxaPkP1s PЪXQY~<~$i PPWW  Pk P P P P` P PPWR P PRRW4 PM$~Ϝ P PRP PPPPRPP PσP PWRPvPPH~%PPV(fԦԦDԦ Ԧ$W$VXmIPPMPQPWP^PV[ePѦcpPЩR1yPѢLPݨ VݦXP7PRSѩSPcPЩRPbSPcbPbRPݣ PSP?PbRP8PѦPѦPѦ PѦPݨ VݦXVϮPjZ1IPP^ЬVЬUЬ WЬXTSԭԭRODPTТQaPPfSPPfxaPPeա,bPSСP$jPխoPխtPѠ {P }PѠP}`PPbRPSPTP~P׭@B­­ѭ@BP֭ѭ@B! CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-Z(PխPԭԭhPѭg PPѭP}ghPP^T~PV1z#PЦUЦWRЧS1P6PT :PTCPTѣLP1*QPѣ1 [Pѣ0bPݥ ݣ У PݠUR{PcPcbݣ 4PST1P<֣ ݣ UϩPPPϯPPPPJPRR6PM~ϞPPRPPPPPRPP PυP PRPvPP~'Pݣ ~g?PP CPEGPNP} Ǐ@BPPď@BPP}SRcS1PT PTPTfV1P P P" P PN7 P P" P" P" P" P" P" P" P"" P"$ P"& P"( P"* P", P". P"0 P"2 P"4 P"6 P"8 P": P"< P"> P"@ P"B P"D P"F P"H P"J P"L P"N P"P P"R P"T P"V P"X P"Z P"\ P"^ P"` P"b P"d P"f P"h P"j P"l P"n P"p P"r P"t P"v P"x P"z P"| P"~ P" P" P" P P P P PPFREEIP S" CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-OCKET_PERROR:P NET_SENDTO"P GETTIMEOFDAYPPRINTFPPRINTFPPRINTFPPFPRINTFP>PFREEP GETTIMEOFDAYP GETTIMEOFDAYPFREEYPFPRINTFRP PMALLOCPPRINTFPPRINTF PPRINTF PPRINTF P INET_NTOA P P SOCKET_PERROR P NET_RECVFROM PFREE PFREE PFREE PFREE PFREEk PMALLOC: P SOCKET_PERROR+ P NET_SENDTO P GETTIMEOFDAY PPRINTF PPRINTF PPRINTF P PFPRINTF P PBCOPYt PFPRINTFm PM PBCOPY8 PMALLOC: PFPRINTF3 P# PBCOPY PMALLOC PASN_PARSE_OBJID PASN_PARSE_STRING PMALLOC P ASN_PARSE_INT PMALLOCPBCOPYPMALLOCPSNMP_PARSE_VAR_OPPMALLOCPMALLOC`PASN_PARSE_HEADERKP ASN_PARSE_INT1P ASN_PARSE_INTP ASN_PARSE_INTPASN_PARSE_STRINGPBCOPYPMALLOCPASN_PARSE_OBJIDP ASN_PARSE_INTnP ASN_PARSE_INTAPASN_PARSE_HEADERPPFPRINTFPPSNMP_AUTH_PARSEhPBCOPYCPSNMP_AUTH_BUILDPBCOPYPASN_BUILD_HEADERPBCOPYP ASN_BUILD_INTP ASN_BUILD_INTP ASN_BUILD_INThPASN_BUILD_STRINGLPASN_BUILD_OBJID# CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-c[(P ASN_BUILD_INT P ASN_BUILD_INTPBCOPYPASN_BUILD_HEADERPSNMP_BUILD_VAR_OP=PFREE(P NET_CLOSEPFREEPFREEPFREEPFREEmPEXITdPFPRINTF]P5P SOCKET_PERROR&PNET_BINDPHTONSPHTONSP GETSERVBYNAMEPBCOPYP}PFPRINTFwPfP GETHOSTBYNAMEEP INET_ADDR+PFPRINTF$PP SOCKET_PERRORP NET_SOCKETPBCOPYPMALLOCPSTRLEN~PMALLOCkPSTRCPYVPSTRLEN5PBCOPYPBZEROPMALLOCPRANDOM}PSRANDOMpP GETTIMEOFDAYP<PX PA P{ PF P P P P POPPPPLP<PPPPPGP?PPPXPPPPPP P0PPPsSNMP_APIRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS$ CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-W itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRSprotoent` p_name  p_aliases @p_proto R Sservent s_name  s_aliases  @s_port`s_proto  R Snetent n_name  n_aliases @ n_addrtype `n_net n_addresses  R R Shostent  h_name  h_aliases @ h_addrtype`h_length h_addr_list  h_cputype h_opsys h_protosP  h_addresses  RRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslenRS sockproto  sp_family sp_protocolR ST STSsockaddr sa_familysa_data*& RSlinger@l_onoff l_lingerRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&% CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-(RSTSin_addr s_addrRSval integer  string  objid RS variable_list next_variable T name @ name_length `type hval Tval_lenRSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise  enterprise_length@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic RS session_list` next T session T@internal RRS request_list  next_request T request_id@retries`timeout time T expire T pdu TRSTS snmp_internal_session sd addr Trequests TRSTS default_enterprise*& Sessions T& CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-$ Reqid snmp_errno api_errors3/&$$PsectAttributes_NOSHR$$stderr T&t $$PsectAttributes_NOSHR$$stdout T% $$PsectAttributes_NOSHR$$stdin TWS=M;?DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.C;5  > api_errstringP1'snmp_errnumberBB j>&d init_snmp tv T4 snmp_open sessionx Tslpx Tispx Tcpx sdx addr me Thpx  Tservpx  T   snmp_close sessionZ TslpZ ToslpZ T' CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-"zfree_request_listhrp Torp T@*  snmp_free_pdupdu   Tvp   Tovp   T   \ snmp_build sessionsw Tpdusw Tpacketsw # out_lengthsw  $buf*&cpsw vpsw T  length zeroR.$ totallengthswY  OZ snmp_parseA length sessionI  TpduI  TdataI  msg_ty( CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1- =%pe typevar_val version len fourـ community*&community_lengthvpI  T objid*&@@?opI  H  E  snmp_send session   Tpdu   Tslp   Tisp   T $packet*&  lengthrp   T tv T  $0count  JP  ?  ^  o ) CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1.OBJ;1-(6,L  snmp_readfdsetW  slpW  TspW  TispW  T $packet*& from TlengthW  fromlengthpduW  TrpW  TorpW  T  $0count `S       snmp_select_infonumfds1 fdset1  timeout1 Tblock1 slp1 Tisp1 Trp1 T now Topearliest Tactive1! requests1U* CMUSNMP.SAVJ3[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_API.OBJ;1ETSTAT.EXE;1-+ , # snmp_timeoutslp  Tsp  Tisp  Trp  Torp  Tfreeme  T now T $0 packet*&n length tv T $0countJ2    i~3 eength@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic RS session_list` next T session + CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2NETSTAT.EXE;1l2*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2+,./ 4l-0@123KPWO56޶7`o8j΁9FRQٓGHJ/* * snmp_auth.c -@ * Authentication for SNMP (RFC 1067). This implements a null * authentication layer. * * */</***********************************************************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 notice 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, D, CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2NETSTAT.EXE;1lyATA 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******************************************************************/#ifdef KINETICS#include "gw.h"#include "fp4/cmdmacro.h"#endif)#if (defined(unix) && !defined(KINETICS))#include #include #ifndef NULL#define NULL 0#endif#endif#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"u_char *1snmp_auth_parse(data, length, sid, slen, version) u_char *data; int *length; u_char *sid; int *slen; long *version;{ u_char type;1 data = asn_parse_header(data, length, &type); if (data == NULL){ ERROR("bad header"); return NULL; }2 if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)){! ERROR("wrong auth header type"); return NULL; }I data = asn_parse_int(data, length, &type, version, sizeof(*version)); if (data == NULL){ ERROR("bad parse of version"); return NULL; }< data = asn_parse_string(data, length, &type, sid, slen); if (data == NULL){! ERROR("bad parse of community"); return NULL; } sid[*slen] = '\0'; return (u_char *)data;}u_char *=snmp_auth_build(data, length, sid, slen, version, messagelen) u_char *data; int *length; u_char *sid; int *slen; long *version; int mes- CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2NETSTAT.EXE;1lsagelen;{l data = asn_build_header(data, length, (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), messagelen + *slen + 5); if (data == NULL){ ERROR("buildheader"); return NULL; }& data = asn_build_int(data, length,; (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),( (long *)version, sizeof(*version)); if (data == NULL){ ERROR("buildint"); return NULL; }) data = asn_build_string(data, length,> (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),  sid, *slen); if (data == NULL){ ERROR("buildstring"); return NULL; } return (u_char *)data;}4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.OBJ;1+,J ./ 4-0D123KPWO562ē7&Skē8&ET 9FRQٓGHJ. CMUSNMP.SAVJ 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.OBJ;1TSTAT.EXE;1q,6 SNMP_AUTHV1.0 6-SEP-1990 11:48GNU CC V1.22$CODESID SNMP_AUTH_PARSEASN_PARSE_HEADER ASN_PARSE_INTASN_PARSE_STRING b SNMP_AUTH_BUILDASN_BUILD_HEADER ASN_BUILD_INTASN_BUILD_STRINGPP^ЬPЬRЬ TЬSRP#PP3'P0--PݬRP@PPDPSTRPVPPZPPDbP ЬQЬRЬScP0RQPPQ.PݬRQPPQPcݬ RQPPQPPQPPASN_BUILD_STRINGP ASN_BUILD_INTPASN_BUILD_HEADERLQPASN_PARSE_STRING;P ASN_PARSE_INTPASN_PARSE_HEADER SNMP_AUTHRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrXT޶@DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.C;2  lsnmp_auth_parseversion dataa lengtha sida slena  type~ 0bbsnmp_auth_build sid / CMUSNMP.SAVJ 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_AUTH.OBJ;1TSTAT.EXE;1version  messagelendata length slen P^^4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3+,./ 4_<-0@123KPWO56/M7 Lo8 9FRQٓGHJ/*D * snmp_client.c - a toolkit of common functions for an SNMP client. * */</***********************************************************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 in90 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_supporting 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******************************************************************/#include #include #include #include #include #include #include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "snmp_api.h"#include "snmp_client.h"typedef int fd_set;)#define FD_SET(n, p) (*(p) |= (1 << (n)))*#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))*#define FD_ISSET(n, p) (*(p) & (1 << (n)))#define FD_ZERO(p) (*(p) = 0) #define perror socket_perror#define sendto net_sendto #define recvfrom net_recvfrom#define select net_select#define bind net_bind#define close net_close#define socket net_socketextern int errno;$struct synch_state snmp_synch_state;struct snmp_pdu *snmp_pdu_create(command) int command;{ struct snmp_pdu *pdu;= pdu = (struc1 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_et snmp_pdu *)malloc(sizeof(struct snmp_pdu));0 bzero((char *)pdu, sizeof(struct snmp_pdu)); pdu->command = command;( pdu->errstat = SNMP_DEFAULT_ERRSTAT;* pdu->errindex = SNMP_DEFAULT_ERRINDEX;8 pdu->address.sin_addr.s_addr = SNMP_DEFAULT_ADDRESS; pdu->enterprise = NULL; pdu->enterprise_length = 0; pdu->variables = NULL; return pdu;}/*H * Add a null variable with the requested name to the end of the list of * variables for this pdu. */)snmp_add_null_var(pdu, name, name_length) struct snmp_pdu *pdu; oid *name; int name_length;{ struct variable_list *vars; if (pdu->variables == NULL){V pdu->variables = vars = (struct variable_list *)malloc(sizeof(struct variable_list)); } else {L for(vars = pdu->variables; vars->next_variable; vars = vars->next_variable) ;T vars->next_variable = (struct variable_list *)malloc(sizeof(struct variable_list)); vars = vars->next_variable; } vars->next_variable = NULL;: vars->name = (oid *)malloc(name_length * sizeof(oid));G bcopy((char *)name, (char *)vars->name, name_length * sizeof(oid));$ vars->name_length = name_length; vars->type = ASN_NULL; vars->val.string = NULL; vars->val_len = 0;}0snmp_synch_input(op, session, reqid, pdu, magic) int op;! struct snmp_session *session; int reqid; struct snmp_pdu *pdu; void *magic;{' struct variable_list *var, *newvar;< struct synch_state *state = (str2 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_uct synch_state *)magic; struct snmp_pdu *newpdu; if (reqid != state->reqid) return 0; state->waiting = 0;? if (op == RECEIVED_MESSAGE && pdu->command == GET_RSP_MSG){ /* clone the pdu */J state->pdu = newpdu = (struct snmp_pdu *)malloc(sizeof(struct snmp_pdu));= bcopy((char *)pdu, (char *)newpdu, sizeof(struct snmp_pdu)); newpdu->variables = 0; var = pdu->variables; if (var != NULL){_ newpdu->variables = newvar = (struct variable_list *)malloc(sizeof(struct variable_list));F bcopy((char *)var, (char *)newvar, sizeof(struct variable_list)); if (var->name != NULL){? newvar->name = (oid *)malloc(var->name_length * sizeof(oid));Q bcopy((char *)var->name, (char *)newvar->name, var->name_length * sizeof(oid)); }" if (var->val.string != NULL){6 newvar->val.string = (u_char *)malloc(var->val_len);K bcopy((char *)var->val.string, (char *)newvar->val.string, var->val_len); } newvar->next_variable = 0; while(var->next_variable){W newvar->next_variable = (struct variable_list *)malloc(sizeof(struct variable_list)); var = var->next_variable;! newvar = newvar->next_variable;C bcopy((char *)var, (char *)newvar, sizeof(struct variable_list)); if (var->name != NULL){C newvar->name = (oid *)malloc(var->name_length * sizeof(oid));U bcopy((char *)var->name, (char *)newvar->name, var->name_length * sizeof(oid)); } if (var->val.string != NULL){: newvar->val.string = (u_char *)malloc(var->val_l3 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_% en);O bcopy((char *)var->val.string, (char *)newvar->val.string, var->val_len); } newvar->next_variable = 0; } } state->status = STAT_SUCCESS; } else if (op == TIMED_OUT){ state->status = STAT_TIMEOUT; } return 1;}/*E * If there was an error in the input pdu, creates a clone of the pduI * that includes all the variables except the one marked by the errindex.F * The command is set to the input command and the reqid, errstat, and& * errindex are set to default values.G * If the error status didn't indicate an error, the error index didn'tG * indicate a variable, the pdu wasn't a get response message, or thereC * would be no remaining variables, this function will return NULL.G * If everything was successful, a pointer to the fixed cloned pdu will * be returned. */struct snmp_pdu *snmp_fix_pdu(pdu, command) struct snmp_pdu *pdu; int command;{' struct variable_list *var, *newvar; struct snmp_pdu *newpdu; int index, copied = 0;^ if (pdu->command != GET_RSP_MSG || pdu->errstat == SNMP_ERR_NOERROR || pdu->errindex <= 0) return NULL; /* clone the pdu */@ newpdu = (struct snmp_pdu *)malloc(sizeof(struct snmp_pdu));@ bcopy((char *)pdu, (char *)newpdu, sizeof(struct snmp_pdu)); newpdu->variables = 0; newpdu->command = command;' newpdu->reqid = SNMP_DEFAULT_REQID;+ newpdu->errstat = SNMP_DEFAULT_ERRSTAT;- newpdu->errindex = SNMP_DEFAULT_ERRINDEX; var = pdu->variables4 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_; index = 1;: if (pdu->errindex == index){ /* skip first variable */ var = var->next_variable; index++; } if (var != NULL){[ newpdu->variables = newvar = (struct variable_list *)malloc(sizeof(struct variable_list));B bcopy((char *)var, (char *)newvar, sizeof(struct variable_list)); if (var->name != NULL){B newvar->name = (oid *)malloc(var->name_length * sizeof(oid));T bcopy((char *)var->name, (char *)newvar->name, var->name_length * sizeof(oid)); } if (var->val.string != NULL){9 newvar->val.string = (u_char *)malloc(var->val_len);N bcopy((char *)var->val.string, (char *)newvar->val.string, var->val_len); } newvar->next_variable = 0; copied++; while(var->next_variable){ var = var->next_variable;" if (++index == pdu->errindex) continue;Z newvar->next_variable = (struct variable_list *)malloc(sizeof(struct variable_list));$ newvar = newvar->next_variable;F bcopy((char *)var, (char *)newvar, sizeof(struct variable_list)); if (var->name != NULL){? newvar->name = (oid *)malloc(var->name_length * sizeof(oid));Q bcopy((char *)var->name, (char *)newvar->name, var->name_length * sizeof(oid)); }" if (var->val.string != NULL){6 newvar->val.string = (u_char *)malloc(var->val_len);K bcopy((char *)var->val.string, (char *)newvar->val.string, var->val_len); } newvar->next_variable = 0; copied++; } }. if (index < pdu->errindex || copied == 0){ snmp_free_pdu(newpdu); r5 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_neturn NULL; } return newpdu;}int&snmp_synch_response(ss, pdu, response) struct snmp_session *ss; struct snmp_pdu *pdu; struct snmp_pdu **response;{2 struct synch_state *state = &snmp_synch_state; int numfds, count; fd_set fdset;! struct timeval timeout, *tvp; int block;2 if ((state->reqid = snmp_send(ss, pdu)) == 0){ *response = NULL; snmp_free_pdu(pdu); return STAT_ERROR; } state->waiting = 1; while(state->waiting){ numfds = 0; FD_ZERO(&fdset); block = 1; tvp = &timeout; timerclear(tvp);0 snmp_select_info(&numfds, &fdset, tvp, &block); if (block == 1), tvp = NULL; /* block without timeout */+ count = select(numfds, &fdset, 0, 0, tvp); if (count > 0){ snmp_read(&fdset); } else switch(count){ case 0: snmp_timeout(); break; case -1: if (errno == EINTR){ continue; } else { perror("select"); } /* FALLTHRU */ default: return STAT_ERROR; } } *response = state->pdu; return state->status;}snmp_synch_setup(session)! struct snmp_session *session;{) session->callback = snmp_synch_input;8 session->callback_magic = (void *)&snmp_synch_state;}char *error_string[6] = { "No Error",2 "Response message would have been too large.",2 "There is no such variable name in this MIB.",3 "The value given has the wrong type or length",! "This variable is read only",6 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3TSTAT.EXE;1_i "A general failure occured"};char *snmp_errstring(errstat) int errstat;{C if (errstat <= SNMP_ERR_GENERR && errstat >= SNMP_ERR_NOERROR){ return error_string[errstat]; } else { return "Unknown Error"; }}4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.H;2+,. / 4H -0@123KPWO 567`+o8&wFX 9FRQٓGHJ/* * snmp_client.h */</***********************************************************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 notice appear in 9supporting documentation, and that the n7 CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.H;2TSTAT.EXE;1H r2ame 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******************************************************************/struct synch_state { int waiting; int status;/* status codes */#define STAT_SUCCESS 0#define STAT_ERROR 1#define STAT_TIMEOUT 2 int reqid; struct snmp_pdu *pdu;};+extern struct synch_state snmp_synch_state;#struct snmp_pdu *snmp_pdu_create(); struct snmp_pdu *snmp_fix_pdu();char *snmp_errstring();6*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1+,J./ 4-0D123KPWO56Zʙē7fē8f^ 9FRQٓGHJ8 CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1TAT.EXE;1P58 SNMP_CLIENTV1.0 6-SEP-1990 11:48GNU CC V1.22$CODESID SNMP_ERRNOSNMP_DUMP_PACKETSNMP_SYNCH_STATE SNMP_PDU_CREATEMALLOCBZERO :SNMP_ADD_NULL_VARBCOPY SNMP_SYNCH_INPUT  SNMP_FIX_PDU SNMP_FREE_PDU <SNMP_SYNCH_RESPONSE SNMP_SENDSNMP_SELECT_INFO NET_SELECT SNMP_READERRNO SOCKET_PERROR SNMP_TIMEOUT SNMP_SYNCH_SETUP ERROR_STRING SNMP_ERRSTRING SOCKET_ERRNOVMSERRNO VAXC$ERRNOSTDERRSTDOUTSTDINPPH~ PPRH~RPЬԢԢ Ԣ$ԢDRP:PЬRЬ TբDIPRPPSSD[PТDSccPcScjPsPPcPScxTRRPPRPݬPT ԣ ԣPЬPЬRЬWѬ PPgP1PѢ1PH~PUePTT H~TRPVfԤDТDR1 PePSSDSRfբ^&Px~ePx~PݢfCAPIPUePcbRPSSRbPTdբkPx~ePx~Pݢdբ PݢPP ݢPݢ PcbPԧ PPPPPЬYXѩ1%Pթ1Pթ1PH~PPWH~WYPԧDЬԧЩDRVѩV PbRVR1-P9 CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1TAT.EXE;1ͬ5PTdPSSDSRLPUeբfUPx~dPx~PݢeKpPbRVVf{PPUePcPSSRPTdբPx~ePx~Pݢdբ PݢPP ݢPݢ PcXbPVPX PWPPWPselectP<^ЬRЬ UPSRݬ&PP-P/PeR:PPc1FP؞Tԭԭ잭RԢbRTnPѭtPRR~~TݭPP PTP.PяPPPPRPPPP1|PPcPУ eУPPЬPPP No ErrorResponse message would have been too large.There is no such variable name in this MIB.The value given has the wrong type or lengthThis variable is read onlyA general failure occuredPUnknown ErrorPЬPP PP P@PPPPP SNMP_TIMEOUTP SOCKET_PERRORPP SNMP_READP NET_SELECTiPSNMP_SELECT_INFO5P SNMP_FREE_PDU(P!P SNMP_SENDPP SNMP_FREE_PDUPBCOPYPMALLOCPBCOPY~PMALLOCGPBCOPY0PMALLOCPBCOPYPMALLOCPBCOPYPMALLOC]PBCOPYDPMALLOCPBCOPYPMALLOCPBCOPYPMALLOCn: CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1TAT.EXE;1iFPMALLOCMPMALLOCPBZEROPMALLOCPPPPu PHPPP SNMP_CLIENTRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRS sockaddr_in sin_familysin_port sin_addr  R@sin_zero*& R S T Sin_addr s_addr R S synch_statewaiting  status @reqid `pdu  R R Sval integer  string  objid RS variable_list next_variable T name @ name_length `type hval  Tval_lenR STSsnmp_pdu@address Tcommand reqiderrstaterrindex enterprise ; CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1TAT.OPT;2  enterprise_length@ agent_addr T trap_type specific_type time  variables TRS snmp_session  community  community_len@retries`timeoutpeername  remote_port local_port authenticator callback callback_magic  error_string3/snmp_synch_state  T,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno * #$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errno& $$PsectAttributes_NOSHR$$stderr T& $$PsectAttributes_NOSHR$$stdout T% $$PsectAttributes_NOSHR$$stdin TZV/MBDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.C;3  6snmp_pdu_createEcommandpdu9 Td 9::snmp_add_null_var name pduD T$ name_lengthDvarsD Tepsnmp_synch_input@session T< CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1YU  reqid magic oppdu Tvar Tnewvar Tstate  T snmp_fix_pdu6commandpdu Tvar Tnewvar Tnewpdu TindexcopiedHsnmp_synch_responsec ss Tpdu T! response Tstate  T numfdscount fdsettimeout Ttvp T block = CMUSNMP.SAVJ6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_CLIENT.OBJ;1  snmp_synch_setup9 session T5snmp_errstring* errstat,   2*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_IMPL.H;2+,./ 4N-0@123KPWO56 7Ko8Fy 9FRQٓGHJ/*2 * Definitions for SNMP (RFC 1067) implementation. * * */</***********************************************************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 notice appear in > CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_IMPL.H;2N9supporting 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******************************************************************/%#if (defined vax) || (defined (mips))/*N * This is a fairly bogus thing to do, but there seems to be no better way for1 * compilers that don't understand void pointers. */#define void char#endif/* * Error codes: *//*= * These must not clash with SNMP error codes (all positive). */#define PARSE_ERROR -1#define BUILD_ERROR -2#define SID_MAX_LEN 64;#define MAX_NAME_LEN 64 /* number of subid's in a objid */ #ifndef NULL#define NULL 0#endif #ifndef TRUE#define TRUE 1#endif #ifndef FALSE#define FALSE 0#endif#define READ 1#define WRITE 03#define RONLY 0xAAAA /* read access for everyone */B#define RWRITE 0xAABA /* add write access for community private */3#define NOACCESS 0x0000 /* no access for anybody */#define INTEGER ASN_INTEGER #defin? CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_IMPL.H;2Ne$e STRING ASN_OCTET_STR#define OBJID ASN_OBJECT_ID#define NULLOBJ ASN_NULL,/* defined types (from the SMI, RFC 1065) */)#define IPADDRESS (ASN_APPLICATION | 0))#define COUNTER (ASN_APPLICATION | 1)'#define GAUGE (ASN_APPLICATION | 2))#define TIMETICKS (ASN_APPLICATION | 3)(#define OPAQUE (ASN_APPLICATION | 4) #ifdef notdefE#define ERROR(string) sendf("%s(%d): %s",__FILE__, __LINE__, string);#else#define ERROR(string)#endif/* from snmp.c*/+extern u_char sid[]; /* size SID_MAX_LEN */u_char *snmp_parse_var_op();u_char *snmp_build_var_op();u_char *snmp_auth_parse();u_char *snmp_auth_build();4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228+,.Z/ 4ZVL<-0@123KPWO[56@^U7 UYo8*v9FRQٓGHJ@ CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z/*8 * snmp_vars.c - return a pointer to the named variable. * * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University( Copyright 1989, 1990 TGV, Incorporated 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 inFsupporting documentation, and that the name of CMU and TGV not be usedFin advertising or publicity pertaining to distribution of the software+without specific, written prior permission.BCMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,FINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO=EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT ORFCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OFEUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ORFOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.C******************************************************************/:#define USE_NAME_AS_DESCRIPTION /*"se0" instead of text */?#define GATEWAY /* MultiNet is always configured this way! */#include #include #include #include #include #include #incA CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zblude #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ##include "../../kernel/h/protosw.h" #ifndef NULL#define NULL 0#endif#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "mib.h"#include "snmp_vars.h" #ifdef vax11c#define ioctl socket_ioctl#define perror socket_perror #endif vax11c(extern char *Lookup_Device_Annotation();#static int TCP_Count_Connections();static TCP_Scan_Init();static int TCP_Scan_Next();%static int Interface_Scan_By_Index();&static int Interface_Scan_Get_Count();*static int Interface_Get_Ether_By_Index();static struct nlist nl[] = {#define N_IPSTAT 0 { "_ipstat" },#define N_IPFORWARDING 1 { "_ipforwarding" },#define N_TCP_TTL 2 { "_tcp_ttl" },#define N_UDPSTAT 3 { "_udpstat" },#define N_IN_INTERFACES 4 { "_in_interfaces" },#define N_ICMPSTAT 5 { "_icmpstat" },#define N_IFNET 6 { "_ifnet" },#define N_TCPSTAT 7 { "_tcpstat" },#define N_TCB 8 { "_tcb" },#define N_IN_IFADDR 9 { "_in_ifaddr" }, 0,};/*N * Each variable name is placed in the variable table,B CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z without the terminatingW * substring that determines the instance of the variable. When a string is found thatR * is lexicographicly preceded by the input string, the function for that entry isQ * called to find the method of access of the instance of the named variable. IfQ * that variable is not found, NULL is returned, and the search through the tableV * continues (it should stop at the next entry). If it is found, the function returnsU * a character pointer and a length or a function pointer. The former is the addressD * of the operand, the latter is an access routine for the variable. * * u_char *7 * findVar(name, length, exact, var_len, access_method)F * oid *name; IN/OUT - input name requested, output name foundI * int length; IN/OUT - number of sub-ids in the in and out oid's@ * int exact; IN - TRUE if an exact match was requested.G * int len; OUT - length of variable or 0 if function returned.A * int access_method; OUT - 1 if function, 0 if char pointer. * * accessVar(rw, var, varLen)= * int rw; IN - request to READ or WRITE the variable9 * u_char *var; IN/OUT - input or output buffer space7 * int *varLen;IN/OUT - input and output buffer len */long long_return;u_char return_buf[64]; init_snmp(){5 multinet_kernel_nlist("MULTINET_NETWORK_IMAGE:",nl);}#struct variable variables[] = {? /* these must be lexicographly ordered by the name field */E {{MIB, 1, 1, 0}, 9, STRINC CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z[{ G, VERSION_DESCR, RONLY, var_system },B {{MIB, 1, 2, 0}, 9, OBJID, VERSION_ID, RONLY, var_system },@ {{MIB, 1, 3, 0}, 9, TIMETICKS, UPTIME, RONLY, var_system },@ {{MIB, 2, 1, 0}, 9, INTEGER, IFNUMBER, RONLY, var_system },J {{MIB, 2, 2, 1, 1, 0xFF}, 11, INTEGER, IFINDEX, RONLY, var_ifEntry },J {{MIB, 2, 2, 1, 2, 0xFF}, 11, STRING, IFDESCR, RONLY, var_ifEntry },I {{MIB, 2, 2, 1, 3, 0xFF}, 11, INTEGER, IFTYPE, RONLY, var_ifEntry },H {{MIB, 2, 2, 1, 4, 0xFF}, 11, INTEGER, IFMTU, RONLY, var_ifEntry },J {{MIB, 2, 2, 1, 5, 0xFF}, 11, GAUGE, IFSPEED, RONLY, var_ifEntry },P {{MIB, 2, 2, 1, 6, 0xFF}, 11, STRING, IFPHYSADDRESS, RONLY, var_ifEntry },Q {{MIB, 2, 2, 1, 7, 0xFF}, 11, INTEGER, IFADMINSTATUS, RWRITE, var_ifEntry },O {{MIB, 2, 2, 1, 8, 0xFF}, 11, INTEGER, IFOPERSTATUS, RONLY, var_ifEntry },Q {{MIB, 2, 2, 1, 9, 0xFF}, 11, TIMETICKS, IFLASTCHANGE, RONLY, var_ifEntry },M {{MIB, 2, 2, 1, 10, 0xFF}, 11, COUNTER, IFINOCTETS, RONLY, var_ifEntry },P {{MIB, 2, 2, 1, 11, 0xFF}, 11, COUNTER, IFINUCASTPKTS, RONLY, var_ifEntry },Q {{MIB, 2, 2, 1, 12, 0xFF}, 11, COUNTER, IFINNUCASTPKTS, RONLY, var_ifEntry },O {{MIB, 2, 2, 1, 13, 0xFF}, 11, COUNTER, IFINDISCARDS, RONLY, var_ifEntry },M {{MIB, 2, 2, 1, 14, 0xFF}, 11, COUNTER, IFINERRORS, RONLY, var_ifEntry },T {{MIB, 2, 2, 1, 15, 0xFF}, 11, COUNTER, IFINUNKNOWNPROTOS, RONLY, var_ifEntry },N {{MIB, 2, 2, 1, 16, 0xFF}, 11, COUNTER, IFOUTOCTETS, RONLY, var_ifEntry },Q {{MIB,D CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zw 2, 2, 1, 17, 0xFF}, 11, COUNTER, IFOUTUCASTPKTS, RONLY, var_ifEntry },R {{MIB, 2, 2, 1, 18, 0xFF}, 11, COUNTER, IFOUTNUCASTPKTS, RONLY, var_ifEntry },P {{MIB, 2, 2, 1, 19, 0xFF}, 11, COUNTER, IFOUTDISCARDS, RONLY, var_ifEntry },N {{MIB, 2, 2, 1, 20, 0xFF}, 11, COUNTER, IFOUTERRORS, RONLY, var_ifEntry },L {{MIB, 2, 2, 1, 21, 0xFF}, 11, GAUGE, IFOUTQLEN, RONLY, var_ifEntry },m {{MIB, 3, 1, 1, 1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 16, INTEGER, ATIFINDEX, RWRITE, var_atEntry },q {{MIB, 3, 1, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 16, STRING, ATPHYSADDRESS, RWRITE, var_atEntry },p {{MIB, 3, 1, 1, 3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 16, IPADDRESS, ATNETADDRESS, RWRITE, var_atEntry },C {{MIB, 4, 1, 0}, 9, INTEGER, IPFORWARDING, RONLY, var_ip },D {{MIB, 4, 2, 0}, 9, INTEGER, IPDEFAULTTTL, RWRITE, var_ip },C {{MIB, 4, 3, 0}, 9, COUNTER, IPINRECEIVES, RONLY, var_ip },D {{MIB, 4, 4, 0}, 9, COUNTER, IPINHDRERRORS, RONLY, var_ip },E {{MIB, 4, 5, 0}, 9, COUNTER, IPINADDRERRORS, RONLY, var_ip },F {{MIB, 4, 6, 0}, 9, COUNTER, IPFORWDATAGRAMS, RONLY, var_ip },H {{MIB, 4, 7, 0}, 9, COUNTER, IPINUNKNOWNPROTOS, RONLY, var_ip },C {{MIB, 4, 8, 0}, 9, COUNTER, IPINDISCARDS, RONLY, var_ip },C {{MIB, 4, 9, 0}, 9, COUNTER, IPINDELIVERS, RONLY, var_ip },E {{MIB, 4, 10, 0}, 9, COUNTER, IPOUTREQUESTS, RONLY, var_ip },E {{MIB, 4, 11, 0}, 9, COUNTER, IPOUTDISCARDS, RONLY, var_ip },E {{MIB, 4, E CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z12, 0}, 9, COUNTER, IPOUTNOROUTES, RONLY, var_ip },F {{MIB, 4, 13, 0}, 9, INTEGER, IPREASMTIMEOUT, RONLY, var_ip },D {{MIB, 4, 14, 0}, 9, COUNTER, IPREASMREQDS, RONLY, var_ip },B {{MIB, 4, 15, 0}, 9, COUNTER, IPREASMOKS, RONLY, var_ip },D {{MIB, 4, 16, 0}, 9, COUNTER, IPREASMFAILS, RONLY, var_ip },A {{MIB, 4, 17, 0}, 9, COUNTER, IPFRAGOKS, RONLY, var_ip },C {{MIB, 4, 18, 0}, 9, COUNTER, IPFRAGFAILS, RONLY, var_ip },E {{MIB, 4, 19, 0}, 9, COUNTER, IPFRAGCREATES, RONLY, var_ip },c {{MIB, 4, 20, 1, 1, 0xFF, 0xFF, 0xFF, 0xFF}, 14, IPADDRESS, IPADADDR, RONLY, var_ipAddrEntry },d {{MIB, 4, 20, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPADIFINDEX, RONLY, var_ipAddrEntry },f {{MIB, 4, 20, 1, 3, 0xFF, 0xFF, 0xFF, 0xFF}, 14, IPADDRESS, IPADNETMASK, RONLY, var_ipAddrEntry },f {{MIB, 4, 20, 1, 4, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPADBCASTADDR, RONLY, var_ipAddrEntry },h {{MIB, 4, 21, 1, 1, 0xFF, 0xFF, 0xFF, 0xFF}, 14, IPADDRESS, IPROUTEDEST, RWRITE, var_ipRouteEntry },i {{MIB, 4, 21, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEIFINDEX, RWRITE, var_ipRouteEntry },i {{MIB, 4, 21, 1, 3, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEMETRIC1, RWRITE, var_ipRouteEntry },i {{MIB, 4, 21, 1, 4, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEMETRIC2, RWRITE, var_ipRouteEntry },i {{MIB, 4, 21, 1, 5, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEMETRIC3, RWRITE, var_ipRouteEntry },i {{MIB, 4, 21, 1, 6, 0xFF, 0xFF, 0xF CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZFF, 0xFF}, 14, INTEGER, IPROUTEMETRIC4, RWRITE, var_ipRouteEntry },k {{MIB, 4, 21, 1, 7, 0xFF, 0xFF, 0xFF, 0xFF}, 14, IPADDRESS, IPROUTENEXTHOP, RWRITE, var_ipRouteEntry },f {{MIB, 4, 21, 1, 8, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTETYPE, RWRITE, var_ipRouteEntry },f {{MIB, 4, 21, 1, 9, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEPROTO, RONLY, var_ipRouteEntry },f {{MIB, 4, 21, 1, 10, 0xFF, 0xFF, 0xFF, 0xFF}, 14, INTEGER, IPROUTEAGE, RWRITE, var_ipRouteEntry },C {{MIB, 5, 1, 0}, 9, COUNTER, ICMPINMSGS, RONLY, var_icmp },E {{MIB, 5, 2, 0}, 9, COUNTER, ICMPINERRORS, RONLY, var_icmp },K {{MIB, 5, 3, 0}, 9, COUNTER, ICMPINDESTUNREACHS, RONLY, var_icmp },H {{MIB, 5, 4, 0}, 9, COUNTER, ICMPINTIMEEXCDS, RONLY, var_icmp },H {{MIB, 5, 5, 0}, 9, COUNTER, ICMPINPARMPROBS, RONLY, var_icmp },I {{MIB, 5, 6, 0}, 9, COUNTER, ICMPINSRCQUENCHS, RONLY, var_icmp },H {{MIB, 5, 7, 0}, 9, COUNTER, ICMPINREDIRECTS, RONLY, var_icmp },D {{MIB, 5, 8, 0}, 9, COUNTER, ICMPINECHOS, RONLY, var_icmp },G {{MIB, 5, 9, 0}, 9, COUNTER, ICMPINECHOREPS, RONLY, var_icmp },*J {{MIB, 5, 10, 0}, 9, COUNTER, ICMPINTIMESTAMPS, RONLY, var_icmp },M {{MIB, 5, 11, 0}, 9, COUNTER, ICMPINTIMESTAMPREPS, RONLY, var_icmp }, I {{MIB, 5, 12, 0}, 9, COUNTER, ICMPINADDRMASKS, RONLY, var_icmp }, L {{MIB, 5, 13, 0}, 9, COUNTER, ICMPINADDRMASKREPS, RONLY, var_icmp },E {{MIB, 5, 14, 0}, 9, COUNTER, ICMPOUTMSGS, RONLY, var_icmp },dGG CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z) {{MIB, 5, 15, 0}, 9, COUNTER, ICMPOUTERRORS, RONLY, var_icmp },eM {{MIB, 5, 16, 0}, 9, COUNTER, ICMPOUTDESTUNREACHS, RONLY, var_icmp },tJ {{MIB, 5, 17, 0}, 9, COUNTER, ICMPOUTTIMEEXCDS, RONLY, var_icmp },J {{MIB, 5, 18, 0}, 9, COUNTER, ICMPOUTPARMPROBS, RONLY, var_icmp },K {{MIB, 5, 19, 0}, 9, COUNTER, ICMPOUTSRCQUENCHS, RONLY, var_icmp }, J {{MIB, 5, 20, 0}, 9, COUNTER, ICMPOUTREDIRECTS, RONLY, var_icmp },F {{MIB, 5, 21, 0}, 9, COUNTER, ICMPOUTECHOS, RONLY, var_icmp },I {{MIB, 5, 22, 0}, 9, COUNTER, ICMPOUTECHOREPS, RONLY, var_icmp },OK {{MIB, 5, 23, 0}, 9, COUNTER, ICMPOUTTIMESTAMPS, RONLY, var_icmp },*N {{MIB, 5, 24, 0}, 9, COUNTER, ICMPOUTTIMESTAMPREPS, RONLY, var_icmp },J {{MIB, 5, 25, 0}, 9, COUNTER, ICMPOUTADDRMASKS, RONLY, var_icmp },M {{MIB, 5, 26, 0}, 9, COUNTER, ICMPOUTADDRMASKREPS, RONLY, var_icmp },tG {{MIB, 6, 1, 0}, 9, INTEGER, TCPRTOALGORITHM, RONLY, var_tcp },.A {{MIB, 6, 2, 0}, 9, INTEGER, TCPRTOMIN, RONLY, var_tcp },/A {{MIB, 6, 3, 0}, 9, INTEGER, TCPRTOMAX, RONLY, var_tcp },B {{MIB, 6, 4, 0}, 9, INTEGER, TCPMAXCONN, RONLY, var_tcp },F {{MIB, 6, 5, 0}, 9, COUNTER, TCPACTIVEOPENS, RONLY, var_tcp },G {{MIB, 6, 6, 0}, 9, COUNTER, TCPPASSIVEOPENS, RONLY, var_tcp },iG {{MIB, 6, 7, 0}, 9, COUNTER, TCPATTEMPTFAILS, RONLY, var_tcp },pF {{MIB, 6, 8, 0}, 9, COUNTER, TCPESTABRESETS, RONLY, var_tcp },B {{MIB, 6, 9, 0}, 9, GAUGE, TCPCURRESH CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZTAB, RONLY, var_tcp },A {{MIB, 6,10, 0}, 9, COUNTER, TCPINSEGS, RONLY, var_tcp },iB {{MIB, 6,11, 0}, 9, COUNTER, TCPOUTSEGS, RONLY, var_tcp },F {{MIB, 6,12, 0}, 9, COUNTER, TCPRETRANSSEGS, RONLY, var_tcp }, {{MIB, 6,13, 1, 1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 20, INTEGER, TCPCONNSTATE, RONLY, var_tcp },i {{MIB, 6,13, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 20, IPADDRESS, TCPCONNLOCALADDRESS, RONLY, var_tcp }, {{MIB, 6,13, 1, 3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 20, INTEGER, TCPCONNLOCALPORT, RONLY, var_tcp },_ {{MIB, 6,13, 1, 4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 20, IPADDRESS, TCPCONNREMADDRESS, RONLY, var_tcp }, {{MIB, 6,13, 1, 5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 20, INTEGER, TCPCONNREMPORT, RONLY, var_tcp },F {{MIB, 7, 1, 0}, 9, COUNTER, UDPINDATAGRAMS, RONLY, var_udp },B {{MIB, 7, 2, 0}, 9, COUNTER, UDPNOPORTS, RONLY, var_udp },C {{MIB, 7, 3, 0}, 9, COUNTER, UDPINERRORS, RONLY, var_udp },rG {{MIB, 7, 4, 0}, 9, COUNTER, UDPOUTDATAGRAMS, RONLY, var_udp },hG {{1,3,6,1,4,1, 58, 2, 1}, 9, STRING, SERIAL, RONLY, var_MultiNet },hL {{1,3,6,1,4,1, 58, 2, 2}, 9, STRING, DISTRIBUTOR, RONLY, var_MultiNet },H {{1,3,6,1,4,1, 58, 2, 3}, 9, STRING, KITDATE, RONLY, var_MultiNet },K {{1,3,6,1,4,1, 58, 2, 4}, 9, STRING, KITVERSION, RONLY, var_MultiNet },iI {{1,3,6,1,4,1, 58, 2, 5}, 9, STRI CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZING, BASELEVEL, RONLY, var_MultiNet } };/*G * getStatPtr - return a pointer to the named variable, as well as it'sV) * type, length, and access control list.h *K * If an exact match for the variable name exists, it is returned. If not,iD * and exact is false, the next variable lexicographically after the * requested one is returned.U *= * If no appropriate variable can be found, NULL is returned.h */au_char *?getStatPtr(name, namelen, type, len, acl, exact, access_method)n> oid *name; /* IN - name of var, OUT - name matched */X int *namelen; /* IN -number of sub-ids in name, OUT - subid-is in matched name */: u_char *type; /* OUT - type of matched variable */9 int *len; /* OUT - length of matched variable */5 u_short *acl; /* OUT - access control list */_9 int exact; /* IN - TRUE if exact match wanted */t? int *access_method; /* OUT - 1 if function, 0 if char * */y{d! register struct variable *vp;, register int x;  register u_char *access; int result;1Y for(x = 0, vp = variables; x < sizeof(variables)/sizeof(struct variable); vp++, x++){P /* & * compare should be expanded inline. */> result = compare(name, *namelen, vp->name, (int)vp->namelen);/ if ((result < 0) || (exact && (result == 0))){ M access = (*(vp->findVar))(vp, name, namelen, exact, len, access_method); if (access != NULL) break; } }Y7 if (x == sizeof(variables)/sizeof(struct variable)) return NUJ CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z!nLL;F0 /* vp now points to the approprate struct */ *type = vp->type;P *acl = vp->acl;r return access;}1int !compare(name1, len1, name2, len2) $ register oid *name1, *name2; register int len1, len2;{R register int len;( /* len = minimum of len1 and len2 */ if (len1 < len2) len = len1; else len = len2;& /* find first non-matching byte */ while(len-- > 0){  if (*name1 < *name2)F return -1;F if (*name2++ < *name1++)y return 1; }14 /* bytes match up to length of shorter string */ if (len1 < len2)1 return -1; /* name1 shorter, so it is "less" */L if (len2 < len1) return 1;* return 0; /* both strings are equal */}Lu_char *;var_system(vp, name, length, exact, var_len, access_method) Y register struct variable *vp; /* IN - pointer to variable entry that points here */YR register oid *name; /* IN/OUT - input name requested, output name found */L register int *length; /* IN/OUT - length of input and output oid's */E int exact; /* IN - TRUE if an exact match was requested. */CO int *var_len; /* OUT - length of variable or 0 if function returned. */DG int *access_method; /* OUT - 1 if function, 0 if char pointer. */R{F static int uptime;: static char version_descr[] = "VAX/VMS MultiNet V2.2"; #ifdef vax11c_Q static oid version_id[] = {1, 3, 6, 1, 4, 1, 58, 1, 1, 1}; /* TGV MultiNet */, #else vax11cR: static oid version_iK CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z"d[] = {1, 3, 6, 1, 4, 1, 3, 1, 1}; #endif vax11c,K if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0)), return NULL;FJ bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizeof(oid)); *length = vp->namelen; *access_method = 0;N1 *var_len = sizeof(long); /* default length */N switch (vp->magic){T case VERSION_DESCR:& *var_len = strlen(version_descr);$ return (u_char *)version_descr; case VERSION_ID:,# *var_len = sizeof(version_id); ! return (u_char *)version_id;I case UPTIME:N #ifdef vax11c, uptime = VMS_GET_EXE$GL_ABSTIM() * 100; #else vax11cv BARFO(); /* XXX */, #endif vax11c, return (u_char *) &uptime;  case IFNUMBER: . long_return = Interface_Scan_Get_Count();$ return (u_char *) &long_return; default:D ERROR("");a } return NULL;}}u_char *<var_ifEntry(vp, name, length, exact, var_len, access_method)Y register struct variable *vp; /* IN - pointer to variable entry that points here */NR register oid *name; /* IN/OUT - input name requested, output name found */L register int *length; /* IN/OUT - length of input and output oid's */E int exact; /* IN - TRUE if an exact match was requested. */ O int *var_len; /* OUT - length of variable or 0 if function returned. */IG int *access_method; /* OUT - 1 if function, 0 if char pointer. */ { oid newname[MAX_NAME_LEN]; register int interface;4 int result, count;L CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zj% static struct ifnet ifnet;& static struct in_ifaddr in_ifaddr; static char Name[16];  register char *cp;M bcopy((char *)vp->name, (char *)newname, (int)vp->namelen * sizeof(oid));F /* find "next" interface */' count = Interface_Scan_Get_Count(); 8 for(interface = 1; interface <= count; interface++){ newname[10] = (oid)interface;< result = compare(name, *length, newname, (int)vp->namelen);: if ((exact && (result == 0)) || (!exact && (result < 0))) break;E }O if (interface > count) return NULL;{I bcopy((char *)newname, (char *)name, (int)vp->namelen * sizeof(oid));E *length = vp->namelen; *access_method = 0;  *var_len = sizeof(long);A Interface_Scan_By_Index(interface, Name, &ifnet, &in_ifaddr);4 switch (vp->magic){, case IFINDEX: long_return = interface;t$ return (u_char *) &long_return; case IFDESCR:#ifdef USE_NAME_AS_DESCRIPTION cp = Name;p#else USE_NAME_AS_DESCRIPTION7 cp = Lookup_Device_Annotation(Name, "snmp-descr");I if (!cp)_) cp = Lookup_Device_Annotation(Name, 0);x if (!cp) cp = Name;#endif USE_NAME_AS_DESCRIPTION *var_len = strlen(cp);  return (u_char *) cp; case IFTYPE:,6 cp = Lookup_Device_Annotation(Name, "snmp-type");$ if (cp) long_return = atoi(cp);& else long_return = 1; /* OTHER */$ return (u_char *) &long_return; case IFMTU: {' long_return = (long) ifnet.if_mtu;E$ return (u_char *) &long_return; } case IFSPM CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zb(EED:7 cp = Lookup_Device_Annotation(Name, "snmp-speed");5$ if (cp) long_return = atoi(cp);& else long_return = 1; /* OTHER */$ return (u_char *) &long_return; case IFPHYSADDRESS:= if (Lookup_Device_Annotation(Name, "ethernet-device")) {r6 Interface_Get_Ether_By_Index(interface, return_buf); *var_len = 6;r return(u_char *) return_buf; } else {I long_return = 0; return (u_char *) long_return; } case IFADMINSTATUS:8 long_return = ifnet.if_flags & IFF_RUNNING ? 1 : 2;$ return (u_char *) &long_return; case IFOPERSTATUS:,3 long_return = ifnet.if_flags & IFF_UP ? 1 : 2;$ return (u_char *) &long_return; case IFLASTCHANGE:L long_return = 0; /* XXX */ $ return (u_char *) &long_return; case IFINOCTETS:}D long_return = ifnet.if_ipackets * (ifnet.if_mtu / 2); /* XXX */$ return (u_char *) &long_return; case IFINUCASTPKTS:% long_return = ifnet.if_ipackets;5$ return (u_char *) &long_return; case IFINNUCASTPKTS:  long_return = 0; /* XXX */R$ return (u_char *) &long_return; case IFINDISCARDS:  long_return = 0; /* XXX */H$ return (u_char *) &long_return; case IFINERRORS:T) return (u_char *) &ifnet.if_ierrors;  case IFINUNKNOWNPROTOS: long_return = 0; /* XXX */,$ return (u_char *) &long_return; case IFOUTOCTETS:D long_return = ifnet.if_opackets * (ifnet.if_mtu / 2); /* XXX */$ return (u_char *) &long_return; case IFOUTUCASTPKTS: % long_return = ifnet.if_N CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZS+opackets;r$ return (u_char *) &long_return; case IFOUTNUCASTPKTS: long_return = 0; /* XXX */,$ return (u_char *) &long_return; case IFOUTDISCARDS:/ return (u_char *) &ifnet.if_snd.ifq_drops;P case IFOUTERRORS:) return (u_char *) &ifnet.if_oerrors;  case IFOUTQLEN:- return (u_char *) &ifnet.if_snd.ifq_len;6 default:, ERROR("");A }R return;a}cu_char *7var_ip(vp, name, length, exact, var_len, access_method)vY register struct variable *vp; /* IN - pointer to variable entry that points here */6M oid *name; /* IN/OUT - input name requested, output name found */ H int *length; /* IN/OUT - length of input and output oid's */G int exact; /* IN - TRUE if an exact match was requested. */NS int *var_len; /* OUT - length of variable or 0 if function returned. */EI int *access_method; /* OUT - 1 if function, 0 if char pointer. */R{T int i; static struct ipstat ipstat;K if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0)), return NULL;LJ bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizeof(oid)); *length = vp->namelen; *access_method = 0;S1 *var_len = sizeof(long); /* default length */, /*/ * Get the IP statistics from the kernel...2 */R! klseek(nl[N_IPSTAT].n_value); - klread((char *)&ipstat, sizeof (ipstat));F switch (vp->magic){0 case IPFORWARDING: ( klseek(nl[N_IPFORWARDING].n_value);$ O CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z. klread((char *) &i, sizeof(i)); if (i) {F& klseek(nl[N_IN_INTERFACES].n_value);! klread((char *) &i, sizeof(i));} if (i > 1)% long_return = 1; /* GATEWAY */F else8 long_return = 2; /* GATEWAY configured as HOST */ } else {c$ long_return = 2; /* HOST */ }$ return (u_char *) &long_return; case IPDEFAULTTTL:C /*O# * Allow for a kernel w/o TCP.  */! if (nl[N_TCP_TTL].n_value) { klseek(nl[N_TCP_TTL].n_value);5 klread((char *) &long_return, sizeof(long_return));,+ } else long_return = 60; /* XXX */,$ return (u_char *) &long_return; case IPINRECEIVES:T) return (u_char *) &ipstat.ips_total;, case IPINHDRERRORS:< long_return = ipstat.ips_badsum + ipstat.ips_tooshort +/ ipstat.ips_toosmall + ipstat.ips_badhlen +, ipstat.ips_badlen;2$ return (u_char *) &long_return; case IPINADDRERRORS:,/ return (u_char *) &ipstat.ips_cantforward;a case IPFORWDATAGRAMS:+ return (u_char *) &ipstat.ips_forward;O case IPINUNKNOWNPROTOS: long_return = 0;t$ return (u_char *) &long_return; case IPINDISCARDS:V long_return = 0;a$ return (u_char *) &long_return; case IPINDELIVERS:a% long_return = ipstat.ips_total -t. (ipstat.ips_badsum + ipstat.ips_tooshort +/ ipstat.ips_toosmall + ipstat.ips_badhlen +u ipstat.ips_badlen);$ return (u_char *) &long_return; case IPOUTREQUESTS: long_return = 0;n$ return (u_char *) &long_return; case IPOUTDP CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z21ISCARDS: long_return = 0; $ return (u_char *) &long_return; case IPOUTNOROUTES:/ return (u_char *) &ipstat.ips_cantforward;n case IPREASMTIMEOUT:e long_return = IPFRAGTTL;v$ return (u_char *) &long_return; case IPREASMREQDS:a- return (u_char *) &ipstat.ips_fragments;s case IPREASMOKS:- return (u_char *) &ipstat.ips_fragments;  case IPREASMFAILS:*C long_return = ipstat.ips_fragdropped + ipstat.ips_fragtimeout;i$ return (u_char *) &long_return; case IPFRAGOKS: long_return = 0;;$ return (u_char *) &long_return; case IPFRAGFAILS: long_return = 0;o$ return (u_char *) &long_return; case IPFRAGCREATES: long_return = 0;/$ return (u_char *) &long_return; default:t ERROR("");i }u return NULL;}(u_char *@var_ipAddrEntry(vp, name, length, exact, var_len, access_method)Z register struct variable *vp; /* IN - pointer to variable entry that points here */R register oid *name; /* IN/OUT - input name requested, output name found */L register int *length; /* IN/OUT - length of input and output oid's */E int exact; /* IN - TRUE if an exact match was requested. */oO int *var_len; /* OUT - length of variable or 0 if function returned. */ G int *access_method; /* OUT - 1 if function, 0 if char pointer. */l{= /*$ * object identifier is of form:B * 1.3.6.1.2.1.4.20.1.?.A.B.C.D, where A.B.C.D is IP address." * IPADDR starts at offset 10. */1Q CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZQ4 oid lowest[14];1 oid current[14];( int interface, lowinterface=0;( static struct ifnet ifnet, lowifnet;4 static struct in_ifaddr in_ifaddr, lowin_ifaddr;M /* fill in object part of name for current (less sizeof instance part) */lS bcopy((char *)vp->name, (char *)current, (int)(vp->namelen - 4) * sizeof(oid));n Interface_Scan_Init(); for (;;) {H if (Interface_Scan_Next(&interface, 0, &ifnet, &in_ifaddr) == 0) break;W current[10] = (((struct sockaddr_in *) &(in_ifaddr.ia_addr))->sin_addr.s_addr) & 0xff;n\ current[11] = (((struct sockaddr_in *) &(in_ifaddr.ia_addr))->sin_addr.s_addr >> 8) & 0xff;] current[12] = (((struct sockaddr_in *) &(in_ifaddr.ia_addr))->sin_addr.s_addr >> 16) & 0xff;u] current[13] = (((struct sockaddr_in *) &(in_ifaddr.ia_addr))->sin_addr.s_addr >> 24) & 0xff;V if (exact){3 if (compare(current, 14, name, *length) == 0){ ; bcopy((char *)current, (char *)lowest, 14 * sizeof(oid));v lowinterface = interface;n lowifnet = ifnet;4 lowin_ifaddr = in_ifaddr;,( break; /* no need to search further */ } } else {p5 if ((compare(current, 14, name, *length) > 0) &&p> (!lowinterface || (compare(current, 14, lowest, 14) < 0))){ /*> * if new one is greater than input and closer to input than6 * previous lowest, save this one as the "next" one. */S lowinterface = interface;t lowifnet = ifnet; lowin_ifaddr = in_ifaddr;_; bcopy((char *)current, (char *)lowest, 14 * sizeof(oid));)R CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z 7 } } }c$ if (!lowinterface) return(NULL);: bcopy((char *)lowest, (char *)name, 14 * sizeof(oid)); *length = 14;  *access_method = 0;# *var_len = sizeof(long_return);) switch(vp->magic){ case IPADADDR:eW return(u_char *) &((struct sockaddr_in *) &lowin_ifaddr.ia_addr)->sin_addr.s_addr;  case IPADIFINDEX: long_return = lowinterface;# return(u_char *) &long_return;c case IPADNETMASK:5 long_return = ntohl(lowin_ifaddr.ia_subnetmask);n# return(u_char *) &long_return;e case IPADBCASTADDR:^ long_return = ntohl(((struct sockaddr_in *) &lowin_ifaddr.ia_addr)->sin_addr.s_addr) & 1;# return(u_char *) &long_return;u default: ERROR("");  }N return NULL;}au_char *9var_icmp(vp, name, length, exact, var_len, access_method) Z register struct variable *vp; /* IN - pointer to variable entry that points here */M oid *name; /* IN/OUT - input name requested, output name found */4H int *length; /* IN/OUT - length of input and output oid's */G int exact; /* IN - TRUE if an exact match was requested. */;S int *var_len; /* OUT - length of variable or 0 if function returned. */ I int *access_method; /* OUT - 1 if function, 0 if char pointer. */ {o register int i;r$ static struct icmpstat icmpstat;K if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0))l return NULL;cJ bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizS CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z":eof(oid)); *length = vp->namelen; *access_method = 0;cJ *var_len = sizeof(long); /* all following variables are sizeof long */ /*0 * Get the UDP statistics from the kernel... */;# klseek(nl[N_ICMPSTAT].n_value);c1 klread((char *)&icmpstat, sizeof (icmpstat));i switch (vp->magic){l case ICMPINMSGS:aC long_return = icmpstat.icps_badcode + icmpstat.icps_tooshort +E3 icmpstat.icps_checksum + icmpstat.icps_badlen;M& for (i=0; i <= ICMP_MAXTYPE; i++)) long_return += icmpstat.icps_inhist[i]; # return (u_char *)&long_return;o case ICMPINERRORS: C long_return = icmpstat.icps_badcode + icmpstat.icps_tooshort +l3 icmpstat.icps_checksum + icmpstat.icps_badlen;# return (u_char *)&long_return;m case ICMPINDESTUNREACHS:c; return (u_char *) &icmpstat.icps_inhist[ICMP_UNREACH];E case ICMPINTIMEEXCDS:< return (u_char *) &icmpstat.icps_inhist[ICMP_TIMXCEED]; case ICMPINPARMPROBS:= return (u_char *) &icmpstat.icps_inhist[ICMP_PARAMPROB];k case ICMPINSRCQUENCHS:,@ return (u_char *) &icmpstat.icps_inhist[ICMP_SOURCEQUENCH]; case ICMPINREDIRECTS:< return (u_char *) &icmpstat.icps_inhist[ICMP_REDIRECT]; case ICMPINECHOS:8 return (u_char *) &icmpstat.icps_inhist[ICMP_ECHO]; case ICMPINECHOREPS:t= return (u_char *) &icmpstat.icps_inhist[ICMP_ECHOREPLY];r case ICMPINTIMESTAMPS: : return (u_char *) &icmpstat.icps_inhist[ICMP_TSTAMP]; case ICMPINTIMESTAMPREPS:? return (u_char *) &icmpstatT CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Z@.=.icps_inhist[ICMP_TSTAMPREPLY];u case ICMPINADDRMASKS:; return (u_char *) &icmpstat.icps_inhist[ICMP_MASKREQ];_ case ICMPINADDRMASKREPS:u= return (u_char *) &icmpstat.icps_inhist[ICMP_MASKREPLY];= case ICMPOUTMSGS:B long_return = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;& for (i=0; i <= ICMP_MAXTYPE; i++)* long_return += icmpstat.icps_outhist[i];# return (u_char *)&long_return;l case ICMPOUTERRORS:B long_return = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;# return (u_char *)&long_return;R case ICMPOUTDESTUNREACHS:< return (u_char *) &icmpstat.icps_outhist[ICMP_UNREACH]; case ICMPOUTTIMEEXCDS: = return (u_char *) &icmpstat.icps_outhist[ICMP_TIMXCEED];f case ICMPOUTPARMPROBS:F> return (u_char *) &icmpstat.icps_outhist[ICMP_PARAMPROB]; case ICMPOUTSRCQUENCHS:A return (u_char *) &icmpstat.icps_outhist[ICMP_SOURCEQUENCH];f case ICMPOUTREDIRECTS: = return (u_char *) &icmpstat.icps_outhist[ICMP_REDIRECT];l case ICMPOUTECHOS:_9 return (u_char *) &icmpstat.icps_outhist[ICMP_ECHO];U case ICMPOUTECHOREPS:> return (u_char *) &icmpstat.icps_outhist[ICMP_ECHOREPLY]; case ICMPOUTTIMESTAMPS:; return (u_char *) &icmpstat.icps_outhist[ICMP_TSTAMP];: case ICMPOUTTIMESTAMPREPS:e@ return (u_char *) &icmpstat.icps_outhist[ICMP_TSTAMPREPLY]; case ICMPOUTADDRMASKS:,< return (u_char *) &icmpstat.icps_outhist[ICMP_MASKREQ]; case ICMPOUTADDRMASKREPS:> return (u_char *) &icmpstat.icps_outhist[ICMP_MASKREPLY];U CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zݷ@ default:e ERROR("");r }p return NULL;}iu_char *8var_udp(vp, name, length, exact, var_len, access_method)Z register struct variable *vp; /* IN - pointer to variable entry that points here */M oid *name; /* IN/OUT - input name requested, output name found */ H int *length; /* IN/OUT - length of input and output oid's */G int exact; /* IN - TRUE if an exact match was requested. */ S int *var_len; /* OUT - length of variable or 0 if function returned. */vI int *access_method; /* OUT - 1 if function, 0 if char pointer. */a{ int i;" static struct udpstat udpstat;K if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0))o return NULL; J bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizeof(oid)); *length = vp->namelen; *access_method = 0;h1 *var_len = sizeof(long); /* default length */> /*/ * Get the IP statistics from the kernel...D */l" klseek(nl[N_UDPSTAT].n_value);/ klread((char *)&udpstat, sizeof (udpstat));] switch (vp->magic){* case UDPINDATAGRAMS:f case UDPNOPORTS:g case UDPOUTDATAGRAMS: long_return = 0;g$ return (u_char *) &long_return; case UDPINERRORS:> long_return = udpstat.udps_hdrops + udpstat.udps_badsum + udpstat.udps_badlen;c$ return (u_char *) &long_return; default:  ERROR(""); }/ return NULL;}Tu_char *8var_tcp(vp, name, length, exact, var_len, access_metV CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228Zy]Chod)Z register struct variable *vp; /* IN - pointer to variable entry that points here */M oid *name; /* IN/OUT - input name requested, output name found */tH int *length; /* IN/OUT - length of input and output oid's */G int exact; /* IN - TRUE if an exact match was requested. */S int *var_len; /* OUT - length of variable or 0 if function returned. */,I int *access_method; /* OUT - 1 if function, 0 if char pointer. */{ int i;" static struct tcpstat tcpstat;4 oid newname[MAX_NAME_LEN], lowest[MAX_NAME_LEN]; int result;g int State, LowState;( static struct inpcb inpcb, Lowinpcb; /*! * Allow for a kernel w/o TCPa */n1 if (nl[N_TCPSTAT].n_value == 0) return(NULL);m# if (vp->magic < TCPCONNSTATE) {pH if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0)) return NULL;tG bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizeof(oid));) *length = vp->namelen;D *access_method = 0;1 *var_len = sizeof(long); /* default length */c /*P. * Get the TCP statistics from the kernel... */ klseek(nl[N_TCPSTAT].n_value); , klread((char *)&tcpstat, sizeof (tcpstat)); switch (vp->magic){ case TCPRTOALGORITHM:1 long_return = 4; /* Van Jacobsen's algorithm */S! return (u_char *) &long_return;t case TCPRTOMIN:- long_return = TCPTV_MIN / PR_SLOWHZ * 1000;p! return (u_char *) &long_return;o case TCPRTOMAX:2 long_return = TCPTV_REXMW CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZFTMAX / PR_SLOWHZ * 1000;! return (u_char *) &long_return;& case TCPMAXCONN:R long_return = -1;e! return (u_char *) &long_return;& case TCPACTIVEOPENS:R. return (u_char *) &tcpstat.tcps_connattempt; case TCPPASSIVEOPENS:* return (u_char *) &tcpstat.tcps_accepts; case TCPATTEMPTFAILS:, return (u_char *) &tcpstat.tcps_conndrops; case TCPESTABRESETS:s( return (u_char *) &tcpstat.tcps_drops; case TCPCURRESTAB:s( long_return = TCP_Count_Connections();! return (u_char *) &long_return;t case TCPINSEGS:+ return (u_char *) &tcpstat.tcps_rcvtotal;i case TCPOUTSEGS:/+ return (u_char *) &tcpstat.tcps_sndtotal;c case TCPRETRANSSEGS:0 return (u_char *) &tcpstat.tcps_sndrexmitpack; default:n ERROR(""); }5 } else { /* Info about a particular connection */aJ bcopy((char *)vp->name, (char *)newname, (int)vp->namelen * sizeof(oid)); /* find "next" connection */rAgain:+LowState = -1; /* Don't have one yet */s TCP_Scan_Init(); for (;;) {o= if ((i = TCP_Scan_Next(&State, &inpcb)) < 0) goto Again;,& if (i == 0) break; /* Done */3 newname[10] = (inpcb.inp_laddr.s_addr) & 0xff;a8 newname[11] = (inpcb.inp_laddr.s_addr >> 8) & 0xff;9 newname[12] = (inpcb.inp_laddr.s_addr >> 16) & 0xff;a9 newname[13] = (inpcb.inp_laddr.s_addr >> 24) & 0xff;e* newname[14] = ntohs(inpcb.inp_lport);3 newname[15] = (inpcb.inp_faddr.s_addr) & 0xff; 8 newname[16] = (inpcb.inp_faddr.s_addr >> 8) & 0xff;9 X CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ZDI newname[17] = (inpcb.inp_faddr.s_addr >> 16) & 0xff; 9 newname[18] = (inpcb.inp_faddr.s_addr >> 24) & 0xff;.* newname[19] = ntohs(inpcb.inp_fport); if (exact){0 if (compare(newname, 20, name, *length) == 0){? bcopy((char *)newname, (char *)lowest, 20 * sizeof(oid));( LowState = State;a Lowinpcb = inpcb;V- break; /* no need to search further */  } } else { 2 if ((compare(newname, 20, name, *length) > 0) &&C ((LowState < 0) || (compare(newname, 20, lowest, 20) < 0))){i /*B * if new one is greater than input and closer to input than: * previous lowest, save this one as the "next" one. */w? bcopy((char *)newname, (char *)lowest, 20 * sizeof(oid));* LowState = State;a Lowinpcb = inpcb;u }n } } if (LowState < 0) return(NULL);E bcopy((char *)lowest, (char *)name, (int)vp->namelen * sizeof(oid)); *length = vp->namelen;r *access_method = 0; *var_len = sizeof(long);  switch (vp->magic) { case TCPCONNSTATE: {e< static int StateMap[]={1, 2, 3, 4, 5, 8, 6, 10, 9, 7, 11};( return (u_char *) &StateMap[LowState]; } case TCPCONNLOCALADDRESS:/ return (u_char *) &Lowinpcb.inp_laddr.s_addr;s case TCPCONNLOCALPORT:h* long_return = ntohs(Lowinpcb.inp_lport);! return (u_char *) &long_return;  case TCPCONNREMADDRESS:/ return (u_char *) &Lowinpcb.inp_faddr.s_addr;u case TCPCONNREMPORT: * long_return = ntohs(Lowinpcb.inp_fport);! return (u_char *Y CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ION.C;13ZoL) &long_return;n } } return NULL;}/* * Print INTERNET connectionsk */i"static int TCP_Count_Connections(){d int Established;r struct inpcb cb;e$ register struct inpcb *prev, *next; struct inpcb inpcb; struct tcpcb tcpcb; Again: /*n& * Prepare to scan the control blocks */ Established = 0;  klseek(nl[N_TCB].n_value);t# klread(&cb, sizeof(struct inpcb)); inpcb = cb;+ prev = (struct inpcb *) nl[N_TCB].n_value;, /*u * Scan the control blocks  */? while (inpcb.inp_next != (struct inpcb *) nl[N_TCB].n_value) {  next = inpcb.inp_next; klseek((caddr_t)next);! klread(&inpcb, sizeof (inpcb)); - if (inpcb.inp_prev != prev) { /* ??? */r sleep(1); goto Again; }e9 if (inet_lnaof(inpcb.inp_laddr.s_addr) == INADDR_ANY) {  prev = next;r continue; } " klseek((caddr_t)inpcb.inp_ppcb);! klread(&tcpcb, sizeof (tcpcb));,, if ((tcpcb.t_state == TCPS_ESTABLISHED) ||) (tcpcb.t_state == TCPS_CLOSE_WAIT))t Established++; prev = next; } return(Established);c}_!static struct inpcb inpcb, *prev;gstatic TCP_Scan_Init(){  klseek(nl[N_TCB].n_value); klread(&inpcb, sizeof(inpcb));m+ prev = (struct inpcb *) nl[N_TCB].n_value;C}T)static int TCP_Scan_Next(State, RetInPcb) int *State;tstruct inpcb *RetInPcb;>{i register struct inpcb *next;l struct tcpcb tcpcb;< if (inpcb.inp_next == (struct inpcb *) nl[N_TCB].n_value) { return(0); /* "EOF" */  } next = inpcb.inp_next; Z CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ION.C;13ZO klseek((caddr_t)next);m klread(&inpcb, sizeof (inpcb));) if (inpcb.inp_prev != prev) /* ??? */O return(-1); /* "FAILURE" */a! klseek((caddr_t)inpcb.inp_ppcb);h klread(&tcpcb, sizeof (tcpcb)); *State = tcpcb.t_state; *RetInPcb = inpcb; prev = next;m return(1); /* "OK" */}c:static struct ifnet *ifnetaddr, saveifnet, *saveifnetaddr;&static struct in_ifaddr savein_ifaddr;static int saveIndex=0;istatic char saveName[16];C#static struct ifnet *saveifnetaddr;)Interface_Scan_Init()M{A klseek(nl[N_IFNET].n_value);C& klread(&ifnetaddr, sizeof ifnetaddr); saveIndex=0;_}R<int Interface_Scan_Next(Index, Name, Retifnet, Retin_ifaddr) int *Index;i char *Name;Estruct ifnet *Retifnet;struct in_ifaddr *Retin_ifaddr;i{_ struct ifnet ifnet;! struct in_ifaddr *ia, in_ifaddr;u register char *cp;p extern char *index(); while (ifnetaddr) { /* A * Get the "ifnet" structure and extract the device nameN */ klseek(ifnetaddr); " klread(&ifnet, sizeof ifnet);$ klseek((caddr_t)ifnet.if_name); klread(saveName, 16); saveName[15] = '\0';_ cp = index(saveName, '\0');! *cp++ = ifnet.if_unit + '0';n *cp = '\0';' if (strcmp(saveName,"lo0") != 0) {n /*/ * Try to find an address for this interface  */=" klseek(nl[N_IN_IFADDR].n_value);# klread((char *) &ia, sizeof(ia));  while (ia) { klseek(ia);5 klread((char *) &in_ifaddr, sizeof(in_ifaddr));o/ if (in_ifaddr.ia_ifp == if[ CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ION.C;13ZVeRnetaddr) break;c ia = in_ifaddr.ia_next;P }S if (Index) *Index = ++saveIndex;i if (Retifnet)U *Retifnet = ifnet; if (Retin_ifaddr) *Retin_ifaddr = in_ifaddr; if (Name)] strcpy(Name, saveName);  saveifnet = ifnet; saveifnetaddr = ifnetaddr; savein_ifaddr = in_ifaddr; saveifnetaddr = ifnetaddr; ifnetaddr = ifnet.if_next; return(1); /* DONE */U } ifnetaddr = ifnet.if_next;p } return(0); /* EOF */]}Gstatic int Interface_Scan_By_Index(Index, Name, Retifnet, Retin_ifaddr)H int Index; char *Name;Pstruct ifnet *Retifnet;)struct in_ifaddr *Retin_ifaddr;R{Y int i; . if (saveIndex != Index) { /* Optimization! */ Interface_Scan_Init();:D while (Interface_Scan_Next(&i, Name, Retifnet, Retin_ifaddr)) { if (i == Index) break; }? if (i != Index) return(-1); /* Error, doesn't exist */[ } else {Q /* + * Get the "ifnet" structure again& */ klseek(saveifnetaddr);* klread(&saveifnet, sizeof saveifnet); if (Retifnet) *Retifnet = saveifnet; if (Retin_ifaddr) *Retin_ifaddr = savein_ifaddr; if (Name) strcpy(Name, saveName);i } return(0); /* DONE */}static int Interface_Count=0;-%static int Interface_Scan_Get_Count()*{ if (!Interface_Count) { Interface_Scan_Init();dD while (Interface_Scan_Next(0, 0, 0, 0) != 0) Interface_Count++; } return(Interface_Count); }v9static int Interface_Get_Ether_By_Index(\ CMUSNMP.SAV4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228ION.OBJ;1Z0UIndex, EtherAddr)r int Index;char *EtherAddr;{h int i;T struct arpcom arpcom;. if (saveIndex != Index) { /* Optimization! */ Interface_Scan_Init();(/ while (Interface_Scan_Next(&i, 0, 0, 0)) {p if (i == Index) break; }? if (i != Index) return(-1); /* Error, doesn't exist */z } /*> * the arpcom structure is an extended ifnet structure which# * contains the ethernet address.h */ klseek(saveifnetaddr); klread(&arpcom, sizeof arpcom);> bcopy(arpcom.ac_enaddr, EtherAddr, sizeof(arpcom.ac_enaddr)); return(0); /* DONE */}) switch (vp->magic){* case UDPINDATAGRAMS:f case UDPNOPORTS:g case UDPOUTDATAGRAMS: long_return = 0;g$ return (u_char *) &long_return; case UDPINERRORS:> long_return = udpstat.udps_hdrops + udpstat.udps_badsum + udpstat.udps_badlen;c$ return (u_char *) &long_return; default:  ERROR(""); }/ return NULL;}Tu_char *8var_tcp(vp, name, length, exact, var_len, access_met2*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.H;9+,./ 4H <-0@123KPWO56sc7`ho8$ 9FRQٓGHJ] CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.H;9ATION.OBJ;1H?F/*9 * Definitions for SNMP (RFC 1067) agent variable finder. * * */</***********************************************************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 TORTIOUS ACTION,CARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.C******************************************************************/u_char *var_system();u_char *var_ifEntry();u_char *var_atEntry();u_char *var_ip();u_char *var_ipAddrEntry();u_char *var_ipRouteEntry();u_char *var_icmp();u_char *var_tcp();u_char *var_udp(); #ifdef vax11cu_char *var_MultiNet(); #endif vax11cu_char *getStatPtr();/*0 * These are byte offsets into their^ CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.H;9ATION.OBJ;1H structures.: * This really should be computed by the compiler, but the. * compiler I'm using doesn't want to do this. */#define VERSION_DESCR 0#define VERSION_ID 1#define IFNUMBER 2#define UPTIME 3#define IFINDEX 1#define IFDESCR 2#define IFTYPE 3#define IFMTU 4#define IFSPEED 5#define IFPHYSADDRESS 6#define IFADMINSTATUS 7#define IFOPERSTATUS 8#define IFLASTCHANGE 9#define IFINOCTETS 10#define IFINUCASTPKTS 11#define IFINNUCASTPKTS 12#define IFINDISCARDS 13#define IFINERRORS 14#define IFINUNKNOWNPROTOS 15#define IFOUTOCTETS 16#define IFOUTUCASTPKTS 17#define IFOUTNUCASTPKTS 18#define IFOUTDISCARDS 19#define IFOUTERRORS 20#define IFOUTQLEN 21#define ATIFINDEX 0#define ATPHYSADDRESS 1#define ATNETADDRESS 2#define IPFORWARDING 0#define IPDEFAULTTTL 1#define IPINRECEIVES 2#define IPINHDRERRORS 3#define IPINADDRERRORS 4#define IPFORWDATAGRAMS 5#define IPINUNKNOWNPROTOS 6#define IPINDISCARDS 7#define IPINDELIVERS 8#define IPOUTREQUESTS 9#define IPOUTDISCARDS 10#define IPOUTNOROUTES 11#define IPREASMTIMEOUT 12#define IPREASMREQDS 13#define IPREASMOKS 14#define IPREASMFAILS 15#define IPFRAGOKS 16#define IPFRAGFAILS 17#define IPFRAGCREATES 18#define IPADADDR 1#define IPADIFINDEX 2#define IPADNETMASK 3#define IPADBCASTADDR 4#define IPROUTEDEST 0#define IPROUTEIFINDEX 1#define IPROUTEMETRIC1 2#define IPROUTEMETRIC2 3#define IPROUTEMETRIC3 4#define IPROUTEMETRIC4_ CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.H;9ATION.OBJ;1H5 5#define IPROUTENEXTHOP 6#define IPROUTETYPE 7#define IPROUTEPROTO 8#define IPROUTEAGE 9#define ICMPINMSGS 0#define ICMPINERRORS 1#define ICMPINDESTUNREACHS 2#define ICMPINTIMEEXCDS 3#define ICMPINPARMPROBS 4#define ICMPINSRCQUENCHS 5#define ICMPINREDIRECTS 6#define ICMPINECHOS 7#define ICMPINECHOREPS 8#define ICMPINTIMESTAMPS 9#define ICMPINTIMESTAMPREPS 10#define ICMPINADDRMASKS 11#define ICMPINADDRMASKREPS 12#define ICMPOUTMSGS 13#define ICMPOUTERRORS 14#define ICMPOUTDESTUNREACHS 15#define ICMPOUTTIMEEXCDS 16#define ICMPOUTPARMPROBS 17#define ICMPOUTSRCQUENCHS 18#define ICMPOUTREDIRECTS 19#define ICMPOUTECHOS 20#define ICMPOUTECHOREPS 21#define ICMPOUTTIMESTAMPS 22#define ICMPOUTTIMESTAMPREPS 23#define ICMPOUTADDRMASKS 24#define ICMPOUTADDRMASKREPS 25#define TCPRTOALGORITHM 1#define TCPRTOMIN 2#define TCPRTOMAX 3#define TCPMAXCONN 4#define TCPACTIVEOPENS 5#define TCPPASSIVEOPENS 6#define TCPATTEMPTFAILS 7#define TCPESTABRESETS 8#define TCPCURRESTAB 9#define TCPINSEGS 10#define TCPOUTSEGS 11#define TCPRETRANSSEGS 12#define TCPCONNSTATE 13#define TCPCONNLOCALADDRESS 14#define TCPCONNLOCALPORT 15#define TCPCONNREMADDRESS 16#define TCPCONNREMPORT 17#define UDPINDATAGRAMS 0#define UDPNOPORTS 1#define UDPINERRORS 2#define UDPOUTDA` CMUSNMP.SAV2[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.H;9ATION.OBJ;1H`_ TAGRAMS 3#define SERIAL 1#define DISTRIBUTOR 2#define KITDATE 3#define KITVERSION 4#define BASELEVEL 5struct variable {> oid name[26]; /* object identifier of variable */1 u_char namelen; /* length of above */H char type; /* type of variable, INTEGER or (octet) STRING */< u_char magic; /* passed to function as a hint */? u_short acl; /* access control list for variable */A u_char *(*findVar)(); /* function that finds variable */};4*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1+,K ._/ 4_[-0D123KPWO`56ē7fҸē8k9f 9FRQٓGHJa CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1ION.OBJ;1_s6 SNMP_VARSV1.0 6-SEP-1990 11:49GNU CC V1.22$CODE$UNINITIALIZED_DATASID z INIT_SNMPMULTINET_KERNEL_NLIST VARIABLES P< VAR_SYSTEM "VAR_IFENTRY_010000XVAR_ATENTRY_010000X ^<VAR_IP VAR_IPADDRENTRY_011000XVAR_IPROUTEENTRY_012000X VAR_ICMP < VAR_TCP VAR_UDPVAR_MULTINET_480000X GETSTATPTR_440000XV COMPAREBCOPYSTRLENVMS_GET_EXE$GL_ABSTIM LONG_RETURNLOOKUP_DEVICE_ANNOTATIO_001804XATOI@ RETURN_BUFKLSEEKKLREAD \INTERFACE_SCAN_INIT_801040X INTERFACE_SCAN_NEXT_801040XNTOHLNTOHSSLEEP INET_LNAOFINDEXSTRCMPSTRCPY$DATAP_ipstat_ipforwarding_tcp_ttl_udpstat_in_interfaces_icmpstat_ifnet_tcpstat_tcb_in_ifaddraPMULTINET_NETWORK_IMAGE:zPPPPPЬWЬVЬYЬUЬXSR4~RfWIPPPUPPPXYUVWR9PTP=RSSqPSqPP5 7TPPЬRЬTЬ PЬSTSPTQ PSQ %Pb`*P/PQQ:PTS?PPSTHPPPOPPP<ЬRЬTЬ UЬSլgP4~ReTuPPyPP4PxP~TRP䚢4eԼc6PPPPPcPcPb CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_O PPdPτPPPPPsnmp-typesnmp-speedethernet-device"P^ЬTЬVЬ WЬUЬX4PxP~TPPUPPSRRS(`PR4~gVϐtPUxPP |PUPPPSRPRSPP4PxP~VPݚ4gԼhR P˚6PP1`PRP PPRRPPhRP&P3PPR 8PRAP1DPKPMP2XPZPϩ^PkPPR pPRyP^{PP1~PωPPPPPR PhPPPP@ PPPPPPPP1 P<QP!P<P1P@PDQPPPP2PPxPP2PPPa*P1-PD8P1;PAP1DP$PHPP^P<^ЬRЬSЬ TլtP4~RdSρPPPP4PxP~SRP蚢4dԼP0PК6PPPUePTdSSPRbխPݥ$dSbѭ 1P8PS:PAPJCP P`zNP`WPc CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_Ғ_PfP%hP۞PQaPP PPPPP$PQP PPPPaPP(P<PPPP`PPPPP<^ЬYЬ ZWЬ[4PPxP~[P9#P➭VX~EAPP1HPÛ[[PP[[PP[[PPլ@PjYVrPPPXVPЭW(T(D]PjYV3PRbP1OPWPXVbP19PЭW(T(DXVP1 "PW&PPY7PjԼЬ[6PPWPPWfPlPP4{PPPPPPˏPPPPPЬRЬSЬ TլP4~RdS6PPPP4PxP~SRP蚢4dԼDP~Pš6PPOPXQaPPP hPPlQ@ayPP}PPPXQaPPP PPPxPPP|PPPlPPPPPP` PP Q@a PP# P) PPP`; PA PPP8P<PP P,Pd CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_ P@PDPPPTP PЬRЬSЬ Tլ P4~RdSF PP PP4PxP~SR P蚢4dԼ, P  P6PP P P PPQaPP4 P: PP< P< P^ЬZ\1R P6 1[ Pլ` P4~Zݼ ݬϓq PP1x P욪4PxP~ݬZ P皪4 Լ\ P~ Pꚪ6PP  P1= P P PP< P PP< P PP P PPPP$P P> P1A PԞxPPP\P4PxP~Zm PWGu PXYVS PP P1 PΛhh[[PPh[[PPh[[PP<~ PRbPii[[PPi[[PPi[[PP<~bPլ8 Pݼ ݬV PP1]' P(V6 PW(<TI Pݼ ݬVϭW PRbP1"b PWf PVbP1 z P(V PW(<1 PWu Pꚪ4PxP~ݬ P4 Լ6PP ? PGPP<~ P P<~ PP P PPP P^WhVf3 P<? P(<ĭfRdJ PЭSSW P<c PѭRe CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_ i Pr Pt Pݭ~ PP) Pݭ Pj~ P& P& PWSRѭh PWP PhRb P< P Pb P P|^ Ph PPPRbVVPPKLREAD0PKLSEEK)PPPKLREAD PKLSEEK P P P PKLREAD P PKLSEEK PKLREAD PKLSEEKy P INET_LNAOFm PSLEEP^ PKLREADR PKLSEEK: PKLREAD. PKLSEEK P P PNTOHS PBCOPY PBCOPY1 PBCOPY PNTOHSh PBCOPY P P P P P P P P PKLREAD PKLSEEK PBCOPY5 P/ P P P PKLREAD PKLSEEK PBCOPY< P6 P$ P P PPP~PtPcP PKLREADPKLSEEKPBCOPYPPPNTOHLP}PvPNTOHLgPaP2PBCOPYPBCOPYPBCOPYPBCOPYPPPPPPaPKLREADZPRPKLSEEK<P3PPKLREADPKLSEEKPh CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_KLREADPKLSEEKPBCOPY<P3P%PPPPPPPLOOKUP_DEVICE_ANNOTATIO_001804X}PtPATOIfPLOOKUP_DEVICE_ANNOTATIO_001804XSPFP<PATOI.PLOOKUP_DEVICE_ANNOTATIO_001804XPSTRLENPPPBCOPYKPBCOPYPPPVMS_GET_EXE$GL_ABSTIMPSTRLENPBCOPYPMULTINET_KERNEL_NLISTPPPuPP_PYPPt{P_PP Ph Ph Ph$ Ph P P P P P P PB P= P P Pv PR P,J P B PH2 P* P" P P P P\H P\ P P P, P` P\ PP| PLt Pl P8d P,\ P(T PHL PDD P$, P PPPPPPPxPPPPPPPdkPxPPdP PDPoi CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_ mPXP PPP0PPPP0PqPaPQPIP2P,PPPPPPqPiPDP PPPUP MPLEP(.PHPHPDP@P@P P P_PNP 'P PPPPXPPPPPP}PPPP  P:PVAX/VMS MultiNet V2.2P   C      B j CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_    C  A  A  A  A  A A A A A A A B@   A A A A Ak CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_5 A A  A  A  A    A  A A A A A@@@@  l CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_"  A A A A A A A A  A A  A  A  A  A  A A A A A A A A A Am CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_~% A A     A A A A B  A  A  A    @  @  A A A A: : n CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_a(: : : PPVAR_MULTINET_480000XPVAR_MULTINET_480000XoPVAR_MULTINET_480000X2PVAR_MULTINET_480000XPVAR_MULTINET_480000XPVAR_UDP{PVAR_UDP>PVAR_UDPPVAR_UDPPVAR_TCPPVAR_TCPJPVAR_TCP PVAR_TCPPVAR_TCPPVAR_TCPVPVAR_TCPPVAR_TCPPVAR_TCPPVAR_TCPbPVAR_TCP%PVAR_TCPPVAR_TCPPVAR_TCPnPVAR_TCP1PVAR_TCPPVAR_TCPPVAR_ICMPzPVAR_ICMP=PVAR_ICMPPVAR_ICMPPVAR_ICMPPVAR_ICMPIPVAR_ICMP PVAR_ICMPPVAR_ICMPPVAR_ICMPUPVAR_ICMPPVAR_ICMPPVAR_ICMPPVAR_ICMPaPVAR_ICMP$PVAR_ICMPPVAR_ICMPPVAR_ICMPmPVAR_ICMP0PVAR_ICMPPVAR_ICMPPVAR_ICMPyPVAR_ICMP<PVAR_ICMPPVAR_ICMPPVAR_ICMPPVAR_IPROUTEENTRY_012000XHPVAR_IPROUTEENTRY_012000X PVAR_IPROUTEENTRY_012000X PVAR_IPROUTEENTRY_012000X PVAR_IPROUTEENTRY_012000XT PVAR_IPROUTEENTRY_012000X PVAo CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_G+R_IPROUTEENTRY_012000X PVAR_IPROUTEENTRY_012000X PVAR_IPROUTEENTRY_012000X` PVAR_IPROUTEENTRY_012000X# PVAR_IPADDRENTRY_011000X PVAR_IPADDRENTRY_011000X PVAR_IPADDRENTRY_011000Xl PVAR_IPADDRENTRY_011000X/ PVAR_IP PVAR_IP PVAR_IPx PVAR_IP; PVAR_IP PVAR_IP PVAR_IP PVAR_IPG PVAR_IP PVAR_IPPVAR_IPPVAR_IPSPVAR_IPPVAR_IPPVAR_IPPVAR_IP_PVAR_IP"PVAR_IPPVAR_IPPVAR_ATENTRY_010000XkPVAR_ATENTRY_010000X.PVAR_ATENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XwPVAR_IFENTRY_010000X:PVAR_IFENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XFPVAR_IFENTRY_010000X PVAR_IFENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XRPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000XPVAR_IFENTRY_010000X^PVAR_IFENTRY_010000X!PVAR_IFENTRY_010000XPJVAR_IFENTRY_010000XPVAR_IFENTRY_010000XjPVAR_IFENTRY_010000X-PVAR_IFENTRY_010000XP VAR_SYSTEMP VAR_SYSTEMvP VAR_SYSTEM9P VAR_SYSTEMlPV`PQTPHHPA<P70P($PP PP SNMP_VARSRSinpcbp CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1FILE.;2_.inp_next T inp_prev T@inp_head T` inp_faddr R inp_fport inp_dummy1 inp_laddr R inp_lport inp_dummy2 inp_socket Rinp_ppcb   inp_route R inp_options RRSrtstatPrts_badredirect rts_dynamic rts_newgateway0 rts_unreach@ rts_wildcardRSrtentryrt_hash rt_dst  R rt_gateway  R rt_flags0 rt_refcnt @rt_use `rt_ifp  R RS T Sroute ro_rt T ro_dst  RRSarpreq  arp_pa R arp_ha R arp_flagsRSarphdr@ ar_hrd ar_pro  ar_hln (ar_pln 0ar_opRSifc_ifcu ifcu_buf ifcu_req RRSifconf@ifc_len ifc_ifcu TRSifr_ifru ifru_addr R ifru_dstaddr Rifru_broadaddr R ifru_flags ifru_metricifru_mtu ifru_asyncmap ifru_data RSTSifreqifr_name*&q CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_&1ifr_ifru TRSifqueueifq_head R ifq_tail R@ifq_len` ifq_maxlen ifq_dropsRSifa_ifu ifu_broadaddr R ifu_dstaddr R R Sifaddr@ifa_addr !Rifa_ifu Tifa_ifp "R ifa_next  T#R"S#T S#T#Sifnetif_name  if_unit 0if_mtu@if_flagsPif_timer` if_metric if_addrlist  T if_snd T@if_init ` if_output if_ioctl if_reset  if_watchdog  if_ipackets if_ierrors  if_opackets@ if_oerrors` if_collisionsif_next #T$R$S sockaddr_in sin_familysin_port sin_addr %R@sin_zero*&&R%S&TS&TS&T&Sin_addr s_addr'R'Smsghdrmsg_name  msg_namelen@msg_iov (R` msg_iovlen msg_accrights msg_accrightslen)R)S sockproto  sp_family sp_protocol*R!S*TS*TS*TS*TS*TS*Tr CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_R4S*TS*T S*T S*T S*T*Ssockaddr sa_familysa_data*& +R+Slinger@l_onoff l_linger,R,S __chaos_addr chaos_host chaos_subnet-R-Schaos_sts_packet sts_header .R sts_receipt sts_rwsize/R/S chaos_packet data_header 0R data*&1R0S1T.S1T1S chaos_header type opcode length_count dest_addr0 dest_conn@ source_addrP source_conn` packet_numberp ack_number2R2Ssockaddr_chaos schaos_family schaos_addr schaos_port*& 3R3S __pup_addrpup_netpup_host4R4S pup_socket socket*&5R5Sat_addr at_ip &Tat_chaos at_pup6R6Sarptabat_proto at_addr 5T@ at_enaddr*&pat_timerxat_flagsat_hold 7R8R8Sarpcom ac_if #T ac_enaddr*& ac_ipaddr &T9R9S arp_pas CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_7cket ether_arp :R pup_ether_arp ;R<R;S<T<S pup_ether_arp puparp_op puparp_xtha*&@ puparp_xtpaH puparp_zero1P puparp_xsha*& puparp_xspa puparp_zero2=R=S arp_chaosarp_xsha*&0arp_xspa*&@arp_xtha*&parp_xtpa*&>R>Sarp_iparp_xsha*&0arp_xspa*&Parp_xtha*&arp_xtpa*&?R?Sarp_data arp_ip >T arp_chaos =T@R:S@T@S ether_arp ea_hdr T@arp_data ?TARAS ether_headerp ether_dhost*&0 ether_shost*&` ether_typeBRBS sockaddr_pupC spup_family spup_addr spup_socket@ spup_zero2*&CRCS pup_header pup_length pup_tcontrolpup_typt CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_:e  pup_id@ pup_daddrP pup_dsocket 4Tp pup_saddr pup_ssocket 4TDRDSipstat ips_total ips_badsumP@ ips_tooshort` ips_toosmall ips_badhlen ips_badlen ips_fragmentsips_fragdroppedips_fragtimeout  ips_forward@ips_cantforward`ips_redirectsentERESipoption` ipopt_dst &T ipopt_list*&(('FRFSipasfrag"ip_hl" "ip_v" ipf_mff ip_len  ip_id 0ip_off @ip_ttl Hip_p Pip_sum`ipf_next FTipf_prev FTGRGSipq next GT prev GT@ipq_ttl Hipq_p Pipq_id`ipq_next FTipq_prev FTIipq_src &Tipq_dst &THRHSipovlyih_next  ih_prev  @ih_x1 Hih_pr Pih_len `ih_src &T ih_dst &TIRIS in_ifaddr  ia_ifa  T @ia_net` ia_netmask ia_subnet ia_subnetmaskia_netbroadcast &Tia_flagsia_next ITJRJSprotoswppr_type pr_domain KR0 pr_pu CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_T^=rotocol@pr_flagsPpr_input p pr_output  pr_ctlinput  pr_ctloutput  pr_usrreq pr_init  pr_fasttimo N0 pr_slowtimo Ppr_drain LRLSnlist` n_name   n_type(n_other 0n_desc@n_valueMRMSicmpstat icps_error icps_oldshort@ icps_oldicmp` icps_outhist*&L icps_badcode icps_tooshort icps_checksum  icps_badlen@ icps_reflect` icps_inhist*&LNRNSid_ip idi_ip ORPRPSid_ts` its_otime its_rtime@ its_ttimeQRQSih_idseq icd_idicd_seqRRRSicmp_dun id_ts PT id_ip dNTid_maskid_data*&SRSSicmp_hun ih_pptr ih_gwaddr &Tih_idseq QTih_voidTRTSicmp icmp_type icmp_code icmp_cksum icmp_hun ST@icmp_dun RTURUSipt_ta@ipt_addr &T ipt_timeVRVS ipt_timestamp@ipt_time*&v CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_@ ipt_ta3/UTWRWS ip_timestamp`ipt_codeipt_lenipt_ptr"ipt_flg" " ipt_oflw"  ipt_timestamp VTXROSXTXS ip"ip_hl" "ip_v"  ip_tos ip_len  ip_id 0ip_off @ip_ttl Hip_p Pip_sum `ip_src &T ip_dst &TYRYSudpstat` udps_hdrops udps_badsum@ udps_badlenZRZSudpiphdr ui_i HT ui_u@ [R\R[S\T\Sudphdr@uh_sportuh_dport uh_ulen 0uh_sum]R]Stcpstattcps_rcvbadsum tcps_rcvbadoff@ tcps_rcvshort` tcps_badsegs tcps_unacktcps_connattempt tcps_accepts tcps_connects tcps_drops tcps_conndrops@ tcps_closed`tcps_segstimedtcps_rttupdated tcps_delacktcps_timeoutdroptcps_rexmttimeotcps_persisttimeo tcps_keeptimeo@tcps_keepprobe`tcps_keepdrops tcps_sndtotal tcps_sndpack tcps_sndbytetcps_sndrexmitpacktcps_sndrexmitbyte  tcps_sndacks@ tcps_sndprobe` tcps_sndurg tcps_sndwinup tcps_sndctrl tcps_rcvtotalw CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1_m-C tcps_rcvpack tcps_rcvbyte tcps_rcvduppack@tcps_rcvdupbyte`tcps_rcvpartduppacktcps_rcvpartdupbytetcps_rcvoopacktcps_rcvoobytetcps_rcvpackafterwintcps_rcvbyteafterwin tcps_rcvafterclose@tcps_rcvwinprobe`tcps_rcvdupackltcps_rcvacktoomuchtcps_rcvackpacktcps_rcvackbytetcps_rcvwinupd^R^StcpcbPseg_next _R seg_prev `R@t_statePt_timer*& t_rxtshiftt_rxtcur t_dupackst_maxsegt_forcet_flags t_template aRt_inpcb T snd_una@snd_nxt `snd_upsnd_wl1snd_wl2 isssnd_wndrcv_wndrcv_nxt  rcv_up @irs`rcv_advsnd_maxsnd_cwnd snd_ssthresh t_idle t_rttt_rtseq t_srttt_rttvar max_rcvd0 max_sndwnd@ t_oobflags Ht_iobcbRbStcphdrth_sportth_dport  th_seq @th_ack"th_x2" `"th_off" dhth_flags pth_win th_sum th_urpcRcSvariable name*&namelen type magic aclfindVar x CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1;1_7FdRdSmib_egpNeighEntry@ egpNeighState egpNeighAddreReSmib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrorsfRfSmib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsgRgSmib_tcpConnEntry tcpConnStatea tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPorthRhSmib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegsiRiSmib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsjRjSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRy CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1;1_IouteMetric1h`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgekRkSmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrlRlSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesmRmS mib_atEntry atIfIndex atPhysAddressf*& xPhysAddressLen atNetAddressnRnS mib_ifEntryifIndex ifDescr*&   ifType @ifMtu`ifSpeed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknownProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLenoRoS mib_interface ifNumberpRz CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1;1_LpS mib_systemsysDescr*&   sysObjectID*&ObjIDLen sysUpTimeqRaSqT`SqT_SqTqS rRKSrTrS sR7SsTSsTSsTSsTsS tR(StTtS uRSuTuS  nl3/LT  o variables3/cT=qp saveIndexInterface_CountsaveName*& savein_ifaddr IT\ saveifnetaddr #T` saveifnet #T ifnetaddr #T prev T inpcb ]T return_buf*&@@? long_returnZV@^UVLBDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.C;228  z init_snmp zP var_system exact access_method vpb cTnameb lengthb  var_lenb "" var_ifEntry access_method vp<\ cTname{ CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1;1_mO<\ length<\ exact<\ var_len<\ ـnewname*&@@?" interface<\resultk<\count<\cp<\ < ^var_ip exactvar_len  access_method vpo cTnameo lengtho i&var_ipAddrEntry vp cT exactvar_len  access_method name length  lowest*& current*&  interface% lowinterfacevar_icmpd exactvar_len  access_method vp  cTname  length  i o< var_tcp name  length  exactvar_len | CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;1;1_EaR access_method vpG   cTiG  ـnewname*&@@? lowest*&@@? State! LowStateG    $0 y var_udp exactvar_len  access_method vp ;  cTname ;  length ;  ! getStatPtrp type  acl name  namelen len exact& access_method vp cTxaccessH result0vcomparename1N len1Nname2N len2NlenN  } CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;111_gULrInterface_Scan_Get_Count 0Interface_Scan_By_IndexIndexqNameq ! Retifnetq #T% Retin_ifaddrq ITie#Interface_Get_Ether_By_Indexj EtherAddr Index ٞi ٢arpcom 8T M n\Interface_Scan_Init*Interface_Scan_Nextt[Index Name ! Retifnet #T% Retin_ifaddr IT ٬ifnet #T dia ITh in_ifad~ CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;111_)Xdr ITcp k u  y  @F R TCP_Count_Connections$ Established!   cb Tprev!   Tnext!   T وinpcb T tcpcb ^TIu  TCP_Scan_Init*  TCP_Scan_Next State RetInPcb Tnext [ T ٖtcpcb ^T   !  CMUSNMP.SAVK 4[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VARS.OBJ;111_[ 8 *vQLenoRoS mib_interface ifNumberpR6*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14+,./ 4W <-0@123KPWO56xYĒ7 )o8ʺ9FRQٓGHJ/*; * snmp_var_arp.c - return a pointer to the named variable. * * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University! Copyright 1989 TGV, Incorporated 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 thi CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14Whs permission notice appear inFsupporting documentation, and that the name of CMU and TGV not be usedFin advertising or publicity pertaining to distribution of the software+without specific, written prior permission.BCMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,FINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO=EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT ORFCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OFEUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ORFOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.C******************************************************************/?#define GATEWAY /* MultiNet is always configured this way! */#include #include #include #include #include #include #include #include #ifndef NULL#define NULL 0#endif#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "mib.h"#include "snmp_vars.h"static u_long long_return;static ARP_Scan_Init();static int ARP_Scan_Next();static struct nlist nl[] = {#define N_ARPTAB_SIZE 0 { "_arptab_size" },#define N_ARPTAB 1 { "_arptab" }, 0,};/* * Read the ARP table */u_char *<var_atEntry(vp, name, length, exact, var_len, access_method)W register struct variable *vp; /* IN - pointer  CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14WKto variable entry that points here */R register oid *name; /* IN/OUT - input name requested, output name found */M register int *length; /* IN/OUT - length of input and output oid's */E int exact; /* IN - TRUE if an exact match was requested. */Q int *var_len; /* OUT - length of variable or 0 if function returned. */K int *access_method; /* OUT - 1 if function, 0 if char pointer. */{ /*$ * object identifier is of form:M * 1.3.6.1.2.1.3.1.1.1.interface.1.A.B.C.D, where A.B.C.D is IP address.! * Interface is at offset 10," * IPADDR starts at offset 12. */ oid lowest[16]; oid current[16];1 static char PhysAddr[6], LowPhysAddr[6];5 int Addr, LowAddr, Interface, LowInterface;M /* fill in object part of name for current (less sizeof instance part) */S bcopy((char *)vp->name, (char *)current, (int)(vp->namelen - 6) * sizeof(oid));/ LowAddr = -1; /* Don't have one yet */ ARP_Scan_Init(); for (;;) {< if (ARP_Scan_Next(&Addr, PhysAddr, &Interface) == 0) break;> current[10] = Interface; /* IfIndex == 1 (ethernet???) XXX */ current[11] = 1; current[12] = (Addr) & 0xff;" current[13] = (Addr >> 8) & 0xff;# current[14] = (Addr >> 16) & 0xff;# current[15] = (Addr >> 24) & 0xff; if (exact){3 if (compare(current, 16, name, *length) == 0){; bcopy((char *)current, (char *)lowest, 16 * sizeof(oid)); LowAddr = Addr; LowInterface = Int CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14WQerface;1 bcopy(PhysAddr, LowPhysAddr, sizeof(PhysAddr));( break; /* no need to search further */ } } else {5 if ((compare(current, 16, name, *length) > 0) &&@ ((LowAddr == -1) || (compare(current, 16, lowest, 16) < 0))){ /*> * if new one is greater than input and closer to input than6 * previous lowest, save this one as the "next" one. */; bcopy((char *)current, (char *)lowest, 16 * sizeof(oid)); LowAddr = Addr; LowInterface = Interface;1 bcopy(PhysAddr, LowPhysAddr, sizeof(PhysAddr)); } } }$ if (LowAddr == -1) return(NULL);: bcopy((char *)lowest, (char *)name, 16 * sizeof(oid)); *length = 16; *access_method = 0; switch(vp->magic){ case ATIFINDEX:# *var_len = sizeof long_return; long_return = LowInterface;# return (u_char *)&long_return; case ATPHYSADDRESS:$ *var_len = sizeof(LowPhysAddr);" return (u_char *)LowPhysAddr; case ATNETADDRESS:# *var_len = sizeof long_return; long_return = LowAddr;# return (u_char *)&long_return; default: ERROR(""); } return NULL;}'static int arptab_size, arptab_current;static struct arptab *at=0;static ARP_Scan_Init(){ if (!at) {9 multinet_kernel_nlist("MULTINET_NETWORK_IMAGE:",nl);' klseek(nl[N_ARPTAB_SIZE].n_value);. klread(&arptab_size, sizeof arptab_size);H at = (struct arptab *) malloc(arptab_size * sizeof(struct arptab)); } klseek(nl[N_ARPTAB].n_value);9 klread( CMUSNMP.SAV6[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14W8 (char *)at, arptab_size * sizeof(struct arptab)); arptab_current = 0;}5static int ARP_Scan_Next(IPAddr, PhysAddr, Interface)int *IPAddr, *Interface;char *PhysAddr;{ register struct arptab *atab; struct in_ifaddr in_ifaddr; register int mask;' while (arptab_current < arptab_size) { atab = &at[arptab_current++];7 if (atab->at_proto != AF_INET || atab->at_flags == 0) continue;, if (!(atab->at_flags & ATF_COM)) continue;' *IPAddr = atab->at_addr.at_ip.s_addr;< bcopy(atab->at_enaddr, PhysAddr, sizeof(atab->at_enaddr)); if (Interface) { Interface_Scan_Init();@ while (Interface_Scan_Next(Interface, 0, 0, &in_ifaddr)) {' mask=htonl(in_ifaddr.ia_subnetmask); if ((*IPAddr & mask) ==D (((struct sockaddr_in *) &in_ifaddr.ia_addr)->sin_addr.s_addr & mask)) break; } } return(1); } return(0); /* "EOF" */}7*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1+, K+./ 4t-0D123KPWO56F#<ē7&ē8=f 9FRQٓGHJ CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1H9 SNMP_VAR_ARPV1.0 6-SEP-1990 11:49GNU CC V1.22$CODE$UNINITIALIZED_DATASID VAR_ATENTRY_010000XBCOPYCOMPAREMULTINET_KERNEL_NLISTKLSEEKKLREADMALLOCINTERFACE_SCAN_INIT_801040XHTONLINTERFACE_SCAN_NEXT_801040X($DATAP_arptab_size_arptabPP^ЬYЬWЬ XЬ[ЬZ4PPxP~YGPTiOP瞭SUhPP1oPа԰֛xPPxPPx譼PP[>PhWSPPP USPRbЭTЭVb`PhWSPRbP1aPTPUSbP1FP USPRbЭTЭVb1=PTFPP WWPhԼ6PP'fPPkPPpPjVzPPPjPjTPPPPMULTINET_NETWORK_IMAGE:PNPPPPPPxPPxPQPQ~ PPPx$PQx,PPQP~>PDPFP^ЬSЬTЬ R^PcP1hPxoPQxwPPPQQPP`PPPРcTPR8PPPݭPPPPcQPPQP CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1qP🭼~~RPPPPPPINTERFACE_SCAN_NEXT_801040XPHTONLPINTERFACE_SCAN_INIT_801040XPBCOPYP rP jP ^PYP ?P 9PKLREAD'PPPKLSEEKPMALLOCPPPKLREADPPKLSEEKPMULTINET_KERNEL_NLISTPP{PuPRPBCOPYPBCOPYPCOMPAREPBCOPYPCOMPAREBPBCOPY}P$2P$P P$PPP$P2P,PPP[PU$PP P P SNMP_VAR_ARPRSarpreq  arp_pa R arp_ha R arp_flagsRSarphdr@ ar_hrd ar_pro  ar_hln (ar_pln 0ar_opRSifc_ifcu ifcu_buf ifcu_req RRSifconf@ifc_len ifc_ifcu TRSifr_ifru ifru_addr  R ifru_dstaddr  Rifru_broadaddr  R ifru_flags ifru_metricifru_mtu ifru_asyncmap ifru_data  RS T Sifreq CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1;ifr_name*&ifr_ifru T R Sifqueueifq_head R ifq_tail R@ifq_len` ifq_maxlen ifq_dropsRSifa_ifu ifu_broadaddr R ifu_dstaddr RRSifaddr@ifa_addr Rifa_ifu Tifa_ifp R ifa_next TRSTSifnetif_name  if_unit 0if_mtu@if_flagsPif_timer` if_metric if_addrlist T if_snd  T@if_init ` if_output if_ioctl if_reset  if_watchdog  if_ipackets if_ierrors  if_opackets@ if_oerrors` if_collisionsif_next TRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_addrRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslenRS sockproto  sp_family sp_protocolRSTSTST ST  CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1H ST STSTSTSsockaddr sa_familysa_data*& RSlinger@l_onoff l_lingerRS __chaos_addr chaos_host chaos_subnet R Schaos_sts_packet sts_header !R sts_receipt sts_rwsize"R"S chaos_packet data_header #R data*&$R#S$T!S$T$S chaos_header type opcode length_count dest_addr0 dest_conn@ source_addrP source_conn` packet_numberp ack_number%R%Ssockaddr_chaos schaos_family schaos_addr schaos_port*& &R&S __pup_addrpup_netpup_host'R'S pup_socket socket*&(R(Snlist` n_name   n_type(n_other 0n_desc@n_value)R)S in_ifaddr  ia_ifa T @ia_net` ia_netmask ia_subnet ia_subnetmaskia_netbroadcast Tia_flagsia_next )T*R*Sat_addr at_ip Tat_chaos at_pup+R+Sarptabat_proto at CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1y" _addr *T@ at_enaddr*&pat_timerxat_flagsat_hold ,R-R-Sarpcom ac_if T ac_enaddr*& ac_ipaddr T.R.S arp_packet ether_arp /R pup_ether_arp 0R1R0S1T1S pup_ether_arp puparp_op puparp_xtha*&@ puparp_xtpaH puparp_zero1P puparp_xsha*& puparp_xspa puparp_zero22R2S arp_chaosarp_xsha*&0arp_xspa*&@arp_xtha*&parp_xtpa*&3R3Sarp_iparp_xsha*&0arp_xspa*&Parp_xtha*&arp_xtpa*&4R4Sarp_data arp_ip 3T arp_chaos 2T5R/S5T5S ether_arp ea_hdr T@arp_data 4T6R6S ether_headerp ether_dhost*&0  CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1ether_shost*&` ether_type7R7S sockaddr_pup spup_family spup_addr spup_socket@ spup_zero2*&8R8S pup_header pup_length pup_tcontrolpup_type  pup_id@ pup_daddrP pup_dsocket 'Tp pup_saddr pup_ssocket 'T9R9Svariable name*&namelen type magic aclfindVar :RI:Smib_egpNeighEntry@ egpNeighState egpNeighAddr;R;Smib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrors<R<Smib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagrams=R=Smib_tcpConnEntry tcpConnState tcpConnLocalAddressЈ@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPort>R>Smib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegs?R?Smib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbs CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1@QicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskReps@R@Smib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgeARASmib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrBRBSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesCRCS mib_atEntry atIfIndex atPhysAddress*& xPhysAddressLen atNetAddressDRDS CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;1 mib_ifEntryifIndex ifDescr*&   ifType @ifMtu`ifSpeed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknownProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLenERES mib_interface ifNumberFRFS mib_systemsysDescr*&  sysObjectID*&o ObjIDLen sysUpTimeGR,SGTSGTSGTGS HRSHTHS  nl3/(T $ $at +T arptab_current arptab_size long_return\XxYĒ DDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.C;14   var_atEntry access_method vp0 9Tname0 length0 exact0 var_len0  lowest*&cu CMUSNMP.SAV K+7[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ARP.OBJ;11brrent*&pw ټAddr LowAddr0ٸ Interface% LowInterface0q A ARP_Scan_InitF ARP_Scan_Next@IPAddrX ! PhysAddrX " InterfaceX atabX +Tټ in_ifaddr )TmaskX4 Y: sts_rwsize"R"S chaos_packet data_header #R data*&:*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.C;5+,. / 4Y (<-0@123KPWO 56O)h7o8J?9FRQٓGHJ CMUSNMP.SAV:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.C;5Y /*@ * snmp_var_multinet.c - return a pointer to the named variable. * * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University! Copyright 1989 TGV, Incorporated 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 inFsupporting documentation, and that the name of CMU and TGV not be usedFin advertising or publicity pertaining to distribution of the software+without specific, written prior permission.BCMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,FINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO=EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT ORFCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OFEUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ORFOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.C******************************************************************/#include #include #include #include #include #include #ifndef NULL#define NULL 0#endif#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "mib.h"#include "sn CMUSNMP.SAV:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.C;5Y \mp_vars.h"u_char *=var_MultiNet(vp, name, length, exact, var_len, access_method)Y register struct variable *vp; /* IN - pointer to variable entry that points here */R register oid *name; /* IN/OUT - input name requested, output name found */L register int *length; /* IN/OUT - length of input and output oid's */E int exact; /* IN - TRUE if an exact match was requested. */O int *var_len; /* OUT - length of variable or 0 if function returned. */G int *access_method; /* OUT - 1 if function, 0 if char pointer. */{* static char *Get_MultiNet_Parameter(); char *cp;K if (exact && (compare(name, *length, vp->name, (int)vp->namelen) != 0)) return NULL;J bcopy((char *)vp->name, (char *)name, (int)vp->namelen * sizeof(oid)); *length = vp->namelen; *access_method = 0; switch (vp->magic){ case SERIAL:+ cp = Get_MultiNet_Parameter("SERIAL"); if (cp) *var_len = strlen(cp); return (u_char *)cp; case KITDATE:) cp = Get_MultiNet_Parameter("DATE"); if (cp) *var_len = strlen(cp); return (u_char *)cp; case DISTRIBUTOR:0 cp = Get_MultiNet_Parameter("DISTRIBUTOR"); if (cp) *var_len = strlen(cp); return (u_char *)cp; case KITVERSION:, cp = Get_MultiNet_Parameter("VERSION"); if (cp) *var_len = strlen(cp); return (u_char *)cp; case BASELEVEL:. cp = Get_MultiNet_Parameter("BASELEVEL"); if (cp) *var_len = strlen(cp); return (u CMUSNMP.SAV:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.C;5Y _char *)cp; default: ERROR(""); } return NULL;}.static char *Get_MultiNet_Parameter(Parameter){ FILE *fp; static char buf[128]; register char *cp;= if (!(fp=fopen("MULTINET:MULTINET_VERSION","r"))) return(0);& while (fgets(buf, sizeof(buf), fp)) {? if (strncasecmp(Parameter, buf, strlen(Parameter)) == 0) { fclose(fp); cp = buf;$ while (*cp && !isspace(*cp)) cp++;# while (*cp && isspace(*cp)) cp++; cp[strlen(cp)-1] = '\0'; return(cp); } } fclose(fp); return(0);} CMUSNMP.SAVK <[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;12<*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;1+,K ./ 4L-0D123KPWO56Fē7&ē8f 9FRQٓGHJ>SNMP_VAR_MULTINETV1.0 6-SEP-1990 11:49GNU CC V1.22$CODE$UNINITIALIZED_DATA_CTYPE_ C$V_CTYPEDEFSSID 4<VAR_MULTINET_480000XCOMPAREBCOPYSTRLENFOPEN STRNCASECMPFCLOSEFGETSSTDERRSTDOUTSTDINPP PSERIALDATEDISTRIBUTORVERSIONBASELEVEL4P<ЬRЬTЬ UЬSլKP4~ReT\PP`PP4PxP~TRvP嚢4eԼ6PPPuPPvPPuP P{PP}P1PPR PRPPcRPrMULTINET:MULTINET_VERSIONP ЬSPPPPRxPPSPPSPPWPR$PR1PQ4P򋏀bPPPA`BPRbHPJPbPPP[PRbaPRjP@RPR~ CMUSNMP.SAVK <[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;1PP1qPRPPP PPPP$PFCLOSEPFGETSePSTRLEN,PPFCLOSEP STRNCASECMPPSTRLENPFOPENPSTRLENqPBCOPYWPCOMPAREP C$V_CTYPEDEFSyPTP%P PSNMP_VAR_MULTINETRS_iobufp _cnt _ptr  @_base  `_flag h_fileRS sockaddr_in sin_familysin_port sin_addr R@sin_zero*&RSTSin_addr s_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 Svariable name*&namelen type magic aclfindVar  R Smib_egpNeighEntry@ egpNeighState egpNeighAddr R Smib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrors  CMUSNMP.SAVK <[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;1 {R Smib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagramsRSmib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPortRSmib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegsRSmib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskRepsRSmib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAgeRSmib_ipAddrEntry CMUSNMP.SAVK <[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;1  ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddrRSmib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreatesRS mib_atEntry atIfIndex atPhysAddress*& xPhysAddressLen atNetAddressRS mib_ifEntryifIndex ifDescr*&   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 sysUpTimeRST CMUSNMP.SAVK <[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.OBJ;1@ S &$$PsectAttributes_NOSHR$$stderr T&$$PsectAttributes_NOSHR$$stdout T%$$PsectAttributes_NOSHR$$stdin T`\O)h(HDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_MULTINET.C;5  q__ctype__dummy44 var_MultiNet* exact access_method vpF  TnameF lengthF  var_lenF cpF  .4 Get_MultiNet_Parameter" Parameterfp Tcp ^ CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24g']8*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24+,./ 4gn<-0@123KPWO56xYĒ7`o8傪9FRQٓGHJ/*= * snmp_var_route.c - return a pointer to the named variable. * * */</***********************************************************3 Copyright 1988, 1989 by Carnegie Mellon University! Copyright 1989 TGV, Incorporated 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 inFsupporting documentation, and that the name of CMU and TGV not be usedFin advertising or publicity pertaining to distribution of the software+without specific, written prior permission.BCMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,FINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO=EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT ORFCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OFEUSE, DATA  CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24gOR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ORFOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.C******************************************************************/?#define GATEWAY /* MultiNet is always configured this way! */#include #include #include #include #include #include 4#define KERNEL /* to get routehash and RTHASHSIZ */#include #undef KERNELC#define rt_unit rt_hash /* Reuse this field for device # */#include #ifndef NULL#define NULL 0#endif*#define CACHE_TIME (120) /* Seconds */#include "asn1.h"#include "snmp.h"#include "snmp_impl.h"#include "mib.h"#include "snmp_vars.h"static Route_Scan_Reload();static int qsort_compare();static u_long long_return;!static struct rtentry **rthead=0;static int rtsize=0, rtalloc=0;static struct nlist nl[] = {#define N_RTHOST 0 { "_rthost" },#define N_RTNET 1 { "_rtnet" }, 0,};u_char *Avar_ipRouteEntry(vp, name, length, exact, var_len, access_method)Y register struct variable *vp; /* IN - pointer to variable entry that points here */R register oid *name; /* IN/OUT - input name requested, output name found */N register int *length; /* IN/OUT - length of input and output strings */E int exact; /* IN - TRUE if an exact match was requested. */O int *var CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24g._len; /* OUT - length of variable or 0 if function returned. */G int *access_method; /* OUT - 1 if function, 0 if char pointer. */{ /*$ * object identifier is of form:B * 1.3.6.1.2.1.4.21.1.1.A.B.C.D, where A.B.C.D is IP address." * IPADDR starts at offset 10. */- register int Save_Valid, result, RtIndex;9 static int saveNameLen=0, saveExact=0, saveRtIndex=0;) static oid saveName[14], Current[14]; /* * OPTIMIZATION: *C * If the name was the same as the last name, with the possibleF * exception of the [9]th token, then don't read the routing table * */; if ((saveNameLen == *length) && (saveExact == exact)) { register int temp=name[9]; name[9] = 0;C Save_Valid = (compare(name, *length, saveName, saveNameLen) == 0); name[9] = temp; } else Save_Valid = 0; if (Save_Valid) {@ register int temp=name[9]; /* Fix up 'lowest' found entry */: bcopy((char *) Current, (char *) name, 14 * sizeof(oid)); name[9] = temp; *length = 14; RtIndex = saveRtIndex; } else {J /* fill in object part of name for current (less sizeof instance part) */P bcopy((char *)vp->name, (char *)Current, (int)(vp->namelen - 4) * sizeof(oid)); /*3 * Only reload if this is the start of a wildcard */ if (*length < 14) { Route_Scan_Reload(); }. for(RtIndex=0; RtIndex < rtsize; RtIndex++) {a Current[10] = (((struct sockaddr_in *) &(rthead[RtIndex]->rt_dst))->sin_addr.s_addr) & 0x CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24g/ ff;f Current[11] = (((struct sockaddr_in *) &(rthead[RtIndex]->rt_dst))->sin_addr.s_addr >> 8) & 0xff;g Current[12] = (((struct sockaddr_in *) &(rthead[RtIndex]->rt_dst))->sin_addr.s_addr >> 16) & 0xff;g Current[13] = (((struct sockaddr_in *) &(rthead[RtIndex]->rt_dst))->sin_addr.s_addr >> 24) & 0xff;2 result = compare(name, *length, Current, 14);> if ((exact && (result == 0)) || (!exact && (result < 0))) break; }% if (RtIndex >= rtsize) return(NULL); /* * Save in the 'cache' */@ bcopy((char *) name, (char *) saveName, *length * sizeof(oid)); saveName[9] = '\0'; saveNameLen = *length; saveExact = exact; saveRtIndex = RtIndex; /* * Return the name */: bcopy((char *) Current, (char *) name, 14 * sizeof(oid)); *length = 14; } *access_method = 0;# *var_len = sizeof(long_return); switch(vp->magic){ case IPROUTEDEST:Z return(u_char *) &((struct sockaddr_in *) &rthead[RtIndex]->rt_dst)->sin_addr.s_addr; case IPROUTEIFINDEX:, long_return = rthead[RtIndex]->rt_unit;# return (u_char *)&long_return; case IPROUTEMETRIC1:E long_return = (rthead[RtIndex]->rt_flags & RTF_GATEWAY) ? 1 : 0;# return (u_char *)&long_return; case IPROUTEMETRIC2: long_return = -1;# return (u_char *)&long_return; case IPROUTEMETRIC3: long_return = -1;# return (u_char *)&long_return; case IPROUTEMETRIC4: long_return = -1;# return (u_char *)&long_return; case IPROUTENEXTHOP: CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24g7 ^ return(u_char *) &((struct sockaddr_in *) &rthead[RtIndex]->rt_gateway)->sin_addr.s_addr; case IPROUTETYPE:E long_return = (rthead[RtIndex]->rt_flags & RTF_GATEWAY) ? 4 : 3;# return (u_char *)&long_return; case IPROUTEPROTO:E long_return = (rthead[RtIndex]->rt_flags & RTF_DYNAMIC) ? 4 : 2;# return (u_char *)&long_return; case IPROUTEAGE: long_return = 0;# return (u_char *)&long_return; default: ERROR(""); } return NULL;}static Route_Scan_Reload(){' struct mbuf *routehash[RTHASHSIZ], mb; register struct mbuf *m; struct ifnet ifnet; struct rtentry *rt; int i, table, qsort_compare(); register char *cp; char name[16], temp[16];" static int Time_Of_Last_Reload=0;F if (Time_Of_Last_Reload+CACHE_TIME > VMS_GET_EXE$GL_ABSTIM()) return;0 Time_Of_Last_Reload = VMS_GET_EXE$GL_ABSTIM(); if (!nl[0].n_value)9 multinet_kernel_nlist("MULTINET_NETWORK_IMAGE:",nl); /*D * Makes sure we have SOME space allocated for new routing entries */ if (!rthead) {I rthead = (struct rtentry **) malloc(100 * sizeof(struct rtentry *));3 bzero(rthead, 100 * sizeof(struct rtentry *)); rtalloc = 100; }0 for (table=N_RTHOST; table<=N_RTNET; table++) { klseek(nl[table].n_value);+ klread(routehash, sizeof (routehash));& for (i = 0; i < RTHASHSIZ; i++) { if (routehash[i] == 0) continue; m = routehash[i]; while (m) { /*+ * Dig the route out of the kernel CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24g... */ klseek(m); klread(&mb, sizeof (mb)); m = mb.m_next;' rt = mtod(&mb, struct rtentry *); if (rt->rt_ifp != 0) { klseek(rt->rt_ifp);" klread(&ifnet, sizeof (ifnet)); klseek((int)ifnet.if_name); klread(name, 16); name[15] = '\0';# cp = (char *) index(name, '\0'); *cp++ = ifnet.if_unit + '0'; *cp = '\0';) if (strcmp(name,"lo0") == 0) continue; Interface_Scan_Init();? while (Interface_Scan_Next(&rt->rt_unit, temp, 0, 0) != 0) {* if (strcmp(name, temp) == 0) break; } } /*? * Allocate a block to hold it and add it to the database */ if (rtsize >= rtalloc) {X rthead = (struct rtentry **) realloc(rthead, 2 * rtalloc * sizeof(struct rtentry *));H bzero((char *) &rthead[rtalloc], rtalloc * sizeof(struct rtentry *)); rtalloc *= 2; } if (!rthead[rtsize])F rthead[rtsize] = (struct rtentry *) malloc(sizeof(struct rtentry)); /*! * Add this to the database */8 bcopy(rt, rthead[rtsize], sizeof(struct rtentry)); rtsize++; } } } /* * Sort it! */6 qsort(rthead,rtsize,sizeof(rthead[0]),qsort_compare);} /* * Create a host table */static int qsort_compare(r1,r2)struct rtentry **r1, **r2;{Z register u_long dst1 = ntohl(((struct sockaddr_in *) &((*r1)->rt_dst))->sin_addr.s_addr);Z register u_long dst2 = ntohl(((struct sockaddr_in *) &((*r2)->rt_dst))->sin_addr.s_addr); /* CMUSNMP.SAV8[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24gD * Do the comparison */ if (dst1 == dst2) return(0); if (dst1 > dst2) return(1); return(-1);}9*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1+,K ./ 4-0D123KPWO56 ē7&lē8f 9FRQٓGHJ;SNMP_VAR_ROUTEV1.0 6-SEP-1990 11:50GNU CC V1.22$CODE<$UNINITIALIZED_DATASID VAR_IPROUTEENTRY_012000XCOMPAREBCOPYVMS_GET_EXE$GL_ABSTIMMULTINET_KERNEL_NLISTMALLOCBZEROKLSEEKKLREADINDEXSTRCMPINTERFACE_SCAN_INIT_801040XINTERFACE_SCAN_NEXT_801040XREALLOCQSORTNTOHL RTSTATRTNETRTHOST@$DATAP_rthost_rtnetPPЬ CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1*ZЬTЬ UЬVe9+PV04P<ReTRPQPXPQQPRdPPP&jP<RTPReS1P暪4PPxP~ZPePϮPSS}PRYXWPC`QbC`QС[[QQiC`QС[[QQhC`PР[[PPgeT$PV(PP,PV0PP4PS<PSEPPxe~TZPRbeVSTbeԼ6PP PCPCP`PPPCP$PPFPPBPPPPCPCP$ PPPCP$ PP%PPP/P5PP=PCPPEPMULTINET_NETWORK_IMAGE:lo0bP ^xR|PRPPPPPPP)P<~PP<~PPښdX̀YWxXPHP<~PVF1JPFUU1= PU(PSc~Y8PRb̀UŸ́Tդ,wLPݤ,cT~,b,cWb+~WzP00`PWPPPP RPRWPPP~~RTPPP@Px~PPxPPP CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1,~PP@ P0)PPQPQ@0P@TTP1]P@V1jPX1rsPvPPP мPݠPRbPSмPݠbSPPPSPPPPPP P7PNPNPNP]PgPzPPNTOHLPQSORTOPBCOPY$PMALLOCPBZEROPREALLOCPINTERFACE_SCAN_NEXT_801040XPSTRCMPPINTERFACE_SCAN_INIT_801040XPSTRCMPuPINDEX3PKLREAD#PKLSEEKPKLREADPKLSEEKPBZEROPMALLOCPMULTINET_KERNEL_NLISTPVMS_GET_EXE$GL_ABSTIMwPVMS_GET_EXE$GL_ABSTIM>P88P80P8*P8P8P8P8P8UPBCOPYPCOMPAREPBCOPYzPBCOPYMPCOMPAREPyPUPFPFP>P6P6P-PPPP PPPPPPPPPPPPPP PP<jP<PPPPPPPPPPP CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1YP~PtP8mP4fP0o_PMP>P5PPPP0PPP8sPBP<P0,P4#P0<P8P4P0P PPPPP PSNMP_VAR_ROUTERSnlist` n_name   n_type(n_other 0n_desc@n_valueRSrtstatPrts_badredirect rts_dynamic rts_newgateway0 rts_unreach@ rts_wildcardRSrtentryrt_hash rt_dst R rt_gateway R rt_flags0 rt_refcnt @rt_use `rt_ifp RRSroute ro_rt T ro_dst R R Sarpreq  arp_pa  R arp_ha  R arp_flags R Sarphdr@ ar_hrd ar_pro  ar_hln (ar_pln 0ar_op R Sifc_ifcu ifcu_buf ifcu_req RRSifconf@ifc_len ifc_ifcu  TRSifr_ifru ifru_addr R ifru_dstaddr Rifru_broadaddr R CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1 ifru_flags ifru_metricifru_mtu ifru_asyncmap ifru_data RSTSifreqifr_name*&ifr_ifru TRSifqueueifq_head R ifq_tail R@ifq_len` ifq_maxlen ifq_dropsRSifa_ifu ifu_broadaddr R ifu_dstaddr RRSifaddr@ifa_addr Rifa_ifu Tifa_ifp R ifa_next TRSTSTSifnetif_name  if_unit 0if_mtu@if_flagsPif_timer` if_metric if_addrlist T if_snd T@if_init ` if_output if_ioctl if_reset  if_watchdog  if_ipackets if_ierrors  if_opackets@ if_oerrors` if_collisionsif_next TRSmbstatm_mbufs m_clusters@m_space`m_clfreem_drops m_waitm_drainm_mtypes*& RS TS T Smbuf m_next  T  m_off @m_len Pm_type `m_dat*&pp CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1so m_act  T!R!S sockaddr_in sin_familysin_port sin_addr "R@sin_zero*&#R"S#T#Sin_addr s_addr$R$Smsghdrmsg_name  msg_namelen@msg_iov %R` msg_iovlen msg_accrights msg_accrightslen&R&S sockproto  sp_family sp_protocol'RS'TS'TS'TS'TS'TS'T S'T S'TS'TS'TS'T'Ssockaddr sa_familysa_data*& (R(Slinger@l_onoff l_linger)R)Svariable name*&namelen type magic aclfindVar *R*Smib_egpNeighEntry@ egpNeighState egpNeighAddr+R+Smib_egp egpInMsgs egpInErrors@ egpOutMsgs` egpOutErrors,R,Smib_udpudpInDatagrams udpNoPorts@ udpInErrors`udpOutDatagrams-R-Smib_tcpConnEntry tcpConnState tcpConnLocalAddress@tcpConnLocalPort`tcpConnRemAddresstcpConnRemPort.R.Smib_tcptcpRtoAlgorithm tcpRtoMin@ tcpRtoMax CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;13` tcpMaxConntcpActiveOpenstcpPassiveOpenstcpAttemptFailstcpEstabResets tcpCurrEstab  tcpInSegs@ tcpOutSegs`tcpRetransSegs/R/Smib_icmp@ icmpInMsgs icmpInErrors@icmpInDestUnreachs`icmpInTimeExcdsicmpInParmProbsicmpInSrcQuenchsicmpInRedirects icmpInEchosicmpInEchoReps icmpInTimestamps@icmpInTimestampReps`icmpInAddrMasksicmpInAddrMaskReps icmpOutMsgs< icmpOutErrorsicmpOutDestUnreachsicmpOutTimeExcds icmpOutParmProbs@icmpOutSrcQuenchs`icmpOutRedirects icmpOutEchosicmpOutEchoRepsicmpOutTimestampsicmpOutTimestampRepsicmpOutAddrMasks icmpOutAddrMaskReps0R0Smib_ipRouteEntry@ ipRouteDest ipRouteIfIndex@ipRouteMetric1`ipRouteMetric2ipRouteMetric3ipRouteMetric4ipRouteNextHop ipRouteType ipRouteProto  ipRouteAge1R1Smib_ipAddrEntry ipAdEntAddr ipAdEntIfIndex@ipAdEntNetMask`ipAdEntBcastAddr2R2Smib_ip` ipForwarding ipDefaultTTL@ ipInReceives` ipInHdrErrorsipInAddrErrorsipForwDatagramsipInUnknownProtos ipInDiscards ipInDelivers  ipOutRequests@ ipOutDiscards CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1J` ipOutNoRoutesipReasmTimeout ipReasmReqds ipReasmOKs ipReasmFails ipFragOKs  ipFragFails@ ipFragCreates3R3S mib_atEntry atIfIndex͌ atPhysAddress*& xPhysAddressLen atNetAddress4R4S mib_ifEntryifIndex ifDescr*&   ifType @ifMtu`ifSpeed ifPhysAddress*&  PhysAddrLen ifAdminStatus ifOperStatus  ifLastChange@ ifInOctets` ifInUcastPktsifInNUcastPkts ifInDiscards ifInErrorsifInUnknownProtos ifOutOctets ifOutUcastPkts@ifOutNUcastPkts` ifOutDiscards ifOutErrors ifOutQLen5R5S mib_interface ifNumber6R6S mib_systemsysDescr*&  sysObjectID*&ObjIDLen sysUpTime7R%S7T7S  rthead T rtsizertalloc  nl3/T $8 long_return rtstat T rtnet62  T@?CL rthost62  T@?^ CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1@ZxYĒnFDISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.C;24  var_ipRouteEntryvar_len  access_method vp"D )Tname"D length"D exact"D# Save_Valid"Dresult"D RtIndex"D 4$0mtemp4a. j$1tempj#~ ERbRoute_Scan_Reload routehash62  T@? ـmb  Tmi  T ,ifnet Trti Tiitableicpi  name*&t: temp*& v4   CMUSNMP.SAVK 9[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]SNMP_VAR_ROUTE.OBJ;1Ll ] j2* qsort_compare r1 T r2 Tdst1dst2288 ifru_addr R ifru_dstaddr Rifru_broadaddr R/*[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.C;19+,./ 4K <-0@123KPWO56\yYĒ7 ;o8 9FRQٓGHJ/*. * Copyright (C) 1987, 1988 SRI International. * Copyright (C) 1988, 1989 TGV, Incorporated *; * Special runtime library which fakes select() so we don't< * have to restructure snmp_api.c and the snmp applications. */#include #include #include #include #include #include /*> * Network I/O data (makes things look like file descriptors!) */struct Network_IO { unsigned short Channel; uns CMUSNMP.SAV/[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.C;19;513OBJ;1Kigned short IOSB[4]; } *Network_IO[32]; 1static int Dummy_Buffer; /* For MSG_PEEK I/O */ /*. * Allocate and fill in a Network_IO structure */&static int Fill_In_Network_IO(Channel) int Channel;{ register int fd; /*4 * Find a free I/O structure pointer and fill it in */E for(fd = 0; fd < (sizeof(Network_IO)/sizeof(Network_IO[0])); fd++) { /*& * Find a free I/O structure pointer */ if (Network_IO[fd] == 0) { /*( * Got it: Allocate and clear memory */) Network_IO[fd] = (struct Network_IO *)+ malloc(sizeof(struct Network_IO)); if (Network_IO[fd] == 0) { /* * Error: No memory */ errno = ENOMEM; return(-1); }3 bzero(Network_IO[fd],sizeof(struct Network_IO)); /* * Fill it in */% Network_IO[fd]->Channel = Channel; /*& * Return it like a file descriptor */ return(fd); } } /*! * No more Network_IO slots left */ errno = EMFILE; return(-1);}/* * Get a socket */5int net_socket(Address_Family, Type, Protocol_Family){ int fd; unsigned short int Channel;9 Channel = socket(Address_Family, Type, Protocol_Family);" if (Channel < 0) return(Channel); /*1 * Allocate and fill in the Network_IO structure */" fd = Fill_In_Network_IO(Channel); if (fd >= 0) return(fd); /* * Can't find one: return error */ socket_close(Channel); return(-1);} /* * Close a socket */int net_close(fd)regi CMUSNMP.SAV/[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.C;19;513OBJ;1KQster int fd;{' socket_close(Network_IO[fd]->Channel); /* * Free the structure */ free(Network_IO[fd]); Network_IO[fd] = 0; /* * Return success */ return(0);} /* * Bind an address to a socket */int net_bind(fd,sa,size){1 return(bind(Network_IO[fd]->Channel, sa, size));} /*8 * Send data on a socket, specifying destination address */)int net_sendto(fd,buf,len,flags,to,tolen){E return(sendto(Network_IO[fd]->Channel, buf, len, flags, to, tolen));} /* * Receive data from a socket *//int net_recvfrom(fd,buf,len,flags,from,fromlen){K return(recvfrom(Network_IO[fd]->Channel, buf, len, flags, from, fromlen));}/*E * Partial emulation of select() only read and timeout functions work */%static int Readyfds, Timeout_Occured;<int net_select(width, readfds, writefds, exceptfds, timeout)int width, *readfds;struct timeval *timeout;{ register int i, Status;/ int Original_Readfds = *readfds, Number_Ready;: static int select_read_wakeup(), select_timeout_wakeup(); long Delta_Time[2]; /* * Assume nothing is 'ready' */ Timeout_Occured = Readyfds = 0; #ifdef DEBUGG printf("select(0x%x,%d,%d)\n",*readfds,timeout ? timeout->tv_sec : -1,# timeout ? timeout->tv_usec : -1); #endif DEBUG /*5 * Start a recv() with peek on each specified file. */ for (i=0; iChannel, IO$_RECEIVE, Network_IO[i]->IOSB, select_read_wakeup, i, &Dummy_Buffer, sizeof(Dummy_Buffer), MSG_PEEK, 0, 0, 0); if (!(Status&1)) { socket_errno = EIO; vmserrno = Status; return(-1); } } } /* * Maybe start a timer */" if (timeout && timeout->tv_sec) { Delta_Time[1] = -1;I Delta_Time[0] = -((timeout->tv_sec*10000000)+(timeout->tv_usec*10)); Status = SYS$SETIMR(0, Delta_Time, select_timeout_wakeup, &Timeout_Occured); if (!(Status&1)) { socket_errno = EIO; vmserrno = Status; return(-1); } /* * Wait for I/O or timer... */ for (;;) {) if (Readyfds || Timeout_Occured) break; SYS$HIBER(); } /* * Cancel the timer */ if (!Timeout_Occured) {( (void) SYS$CANTIM(&Timeout_Occured,0); } } else if (!timeout) { /* * Wait for I/O ... */ for (;;) { if (Readyfds) break; SYS$HIBER(); } } /*7 * Return the mask of I/O's completed. Do this BEFORE; * issuing the cancels, since they would cause the I/O to * complete!!! */ *readfds = Readyfds; /* * Cancel any I/O left over */ #ifdef DEBUG! printf("\tready=0x%x",Readyfds); #endif DEBUG Number_Ready = 0; for (i=0; iChannel); } else { Number_Ready++; } } } #ifdef DEBUG; printf("(%d), timeout=%d\n",Number_Ready,Timeout_Occured); #endif DEBUG /*! * Return the correct status... */ return(Number_Ready);}"static int select_timeout_wakeup(){ Timeout_Occured = 1; SYS$WAKE(0,0);}!static int select_read_wakeup(fd)int fd;{ Readyfds |= (1<PDPRRUQKPxRPfPDTP~~~dPR0jPBqPP1<`~~ PPPPPPPURPS1Pc1PTTcRxQxPPQQRRPϭP~PPPPPPTPPPP PPPP&P~!P(P*PS.P4P 6P=P?PEPfSRRU1OPxRPPQQWP \PQcPPfPBmPP<`~xPzPSURPSPPP~~PPxPPP~~PPݬPPPPRANDPSRANDPSYS$WAKEPPSYS CMUSNMP.SAVK!0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.OBJ;1213.C;7$WAKEPsP SYS$CANCELhP^P@P8P SYS$HIBER/P#P SYS$CANTIMPP P SYS$HIBERPPPPP SYS$SETIMRPPP~PSYS$QIOlP_P?P9PPRECVFROMPPSENDTOPPBINDPPFREEP SOCKET_CLOSEP~Pi SOCKET_CLOSEePSOCKETNP5PBZERO%PPMALLOC P VMSIORS tm  tm_sec  tm_min@tm_hour`tm_mday tm_montm_yeartm_wdaytm_ydaytm_isdstRS itimerval it_interval R@it_value RRStimezone@tz_minuteswest tz_dsttimeRSTSTStimeval@ tv_sec tv_usecRSmsghdrmsg_name  msg_namelen@msg_iov R` msg_iovlen msg_accrights msg_accrightslen R S sockproto  sp_family sp_protocol R Ssockaddr sa_familysa_data*&  R Slinger@l_onoff l_linger R S  CMUSNMP.SAVK!0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.OBJ;1213.C;7CJNetwork_IOPChannel IOSB*& RS T S Timeout_OccuredReadyfds Dummy_Buffer Network_IO62  T ,%$$PsectAttributes_NOSHR$$socket_errno(!$$PsectAttributes_NOSHR$$vmserrno*#$$PsectAttributes_NOSHR$$vaxc$errno%$$PsectAttributes_NOSHR$$errnoUQ\yYĒ =DISK$MULTINET:[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.C;19  Fill_In_Network_ION ChannelVfdV  %EXX net_socketAddress_Family Type Protocol_FamilyfdZ ChannelZD0 net_close%fd;,net_bind$ fd sa  size+  net_sendtoK fd buf  len flags to tolen-( net_recvfromO fd buf  len flags fromfromlen+($ net_select writefds exceptfdswidth5 CMUSNMP.SAVK!0[MULTINET_PLUS.MULTINET.SNMP.SNMPLIB]VMSIO.OBJ;1213.C;7F readfds5  timeout5 Ti5Status5)Original_Readfds5% Number_Ready5 Delta_Time*&K  `select_read_wakeup  fdW select_timeout_wakeup  =  |srandom x: random