#!/bin/sh # This is `snmp2.37' (part 37 of snmp2). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `snmp2/agent/snmp_vars_m2m.h' 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" != 37; 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_m2m.h' else echo 'x - continuing file snmp2/agent/snmp_vars_m2m.h' sed 's/^X//' << 'SHAR_EOF' >> 'snmp2/agent/snmp_vars_m2m.h' && X Copyright 1988, 1989 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 /* various OIDs that are needed throughout the agent */ extern oid alarmVariableOid[]; extern int alarmVariableOidLen; extern oid alarmSampleTypeOid[]; extern int alarmSampleTypeOidLen; extern oid alarmValueOid[]; extern int alarmValueOidLen; extern oid alarmFallingThreshOid[]; extern int alarmFallingThreshOidLen; extern oid alarmRisingThreshOid[]; extern int alarmRisingThreshOidLen; extern oid eventIdOid[]; extern int eventIdOidLen; extern oid sysUpTimeOid[]; extern int sysUpTimeOidLen; extern oid trapRisingAlarmOid[]; extern int trapRisingAlarmOidLen; extern oid trapFallingAlarmOid[]; extern int trapFallingAlarmOidLen; extern oid trapObjUnavailAlarmOid[]; extern int trapObjUnavailAlarmOidLen; 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 magic numbers for each variable. X */ X #define ALARMNEXTINDEX 1 #define ALARMTABINDEX 1 #define ALARMTABVARIABLE 2 #define ALARMTABINTERVAL 3 #define ALARMTABSAMPLETYPE 4 #define ALARMTABVALUE 5 #define ALARMTABSTARTUPALARM 6 #define ALARMTABRISINGTHRESH 7 #define ALARMTABFALLINGTHRESH 8 #define ALARMTABRISINGINDEX 9 #define ALARMTABFALLINGINDEX 10 #define ALARMTABUNAVAILABLEINDEX 11 #define ALARMTABSTATUS 12 X #define EVENTNEXTINDEX 1 #define EVENTTABINDEX 1 #define EVENTTABID 2 #define EVENTTABDESCRIPTION 3 #define EVENTTABEVENTS 4 #define EVENTTABLASTTIMESENT 5 #define EVENTTABSTATUS 6 #define EVENTMININTERVAL 3 #define EVENTMAXRETRANS 4 #define EVENTNOTIFYTABINTERVAL 1 #define EVENTNOTIFYTABRETRANSMISSIONS 2 #define EVENTNOTIFYTABLIFETIME 3 #define EVENTNOTIFYTABSTATUS 4 SHAR_EOF echo 'File snmp2/agent/snmp_vars_m2m.h is complete' && $shar_touch -am 1015123693 'snmp2/agent/snmp_vars_m2m.h' && chmod 0644 'snmp2/agent/snmp_vars_m2m.h' || echo 'restore of snmp2/agent/snmp_vars_m2m.h failed' shar_count="`wc -c < 'snmp2/agent/snmp_vars_m2m.h'`" test 2839 -eq "$shar_count" || echo "snmp2/agent/snmp_vars_m2m.h: original size 2839, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/snmpd.c ============== if test -f 'snmp2/agent/snmpd.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/snmpd.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/snmpd.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/snmpd.c' && /* X * snmpd.c - rrespond to SNMP queries from management stations X * X */ /*********************************************************** X Copyright 1988, 1989 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. ******************************************************************/ #include #ifdef VXWORKS #include #include "VXtime.h" #include #else #include #include #include #include #endif #include #include #include #include X #ifdef VXWORKS #else #include #endif X #include "snmp.h" #include "asn1.h" #include "snmp_impl.h" #include "system.h" #include "snmp_api.h" #include "m2m.h" #include "party.h" #include "alarm.h" #include "view.h" #include "context.h" #include "acl.h" X extern int errno; X #ifdef VXWORKS /* snmp_dump_packets is defined in snmplib for vxWorks version */ #else int snmp_dump_packet = 0; #endif X int log_addresses = 0; X struct addrCache { X u_long addr; X int status; #define UNUSED 0 #define USED 1 #define OLD 2 }; X static struct addrCache addrCache[10]; static int lastAddrAge = 0; X X #ifndef FD_SET #include typedef long fd_mask; #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ X #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) X #endif X /* X * In: My ip address, View subtree X * Initializes a noAuth/noPriv party pair, a context, 2 acl entries, and X * a view subtree. (Are two acl entries really needed?) X * The view subtree is included by default and has no Mask. X * Out: returns 0 if OK, 1 if conflict with a pre-installed X * party/context/acl/view, -1 if an error occurred. X */ agent_party_init(myaddr, view) X u_long myaddr; X char *view; { X u_long addr; X u_short port; X oid partyid1[64]; X int partyidlen1; X oid partyid2[64]; X int partyidlen2; X oid contextid[64]; X int contextidlen; X struct partyEntry *pp1, *pp2, *rp; X struct contextEntry *cxp, *rxp; X int viewIndex; X oid viewSubtree[64]; X int viewSubtreeLen; X struct viewEntry *vwp; X struct aclEntry *ap; X int oneIndex, twoIndex, cxindex; X X X /* X * Check for existence of the party, context, acl, and view and X * exit if any of them exist. We must create the parties to get the X * partyIndexes for acl creation, so we delete these parties if we X * fail anywhere else. X */ X /* This would be better written as follows: X We currently check for the existence of each of the X src/dst/context/acl/view entries before creating anything. X The problem is that in order to check for the existence of the X acl entry, we need to create the src/dst/context to get their X indexes. So we create them with the proviso that we delete them X if checks for other src/dst/context/view/acl fail. [BUG: we don't X delete context and view if acl fails or context if view fails]. X Observation: Because each index for the acl table is taken from X a newly-created and therefore unique src/dst/context index, there X is no reason to check for the existence of such an acl entry. X Therefore, there is no reason to create the party entries until X *after* we have checked everything. This greatly simplifies this code. X In addition, nobody cares what the view index is, so there is no need X to check for the view's existence (just choose something that isn't X in use. X X Suggestion: X check src X check dst X check context X if any used, fail 1 X create src, dst, context X create acl(src.index, dst.index, context.index) and its brother X find an unused view index (preferably one) X create viewEntry(viewIndex, viewSubtree) X context.viewIndex = viewIndex X */ X partyidlen1 = 64; X if (!read_objid(".1.3.6.1.6.3.3.1.3.128.2.35.55.1", X partyid1, &partyidlen1)){ X fprintf(stderr, "Bad object identifier: %s\n", X ".1.3.6.1.6.3.3.1.3.128.2.35.55.1"); X return -1; X } X partyid1[9] = (myaddr & 0xFF000000) >> 24; X partyid1[10] = (myaddr & 0x00FF0000) >> 16; X partyid1[11] = (myaddr & 0x0000FF00) >> 8; X partyid1[12] = (myaddr & 0x000000FF); X partyid1[13] = 1; X pp1 = party_getEntry(partyid1, partyidlen1); X if (pp1){ X return 1; X } X pp1 = party_createEntry(partyid1, partyidlen1); X oneIndex = pp1->partyIndex; X X partyidlen2 = 64; X if (!read_objid(".1.3.6.1.6.3.3.1.3.128.2.35.55.1", X partyid2, &partyidlen2)){ X fprintf(stderr, "Bad object identifier: %s\n", X ".1.3.6.1.6.3.3.1.3.128.2.35.55.1"); X party_destroyEntry(partyid1, partyidlen1); X return -1; X } X partyid2[9] = (myaddr & 0xFF000000) >> 24; X partyid2[10] = (myaddr & 0x00FF0000) >> 16; X partyid2[11] = (myaddr & 0x0000FF00) >> 8; X partyid2[12] = (myaddr & 0x000000FF); X partyid2[13] = 2; X pp2 = party_getEntry(partyid2, partyidlen2); X if (pp2){ X party_destroyEntry(partyid1, partyidlen1); X return 1; X } X pp2 = party_createEntry(partyid2, partyidlen2); X twoIndex = pp2->partyIndex; X X contextidlen = 64; X if (!read_objid(".1.3.6.1.6.3.3.1.4.128.2.35.55.1", X contextid, &contextidlen)){ X fprintf(stderr, "Bad object identifier: %s\n", X ".1.3.6.1.6.3.3.1.4.128.2.35.55.1"); X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return -1; X } X contextid[9] = (myaddr & 0xFF000000) >> 24; X contextid[10] = (myaddr & 0x00FF0000) >> 16; X contextid[11] = (myaddr & 0x0000FF00) >> 8; X contextid[12] = (myaddr & 0x000000FF); X contextid[13] = 1; X cxp = context_getEntry(contextid, contextidlen); X if (cxp){ X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return 1; X } X X viewIndex = 1; X viewSubtreeLen = 64; X if (!read_objid(view, viewSubtree, &viewSubtreeLen)){ X fprintf(stderr, "Bad object identifier: %s\n", view); X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return -1; X } X vwp = view_getEntry(viewIndex, viewSubtree, viewSubtreeLen); X if (vwp){ X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return 1; X } X X ap = acl_getEntry(oneIndex, twoIndex, 1); X if (ap){ X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return 1; X } X ap = acl_getEntry(twoIndex, oneIndex, 1); X if (ap){ X party_destroyEntry(partyid1, partyidlen1); X party_destroyEntry(partyid2, partyidlen2); X return 1; X } X X rp = pp1->reserved; X strcpy(pp1->partyName, "noAuthAgent"); X pp1->partyTDomain = rp->partyTDomain = DOMAINSNMPUDP; X addr = htonl(myaddr); X port = htons(161); X bcopy((char *)&addr, pp1->partyTAddress, sizeof(addr)); X bcopy((char *)&port, pp1->partyTAddress + 4, sizeof(port)); X bcopy(pp1->partyTAddress, rp->partyTAddress, 6); X pp1->partyTAddressLen = rp->partyTAddressLen = 6; X pp1->partyAuthProtocol = rp->partyAuthProtocol = NOAUTH; X pp1->partyAuthClock = rp->partyAuthClock = 0; X pp1->tv.tv_sec = pp1->partyAuthClock; X pp1->partyAuthPublicLen = 0; X pp1->partyAuthLifetime = rp->partyAuthLifetime = 0; X pp1->partyPrivProtocol = rp->partyPrivProtocol = NOPRIV; X pp1->partyPrivPublicLen = 0; X pp1->partyMaxMessageSize = rp->partyMaxMessageSize = 1500; X pp1->partyLocal = 1; /* TRUE */ X pp1->partyAuthPrivateLen = rp->partyAuthPrivateLen = 0; X pp1->partyPrivPrivateLen = rp->partyPrivPrivateLen = 0; X pp1->partyStorageType = 2; /* volatile */ X pp1->partyStatus = rp->partyStatus = PARTYACTIVE; #define PARTYCOMPLETE_MASK 65535 X /* all collumns - from party_vars.c XXX */ X pp1->partyBitMask = rp->partyBitMask = PARTYCOMPLETE_MASK; X X rp = pp2->reserved; X strcpy(pp2->partyName, "noAuthMS"); X pp2->partyTDomain = rp->partyTDomain = DOMAINSNMPUDP; X bzero(pp2->partyTAddress, 6); X bcopy(pp2->partyTAddress, rp->partyTAddress, 6); X pp2->partyTAddressLen = rp->partyTAddressLen = 6; X pp2->partyAuthProtocol = rp->partyAuthProtocol = NOAUTH; X pp2->partyAuthClock = rp->partyAuthClock = 0; X pp2->tv.tv_sec = pp2->partyAuthClock; X pp2->partyAuthPublicLen = 0; X pp2->partyAuthLifetime = rp->partyAuthLifetime = 0; X pp2->partyPrivProtocol = rp->partyPrivProtocol = NOPRIV; X pp2->partyPrivPublicLen = 0; X pp2->partyMaxMessageSize = rp->partyMaxMessageSize = 484; /* ??? */ X pp2->partyLocal = 2; /* FALSE */ X pp2->partyAuthPrivateLen = rp->partyAuthPrivateLen = 0; X pp2->partyPrivPrivateLen = rp->partyPrivPrivateLen = 0; X pp2->partyStorageType = 2; /* volatile */ X pp2->partyStatus = rp->partyStatus = PARTYACTIVE; X pp2->partyBitMask = rp->partyBitMask = PARTYCOMPLETE_MASK; X X cxp = context_createEntry(contextid, contextidlen); X rxp = cxp->reserved; X strcpy(cxp->contextName, "noAuthContext"); X cxp->contextLocal = 1; /* TRUE */ X cxp->contextViewIndex = 1; X cxp->contextLocalEntityLen = 0; X cxp->contextLocalTime = CURRENTTIME; X cxp->contextProxyContextLen = 0; X cxp->contextStorageType = 2; X cxp->contextStatus = rxp->contextStatus = CONTEXTACTIVE; #define CONTEXTCOMPLETE_MASK 0x03FF X /* all collumns - from context_vars.c XXX */ X cxp->contextBitMask = rxp->contextBitMask = CONTEXTCOMPLETE_MASK; X cxindex = cxp->contextIndex; X X vwp = view_createEntry(viewIndex, viewSubtree, viewSubtreeLen); X vwp->viewType = VIEWINCLUDED; X vwp->viewMaskLen = 0; X vwp->viewStorageType = 2; /* volatile */ X vwp->viewStatus = VIEWACTIVE; #define VIEWCOMPLETE_MASK 0x3F X /* all collumns - from view_vars.c XXX */ X vwp->viewBitMask = VIEWCOMPLETE_MASK; X vwp->reserved->viewBitMask = vwp->viewBitMask; X X viewSubtreeLen = 64; X if (!read_objid(".2.6.6", viewSubtree, &viewSubtreeLen)){ X fprintf(stderr, "Bad object identifier: .2.6.6\n"); X return -1; X } X vwp = view_createEntry(viewIndex, viewSubtree, viewSubtreeLen); X vwp->viewType = VIEWINCLUDED; X vwp->viewMaskLen = 0; X vwp->viewStorageType = 2; /* volatile */ X vwp->viewStatus = VIEWACTIVE; X vwp->viewBitMask = VIEWCOMPLETE_MASK; X vwp->reserved->viewBitMask = vwp->viewBitMask; X X ap = acl_createEntry(oneIndex, twoIndex, cxindex); X ap->aclPriveleges = 132; X ap->aclStorageType = 2; /* volatile */ X ap->aclStatus = ACLACTIVE; #define ACLCOMPLETE_MASK 0x3F X /* all collumns - from acl_vars.c XXX */ X ap->aclBitMask = ACLCOMPLETE_MASK; X ap->reserved->aclBitMask = ap->aclBitMask; X X ap = acl_createEntry(twoIndex, oneIndex, cxindex); X /* To play around with SETs with a minimum of hassle, set this to 43 X and noAuth/noPriv parties will be able to set in this default view. X Remember to turn it back off when you're done! */ X ap->aclPriveleges = 35; X ap->aclStorageType = 2; /* volatile */ X ap->aclStatus = ACLACTIVE; X ap->aclBitMask = ACLCOMPLETE_MASK; X ap->reserved->aclBitMask = ap->aclBitMask; X X return 0; /* SUCCESS */ } X #ifdef VXWORKS snmpdMain (argc, argv) #else main(argc, argv) #endif X int argc; X char *argv[]; { X int arg; X int sd, sdlist[32], portlist[32], sdlen = 0, index; X struct sockaddr_in me; X int port_flag = 0, ret; X u_short dest_port = 0; X struct partyEntry *pp; X u_long myaddr; X X X /* X * usage: snmpd X */ X for(arg = 1; arg < argc; arg++){ X if (argv[arg][0] == '-'){ X switch(argv[arg][1]){ X case 'd': X snmp_dump_packet++; X break; X case 'p': X port_flag++; X dest_port = atoi(argv[++arg]); X break; X case 'a': X log_addresses++; X break; X default: X printf("invalid option: -%c\n", argv[arg][1]); X break; X } X continue; X } X } X init_snmp(); X init_mib(); X if (read_party_database("/etc/party.conf") > 0){ X fprintf(stderr, "Couldn't read party database from /etc/party.conf\n"); X exit(0); X } X if (read_context_database("/etc/context.conf") > 0){ X fprintf(stderr, "Couldn't read context database from /etc/context.conf\n"); X exit(0); X } X if (read_acl_database("/etc/acl.conf") > 0){ X fprintf(stderr, "Couldn't read acl database from /etc/acl.conf\n"); X exit(0); X } X if (read_view_database("/etc/view.conf") > 0){ X fprintf(stderr, "Couldn't read view database from /etc/view.conf\n"); X exit(0); X } X X myaddr = get_myaddr(); X /* XXX mib-2 subtree only??? */ X if (ret = agent_party_init(myaddr, ".iso.org.dod.internet")){ X if (ret == 1){ X fprintf(stderr, "Conflict found with initial noAuth/noPriv parties... continuing\n"); X } else if (ret == -1){ X fprintf(stderr, "Error installing initial noAuth/noPriv parties, exiting\n"); X exit(1); X } else { X fprintf(stderr, "Unknown error, exiting\n"); X exit(2); X } X } X X printf("Opening port(s): "); X fflush(stdout); X party_scanInit(); X for(pp = party_scanNext(); pp; pp = party_scanNext()){ X if ((pp->partyTDomain != DOMAINSNMPUDP) X || bcmp((char *)&myaddr, pp->partyTAddress, 4)) X continue; /* don't listen for non-local parties */ X X dest_port = 0; X bcopy(pp->partyTAddress + 4, &dest_port, 2); X for(index = 0; index < sdlen; index++) X if (dest_port == portlist[index]) X break; X if (index < sdlen) /* found a hit before the end of the list */ X continue; X printf("%u ", dest_port); X fflush(stdout); X /* Set up connections */ X sd = socket(AF_INET, SOCK_DGRAM, 0); X if (sd < 0){ X perror("socket"); X return 1; X } X me.sin_family = AF_INET; X me.sin_addr.s_addr = INADDR_ANY; X /* already in network byte order (I think) */ X me.sin_port = dest_port; X if (bind(sd, (struct sockaddr *)&me, sizeof(me)) != 0){ X perror("bind"); X return 2; X } X sdlist[sdlen] = sd; X portlist[sdlen] = dest_port; X if (++sdlen == 32){ X printf("No more sockets... ignoring rest of file\n"); X break; X } X } X printf("\n"); X bzero((char *)addrCache, sizeof(addrCache)); X receive(sdlist, sdlen); X return 0; } X receive(sdlist, sdlen) X int sdlist[]; X int sdlen; { X int numfds, index; X fd_set fdset; X struct timeval timeout, *tvp = &timeout; X struct timeval sched, *svp = &sched, now, *nvp = &now; X int count, block; int counter = 0; X X X gettimeofday(nvp, NULL); X if (nvp->tv_usec < 500000L){ X svp->tv_usec = nvp->tv_usec + 500000L; X svp->tv_sec = nvp->tv_sec; X } else { X svp->tv_usec = nvp->tv_usec - 500000L; X svp->tv_sec = nvp->tv_sec + 1; X } X while(1){ #if 0 X if (counter++ == 8000) X exit(0); #endif X tvp = &timeout; X tvp->tv_sec = 0; X tvp->tv_usec = 500000L; X X numfds = 0; X FD_ZERO(&fdset); X for(index = 0; index < sdlen; index++){ X if (sdlist[index] + 1 > numfds) X numfds = sdlist[index] + 1; X FD_SET(sdlist[index], &fdset); X } X block = 0; X snmp_select_info(&numfds, &fdset, tvp, &block); X if (block == 1) X tvp = NULL; /* block without timeout */ X count = select(numfds, &fdset, 0, 0, tvp); X if (count > 0){ X for(index = 0; index < sdlen; index++){ X if(FD_ISSET(sdlist[index], &fdset)){ X snmp_read_packet(sdlist[index]); X FD_CLR(sdlist[index], &fdset); X } X } X snmp_read(&fdset); X } else switch(count){ X case 0: X snmp_timeout(); X break; X case -1: X if (errno == EINTR){ X continue; X } else { X perror("select"); X } X return -1; X default: X printf("select returned %d\n", count); X return -1; X } X gettimeofday(nvp, NULL); X if (nvp->tv_sec > svp->tv_sec X || (nvp->tv_sec == svp->tv_sec && nvp->tv_usec > svp->tv_usec)){ X alarmTimer(nvp); X eventTimer(nvp); X if (nvp->tv_usec < 500000L){ X svp->tv_usec = nvp->tv_usec + 500000L; X svp->tv_sec = nvp->tv_sec; X } else { X svp->tv_usec = nvp->tv_usec - 500000L; X svp->tv_sec = nvp->tv_sec + 1; X } X if (log_addresses && lastAddrAge++ > 600){ X int count; X X lastAddrAge = 0; X for(count = 0; count < 10; count++){ X if (addrCache[count].status == OLD) X addrCache[count].status = UNUSED; X if (addrCache[count].status == USED) X addrCache[count].status = OLD; X } X } X } X } } X snmp_read_packet(sd) X int sd; { X struct sockaddr_in from; X int length, out_length, fromlength; X u_char packet[1500], outpacket[1500]; X X fromlength = sizeof from; X length = recvfrom(sd, packet, 1500, 0, (struct sockaddr *)&from, X &fromlength); X if (length == -1) X perror("recvfrom"); X if (snmp_dump_packet){ X printf("recieved %d bytes from %s:\n", length, X inet_ntoa(from.sin_addr)); X xdump(packet, length, ""); X printf("\n\n"); X } else if (log_addresses){ X int count; X X for(count = 0; count < 10; count++){ X if (addrCache[count].status > 0 /* used or old */ X && from.sin_addr.s_addr == addrCache[count].addr) X break; X } X if (count >= 10){ X printf("Recieved SNMP packet(s) from %s\n", X inet_ntoa(from.sin_addr)); X for(count = 0; count < 10; count++){ X if (addrCache[count].status == UNUSED){ X addrCache[count].addr = from.sin_addr.s_addr; X addrCache[count].status = USED; X break; X } X } X } else { X addrCache[count].status = USED; X } X } X out_length = 1500; X if (snmp_agent_parse(packet, length, outpacket, &out_length, X from.sin_addr.s_addr)){ X if (snmp_dump_packet){ X printf("sent %d bytes to %s:\n", out_length, X inet_ntoa(from.sin_addr)); X xdump(outpacket, out_length, ""); X printf("\n\n"); X } X if (sendto(sd, (char *)outpacket, out_length, 0, X (struct sockaddr *)&from, X sizeof(from)) < 0){ X perror("sendto"); X return 0; X } X X } X return 1; } X /* deals with replies from remote alarm variables, and from inform pdus */ int snmp_input(op, session, reqid, pdu, magic) X int op; X struct snmp_session *session; X int reqid; X struct snmp_pdu *pdu; X void *magic; { X struct get_req_state *state = (struct get_req_state *)magic; X X if (op == RECEIVED_MESSAGE) { X if (pdu->command == GET_RSP_MSG) { X if (state->type == EVENT_GET_REQ) { X /* this is just the ack to our inform pdu */ X return 1; X } X return alarmGetResponse(pdu, state, op, session); X } X } X else if (op == TIMED_OUT) { X if (state->type == ALARM_GET_REQ) { X return alarmGetResponse(pdu, state, op, session); X } X } X return 1; } X X #ifdef VXWORKS snmpdv2 (priority) X int priority; { X int argcDummy = 1; X int argvDummy = 0; X X printf ("Spawning Task SNMPDv2 at priority %d...", priority); X if (taskSpawn ("SNMPDv2", priority, 0, 0x4000, snmpdMain, argcDummy, argvDummy)) X { X printf ("OK\n"); X } X else X { X printf ("FAILED\n"); X } X X } #endif SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/snmpd.c' && chmod 0644 'snmp2/agent/snmpd.c' || echo 'restore of snmp2/agent/snmpd.c failed' shar_count="`wc -c < 'snmp2/agent/snmpd.c'`" test 19793 -eq "$shar_count" || echo "snmp2/agent/snmpd.c: original size 19793, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/view_parse.c ============== if test -f 'snmp2/agent/view_parse.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/view_parse.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/view_parse.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/view_parse.c' && #include #include #ifdef VXWORKS #include "vxWorks.h" #include "VXtime.h" #else #include #include #endif #include #include #include "asn1.h" #include "view.h" X #define TRUE 1 #define FALSE 0 X static error_exit(str, linenumber, filename) X char *str; X int linenumber; X char *filename; { X fprintf(stderr, "%s on line %d of %s\n", str, linenumber, filename); X exit(1); } X int read_view_database(filename) X char *filename; { X FILE *fp; X char buf[256], buf1[256], buf2[256], buf3[256], buf4[256]; X char *cp; X int blank, nonhex; X int linenumber = 0; X int viewIndex; X oid viewSubtree[64]; X int viewSubtreeLen; X int status; X u_long byte; X u_char mask[16], *ucp; X int maskLen; X struct viewEntry *vwp; X X fp = fopen(filename, "r"); X if (fp == NULL) X return -1; X while (fgets(buf, 256, fp)){ X linenumber++; X if (strlen(buf) > 250) X error_exit("Line longer than 250 bytes", linenumber, filename); X if (buf[0] == '#') X continue; X blank = TRUE; X for(cp = buf; *cp; cp++) X if (!isspace(*cp)){ X blank = FALSE; X break; X } X if (blank) X continue; X X if (sscanf(buf, "%s %s %s %s", buf1, buf2, buf3, buf4) != 4) X error_exit("Bad parse", linenumber, filename); X X for(cp = buf1; *cp; cp++) X if (!isdigit(*cp)) X error_exit("Bad viewIndex value (should be decimal integer)", X linenumber, filename); X viewIndex = atoi(buf1); X X viewSubtreeLen = 64; X if (!read_objid(buf2, viewSubtree, &viewSubtreeLen)) X error_exit("Bad object identifier", linenumber, filename); X X if (!strcasecmp(buf3, "included")) X status = VIEWINCLUDED; X else if (!strcasecmp(buf3, "excluded")) X status = VIEWEXCLUDED; X else X error_exit("Bad status field", linenumber, filename); X X if (strlen(buf4) % 2) X error_exit("Bad mask (should be an even number of hex digits)", X linenumber, filename); X nonhex = 0; X for(cp = buf4; *cp; cp++){ X if (!isxdigit(*cp)) X nonhex = 1; X } X if (nonhex){ X if (strcasecmp(buf4, "Null")) X error_exit("Bad private key value (should be hex digits or null)", X linenumber, filename); X maskLen = 0; X } else { X ucp = mask; X for(cp = buf4; *cp; cp += 2, ucp++){ X if (sscanf(cp, "%2x", &byte) != 1) X error_exit("Bad parse", linenumber, filename); X *ucp = byte; X } X maskLen = ucp - mask; X } X X X vwp = view_getEntry(viewIndex, viewSubtree, viewSubtreeLen); X if (!vwp) X vwp = view_createEntry(viewIndex, viewSubtree, viewSubtreeLen); X vwp->viewType = status; X vwp->viewMaskLen = maskLen; X vwp->viewStorageType = 2; /* volatile */ X vwp->viewStatus = VIEWACTIVE; X bcopy(mask, vwp->viewMask, maskLen); #define VIEWCOMPLETE_MASK 0x3F X /* all collumns - from view_vars.c XXX */ X vwp->viewBitMask = VIEWCOMPLETE_MASK; X vwp->reserved->viewBitMask = vwp->viewBitMask; X } X fclose(fp); X return 0; } X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/view_parse.c' && chmod 0644 'snmp2/agent/view_parse.c' || echo 'restore of snmp2/agent/view_parse.c failed' shar_count="`wc -c < 'snmp2/agent/view_parse.c'`" test 2964 -eq "$shar_count" || echo "snmp2/agent/view_parse.c: original size 2964, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/view_vars.c ============== if test -f 'snmp2/agent/view_vars.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/view_vars.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/view_vars.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/view_vars.c' && #ifdef VXWORKS #include "VXtypes.h" #include "VXtime.h" #else #include #include #endif X X #include "asn1.h" #include "snmp.h" #include "snmp_impl.h" #include "snmp_vars.h" X #include "view.h" X #define OIDCMP(l1, l2, o1, o2) (((l1) == (l2)) \ X && !bcmp((char *)(o1), (char *)(o2), \ X (l1)*sizeof(oid))) X #define VIEWINDEX_MASK 0x01 #define VIEWSUBTREE_MASK 0x02 #define VIEWMASK_MASK 0x04 #define VIEWTYPE_MASK 0x08 #define VIEWSTORAGETYPE_MASK 0x10 #define VIEWSTATUS_MASK 0x20 X #define VIEWCOMPLETE_MASK 0x3F /* all columns */ X X struct viewEntry * view_rowCreate(viewIndex, viewSubtree, viewSubtreeLen) X oid *viewSubtree; X int viewIndex, viewSubtreeLen; { X struct viewEntry *vp; X X if (viewSubtreeLen > 32) X return NULL; X vp = view_createEntry(viewIndex, viewSubtree, viewSubtreeLen); X vp->viewBitMask = 0; X vp->reserved->viewStatus = VIEWNONEXISTENT; X X vp->viewBitMask = vp->reserved->viewBitMask = X VIEWINDEX_MASK | VIEWSUBTREE_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 vp; } X view_rowDelete(viewIndex, viewSubtree, viewSubtreeLen) X oid *viewSubtree; X int viewIndex, viewSubtreeLen; { X view_destroyEntry(viewIndex, viewSubtree, viewSubtreeLen); } X /* X * If statP is non-NULL, the referenced object is at that location. X * If statP is NULL and vp is non-NULL, the instance exists, but not this X * variable. X * If statP is NULL and vp is NULL, then neither this instance nor the X * variable exists. X */ int write_view(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; { #if 0 X struct viewEntry *vp, *rp; X int var, size, viewSubtreeLen; X int viewIndex; X oid *viewSubtree; X long val; X int bigsize = 1000; X /* X * This routine handles requests for variables of the form: X * .iso.org.dod.internet.snmpV2.snmpModules.partyMIB.partyMIBObjects X * .snmpViews.viewTable.viewEntry.X.viewIndex.oidlen.oid, X * or .1.3.6.1.6.3.3.2.4.1.1.X.viewIndex.oidlen.oid X * where the oid suffix is variable length. X * Therefore, the first index is name[12]. The length of the second X * index starts at name[13], and the second index starts at name[14]. X */ X if (length < 14) X return SNMP_ERR_NOCREATION; X var = name[11]; X viewIndex = name[12]; X viewSubtreeLen = name[13]; X viewSubtree = name + 14; X if (length != 14 + viewSubtreeLen) 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 vp = view_getEntry(viewIndex, viewSubtree, viewSubtreeLen); X if (vp) X rp = vp->reserved; X if (action == RESERVE1 && !vp){ X if ((vp = view_rowCreate(viewIndex, X viewSubtree, viewSubtreeLen)) == NULL) X return SNMP_ERR_RESOURCEUNAVAILABLE; X rp = vp->reserved; X /* create default vals here in reserve area */ X rp->viewType = VIEWINCLUDED; X rp->viewMaskLen = 0; X rp->viewBitMask = VIEWCOMPLETE_MASK; X } else if (action == COMMIT){ X if (vp->viewStatus == VIEWNONEXISTENT){ X /* commit the default vals */ X /* This havpens 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 vp->viewMaskLen = rp->viewMaskLen; X bcopy(rp->viewMask, vp->viewMask, rp->viewMaskLen); X vp->viewStatus = rp->viewStatus; X vp->viewBitMask = rp->viewBitMask; X } X } else if (action == FREE){ X if (vp && vp->viewStatus == VIEWNONEXISTENT){ X view_rowDelete(viewParty, viewPartyLen, X viewSubtree, viewSubtreeLen); X vp = rp = NULL; X } X if (vp) /* satisfy postcondition for bitMask */ X rp->viewBitMask = vp->viewBitMask; X } X /* XXX !!! check return values from the asn_parse_* routines */ X switch(var){ X case VIEWMASK: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->viewMask); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->viewMask, &size); X rp->viewMaskLen = size; X if (size > 16) X return SNMP_ERR_WRONGVALUE; X rp->viewBitMask |= VIEWMASK_MASK; X } else if (action == COMMIT){ X vp->viewMaskLen = rp->viewMaskLen; X bcopy(rp->viewMask, vp->viewMask, vp->viewMaskLen); X } X break; X case VIEWSTATUS: 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 > 3) X return SNMP_ERR_WRONGVALUE; X rp->viewStatus = val; X rp->viewBitMask |= VIEWSTATUS_MASK; X } else if (action == RESERVE2){ X if ((rp->viewType == VIEWINCLUDED X || rp->viewType == VIEWEXCLUDED) X && (rp->viewBitMask != VIEWCOMPLETE_MASK)) X return SNMP_ERR_INCONSISTENTVALUE; X /* tried to set incomplete row valid */ X } else if (action == COMMIT){ X vp->viewStatus = rp->viewStatus; X } else if (action == ACTION && vp->viewStatus == VIEWINVALID){ X view_rowDelete(vp->viewParty, vp->viewPartyLen, X vp->viewSubtree, vp->viewSubtreeLen); X } X break; X case VIEWPARTY: X case VIEWSUBTREE: X default: X return SNMP_ERR_NOCREATION; X } X if (action == COMMIT) /* make any new columns avpear */ X vp->viewBitMask = rp->viewBitMask; X #endif X return TRUE; } X u_char * var_view(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 viewEntry *vwp, *lowvwp = NULL; X u_long mask; X oid *viewSubtree; X int viewIndex, viewSubtreeLen; /* X * This routine handles requests for variables of the form: X * .iso.org.dod.internet.snmpV2.snmpModules.partyMIB.partyMIBObjects X * .snmpViews.viewTable.viewEntry.X.viewIndex.oid, X * or .1.3.6.1.6.3.3.2.4.1.1.X.viewIndex.oid X * where the oid suffix is variable length. X * Therefore, the first index is name[12], and the second index starts X * at name[13]. 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 < 14 || X bcmp((char *)name, (char *)vp->name, 12 * sizeof(oid))) X return NULL; X viewIndex = name[12]; X viewSubtreeLen = *length - 13; X viewSubtree = name + 13; X if (*length != 13 + viewSubtreeLen) X return NULL; X *write_method = write_view; X vwp = view_getEntry(viewIndex, viewSubtree, viewSubtreeLen); X if (vwp == NULL) X return NULL; X if (!(vwp->viewBitMask & mask)) X return NULL; X } else { X /* find "next" control entry */ X view_scanInit(); X for(vwp = view_scanNext(); vwp; vwp = view_scanNext()){ X if (!(vwp->viewBitMask & mask)) X continue; X np = newname + 12; X *np++ = vwp->viewIndex; X bcopy((char *)vwp->viewSubtree, (char *)np, X vwp->viewSubtreeLen * sizeof(oid)); X newnamelen = 13 + vwp->viewSubtreeLen; X if ((compare(newname, newnamelen, name, *length) > 0) && X (!lowvwp || 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 lowvwp = vwp; X } X } X if (lowvwp == NULL) X return NULL; X vwp = lowvwp; 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 VIEWMASK: X *var_len = vwp->viewMaskLen; X return (u_char *)vwp->viewMask; X case VIEWTYPE: X return (u_char *)&vwp->viewType; X case VIEWSTORAGETYPE: X return (u_char *)&vwp->viewStorageType; X case VIEWSTATUS: X return (u_char *)&vwp->viewStatus; X default: X ERROR(""); X } X return NULL; } X in_view(name, namelen, viewIndex) X oid *name; X int namelen, viewIndex; { X struct viewEntry *vwp, *savedvwp = NULL; X X view_scanInit(); X for(vwp = view_scanNext(); vwp; vwp = view_scanNext()){ X if (vwp->viewIndex != viewIndex || vwp->viewStatus != VIEWACTIVE) X continue; X if (vwp->viewSubtreeLen > namelen X || bcmp(vwp->viewSubtree, name, vwp->viewSubtreeLen * sizeof(oid))) X continue; X /* no wildcards here yet */ X if (!savedvwp){ X savedvwp = vwp; X } else { X if (vwp->viewSubtreeLen > savedvwp->viewSubtreeLen) X savedvwp = vwp; /* X else if (vwp->viewSubtreeLen == savedvwp->viewSubtreeLen X && greater(vwp->viewSubtree, savedvwp->viewSubtree)) X savedvwp = vwp; X */ X X } X } X if (!savedvwp) X return FALSE; X if (savedvwp->viewType == VIEWINCLUDED) X return TRUE; X return FALSE; } SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/view_vars.c' && chmod 0644 'snmp2/agent/view_vars.c' || echo 'restore of snmp2/agent/view_vars.c failed' shar_count="`wc -c < 'snmp2/agent/view_vars.c'`" test 9826 -eq "$shar_count" || echo "snmp2/agent/view_vars.c: original size 9826, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/vxWorksAnnotations.h ============== if test -f 'snmp2/agent/vxWorksAnnotations.h' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/vxWorksAnnotations.h (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/vxWorksAnnotations.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/vxWorksAnnotations.h' && /* X * X * X * (c) Copyright 1993 by Associated Universities, Inc. (AUI) X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of AUI not be X * used in advertising or publicity pertaining to distribution of the X * software without specific, written prior permission. X * X * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. X * AUI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * AUI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X * X * X */ /* VxWorks definitions */ /* This list of interfaces was taken from the list in the X man pages, and may or may not be complete. The speed X values are probably wrong, or at least in the wrong units. X The SLIP speed is too dynamic to be hard-coded, and I X don't know what the backplane speed is, or if the loopback X even has a speed */ X static ANNOTATION annotations[] = { X X { X "lo", X "VxWorks loopback interface", X "24", X "200000000", /* just a guess */ X "0" X }, X X { X "lnsgi", X "VxWorks LANCE (AMD 7990) Ethernet (for SGI) interface", X "6", X "10000000", X "1" X }, X X { X "ln", X "VxWorks LANCE (AMD 7990) Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "fn", X "VxWorks Fujitsu MB86960 NICE Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "sn", X "VxWorks National DP83932B SONIC Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "nic", X "VxWorks National NIC Chip (for HKV30) Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "eitp", X "VxWorks Intel 82596 Ethernet (for TP41) interface", X "6", X "10000000", X "1" X }, X X { X "ei", X "VxWorks Intel 82596 Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "ex", X "VxWorks Excelan EXOS 201/202/302 Ethernet interface", X "6", X "10000000", X "1" X }, X X { X "enp", X "VxWorks CMC ENP-10/L ethernet interface", X "6", X "10000000", X "1" X }, X X { X "bp", X "VxWorks backplane interface", X "1", X "320000000", /* VMEbus speed */ X "0" X }, X X { X "sm", X "VxWorks backplane interface", X "1", X "320000000", /* VMEbus speed */ X "0" X }, X X { X "sl", X "VxWorks SLIP interface", X "1", X "19200", /* Maximum speed */ X "0" X }, X X { X "", /* if all else fails */ X "Unknown interface", X "0", X "0", X "0" X } X } ; X SHAR_EOF $shar_touch -am 1026094693 'snmp2/agent/vxWorksAnnotations.h' && chmod 0644 'snmp2/agent/vxWorksAnnotations.h' || echo 'restore of snmp2/agent/vxWorksAnnotations.h failed' shar_count="`wc -c < 'snmp2/agent/vxWorksAnnotations.h'`" test 2885 -eq "$shar_count" || echo "snmp2/agent/vxWorksAnnotations.h: original size 2885, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/Lookup_Device_Annotation.c ============== if test -f 'snmp2/agent/Lookup_Device_Annotation.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/Lookup_Device_Annotation.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/Lookup_Device_Annotation.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/Lookup_Device_Annotation.c' && /* X * X * X * (c) Copyright 1993 by Associated Universities, Inc. (AUI) X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of AUI not be X * used in advertising or publicity pertaining to distribution of the X * software without specific, written prior permission. X * X * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. X * AUI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * AUI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X * X * X */ #include X typedef struct { X char *prefix, /* prefix to match */ X *description, /* interface description */ X *type, /* interface type (6 = ethernet) */ X *speed, /* speed in bits/sec (I think) */ X *ethernetDevice; /* is it an ethernet device? */ } ANNOTATION ; X /* vxWorks interface annotations */ #include "vxWorksAnnotations.h" X static const int nAnnotations = sizeof(annotations)/sizeof(annotations[0]); X static const char* SNMP_DESCR = "snmp-descr" ; static const char* SNMP_TYPE = "snmp-type" ; static const char* SNMP_SPEED = "snmp-speed" ; static const char* ENET_DEVICE = "ethernet-device" ; X /* X * look up the text which describes some aspect of an interface X */ X char *Lookup_Device_Annotation(char *device, char *lookup){ X X int i = 0; X X /* check the prefixes for a match */ X for(i = 0; i < nAnnotations; i++) X if(strncmp(device, annotations[i].prefix, strlen(annotations[i].prefix)) == 0){ X X if(strncmp(lookup, SNMP_DESCR, strlen(SNMP_DESCR))==0){ X return annotations[i].description; X } X X if(strncmp(lookup, SNMP_TYPE, strlen(SNMP_TYPE))==0){ X return annotations[i].type; X } X X if(strncmp(lookup, SNMP_SPEED, strlen(SNMP_SPEED))==0){ X return annotations[i].speed; X } X X if(strncmp(lookup, ENET_DEVICE, strlen(ENET_DEVICE))==0){ X return annotations[i].ethernetDevice; X } X X /* unrecognized lookup */ X return(NULL); X } X /* unrecognized device */ return NULL; } SHAR_EOF $shar_touch -am 1026094693 'snmp2/agent/Lookup_Device_Annotation.c' && chmod 0644 'snmp2/agent/Lookup_Device_Annotation.c' || echo 'restore of snmp2/agent/Lookup_Device_Annotation.c failed' shar_count="`wc -c < 'snmp2/agent/Lookup_Device_Annotation.c'`" test 2605 -eq "$shar_count" || echo "snmp2/agent/Lookup_Device_Annotation.c: original size 2605, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/loadSnmp ============== if test -f 'snmp2/loadSnmp' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/loadSnmp (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/loadSnmp (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/loadSnmp' && cd "../snmp2" ld < vx/nlist.o ld < vx/inet_vx.o ld < vx/random.o ld < vx/qsort.o ld < vx/strcasecmp.o ld < vx/load.o ld < syslog.o ld < lib/libsnmp.a ld < bin/snmpd snmpdv2 100 SHAR_EOF $shar_touch -am 1015123793 'snmp2/loadSnmp' && chmod 0644 'snmp2/loadSnmp' || echo 'restore of snmp2/loadSnmp failed' shar_count="`wc -c < 'snmp2/loadSnmp'`" test 177 -eq "$shar_count" || echo "snmp2/loadSnmp: original size 177, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/README.vxWorks ============== if test -f 'snmp2/README.vxWorks' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/README.vxWorks (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/README.vxWorks (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/README.vxWorks' && X README.vxWorks X This file describes the work done to port the CMU SNMPv2 agent to vxWorks. Six separate tasks are involved: X 1) SNMPv2 Library 2) SNMPv2 agent 3) SNMPv2 applications 4) additional routines needed that are not supported by vxWorks 5) implement SSCL Real-Time MIB. 6) loading SNMPv2 on vxWorks X Work was done jointly bewteen SSC and brokhaven. The work was done by: SHAR_EOF : || echo 'restore of snmp2/README.vxWorks failed' fi echo 'End of snmp2 part 37' echo 'File snmp2/README.vxWorks is continued in part 38' echo 38 > _sharseq.tmp exit 0