#!/bin/sh # This is `snmp2.32' (part 32 of snmp2). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `snmp2/agent/snmp_vars.c' is being continued... # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo echo 'WARNING: not restoring timestamps. Consider getting and' echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 1231235999 $$.touch # if test ! -r _sharseq.tmp; then echo 'Please unpack part 1 first!' exit 1 fi shar_sequence=`cat _sharseq.tmp` if test "$shar_sequence" != 32; then echo "Please unpack part $shar_sequence next!" exit 1 fi if test ! -f _sharnew.tmp; then echo 'x - still skipping snmp2/agent/snmp_vars.c' else echo 'x - continuing file snmp2/agent/snmp_vars.c' sed 's/^X//' << 'SHAR_EOF' >> 'snmp2/agent/snmp_vars.c' && X *length = vp->namelen; X *write_method = 0; X *var_len = sizeof(long); X X switch (vp->magic){ X case PROCESSSLOTINDEX: X long_return = slotindex; X return (u_char *) &long_return; X case PROCESSID: X long_return = proc->p_pid; X return (u_char *) &long_return; X case PROCESSCOMMAND: X *var_len = get_command(proc, return_buf); X return (u_char *)return_buf; X default: X ERROR(""); X } X return NULL; } X X X X X X X get_command(proc, buf) X struct proc *proc; X char *buf; { X #if defined(ibm032) X struct user u; struct userx { X char userfill[UPAGES*NBPG-sizeof (struct user)]; X struct user user; }; X #ifdef BSD4_3 #define REDSIZE CLSIZE*2 /* red zone size plus reserved page */ #else #define REDSIZE CLSIZE /* red zone size */ #endif BSD4_3 X union { X struct userx userx; X char upages[UPAGES][NBPG]; } user; #define U user.userx.user #else X #define REDSIZE 0 /* red zone size */ X union { X struct user user; X char upages[UPAGES][NBPG]; } user; #define u user.user #endif X X struct pte *pteaddr, apte; X struct pte *Usrptmap, *usrpt; X #ifdef mips X struct pte arguutl[UPAGES]; X struct pte wpte[UPAGES]; #endif #ifdef sunV3 X struct pte uutl[UPAGES]; X struct pte arguutl[UPAGES]; #endif X X X union { X char argc[CLSIZE*NBPG]; X int argi[CLSIZE*NBPG/sizeof (int)]; X } argspac; X X X X int argaddr; X struct dblock db; X register char *cp; X register int *ip; X char c; X int ncl; X int i; X int usersize, size; X long addr; X int nbad; X X /* X * Handle the 2 system procs now so X * we don't have to worry about them latter X */ X if (proc->p_pid == 0){ X strcpy(buf, "swapper"); X return strlen(buf); X } X if (proc->p_pid == 2){ X strcpy(buf, "pagedaemon"); X return strlen(buf); X } X X #ifdef ibm032 X size = ctob(UPAGES); #endif #ifdef mips X size = sizeof (struct user); #endif #ifdef sunV3 X size = roundup(sizeof (struct user), DEV_BSIZE); #endif X X /* X * We don't deal with Zombies and the like... X */ X if (proc->p_stat == SZOMB || proc->p_flag & (SSYS | SWEXIT)){ X strcpy((char *)buf, ""); X return strlen(buf); X } X #ifdef ibm032 X X if (KNLookup(N_USERSIZE, (char *)&usersize, sizeof(usersize)) == NULL) { X return(0); X } #endif X X usrpt = (struct pte *)nl[N_USRPT].n_value; X Usrptmap = (struct pte *)nl[N_USRPTMAP].n_value; X X /* X * Is our target proc in core?? X */ X if ((proc->p_flag & SLOAD) == 0){ X /* X * Not in core -- poke (peek, actually [hopefully]) around swap for u. struct X */ X lseek(swap, (long)dtob(proc->p_swaddr), 0); X X if (read(swap, (char *)user.upages, size) != size) { X ERROR(""); X return (0); X } #ifdef ibm032 X if ((i = usersize - sizeof (struct user)) > 0) X bcopy(((char *) &U) - i, (char *) &u, sizeof (struct user)); X /* fake the location of the u structure */ X else X u = U; /* added 8-9-85 for consistency */ #endif X argaddr = 0; X } else { X X X X #ifdef sunV3 X pteaddr = &Usrptmap[btokmx(sptopte(proc, CLSIZE-1))]; #endif sunV3 #ifdef ibm032 X pteaddr = &Usrptmap[btokmx(proc->p_p0br) + proc->p_szpt - 1]; #endif ibm032 #ifdef mips X pteaddr = &Usrptmap[btokmx(proc->p_stakbr)+proc->p_stakpt-1]; #endif mips #ifdef VXWORKS X /* ??? */ #endif X X if (klookup((long)pteaddr, (char *)&apte, sizeof(apte)) == NULL) { X ERROR(""); X return(0); X } X #ifdef sunV3 X addr = (long)ctob(apte.pg_pfnum) + (((int)sptopte(proc, CLSIZE-1))&PGOFSET); #endif sunV3 #ifdef ibm032 X addr = (long)ctob(apte.pg_pfnum+1) - (UPAGES+CLSIZE+REDSIZE) * sizeof (struct pte); #endif ibm032 #ifdef mips X addr = (long)ctob(apte.pg_pfnum) + NBPG - ((REDZONEPAGES+1) * sizeof(struct pte)); #endif mips #ifdef VXWORKS X /* ??? */ #endif X X lseek(mem, addr, 0); #ifdef sunV3 X if (read(mem, (char *)arguutl, sizeof(struct pte)) != sizeof(struct pte)) { #else X if (read(mem, (char *)arguutl, sizeof(arguutl)) != sizeof(arguutl)) { #endif X printf("can't read page table for u of pid %d from /dev/mem\n", X proc->p_pid); X return (0); X } X X X if (arguutl[0].pg_fod == 0 && arguutl[0].pg_pfnum) { X argaddr = ctob(arguutl[0].pg_pfnum); X } else { X argaddr = 0; X } X X X #ifdef mips X if (klookup((long)proc->p_addr, (char *)wpte, sizeof(wpte)) == NULL) { X return(0); X } #endif mips X X X #ifdef sunV3 X X pteaddr = &Usrptmap[btokmx(proc->p_addr)]; X if (klookup((long)pteaddr, (char *)&apte, sizeof(apte)) == NULL) { X return(0); X } X addr = (long)ctob(apte.pg_pfnum) + (((int)proc->p_addr)&PGOFSET); X lseek(mem, addr, 0); X if (read(mem, (char *)uutl, sizeof(uutl)) != sizeof(uutl)) { X printf("cant read page table for u of pid %d from /dev/mem\n", X proc->p_pid); X return (0); X } X #endif sunV3 X #ifdef VXWORKS X /* ??? */ #endif X X ncl = (size + NBPG*CLSIZE - 1) / (NBPG*CLSIZE); X X while (--ncl >= 0) { X i = ncl * CLSIZE; #ifdef ibm032 X addr = (long)ctob(arguutl[CLSIZE+REDSIZE+i].pg_pfnum); X X if (addr == 0) { X bzero((char *) &u, sizeof (struct user)); X return(1); /* faked for swapper */ X } #endif #ifdef mips X addr = (long)ctob(wpte[i].pg_pfnum); #endif mips #ifdef sunV3 X addr = (long)ctob(uutl[i].pg_pfnum); #endif sunV3 #ifdef VXWORKS X /* ??? */ #endif X X lseek(mem, addr, 0); X if (read(mem, user.upages[i], CLSIZE*NBPG) != CLSIZE*NBPG) { X printf("cant read page from /dev/mem\n"); X return(0); X } X } X X #ifdef ibm032 X if ((i = usersize - sizeof (struct user)) > 0) X bcopy(((char *) &U) - i, (char *) &u, sizeof (struct user)); X /* fake the location of the u structure */ X else X u = U; /* return the structure */ #endif X X } X X #ifdef sunV3 X if (u.u_ssize == 0) { X (void) strcpy(buf, " ("); X (void) strncat(buf, u.u_comm, sizeof (u.u_comm)); X (void) strcat(buf, ")"); X return strlen(buf); X } #endif sunV3 X X if ((proc->p_flag & SLOAD) == 0 || argaddr == 0){ #if !defined(ibm032) || !defined(BSD4_3) X vstodb(0, CLSIZE, &u.u_smap, &db, 1); #else X vstodb(CLSIZE, CLSIZE, &u.u_smap, &db, 1); #endif X X lseek(swap, (long)dtob(db.db_base), 0); X if (read(swap, (char *)&argspac, sizeof(argspac)) != sizeof(argspac)) { X ERROR(""); X } X } else { X lseek(mem, (long)argaddr, 0); X if (read(mem, (char *)&argspac, sizeof(argspac)) != sizeof(argspac)) { X ERROR(""); X } X } X #if defined(ibm032) && defined(NFL) && !defined(BSD4_3) X ip = &argspac.argi[CLSIZE*NBPG/sizeof (int)]; X ip -= sizeof (struct fp_mach) / sizeof (int); X ip -= 2; /* last arg word and .long 0 */ #endif ibm032 #ifdef sunV3 X ip = &argspac.argi[CLSIZE*NBPG/sizeof (int)]; X ip -= 2; #endif #ifdef mips X ip = &argspac.argi[(CLSIZE*NBPG-EA_SIZE)/sizeof (int)]; X while (*--ip == 0) { X if (ip == argspac.argi) { X (void) strcpy(buf, " ("); X (void) strncat(buf, u.u_comm, sizeof (u.u_comm)); X (void) strcat(buf, ")"); X return strlen(buf); X } X } #endif mips #ifdef VXWORKS X /* ??? */ #endif X X while (*--ip) X if (ip == argspac.argi){ X (void) strcpy(buf, " ("); X (void) strncat(buf, u.u_comm, sizeof (u.u_comm)); X (void) strcat(buf, ")"); X return strlen(buf); X } X *(char *)ip = ' '; X ip++; X X nbad = 0; X #ifndef mips X for (cp = (char *)ip; cp < &argspac.argc[CLSIZE*NBPG]; cp++) { #else X for (cp = (char *)ip; cp < &argspac.argc[CLSIZE*NBPG-EA_SIZE]; cp++) { #endif mips X c = *cp & 0177; X if (c == 0) { X *cp = ' '; X } else if (c < ' ' || c > 0176) { X if (++nbad >= 5) { X *cp++ = ' '; X break; X } X *cp = '?'; X } else if (c == '=') { X while (*--cp != ' ') X if (cp <= (char *)ip) { X break; X } X break; X } X } X X *cp = 0; X while (*--cp == ' ') { X *cp = 0; X } X cp = (char *)ip; X strncpy(buf, cp, &argspac.argc[CLSIZE*NBPG] - cp); X if (cp[0] == '-' || cp[0] == '?' || cp[0] <= ' ') { X (void) strcat(buf, " ("); X (void) strncat(buf, u.u_comm, sizeof(u.u_comm)); X (void) strcat(buf, ")"); X } X return strlen(buf); } X X X X X vstodb(vsbase, vssize, dmp, dbp, rev) X register int vsbase; X int vssize; X struct dmap *dmp; X register struct dblock *dbp; { X int dmmin, dmmax, nswap; X register int blk; X register swblk_t *ip = dmp->dm_map; X X if (KNLookup(N_DMMIN, (char *)&dmmin, sizeof(dmmin)) == NULL || X KNLookup(N_DMMAX, (char *)&dmmax, sizeof(dmmax)) == NULL || X KNLookup(N_NSWAP, (char *)&nswap, sizeof(nswap)) == NULL) { X ERROR(""); X return(0); X } X X blk = dmmin; X vsbase = ctod(vsbase); X vssize = ctod(vssize); X if (vsbase < 0 || vsbase + vssize > dmp->dm_size) { X ERROR("vstodb\n"); X return(0); X } X while (vsbase >= blk) { X vsbase -= blk; X if (blk < dmmax) { X blk *= 2; X } X ip++; X } X if (*ip <= 0 || *ip + blk > nswap) { X ERROR("vstodb *ip\n"); X return(0); X } X dbp->db_size = (vssize < (blk - vsbase)) ? vssize : (blk - vsbase); X dbp->db_base = *ip + (rev ? blk - (vsbase + dbp->db_size) : vsbase); } X #endif X X X X X SHAR_EOF echo 'File snmp2/agent/snmp_vars.c is complete' && $shar_touch -am 1015123693 'snmp2/agent/snmp_vars.c' && chmod 0644 'snmp2/agent/snmp_vars.c' || echo 'restore of snmp2/agent/snmp_vars.c failed' shar_count="`wc -c < 'snmp2/agent/snmp_vars.c'`" test 113800 -eq "$shar_count" || echo "snmp2/agent/snmp_vars.c: original size 113800, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/snmp_vars.h ============== if test -f 'snmp2/agent/snmp_vars.h' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/snmp_vars.h (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/snmp_vars.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/snmp_vars.h' && /* X * Definitions for SNMP (RFC 1067) agent variable finder. X * X */ /*********************************************************** X Copyright 1988, 1989 by Carnegie Mellon University X Copyright 1989 TGV, Incorporated X X All Rights Reserved X Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of CMU and TGV not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. X CMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ X 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(); u_char *var_process(); u_char *var_event(); u_char *var_capture(); u_char *var_demo(); u_char *getStatPtr(); X #ifdef VXWORKS u_char *var_sscl_vxboot (); u_char *var_sscl_vxclock (); u_char *var_sscl_snmpd (); u_char *var_sscl_idle (); u_char *var_sscl_system (); #endif X X extern long long_return; extern u_char return_buf[]; X #define INST 0xFFFFFFFF /* used to fill out the instance field of the variables table */ X /* X * These are unit magic numbers for each variable. X */ X #define VERSION_DESCR 0 #define VERSION_ID 1 #define IFNUMBER 2 #define UPTIME 3 #define SYSCONTACT 4 #define SYSNAME 5 #define SYSLOCATION 6 #define SYSSERVICES 7 X #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 X #define ATIFINDEX 0 #define ATPHYSADDRESS 1 #define ATNETADDRESS 2 X #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 X #define IPADADDR 1 #define IPADIFINDEX 2 #define IPADNETMASK 3 #define IPADBCASTADDR 4 X #define IPROUTEDEST 0 #define IPROUTEIFINDEX 1 #define IPROUTEMETRIC1 2 #define IPROUTEMETRIC2 3 #define IPROUTEMETRIC3 4 #define IPROUTEMETRIC4 5 #define IPROUTENEXTHOP 6 #define IPROUTETYPE 7 #define IPROUTEPROTO 8 #define IPROUTEAGE 9 X #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 X #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 X #define UDPINDATAGRAMS 0 #define UDPNOPORTS 1 #define UDPINERRORS 2 #define UDPOUTDATAGRAMS 3 X #ifdef VXWORKS #define VXBOOT_DEV 0 #define VXBOOT_HOST 1 #define VXBOOT_TARGET 2 #define VXBOOT_EAD 3 #define VXBOOT_BAD 4 #define VXBOOT_HAD 5 #define VXBOOT_GAD 6 #define VXBOOT_BOOTFILE 7 #define VXBOOT_STARTUP 8 #define VXBOOT_USR 9 #define VXBOOT_PASSWD 10 #define VXBOOT_OTHER 11 #define VXBOOT_PROCNUM 12 #define VXBOOT_FLAGS 13 X #define VXCLOCK_RATE 0 #define VXCLOCK_TICKS 1 X #define SNMPD_AGNT_VER 0 #define SNMPD_PORT_VER 1 #define SNMPD_PRIORITY 2 X #define IDLE_CURRENT 0 #define IDLE_10SEC 1 #define IDLE_60SEC 2 #define IDLE_USERSEC 3 #define IDLE_USERINTER 4 #define IDLE_CALIB 5 #define IDLE_HISTSIZE 6 #define IDLE_HISTVALID 7 X #define SYSTEM_REBOOT 0 #define SYSTEM_VME 1 #define SYSTEM_ABORT 2 #define SYSTEM_SILENT 3 #define SYSTEM_SPURIOUS 4 X #endif X struct variable { X u_char magic; /* passed to function as a hint */ X char type; /* type of variable */ /* See important comment in snmp_vars.c relating to acl */ X u_short acl; /* access control list for variable */ X u_char *(*findVar)(); /* function that finds variable */ X u_char namelen; /* length of above */ X oid name[32]; /* object identifier of variable */ }; SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/snmp_vars.h' && chmod 0644 'snmp2/agent/snmp_vars.h' || echo 'restore of snmp2/agent/snmp_vars.h failed' shar_count="`wc -c < 'snmp2/agent/snmp_vars.h'`" test 6050 -eq "$shar_count" || echo "snmp2/agent/snmp_vars.h: original size 6050, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/Makefile ============== if test -f 'snmp2/agent/Makefile' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/Makefile (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/Makefile (binary)' sed 's/^X//' << 'SHAR_EOF' > _sharuue.tmp && begin 600 snmp2/agent/Makefile M(PHC($UA:V5F:6QE(&9OTE.0TQ5 M1$53?2`M1$1%0E5'"D-#(#UC8PIA;&PZ("0H5$%21RD*"G-N;7!D.@ES;FUP M9"YO(&ME'1?=F%RT-#?2`M;R`D0"!S;FUP9"YO(&ME M5]V87)S+F,@8V]N=&5X=%]V87)S+F,@86-L7W9A2YC("XN+W-N;7!L:6(O8V]N=&5X="YC("XN+W-N;7!L:6(O M<&%R='E?<&%R'1?<&%R7-T96TN;R`N+B]L:6(O;&EB9&5S+F$@+VQI8B]L:6)C+F$* M"2-L;V%D("0H0T9,04=3*2!S;FUP9"YC(&ME5]P87)S92YO M("XN+W-N;7!L:6(O8V]N=&5X=%]P87)S92YO("XN+W-N;7!L:6(O5]V87)S+F\Z("XN+W-N;7!L:6(O<&%R='DN:`IC;VYT97AT7W9A _sharnew.tmp echo 'x - extracting snmp2/agent/Makefile.unix (binary)' sed 's/^X//' << 'SHAR_EOF' > _sharuue.tmp && begin 600 snmp2/agent/Makefile.unix M(PHC($UA:V5F:6QE(&9OTE.0TQ5 M1$53?2`M1$1%0E5'"D-#(#UC8PIA;&PZ("0H5$%21RD*"G-N;7!D.@ES;FUP M9"YO(&ME'1?=F%RT-#?2`M;R`D0"!S;FUP9"YO(&ME M5]V87)S+F,@8V]N=&5X=%]V87)S+F,@86-L7W9A2YC("XN+W-N;7!L:6(O8V]N=&5X="YC("XN+W-N;7!L:6(O M<&%R='E?<&%R'1?<&%R7-T96TN;R`N+B]L:6(O;&EB9&5S+F$@+VQI8B]L:6)C+F$* M"2-L;V%D("0H0T9,04=3*2!S;FUP9"YC(&ME5]P87)S92YO M("XN+W-N;7!L:6(O8V]N=&5X=%]P87)S92YO("XN+W-N;7!L:6(O5]V87)S+F\Z("XN+W-N;7!L:6(O<&%R='DN:`IC;VYT97AT7W9A _sharnew.tmp echo 'x - extracting snmp2/agent/Makefile.vxWorks (binary)' sed 's/^X//' << 'SHAR_EOF' > _sharuue.tmp && begin 600 snmp2/agent/Makefile.vxWorks M(PHC($UA:V5F:6QE(&9O5]V87)S+F,@8V]N=&5X=%]V87)S+F,@86-L M7W9A2YC("XN+W-N;7!L:6(O8V]N=&5X M="YC("XN+W-N;7!L:6(O<&%R='E?<&%R'1?<&%R7-T96TN;R`N+B]L:6(O;&EB9&5S M+F$@+VQI8B]L:6)C+F$*"F-L96%N.@H)U1!4D=]("XN+V)I;@H*<&%R='E?=F%R _sharnew.tmp echo 'x - extracting snmp2/agent/acl.conf (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/acl.conf' && # entries are in the following format: # targetParty sourceParty privileges # where privileges is [gnsrt]* # and g = get, n = getnext, s = set, r = get Response, and t = trap X #for example: #partyAdmin.initialPartyId.128.2.35.55.1 partyAdmin.initialPartyId.128.2.35.55.2 GN #partyAdmin.initialPartyId.128.2.35.55.2 partyAdmin.initialPartyId.128.2.35.55.1 RT X X.1.3.6.1.5.1.4.128.2.35.55.1 .1.3.6.1.5.1.4.128.2.35.55.2 GN X.1.3.6.1.5.1.4.128.2.35.55.2 .1.3.6.1.5.1.4.128.2.35.55.1 RT X X.1.3.6.1.5.1.4.128.2.35.55.3 .1.3.6.1.5.1.4.128.2.35.55.4 GNS X.1.3.6.1.5.1.4.128.2.35.55.4 .1.3.6.1.5.1.4.128.2.35.55.3 RT X X.1.3.6.1.5.1.4.128.2.35.55.5 .1.3.6.1.5.1.4.128.2.35.55.6 GNS X.1.3.6.1.5.1.4.128.2.35.55.6 .1.3.6.1.5.1.4.128.2.35.55.5 RT X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/acl.conf' && chmod 0644 'snmp2/agent/acl.conf' || echo 'restore of snmp2/agent/acl.conf failed' shar_count="`wc -c < 'snmp2/agent/acl.conf'`" test 730 -eq "$shar_count" || echo "snmp2/agent/acl.conf: original size 730, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/acl_vars.c ============== if test -f 'snmp2/agent/acl_vars.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/acl_vars.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/acl_vars.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/acl_vars.c' && #ifdef VXWORKS #include "VXtypes.h" #include "VXtime.h" #else #include #include #endif X #include "asn1.h" #include "snmp.h" #include "snmp_impl.h" #include "snmp_vars.h" X #include "acl.h" X #define OIDCMP(l1, l2, o1, o2) (((l1) == (l2)) \ X && !bcmp((char *)(o1), (char *)(o2), \ X (l1)*sizeof(oid))) X #define ACLTARGET_MASK 0x01 #define ACLSUBJECT_MASK 0x02 #define ACLRESOURCES_MASK 0x04 #define ACLPRIVILEGES_MASK 0x08 #define ACLSTORAGETYPE_MASK 0x10 #define ACLSTATUS_MASK 0x20 X #define ACLCOMPLETE_MASK 0x3F /* all columns */ X X struct aclEntry * acl_rowCreate(target, subject, resources) X int target, subject, resources; { X struct aclEntry *ap; X X ap = acl_createEntry(target, subject, resources); X ap->aclBitMask = 0; X ap->reserved->aclStatus = ACLNONEXISTENT; X X ap->aclBitMask = ap->reserved->aclBitMask = X ACLTARGET_MASK | ACLSUBJECT_MASK; X /* Watch out for this becoming permanent by accident: X * If during FREE stage below we discover row didn't exist before, X * free row. X */ X return ap; } X acl_rowDelete(target, subject, resources) X int target, subject, resources; { X acl_destroyEntry(target, subject, resources); } X /* X * If statP is non-NULL, the referenced object is at that location. X * If statP is NULL and ap is non-NULL, the instance exists, but not this variable. X * If statP is NULL and ap is NULL, then neither this instance nor the variable exists. X */ int write_acl(action, var_val, var_val_type, var_val_len, statP, name, length) X int action; X u_char *var_val; X u_char var_val_type; X int var_val_len; X u_char *statP; X oid *name; X int length; { X struct aclEntry *ap, *rp; X int var, targetlen, subjectlen; X oid *target, *subject; X long val; X int bigsize = 1000; X /* X * This routine handles requests for variables of the form: X * .iso.org.dod.internet.snmpSecrets.partyAccess.aclTable.aclEntry.X.oidlen.oid.oidlen.oid X * or .1.3.6.1.2.1.21.2.1.1.X.oidlen.oid.oidlen.oid, where the oid suffixes are X * variable length. X * Therefore, the length of the first index is name[11] and the index starts X * at name[12]. The length of the second index starts at name[12 + name[11]], X * and the second index starts at name[13 + name[1]]. X */ X if (length < 16) X return SNMP_ERR_NOCREATION; X var = name[10]; X targetlen = name[11]; X target = name + 12; X if (length <= 12 + targetlen) X return SNMP_ERR_NOCREATION; X subjectlen = name[12 + targetlen]; X subject = name + 13 + targetlen; X if (length != 13 + targetlen + subjectlen) X return SNMP_ERR_NOCREATION; X /* XXX are these length checks necessary? If not, take them out of X here and party_vars.c */ X X ap = acl_getEntry(target, targetlen, subject, subjectlen); X if (ap) X rp = ap->reserved; X if (action == RESERVE1 && !ap){ X if ((ap = acl_rowCreate(target, targetlen, X subject, subjectlen)) == NULL) X return SNMP_ERR_RESOURCEUNAVAILABLE; X rp = ap->reserved; X /* create default vals here in reserve area */ X rp->aclPriveleges = ACLPRIVELEGESGET | ACLPRIVELEGESGETNEXT; X rp->aclStatus = ACLACTIVE; X rp->aclBitMask = ACLCOMPLETE_MASK; X } else if (action == COMMIT){ X if (ap->aclStatus == ACLNONEXISTENT){ X /* commit the default vals */ X /* This haapens at most once per entry because the status is set to X valid after the first pass. After that, this commit code X does not get executed. It is also important to note that this X gets executed before any of the commits below (and never after X them), so they overlay their data on top of these defaults. X This commit code should allow for the object specific code X to have overlayed data after the code above has executed. X */ X ap->aclPriveleges = rp->aclPriveleges; X ap->aclStatus = rp->aclStatus; X ap->aclBitMask = rp->aclBitMask; X } X } else if (action == FREE){ X if (ap && ap->aclStatus == ACLNONEXISTENT){ X acl_rowDelete(target, targetlen, subject, subjectlen); X ap = rp = NULL; X } X if (ap) /* satisfy postcondition for bitMask */ X rp->aclBitMask = ap->aclBitMask; X } X /* XXX !!! check return values from the asn_parse_* routines */ X switch(var){ X case ACLPRIVELEGES: X if (action == RESERVE1){ X if (var_val_type != ASN_INTEGER) X return SNMP_ERR_WRONGTYPE; X asn_parse_int(var_val, &bigsize, &var_val_type, &val, sizeof(val)); X if (val < 0 || val > 31) X return SNMP_ERR_WRONGVALUE; X rp->aclPriveleges = val; X rp->aclBitMask |= ACLPRIVILEGES_MASK; X } else if (action == COMMIT){ X ap->aclPriveleges = rp->aclPriveleges; X } X break; X case ACLSTATUS: X if (action == RESERVE1){ X if (var_val_type != ASN_INTEGER) X return SNMP_ERR_WRONGTYPE; X asn_parse_int(var_val, &bigsize, &var_val_type, &val, sizeof(val)); X if (val < 1 || val > 2) X return SNMP_ERR_WRONGVALUE; X rp->aclStatus = val; X rp->aclBitMask |= ACLSTATUS_MASK; X } else if (action == RESERVE2){ X if ((rp->aclStatus == ACLACTIVE) X && (rp->aclBitMask != ACLCOMPLETE_MASK)) X return SNMP_ERR_INCONSISTENTVALUE; X /* tried to set incomplete row valid */ X } else if (action == COMMIT){ X ap->aclStatus = rp->aclStatus; X } else if (action == ACTION && ap->aclStatus == ACLDESTROY){ X acl_rowDelete(ap->aclTarget, ap->aclSubject, ap->aclResources); X } X break; X case ACLTARGET: X case ACLSUBJECT: X default: X return SNMP_ERR_NOCREATION; X } X if (action == COMMIT) /* make any new columns aapear */ X ap->aclBitMask = rp->aclBitMask; X X return SNMP_ERR_NOERROR; } X u_char * var_acl(vp, name, length, exact, var_len, write_method) X register struct variable *vp; /* IN - pointer to variable entry that points here */ X register oid *name; /* IN/OUT - input name requested, output name found */ X register int *length; /* IN/OUT - length of input and output oid's */ X int exact; /* IN - TRUE if an exact match was requested. */ X int *var_len; /* OUT - length of variable or 0 if function returned. */ X int (**write_method)(); /* OUT - pointer to function to set variable, otherwise 0 */ { X oid newname[MAX_NAME_LEN], lowname[MAX_NAME_LEN], *np; X int newnamelen, lownamelen; X struct aclEntry *ap, *lowap = NULL; X u_long mask; X int target, subject, resources; X /* X * This routine handles requests for variables of the form: X * X * .iso.org.dod.internet.snmpV2.snmpModules.partyMIB.partyMIBObjects X * .snmpAccess.aclTable.aclEntry.X.tgt.sub.res X * or .1.3.6.1.6.3.3.2.3.1.1.X.sub.tgt.res X * Therefore, the target is at name[12], the subject is at name[13], and X * the resources is at name[14]. X */ X X mask = 1 << (vp->magic - 1); X bcopy((char *)vp->name, (char *)newname, (int)vp->namelen * sizeof(oid)); X if (exact){ X if (*length != 15 || X bcmp((char *)name, (char *)vp->name, 12 * sizeof(oid))) X return NULL; X target = name[12]; X subject = name[13]; X resources = name[14]; X *write_method = write_acl; X ap = acl_getEntry(target, subject, resources); X if (ap == NULL) X return NULL; X if (!(ap->aclBitMask & mask)) X return NULL; X } else { X /* find "next" control entry */ X acl_scanInit(); X for(ap = acl_scanNext(); ap; ap = acl_scanNext()){ X if (!(ap->aclBitMask & mask)) X continue; X np = newname + 12; X *np++ = ap->aclTarget; X *np++ = ap->aclSubject; X *np = ap->aclResources; X newnamelen = 15; X if ((compare(newname, newnamelen, name, *length) > 0) && X (!lowap || compare(newname, newnamelen, X lowname, lownamelen) < 0)){ X /* X * if new one is greater than input and closer to input than X * previous lowest, save this one as the "next" one. X */ X bcopy((char *)newname, (char *)lowname, newnamelen * sizeof(oid)); X lownamelen = newnamelen; X lowap = ap; X } X } X if (lowap == NULL) X return NULL; X ap = lowap; X bcopy((char *)lowname, (char *)name, lownamelen * sizeof(oid)); X *length = lownamelen; X } X X *var_len = sizeof(long); X long_return = 0; X X switch (vp->magic){ X case ACLPRIVELEGES: X return (u_char *)&ap->aclPriveleges; X case ACLSTORAGETYPE: X return (u_char *)&ap->aclStorageType; X case ACLSTATUS: X return (u_char *)&ap->aclStatus; X default: X ERROR(""); X } X return NULL; } X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/acl_vars.c' && chmod 0644 'snmp2/agent/acl_vars.c' || echo 'restore of snmp2/agent/acl_vars.c failed' shar_count="`wc -c < 'snmp2/agent/acl_vars.c'`" test 8348 -eq "$shar_count" || echo "snmp2/agent/acl_vars.c: original size 8348, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/alarm.c ============== if test -f 'snmp2/agent/alarm.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/alarm.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/alarm.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/alarm.c' && /*********************************************************** X Copyright 1992 by Carnegie Mellon University X X All Rights Reserved X Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of CMU not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. X CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ X /* alarm.c: implement the alarm group of the RMON MIB */ X #include #ifdef VXWORKS #include "vxWorks.h" #include "VXtime.h" #else #include #include #endif /* #include */ #include #include #include #include #include #include #include "party.h" #include "context.h" #include "snmp_vars.h" #include "snmp.h" #include "m2m.h" #include "snmp_vars_m2m.h" #include "event.h" #include "alarm.h" #include "system.h" X static struct alarmEntry *alarmTab = NULL; static long alarmNextIndex = 1; X /* retrieve the given variable from the MIB. Returns 0 on success, ** 1 if the request was asynchronously transmitted to another host, ** and another value on errors. */ static int rmonGetValue(srcParty, srcPartyLen, dstParty, dstPartyLen, X context, contextLen, variable, variableLen, value, alarm) X oid *srcParty, *dstParty, *context; X int srcPartyLen, dstPartyLen, contextLen; X oid *variable; X int variableLen; /* number of subids in variable */ X long *value; X struct alarmEntry *alarm; { X oid bigVar[MAX_OID_LEN]; X int bigVarLen; X u_char type; X int len; X u_short acl; X int (*writeFunc)(); X u_char *var; X struct packet_info pinfo, *pi = &pinfo; X int noSuchObject; X struct partyEntry *srcp, *dstp; X struct contextEntry *cxp; X struct snmp_session session; X struct snmp_pdu *pdu; X struct variable_list *varList; X u_long addr; X struct get_req_state *state; X extern int snmp_input(); X X /* whether it's local or non-local, I have to know about the X parties and context */ X if (((srcp = party_getEntry(srcParty, srcPartyLen)) == NULL) X || ((dstp = party_getEntry(dstParty, dstPartyLen)) == NULL) X || ((cxp = context_getEntry(context, contextLen)) == NULL)) X return 2; X X addr = get_myaddr(); X if (bcmp(dstp->partyTAddress, &addr, 4)) { X /* this is a different IP address, so it must be non-local */ X if (alarm->ss == NULL) { X state = (struct get_req_state *)malloc(sizeof(struct get_req_state)); X state->type = ALARM_GET_REQ; X state->info = (void *)alarm; X alarm->magic = state; X bzero((char *)&session, sizeof(struct snmp_session)); X session.peername = SNMP_DEFAULT_PEERNAME; X session.version = SNMP_VERSION_2; X session.srcParty = srcParty; X session.srcPartyLen = srcPartyLen; X session.dstParty = dstParty; X session.dstPartyLen = dstPartyLen; X session.context = context; X session.contextLen = contextLen; X session.retries = 4; X session.timeout = 500000L; /* one half second */ X session.callback = snmp_input; X session.callback_magic = (void *)state; X alarm->ss = snmp_open(&session); X if (!alarm->ss) { X ERROR(""); X return 3; X } X } X X pdu = snmp_pdu_create(GET_REQ_MSG); X bcopy(dstp->partyTAddress, (char *)&pdu->address.sin_addr.s_addr, 4); X bcopy(dstp->partyTAddress + 4, &pdu->address.sin_port, 2); X pdu->address.sin_family = AF_INET; X varList = (struct variable_list *)malloc(sizeof(struct variable_list)); X X varList->name = (oid *)malloc(variableLen * sizeof(oid)); X bcopy(variable, varList->name, variableLen * sizeof(oid)); X varList->name_length = variableLen; X varList->type = ASN_NULL; X varList->val_len = 0; X varList->val.integer = NULL; X varList->next_variable = NULL; X X pdu->variables = varList; X alarm->reqid = snmp_send(alarm->ss, pdu); X return 1; /* this means the request has been sent */ X } X X if (!has_access(GET_REQ_MSG, srcp->partyIndex, dstp->partyIndex, X cxp->contextIndex)) X return 5; X if (!has_access(GET_RSP_MSG, dstp->partyIndex, srcp->partyIndex, X cxp->contextIndex)) X return 4; X X bcopy(srcParty, pi->srcParty, srcPartyLen * sizeof(oid)); X pi->srcPartyLength = srcPartyLen; X bcopy(dstParty, pi->dstParty, dstPartyLen * sizeof(oid)); X pi->dstPartyLength = dstPartyLen; X bcopy(context, pi->context, contextLen * sizeof(oid)); X pi->contextLength = contextLen; X pi->srcp = srcp; X pi->dstp = dstp; X pi->cxp = cxp; X X pi->version = SNMP_VERSION_2; X pi->pdutype = GET_REQ_MSG; X /* rest of pi is not needed */ X X bcopy((char *)variable, (char *)bigVar, variableLen * sizeof(oid)); X bigVarLen = variableLen; X X var = getStatPtr(bigVar, &bigVarLen, &type, &len, &acl, 1, &writeFunc, pi, X &noSuchObject); X if (var == NULL) { X return 6; X } X X if ((type != INTEGER) && (type != COUNTER) && X (type != TIMETICKS) && (type != GAUGE) && X (type != COUNTER64)) { X return 7; X } X X *value = *(int *)var; X return 0; } X /* add the time values t1 and t2, and store the sum in result. This ** routine accounts for tv_usec overflow. */ static void timeradd(result, t1, t2) X struct timeval *result, *t1, *t2; { X result->tv_usec = t1->tv_usec + t2->tv_usec; X result->tv_sec = t1->tv_sec + t2->tv_sec; X while (result->tv_usec > 1000000L) { X (result->tv_usec) -= 1000000L; X (result->tv_sec)++; X } } X /* insert the given row into the alarm table, ordered by index */ static void alarmInsertRow(alarm) X struct alarmEntry *alarm; { X struct alarmEntry *current; X struct alarmEntry *prev; X X for (current = alarmTab, prev = NULL; current; current = current->next) { X if (current->index > alarm->index) { X break; X } X prev = current; X } X X /* put the new entry before "current" */ X alarm->next = current; X if (prev) { X prev->next = alarm; X } X else { X /* this is first on the list */ X alarmTab = alarm; X } } X /* free the shadow space that was allocated to this row */ static void alarmFreeShadow(alarm) X struct alarmEntry *alarm; { X if (alarm->shadow == NULL) { X return; X } X X free((char *)alarm->shadow); X alarm->shadow = NULL; } X /* delete the given row from the alarm table, and free the memory ** associated with it. */ static void alarmDeleteRow(alarm) X struct alarmEntry *alarm; { X struct alarmEntry *temp; X struct alarmEntry *prev = NULL; X X for (temp = alarmTab; temp; temp = temp->next) { X if (temp == alarm) { X /* this is the one to remove */ X if (prev) { X prev->next = temp->next; X } X else { X /* this is the first on the list */ X alarmTab = temp->next; X } X break; X } X prev = temp; X } X X /* KLF debugging */ X if (temp == NULL) { X printf("alarmDeleteRow: didn't find row (%d) in alarmTab\n", X alarm->index); X } X X if (alarm->ss) { X snmp_close(alarm->ss); X free((char *)alarm->magic); X } X alarmFreeShadow(alarm); X /* KLF alarmFreeEntries(alarm); */ X free((char *)alarm); } X /* create a shadow structure for the given row, and copy the world-visible ** data into the shadow structure. Returns 1 on success, 0 otherwise. */ static int alarmShadowRow(alarm) struct alarmEntry *alarm; { X int i = 0; X X if (alarm->shadow != NULL) { X /* it's already been created */ X return 1; X } X X alarm->shadow = (struct alarmEntry *)malloc(sizeof(struct alarmEntry)); X while ((alarm->shadow == NULL) && (i++ < 5)) { X eventFreeSpace(); X alarm->shadow = (struct alarmEntry *)malloc(sizeof(struct alarmEntry)); X } X if (alarm->shadow == NULL) { X /* no more memory */ X return 0; X } X X bcopy((char *)alarm, (char *)alarm->shadow, sizeof(struct alarmEntry)); X X return 1; } X /* return a pointer to the given row in the alarmTab */ static struct alarmEntry * alarmGetRow(context, contextLen, index) X oid *context; X int contextLen; X int index; { X struct alarmEntry *alarm; X X for (alarm = alarmTab; alarm; alarm = alarm->next) { X if (alarm->index == index X && alarm->contextLength == contextLen X && !bcmp(alarm->contextID, context, X contextLen * sizeof(oid))) { X return alarm; X } X } X X return NULL; } X /* return a pointer to the given row in the alarmTab */ static struct alarmEntry * alarmGetRowByIndex(index) X int index; { X struct alarmEntry *alarm; X X for (alarm = alarmTab; alarm; alarm = alarm->next) { X if (alarm->index == index) { X return alarm; X } X } X X return NULL; } X /* create a new row for the alarm table, with the given index. ** Create a shadow for the row. Put default values into the shadow. ** Return a pointer to the new row. This routine does not check that ** the index has not already been used, and does not make the row ** visible to a management station that is doing a walk of the table. ** It makes sure the index is in the valid range. */ static struct alarmEntry * alarmNewRow(context, contextLen, index) X oid *context; X int contextLen; X int index; { X struct alarmEntry *alarm; X int i = 0; SHAR_EOF : || echo 'restore of snmp2/agent/alarm.c failed' fi echo 'End of snmp2 part 32' echo 'File snmp2/agent/alarm.c is continued in part 33' echo 33 > _sharseq.tmp exit 0