#!/bin/sh # This is `snmp2.35' (part 35 of snmp2). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `snmp2/agent/event.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" != 35; then echo "Please unpack part $shar_sequence next!" exit 1 fi if test ! -f _sharnew.tmp; then echo 'x - still skipping snmp2/agent/event.h' else echo 'x - continuing file snmp2/agent/event.h' sed 's/^X//' << 'SHAR_EOF' >> 'snmp2/agent/event.h' && X extern int eventFreeSpace(); extern u_char *var_eventnextindex(); extern u_char *var_eventtab(); extern u_char *var_eventnotifyvars(); extern u_char *var_eventnotifytab(); extern void eventGenerate(); X #define MAX_COMMUNITY_LEN 128 X struct eventEntry { X struct eventEntry *next; X int index; /* 1..65535 */ X oid id[MAX_NAME_LEN]; X int idLen; X char description[MAX_DESCRIPTION_LEN]; /* 0..127 */ X int descriptionLen; X int numEvents; X u_long lastTimeSent; /* timeticks */ X u_long minInterval; X u_long maxRetransmissions; X int status; X struct eventEntry *shadow; /* copy for row creates and changes */ X u_long bitmask; /* mask of valid variables */ }; X struct eventNotifyEntry { X struct eventNotifyEntry *next; X int index; X oid srcParty[MAX_NAME_LEN]; X int srcPartyLen; X oid dstParty[MAX_NAME_LEN]; X int dstPartyLen; X oid context[MAX_NAME_LEN]; X int contextLen; X int interval; X int retransmissions; X int lifetime; X int status; X struct snmp_session *ss; X struct get_req_state *magic; X struct eventNotifyEntry *shadow; X u_long bitmask; }; X X /* defines passed to eventGenerate() to tell it what type of event occured */ #define EVENT_TYPE_STARTUP_RISING 1 #define EVENT_TYPE_STARTUP_FALLING 2 #define EVENT_TYPE_RISING 3 #define EVENT_TYPE_FALLING 4 #define EVENT_TYPE_UNAVAILABLE 5 X /* does this mean anything? */ #define TRAP_RISING_ALARM 1 #define TRAP_FALLING_ALARM 2 #define TRAP_UNAVAILABLE_ALARM 3 X /* masks for the bitmask field in struct eventEntry */ #define EVENTTABINDEXMASK 0x00000001 #define EVENTTABIDMASK 0x00000002 #define EVENTTABDESCRIPTIONMASK 0x00000004 #define EVENTTABEVENTSMASK 0x00000008 #define EVENTTABLASTTIMESENTMASK 0x00000010 #define EVENTTABSTATUSMASK 0x00000020 X #define EVENTTABCOMPLETEMASK 0x0000003F X #define EVENTNOTIFYTABINTERVALMASK 0x00000001 #define EVENTNOTIFYTABRETRANSMISSIONSMASK 0x00000002 #define EVENTNOTIFYTABLIFETIMEMASK 0x00000004 #define EVENTNOTIFYTABSTATUSMASK 0x00000008 X #define EVENTNOTIFYTABCOMPLETEMASK 0x0000000F SHAR_EOF echo 'File snmp2/agent/event.h is complete' && $shar_touch -am 1015123693 'snmp2/agent/event.h' && chmod 0644 'snmp2/agent/event.h' || echo 'restore of snmp2/agent/event.h failed' shar_count="`wc -c < 'snmp2/agent/event.h'`" test 2088 -eq "$shar_count" || echo "snmp2/agent/event.h: original size 2088, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/history.c ============== if test -f 'snmp2/agent/history.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/history.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/history.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/history.c' && #include #include "asn1.h" #define NULL 0 #include "history.h" X static struct historyControlEntry *List = NULL, *ScanPtr = NULL; X X struct historyControlEntry * hc_getEntry(historyControlIndex) X int historyControlIndex; { X struct historyControlEntry *hcp; X X for(hcp = List; hcp; hcp = hcp->next){ X if (hcp->historyControlIndex == historyControlIndex) X return hcp; X } X return NULL; } X hc_scanInit() { X ScanPtr = List; } X struct historyControlEntry * hc_scanNext() { X struct historyControlEntry *returnval; X X /* what if entry is deleted during scan */ X returnval = ScanPtr; X if (ScanPtr != NULL) X ScanPtr = ScanPtr->next; X return returnval; } X struct historyControlEntry * hc_createEntry(historyControlIndex) X int historyControlIndex; { X struct historyControlEntry *hcp; X X hcp = (struct historyControlEntry *)malloc(sizeof(struct historyControlEntry)); X bzero((char *)hcp, sizeof(struct historyControlEntry)); X X hcp->historyControlIndex = historyControlIndex; X X hcp->next = List; X List = hcp; X return hcp; } X hc_destroyEntry(historyControlIndex) X int historyControlIndex; { X struct historyControlEntry *hcp, *lasthcp; X X if (List->historyControlIndex == historyControlIndex){ X hcp = List; X List = List->next; X } else { X for(hcp = List; hcp; hcp = hcp->next){ X if (hcp->historyControlIndex == historyControlIndex) X break; X lasthcp = hcp; X } X if (!hcp) X return; X lasthcp->next = hcp->next; X } X free(hcp); X return; } X struct bucketList * hc_granted(requested) X int *requested; { X struct bucketList *blp; X int granted; X X if (*requested > 100) X granted = 100; X else X granted = *requested; X blp = (struct bucketList *)malloc(sizeof(struct bucketList)); X blp->size = granted; X blp->buckets = (struct bucket *)malloc(granted * sizeof(struct bucket)); X *requested = granted; X return blp; } X hc_freeBuckets(blp) X struct bucketList *blp; { X if (!blp){ X printf("Error: Free NULL Bucket pointer\n"); X return; X } X if (blp->buckets) X free(blp->buckets); X free(blp); } SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/history.c' && chmod 0644 'snmp2/agent/history.c' || echo 'restore of snmp2/agent/history.c failed' shar_count="`wc -c < 'snmp2/agent/history.c'`" test 2145 -eq "$shar_count" || echo "snmp2/agent/history.c: original size 2145, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/history.h ============== if test -f 'snmp2/agent/history.h' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/history.h (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/history.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/history.h' && /* X historyControlIndex INTEGER (1..65535), X historyControlDataSource OBJECT IDENTIFIER, X historyControlBucketsRequested INTEGER (1..65535), X historyControlBucketsGranted INTEGER (1..65535), X historyControlInterval INTEGER (1..3600), X historyControlOwner DisplayString (SIZE (0..127)), X historyControlStatus INTEGER */ X #define HISTORYCONTROLINDEX 1 #define HISTORYCONTROLDATASOURCE 2 #define HISTORYCONTROLBUCKETSREQUESTED 3 #define HISTORYCONTROLBUCKETSGRANTED 4 #define HISTORYCONTROLINTERVAL 5 #define HISTORYCONTROLOWNER 6 #define HISTORYCONTROLSTATUS 7 X #define HCNONEXISTENT 0 #define HCVALID 1 #define HCCREATEREQUEST 2 #define HCUNDERCREATION 3 #define HCINVALID 4 X struct bucket { X int value; }; X struct bucketList { X struct bucket *buckets; X int size; }; X struct historyControlEntry { X int historyControlIndex; X int historyControlIfIndex; /* computed from DataSource */ X oid historyControlDataSource[32]; X int historyControlDataSourceLength; X int historyControlBucketsRequested; X int historyControlBucketsGranted; X struct bucketList *buckets; X int historyControlInterval; X u_char historyControlOwner[128]; X int historyControlOwnerLength; X int historyControlStatus; X X int historyControlBitMask; X /* Reserved area */ X int RhistoryControlIfIndex; /* computed from DataSource */ X oid RhistoryControlDataSource[32]; X int RhistoryControlDataSourceLength; X int RhistoryControlBucketsRequested; X int RhistoryControlBucketsGranted; X struct bucketList *Rbuckets; X int RhistoryControlInterval; X u_char RhistoryControlOwner[128]; X int RhistoryControlOwnerLength; X int RhistoryControlStatus; X X /* Reserved bitmask must equal real bitmask before every PDU starts. X * This means it must be reset after each PDU is over. X * The only time they can be different is between the RESERVE and COMMIT or X * FREE phases. X */ X int RhistoryControlBitMask; X struct historyControlEntry *next; }; X u_char *var_historyControlEntry(); int write_historyControl(); X struct historyControlEntry * hc_getEntry(/* int historyControlIndex */); /* X * Returns a pointer to the historyControlEntry with the X * same index as historyControlIndex. X * Returns NULL if that entry does not exist. X */ X hc_scanInit(); /* X * Initialized the scan routines so that they will begin at the X * beginning of the list of historyControlEntries. X * X */ X X struct historyControlEntry * hc_scanNext(); /* X * Returns a pointer to the next historyControlEntry. X * These entries are returned in no particular order, X * but if N entries exist, N calls to hc_scanNext() will X * return all N entries once. X * Returns NULL if all entries have been returned. X * hc_scanInit() starts the scan over. X */ X struct historyControlEntry * hc_createEntry(/* int historyControlIndex */); /* X * Creates a historyControlEntry with the given index X * and returns a pointer to it. X * The status of this entry is created as invalid. X */ X struct bucketList * hc_granted(/* int * requested */); /* X * Modifies the input number of buckets with the value that X * can be granted. X * Returns a pointer to a bucket list. X * These buckets should be reserved until they are freed. X */ X hc_freeBuckets(/* struct bucketList * freeList */); /* X * Frees a list of buckets X * Care should be taken to free any reserved buckets when X * the entry times out. X */ X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/history.h' && chmod 0444 'snmp2/agent/history.h' || echo 'restore of snmp2/agent/history.h failed' shar_count="`wc -c < 'snmp2/agent/history.h'`" test 3591 -eq "$shar_count" || echo "snmp2/agent/history.h: original size 3591, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/kernel.c ============== if test -f 'snmp2/agent/kernel.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/kernel.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/kernel.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/kernel.c' && X /* X * 13 Jun 91 wsak (wk0x@andrew) added mips support X */ X #include #include #include "asn1.h" #include "snmp_impl.h" X #ifndef NULL #define NULL 0 #endif X X static int kmem; int swap, mem; X init_kmem(file) X char *file; { #ifdef VXWORKS X /* X * ... X */ #else X kmem = open(file, 0); X if (kmem < 0){ X fprintf(stderr, "cannot open "); X perror(file); X exit(1); X } X X mem = open("/dev/mem",0); X if (mem < 0){ X fprintf(stderr, "cannot open "); X perror(file); X exit(1); X } X swap = open("/dev/drum",0); X if (swap < 0){ X fprintf(stderr, "cannot open "); X perror(file); X exit(1); X } #endif } X #ifndef VXWORKS X /* X * Seek into the kernel for a value. X */ off_t klseek(base) X off_t base; { X return (lseek(kmem, (off_t)base, 0)); } X X /* X * Read from the kernel X */ int klread(buf, buflen) X char *buf; X int buflen; { X return (read(kmem, buf, buflen)); } X #endif X X /* X * klookup: X * X * It seeks to the location off in kmem X * It does a read into target of siz bytes. X * X * Return NULL on failure and 1 on sucess. X * X */ X X X klookup(off, target, siz) X int off; X char *target; X int siz; { X #ifdef VXWORKS X X bcopy (off, target, siz); X #else X klseek(off); X if (siz != klread(target, siz)) { X ERROR("klread\n"); X exit(-1); X return(NULL); X } X #endif X X return (1); X } X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/kernel.c' && chmod 0644 'snmp2/agent/kernel.c' || echo 'restore of snmp2/agent/kernel.c failed' shar_count="`wc -c < 'snmp2/agent/kernel.c'`" test 1387 -eq "$shar_count" || echo "snmp2/agent/kernel.c: original size 1387, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/m2m.h ============== if test -f 'snmp2/agent/m2m.h' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/m2m.h (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/m2m.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/m2m.h' && struct get_req_state { X int type; X void *info; }; X /* values for type field in get_req_state */ #define ALARM_GET_REQ 1 #define EVENT_GET_REQ 2 X /* the following define is used to document a routine or variable which ** is not static to a module. */ #define Export X /* values for EntryStatus */ #define ENTRY_ACTIVE 1 #define ENTRY_NOTINSERVICE 2 #define ENTRY_NOTREADY 3 #define ENTRY_CREATEANDGO 4 #define ENTRY_CREATEANDWAIT 5 #define ENTRY_DESTROY 6 X /* maximum length for an OwnerString variable */ #define MAX_OWNER_STR_LEN 128 X /* maximum length for a description field */ #define MAX_DESCRIPTION_LEN 128 X /* defines for noting whether the incoming packet is unicast, broadcast, ** or multicast */ #define PKT_UNICAST 0 #define PKT_BROADCAST 1 #define PKT_MULTICAST 2 X /* macro to compare two ethernet addresses. addr1 is a pointer to a ** struct ether_addr; addr2 is just a struct ether_addr. */ #define sameEtherAddr(addr1, addr2) \ X ((*((short *)((addr1)->ether_addr_octet)) == \ X *((short *)((addr2).ether_addr_octet))) &&\ X (*((short *)(((addr1)->ether_addr_octet) + 2)) == \ X *((short *)((((addr2).ether_addr_octet) + 2)))) &&\ X (*((short *)(((addr1)->ether_addr_octet) + 4)) == \ X *((short *)((((addr2).ether_addr_octet) + 4))))) SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/m2m.h' && chmod 0644 'snmp2/agent/m2m.h' || echo 'restore of snmp2/agent/m2m.h failed' shar_count="`wc -c < 'snmp2/agent/m2m.h'`" test 1268 -eq "$shar_count" || echo "snmp2/agent/m2m.h: original size 1268, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/party_vars.c ============== if test -f 'snmp2/agent/party_vars.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/party_vars.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/party_vars.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/party_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" #include "system.h" X #include "party.h" #include "acl.h" #include "view.h" X oid snmpUdpDomain[] = {1, 3, 6, 1, 6, 1, 1}; /* no others defined yet */ X static oid noAuth[] = {1, 3, 6, 1, 6, 3, 3, 1, 1, 1}; static oid snmpv2MD5AuthProt[] = {1, 3, 6, 1, 6, 3, 3, 1, 1, 4}; X static oid noPriv[] = {1, 3, 6, 1, 6, 3, 3, 1, 1, 2}; static oid dESPrivProt[] = {1, 3, 6, 1, 6, 3, 3, 1, 1, 3}; X #define OIDCMP(l1, l2, o1, o2) (((l1) == (l2)) \ X && !bcmp((char *)(o1), (char *)(o2), \ X (l1)*sizeof(oid))) X #define PARTYIDENTITY_MASK 0x0001 #define PARTYINDEX_MASK 0x0002 #define PARTYTDOMAIN_MASK 0x0004 #define PARTYTADDRESS_MASK 0x0008 #define PARTYMAXMESSAGESIZE_MASK 0x0010 #define PARTYLOCAL_MASK 0x0020 #define PARTYAUTHPROTOCOL_MASK 0x0040 #define PARTYAUTHCLOCK_MASK 0x0080 #define PARTYAUTHPRIVATE_MASK 0x0100 #define PARTYAUTHPUBLIC_MASK 0x0200 #define PARTYAUTHLIFETIME_MASK 0x0400 #define PARTYPRIVPROTOCOL_MASK 0x0800 #define PARTYPRIVPRIVATE_MASK 0x1000 #define PARTYPRIVPUBLIC_MASK 0x2000 #define PARTYSTORAGETYPE_MASK 0x4000 #define PARTYSTATUS_MASK 0x8000 X #define PARTYCOMPLETE_MASK 0xFFFF /* all collumns */ X struct partyEntry * party_rowCreate(partyID, partyIDLen) X oid *partyID; X int partyIDLen; { X struct partyEntry *pp; X X if (partyIDLen > 32) X return NULL; X pp = party_createEntry(partyID, partyIDLen); X pp->partyBitMask = 0; X pp->partyStatus = pp->reserved->partyStatus = PARTYNONEXISTENT; X X pp->partyBitMask = pp->reserved->partyBitMask = X PARTYINDEX_MASK | PARTYSTATUS_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 pp; } X party_rowDelete(partyID, partyIDLen) X oid *partyID; X int partyIDLen; { X party_destroyEntry(partyID, partyIDLen); } X /* X * If statP is non-NULL, the referenced object is at that location. X * If statP is NULL and pp is non-NULL, the instance exists, but not this X * variable. X * If statP is NULL and pp is NULL, then neither this instance nor the X * variable exists. X */ int write_party(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 partyEntry *pp, *rp; X int var, indexlen, len; X oid *index; X long val; X oid buf[32]; X int bigsize = 1000, size; X struct aclEntry *ap; X struct viewEntry *vp; X u_long get_myaddr(), myaddr; X X if (length < 13) /* maybe this should be 15 to guarantee oidlength >= 2 */ X return SNMP_ERR_NOCREATION; X var = name[11]; X indexlen = name[12]; X index = name + 13; X if (length != 13 + indexlen) X return SNMP_ERR_NOCREATION; X X pp = party_getEntry(index, indexlen); X if (pp) X rp = pp->reserved; X if (action == RESERVE1 && !pp){ X if ((pp = party_rowCreate(index, indexlen)) == NULL) X return SNMP_ERR_RESOURCEUNAVAILABLE; X rp = pp->reserved; X /* create default vals here in reserve area X * partyIndex is automatically defval'd by party_createEntry(). X */ X rp->partyTDomain = DOMAINSNMPUDP; X bzero((char *)rp->partyTAddress, 6); X rp->partyTAddressLen = 6; X rp->partyMaxMessageSize = 484; X rp->partyLocal = 2; /* FALSE */ X rp->partyAuthProtocol = NOAUTH; X rp->partyAuthClock = 0; X rp->partyAuthPrivateLen = 0; X rp->partyAuthPublicLen = 0; X rp->partyAuthLifetime = 300; X rp->partyPrivProtocol = NOPRIV; X rp->partyPrivPrivateLen = 0; X rp->partyPrivPublicLen = 0; X rp->partyStorageType = 2; /* volatile */ X rp->partyStatus = PARTYACTIVE; X rp->partyBitMask = PARTYCOMPLETE_MASK ^ PARTYLOCAL_MASK; /* XXX */ X } else if (action == COMMIT){ X if (pp->partyStatus == PARTYNONEXISTENT){ X /* commit the default vals */ X /* This happens 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 pp->partyTDomain = rp->partyTDomain; X bcopy(rp->partyTAddress, pp->partyTAddress, rp->partyTAddressLen); X pp->partyTAddressLen = rp->partyTAddressLen; X pp->partyMaxMessageSize = rp->partyMaxMessageSize; X pp->partyLocal = rp->partyLocal; X pp->partyAuthProtocol = rp->partyAuthProtocol; X pp->partyAuthClock = rp->partyAuthClock; X gettimeofday(&pp->tv, (struct timezone *)0); X pp->tv.tv_sec -= pp->partyAuthClock; X pp->partyAuthPrivateLen = rp->partyAuthPrivateLen; X pp->partyAuthPublicLen = rp->partyAuthPublicLen; X pp->partyAuthLifetime = rp->partyAuthLifetime; X pp->partyPrivProtocol = rp->partyPrivProtocol; X pp->partyPrivPrivateLen = rp->partyPrivPrivateLen; X pp->partyPrivPublicLen = rp->partyPrivPublicLen; X pp->partyStorageType = rp->partyStorageType; X pp->partyStatus = rp->partyStatus; X pp->partyBitMask = rp->partyBitMask; X X } X } else if (action == FREE){ X if (pp && pp->partyStatus == PARTYNONEXISTENT){ X party_rowDelete(index, indexlen); X pp = rp = NULL; X } X if (pp) /* satisfy postcondition for bitMask */ X rp->partyBitMask = pp->partyBitMask; X } X /* XXX !!! check return values from the asn_parse_* routines */ X switch(var){ X case PARTYTDOMAIN: X if (action == RESERVE1){ X if (var_val_type != ASN_OBJECT_ID) X return SNMP_ERR_WRONGTYPE; X size = sizeof(buf)/sizeof(oid); X asn_parse_objid(var_val, &bigsize, &var_val_type, buf, &size); X if (OIDCMP(size, sizeof(snmpUdpDomain)/sizeof(oid), buf, X snmpUdpDomain)){ X rp->partyTDomain = DOMAINSNMPUDP; X rp->partyBitMask |= PARTYTDOMAIN_MASK; X } else { X return SNMP_ERR_WRONGVALUE; X } X } else if (action == COMMIT){ X pp->partyTDomain = rp->partyTDomain; X } X break; X case PARTYTADDRESS: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->partyTAddress); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->partyTAddress, &size); X rp->partyTAddressLen = size; X /* if other TDomains were possible, it would be necessary to X check the size in the reserve2 phase to see if it was X consistent with the TDomain. X Also: what if TAddr is changed to a local party: consider X implications for MaxMessageSize. X */ X if (size != 6) X return SNMP_ERR_WRONGLENGTH; X rp->partyBitMask |= PARTYTADDRESS_MASK; X } else if (action == COMMIT){ X pp->partyTAddressLen = rp->partyTAddressLen; X bcopy(rp->partyTAddress, pp->partyTAddress, pp->partyTAddressLen); X } X break; X case PARTYMAXMESSAGESIZE: 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 < 484 || val > 65507) X return SNMP_ERR_WRONGVALUE; X rp->partyMaxMessageSize = val; X rp->partyBitMask |= PARTYMAXMESSAGESIZE_MASK; X } else if (action == RESERVE2){ X myaddr = get_myaddr(); X if ((rp->partyTDomain == DOMAINSNMPUDP) X && !bcmp((char *)&myaddr, rp->partyTAddress, 4)){ X /* party is local */ X /* 1500 should be constant in snmp_impl.h */ X if (rp->partyMaxMessageSize > 1500) X return SNMP_ERR_INCONSISTENTVALUE; X } X } else if (action == COMMIT){ X pp->partyMaxMessageSize = rp->partyMaxMessageSize; X } X break; X case PARTYLOCAL: 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->partyLocal = val; X rp->partyBitMask |= PARTYLOCAL_MASK; X } else if (action == RESERVE2){ X myaddr = get_myaddr(); X if (val == 1 && (rp->partyTDomain == DOMAINSNMPUDP) X && bcmp((char *)&myaddr, rp->partyTAddress, 4)){ X /* this is an attempt to set this party local with a X remote IP address */ X return SNMP_ERR_INCONSISTENTVALUE; X } X } else if (action == COMMIT){ X pp->partyLocal = rp->partyLocal; X } X break; X case PARTYAUTHPROTOCOL: X if (action == RESERVE1){ X if (var_val_type != ASN_OBJECT_ID) X return SNMP_ERR_WRONGTYPE; X size = sizeof(buf)/sizeof(oid); X asn_parse_objid(var_val, &bigsize, &var_val_type, buf, &size); X if (OIDCMP(size, sizeof(noAuth)/sizeof(oid), buf, noAuth)){ X rp->partyAuthProtocol = NOAUTH; X } else if (OIDCMP(size, sizeof(snmpv2MD5AuthProt)/sizeof(oid), buf, X snmpv2MD5AuthProt)){ X rp->partyAuthProtocol = SNMPV2MD5AUTHPROT; X } else { X /* no other currently defined */ X return SNMP_ERR_WRONGVALUE ; X } X rp->partyBitMask |= PARTYAUTHPROTOCOL_MASK; X } else if (action == COMMIT){ X pp->partyAuthProtocol = rp->partyAuthProtocol; X } X break; X case PARTYAUTHCLOCK: 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 rp->partyAuthClock = val; X rp->partyBitMask |= PARTYAUTHCLOCK_MASK; X } else if (action == COMMIT){ X pp->partyAuthClock = rp->partyAuthClock; X gettimeofday(&pp->tv, (struct timezone *)0); X pp->tv.tv_sec -= pp->partyAuthClock; X } X break; X case PARTYAUTHPRIVATE: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->partyAuthPrivate); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->partyAuthPrivate, &size); X rp->partyAuthPrivateLen = size; X if (size > 16) X return SNMP_ERR_WRONGLENGTH; X rp->partyBitMask |= PARTYAUTHPRIVATE_MASK; X } else if (action == COMMIT){ X if (!(pp->partyBitMask & PARTYAUTHPRIVATE_MASK)) X pp->partyAuthPrivateLen = 0; X for(len = 0; (len < pp->partyAuthPrivateLen) X && (len < rp->partyAuthPrivateLen); len++){ X pp->partyAuthPrivate[len] ^= X rp->partyAuthPrivate[len]; X } X while(len < rp->partyAuthPrivateLen) X pp->partyAuthPrivate[len] = X rp->partyAuthPrivate[len]; X pp->partyAuthPrivateLen = rp->partyAuthPrivateLen; X } X break; X case PARTYAUTHPUBLIC: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->partyAuthPublic); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->partyAuthPublic, &size); X rp->partyAuthPublicLen = size; X if (size > 32) X return SNMP_ERR_WRONGLENGTH; X rp->partyBitMask |= PARTYAUTHPUBLIC_MASK; X } else if (action == COMMIT){ X pp->partyAuthPublicLen = rp->partyAuthPublicLen; X bcopy((char *)rp->partyAuthPublic, X (char *)pp->partyAuthPublic, pp->partyAuthPublicLen); X } X break; X case PARTYAUTHLIFETIME: 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 /* what range should I check for ??? X if (val < 1 || val > 3600) X return SNMP_ERR_WRONGVALUE; X */ X rp->partyAuthLifetime = val; X rp->partyBitMask |= PARTYAUTHLIFETIME_MASK; X } else if (action == COMMIT){ X pp->partyAuthLifetime = rp->partyAuthLifetime; X } X break; X case PARTYPRIVPROTOCOL: X if (action == RESERVE1){ X if (var_val_type != ASN_OBJECT_ID) X return SNMP_ERR_WRONGTYPE; X size = sizeof(buf)/sizeof(oid); X asn_parse_objid(var_val, &bigsize, &var_val_type, buf, &size); X if (OIDCMP(size, sizeof(noPriv)/sizeof(oid), buf, noPriv)){ X rp->partyPrivProtocol = NOPRIV; X } else if (OIDCMP(size, sizeof(dESPrivProt)/sizeof(oid), buf, X dESPrivProt)){ X rp->partyPrivProtocol = DESPRIVPROT; X } else { X /* no other currently defined */ X return SNMP_ERR_WRONGVALUE; X } X rp->partyBitMask |= PARTYPRIVPROTOCOL_MASK; X } else if (action == COMMIT){ X pp->partyPrivProtocol = rp->partyPrivProtocol; X } X break; X case PARTYPRIVPRIVATE: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->partyPrivPrivate); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->partyPrivPrivate, &size); X rp->partyPrivPrivateLen = size; X if (size > 16) X return SNMP_ERR_WRONGLENGTH; X rp->partyBitMask |= PARTYPRIVPRIVATE_MASK; X } else if (action == COMMIT){ X if (!(pp->partyBitMask & PARTYPRIVPRIVATE_MASK)) X pp->partyPrivPrivateLen = 0; X for(len = 0; (len < pp->partyPrivPrivateLen) X && (len < rp->partyPrivPrivateLen); len++){ X pp->partyPrivPrivate[len] ^= X rp->partyPrivPrivate[len]; X } X while(len < rp->partyPrivPrivateLen) X pp->partyPrivPrivate[len] = X rp->partyPrivPrivate[len]; X pp->partyPrivPrivateLen = rp->partyPrivPrivateLen; X } X break; X case PARTYPRIVPUBLIC: X if (action == RESERVE1){ X if (var_val_type != ASN_OCTET_STR) X return SNMP_ERR_WRONGTYPE; X size = sizeof(rp->partyPrivPublic); X asn_parse_string(var_val, &bigsize, &var_val_type, X rp->partyPrivPublic, &size); X rp->partyPrivPublicLen = size; X if (size > 32) X return SNMP_ERR_WRONGLENGTH; X rp->partyBitMask |= PARTYPRIVPUBLIC_MASK; X } else if (action == COMMIT){ X bcopy((char *)rp->partyPrivPublic, (char *)pp->partyPrivPublic, X rp->partyPrivPublicLen); X pp->partyPrivPublicLen = rp->partyPrivPublicLen; X } X break; X case PARTYSTORAGETYPE: 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 > 4) X return SNMP_ERR_WRONGVALUE; X if (val != 2) /* above is as per MIB, X this is implementation specific */ X return SNMP_ERR_WRONGVALUE; X rp->partyStorageType = val; X rp->partyBitMask |= PARTYSTORAGETYPE_MASK; X } else if (action == COMMIT){ X pp->partyStorageType = rp->partyStorageType; X } X break; X case PARTYSTATUS: /* read-write access */ 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 > 6 || val == 3) X return SNMP_ERR_WRONGVALUE; X rp->partyStatus = val; X rp->partyBitMask |= PARTYSTATUS_MASK; X } else if (action == RESERVE2){ X if (((rp->partyStatus == PARTYCREATEANDGO) X || (rp->partyStatus == PARTYCREATEANDWAIT)) X && (pp->partyStatus != PARTYNONEXISTENT)) X return SNMP_ERR_INCONSISTENTVALUE; X if (((rp->partyStatus == PARTYACTIVE) X || (rp->partyStatus == PARTYNOTINSERVICE)) X && (pp->partyStatus == PARTYNONEXISTENT)) X return SNMP_ERR_INCONSISTENTVALUE; X if (((rp->partyStatus == PARTYACTIVE) X || (rp->partyStatus == PARTYNOTINSERVICE)) X && (rp->partyBitMask != PARTYCOMPLETE_MASK)) X return SNMP_ERR_INCONSISTENTVALUE; X /* tried to set incomplete row valid */ X } else if (action == COMMIT){ X if (rp->partyStatus == PARTYCREATEANDGO) X rp->partyStatus = PARTYACTIVE; X if (rp->partyStatus == PARTYCREATEANDWAIT) X rp->partyStatus = PARTYNOTINSERVICE; X pp->partyStatus = rp->partyStatus; X } else if (action == ACTION && pp->partyStatus == PARTYDESTROY){ X /* delete all related acl entries */ #if 0 X acl_scanInit(); X ap = acl_scanNext(); X do { X for(; ap; ap = acl_scanNext()){ X if ((ap->aclTargetLen == pp->partyIdentityLen X && !bcmp(ap->aclTarget, pp->partyIdentity, X ap->aclTargetLen * sizeof(oid))) X || (ap->aclSubjectLen == pp->partyIdentityLen X && !bcmp(ap->aclSubject, pp->partyIdentity, X ap->aclSubjectLen * sizeof(oid)))){ X acl_destroyEntry(ap->aclTarget, ap->aclTargetLen, X ap->aclSubject, ap->aclSubjectLen); X acl_scanInit(); X ap = acl_scanNext(); X break; X /* ap is still set, so we'll start over again */ X } X } X } while (ap); X /* delete all related view entries */ X view_scanInit(); X vp = view_scanNext(); X do { X for(; vp; vp = view_scanNext()){ X if (vp->viewPartyLen == pp->partyIdentityLen X && !bcmp(vp->viewParty, pp->partyIdentity, X vp->viewPartyLen * sizeof(oid))){ X view_destroyEntry(vp->viewParty, vp->viewPartyLen, X vp->viewSubtree, vp->viewSubtreeLen); X view_scanInit(); X vp = view_scanNext(); X break; X /* vp is still set, so we'll start over again */ X } X } X } while (vp); #endif X X /* then delete the party itself */ X party_rowDelete(pp->partyIdentity, pp->partyIdentityLen); X } X /* if action and party created and it is local, open up new X * listening port, if appropriate. X */ X break; X case PARTYIDENTITY: X default: X return SNMP_ERR_NOCREATION; X } X if (action == COMMIT) /* make any new collumns appear */ X pp->partyBitMask = rp->partyBitMask; X X return SNMP_ERR_NOERROR; } X u_char * var_party(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]; X int newnamelen, lownamelen; X struct partyEntry *pp, *lowpp = NULL; X u_long mask; X struct timeval now; /* X * This routine handles requests for variables of the form: X X * .iso.org.dod.internet.snmpV2.snmpModules.partyMIB.partyMIBObjects X * .snmpParties.partyTable.partyEntry.X.oid X * or .1.3.6.1.6.3.3.2.1.1.1.X.oid, where the oid suffix is X * variable length X * Therefore, the index starts at name[12]. 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 < 13 || X bcmp((char *)name, (char *)vp->name, 11 * sizeof(oid))) X return NULL; X *write_method = write_party; X pp = party_getEntry(name + 12, *length - 12); X if (pp == NULL) X return NULL; X if (!(pp->partyBitMask & mask)) X return NULL; X } else { X /* find "next" control entry */ X party_scanInit(); X for(pp = party_scanNext(); pp; pp = party_scanNext()){ X if (!(pp->partyBitMask & mask)) X continue; X bcopy((char *)pp->partyIdentity, (char *)(newname + 12), X pp->partyIdentityLen * sizeof(oid)); X newnamelen = 12 + pp->partyIdentityLen; X if ((compare(newname, newnamelen, name, *length) > 0) && X (!lowpp || 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 lowpp = pp; X } X } X if (lowpp == NULL) X return NULL; X pp = lowpp; 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 PARTYINDEX: X return (u_char *)&pp->partyIndex; X case PARTYTDOMAIN: X if (pp->partyTDomain == DOMAINSNMPUDP){ X *var_len = sizeof(snmpUdpDomain); X return (u_char *)snmpUdpDomain; X } else { X ERROR(""); X return NULL; X } X case PARTYTADDRESS: X *var_len = pp->partyTAddressLen; X return (u_char *)pp->partyTAddress; X case PARTYMAXMESSAGESIZE: X return (u_char *)&pp->partyMaxMessageSize; X case PARTYLOCAL: X return (u_char *)&pp->partyLocal; X case PARTYAUTHPROTOCOL: X if (pp->partyAuthProtocol == SNMPV2MD5AUTHPROT){ X *var_len = sizeof(snmpv2MD5AuthProt); X return (u_char *)snmpv2MD5AuthProt; X } else if (pp->partyAuthProtocol == NOAUTH){ /* noAuth */ X *var_len = sizeof(noAuth); X return (u_char *)noAuth; X } else { X ERROR(""); X return NULL; X } X case PARTYAUTHCLOCK: X gettimeofday(&now, (struct timezone *)0); X (u_long)long_return = now.tv_sec - pp->tv.tv_sec; X return (u_char *)&long_return; X case PARTYAUTHPRIVATE: X *var_len = 0; /* zero length return value */ X return (u_char *)pp->partyIdentity; /* dummy pointer */ X case PARTYAUTHPUBLIC: X *var_len = pp->partyAuthPublicLen; X return (u_char *)pp->partyAuthPublic; X case PARTYAUTHLIFETIME: X return (u_char *)&pp->partyAuthLifetime; X case PARTYPRIVPROTOCOL: X if (pp->partyPrivProtocol == DESPRIVPROT){ X *var_len = sizeof(dESPrivProt); X return (u_char *)dESPrivProt; X } else if (pp->partyPrivProtocol == NOPRIV){ /* noPriv */ X *var_len = sizeof(noPriv); X return (u_char *)noPriv; X } X /*NOTREACHED*/ X case PARTYPRIVPRIVATE: X *var_len = 0; /* zero length return value */ X return (u_char *)pp->partyIdentity; /* dummy pointer */ X case PARTYPRIVPUBLIC: X *var_len = pp->partyPrivPublicLen; X return (u_char *)pp->partyPrivPublic; X case PARTYCLONEFROM: X *var_len = 8; X bzero(return_buf, 8); X return (u_char *)return_buf; X case PARTYSTORAGETYPE: X return (u_char *)&pp->partyStorageType; X case PARTYSTATUS: X if (pp->partyStatus == PARTYNOTINSERVICE X && pp->partyBitMask != PARTYCOMPLETE_MASK){ X long_return = PARTYNOTREADY; X return (u_char *)&long_return; X } X return (u_char *)&pp->partyStatus; X default: X ERROR(""); X } X return NULL; } SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/party_vars.c' && chmod 0644 'snmp2/agent/party_vars.c' || echo 'restore of snmp2/agent/party_vars.c failed' shar_count="`wc -c < 'snmp2/agent/party_vars.c'`" test 21821 -eq "$shar_count" || echo "snmp2/agent/party_vars.c: original size 21821, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/route_write.c ============== if test -f 'snmp2/agent/route_write.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/route_write.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/route_write.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/route_write.c' && #ifdef VXWORKS #include #else #include #include #include #endif #include #include X X #ifdef VXWORKS #else #include #endif X X #include #include #ifdef VXWORKS #include "VXnetdb.h" #else #include #include #endif X #include #include #include #include #include #include X X X #include "asn1.h" #include "snmp.h" #include "snmp_impl.h" #include "snmp_vars.h" X X X X X int addRoute(dstip, gwip, iff, flags) u_long dstip; u_long gwip; u_long iff; u_short flags; { X X X struct sockaddr_in dst; X struct sockaddr_in gateway; X int s; X struct rtentry route; X int ret; X X s = socket(AF_INET, SOCK_RAW, 0); X if (s<0) { X perror("socket"); X return 0; X } X X X flags |= RTF_UP; X X dst.sin_family = AF_INET; X dst.sin_addr.s_addr = htonl(dstip); X X X gateway.sin_family = AF_INET; X gateway.sin_addr.s_addr = htonl(gwip); X X bcopy((char*) &dst, (char *) &route.rt_dst, sizeof(struct sockaddr_in)); X bcopy((char*) &gateway, (char *) &route.rt_gateway, sizeof(struct sockaddr_in)); X X route.rt_flags = flags; X route.rt_hash = iff; X return (ioctl(s, SIOCADDRT , (caddr_t)&route)); X } X X X int delRoute(dstip, gwip, iff, flags) u_long dstip; u_long gwip; u_long iff; u_short flags; { X X X struct sockaddr_in dst; X struct sockaddr_in gateway; X int s; X struct rtentry route; X int ret; X X s = socket(AF_INET, SOCK_RAW, 0); X if (s<0) { X perror("socket"); X return 0; X } X X X flags |= RTF_UP; X X dst.sin_family = AF_INET; X dst.sin_addr.s_addr = htonl(dstip); X X X gateway.sin_family = AF_INET; X gateway.sin_addr.s_addr = htonl(gwip); X X bcopy((char*) &dst, (char *) &route.rt_dst, sizeof(struct sockaddr_in)); X bcopy((char*) &gateway, (char *) &route.rt_gateway, sizeof(struct sockaddr_in)); X X route.rt_flags = flags; X route.rt_hash = iff; X X return (ioctl(s, SIOCDELRT , (caddr_t)&route)); X } X X X X X X X X X #define MAX_CACHE 8 X X X struct rtent { X X u_long in_use; X u_long old_dst; X u_long old_nextIR; X u_long old_ifix; X u_long old_flags; X X u_long rt_dst; /* main entries */ X u_long rt_ifix; X u_long rt_metric1; X u_long rt_nextIR; X u_long rt_type; X u_long rt_proto; X X X u_long xx_dst; /* shadow entries */ X u_long xx_ifix; X u_long xx_metric1; X u_long xx_nextIR; X u_long xx_type; X u_long xx_proto; }; X X X X X X struct rtent rtcache[MAX_CACHE]; X X X struct rtent *findCacheRTE(dst) u_long dst; { X int i; X X for (i = 0; i < MAX_CACHE; i++) { X X if (rtcache[i].in_use && (rtcache[i].rt_dst == dst)) { /* valid & match? */ X return (&rtcache[i]); X } X } X return 0; } X X X struct rtent *newCacheRTE() { X X int i; X X for (i = 0; i < MAX_CACHE; i++) { X X if (!rtcache[i].in_use) { X rtcache[i].in_use = 1; X return (&rtcache[i]); X } X } X return 0; X } X X X int delCacheRTE(dst) u_long dst; { X int i; X struct rtent *rt; X X rt = findCacheRTE(dst); X if (!rt) { X return 0; X } X X rt->in_use = 0; X return 1; } X X X X X struct rtent *cacheKernelRTE(dst) u_long dst; { X X return 0; /* for now */ X X X /* ...... */ X X } X X X X X 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 */ X int write_rte(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 rtent *rp; X int var; X long val; X u_long dst; X char buf[8]; X int bufsz; X u_short flags; X int oldty; X X /* X * object identifier is of form: X * 1.3.6.1.2.1.4.21.1.X.A.B.C.D , where A.B.C.D is IP address. X * IPADDR starts at offset 10. X */ X X if (length != 14) { X printf("length error\n"); X return SNMP_ERR_NOCREATION; X } X X var = name[9]; X X dst = *((u_long *) & name[10] ); X X rp = findCacheRTE(dst); X X if (!rp) { X rp = cacheKernelRTE(dst); X } X X X if (action == RESERVE1 && !rp) { X X rp = newCacheRTE(); X if (!rp) { X printf("newCacheRTE"); X return SNMP_ERR_RESOURCEUNAVAILABLE; X } X rp->rt_type = rp->xx_type = 2; X X } else if (action == COMMIT){ X X X } else if (action == FREE) { X if (rp->rt_type == 2) { /* was invalid before */ X delCacheRTE(dst); X } X } X X X X X switch(var){ X X case IPROUTEDEST: X X if (action == RESERVE1){ X X if (var_val_type != ASN_OCTET_STR) { X printf("not octet"); X return SNMP_ERR_WRONGTYPE; X } X X bufsz = 8; X asn_parse_string(var_val, &var_val_len, &var_val_type, buf, &bufsz); X X if (var_val_type != ASN_OCTET_STR) { X printf("not octet2"); X return SNMP_ERR_WRONGTYPE; X } X X rp->xx_dst = *((u_long *) buf); X X X } else if (action == COMMIT) { X rp->rt_dst = rp->xx_dst; X } X break; X X case IPROUTEMETRIC1: X X if (action == RESERVE1) { X if (var_val_type != ASN_INTEGER) { X printf("not int1"); X return SNMP_ERR_WRONGTYPE; X } X X asn_parse_int(var_val, &var_val_len, &var_val_type, &val, sizeof(val)); X X if (val < -1) { X printf("not right1"); X return SNMP_ERR_WRONGVALUE; X } X X rp->xx_metric1 = val; X X } else if (action == RESERVE2) { X X if ((rp->xx_metric1 == 1) && (rp->xx_type != 4)) { X printf("reserve2 failed\n"); X return SNMP_ERR_WRONGVALUE; X } X X } else if (action == COMMIT) { X rp->rt_metric1 = rp->xx_metric1; X } X break; X X case IPROUTEIFINDEX: X X if (action == RESERVE1) { X if (var_val_type != ASN_INTEGER) { X printf("not right2"); X return SNMP_ERR_WRONGTYPE; X } X X asn_parse_int(var_val, &var_val_len, &var_val_type, &val, sizeof(val)); X X if (val <= 0) { X printf("not right3"); X return SNMP_ERR_WRONGVALUE; X } X X rp->xx_ifix = val; X X } else if (action == COMMIT) { X rp->rt_ifix = rp->xx_ifix; X } X break; X X case IPROUTENEXTHOP: X X if (action == RESERVE1){ X X if (var_val_type != ASN_OCTET_STR) { X printf("not right4"); X return SNMP_ERR_WRONGTYPE; X } X X bufsz = 8; X asn_parse_string(var_val, &var_val_len, &var_val_type, buf, &bufsz); X X if (var_val_type != ASN_OCTET_STR) { X printf("not right5"); X return SNMP_ERR_WRONGTYPE; X } X X rp->xx_nextIR = *((u_long *) buf); X X } else if (action == COMMIT) { X rp->rt_nextIR = rp->xx_nextIR; X } X X X case IPROUTETYPE: X X /* X * flag meaning: X * X * IPROUTEPROTO (rt_proto): none: (cant set == 3 (netmgmt)) X * X * IPROUTEMETRIC1: 1 iff gateway, 0 otherwise X * IPROUTETYPE: 4 iff gateway, 3 otherwise X */ X X if (action == RESERVE1) { X if (var_val_type != ASN_INTEGER) { X return SNMP_ERR_WRONGTYPE; X } X X asn_parse_int(var_val, &var_val_len, &var_val_type, &val, sizeof(val)); X X if ((val < 2) || (val > 4)) { /* only accept invalid, direct, indirect */ X printf("not right6"); X return SNMP_ERR_WRONGVALUE; X } X X rp->xx_type = val; X X } else if (action == COMMIT) { X X oldty = rp->rt_type; X rp->rt_type = rp->xx_type; X X if (rp->rt_type == 2) { /* invalid, so delete from kernel */ X X if (delRoute(rp->rt_dst, rp->rt_nextIR, rp->rt_ifix , rp->old_flags ) < 0) { X perror("delRoute"); X } X X } else { X X /* it must be valid now, so flush to kernel */ X X if (oldty != 2) { /* was the old entry valid ? */ X if (delRoute(rp->old_dst, rp->old_nextIR, rp->old_ifix , rp->old_flags ) < 0) { X perror("delRoute"); X } X } X X /* not invalid, so remove from cache */ X X flags = (rp->rt_type == 4 ? RTF_GATEWAY : 0); X X if (addRoute(rp->rt_dst, rp->rt_nextIR, rp->rt_ifix , flags) < 0) { X perror("addRoute"); X } X X delCacheRTE( rp->rt_type ); X } X } X break; X X X case IPROUTEPROTO: X X default: X printf("err default\n"); X return SNMP_ERR_NOCREATION; X X X } X X X return SNMP_ERR_NOERROR; } X X X X SHAR_EOF $shar_touch -am 1015123693 'snmp2/agent/route_write.c' && chmod 0644 'snmp2/agent/route_write.c' || echo 'restore of snmp2/agent/route_write.c failed' shar_count="`wc -c < 'snmp2/agent/route_write.c'`" test 8372 -eq "$shar_count" || echo "snmp2/agent/route_write.c: original size 8372, current size $shar_count" rm -f _sharnew.tmp fi # ============= snmp2/agent/snmp_agent.c ============== if test -f 'snmp2/agent/snmp_agent.c' && test X"$1" != X"-c"; then echo 'x - skipping snmp2/agent/snmp_agent.c (file already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting snmp2/agent/snmp_agent.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'snmp2/agent/snmp_agent.c' && /* X * Simple Network Management Protocol (RFC 1067). 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 SHAR_EOF : || echo 'restore of snmp2/agent/snmp_agent.c failed' fi echo 'End of snmp2 part 35' echo 'File snmp2/agent/snmp_agent.c is continued in part 36' echo 36 > _sharseq.tmp exit 0