[tkined] Patches to scotty-00-02-21

From: Dunford, Martin (MDunford@unispherenetworks.com)
Date: Tue Dec 19 2000 - 16:52:31 MET


Patches to scotty-00-02-21 that *fix* the following

- Range restriction info. not being parsed correctly

- Range restriction info. not being recorded
    in binary 'frozen' file once MIB parsed

- engineID parameter for command
     tnm::snmp generator -engineID <engineID> ....
  being read incorrectly if specified as a hex constant
  e.g
             set engineID [binary format H* 800008E10500901A10010864656661756C74]
        set session [Tnm::snmp generator -version SNMPv3 -context default
-engineID $engineID -address 10.5.0.232]

  did *not* process the hex data for engineID correctly...

Note: There is a lot of my own source reformatting in the diff files that
has
     no direct bearing on the above

Patches apply to files tnmMibParser.c, tnmMibParser.c and tnmSnmpSend.c

Patch to tnm/snmp/tnmMibParser.c
================================

25c25
< #undef USE_RANGES

---
> #define  USE_RANGES 1 
   
                    

1416c1432 < ckfree(ranges); --- > ckfree(enums);

2050,2058c2073,2080 < /* < * no read keywords until ACCESS is found < */ < < /* < * if the syntax found is LABEL, we should lookup the typedef: < */ < < if (syntax == LABEL) { --- > /* --------------------------------------------------------------- */ > /* ReadKeyword's syntax of LABEL refers to any string that is not */ > /* a MIB Keyword (these are defined in keywords array) or numeric */ > /* value or the string ".." which is used by range restrictions */ > /* ...so it could be a predefined type, look it up! */ > /* --------------------------------------------------------------- */ > if (syntax == LABEL) > { 2061c2083 < if (nodePtr->typePtr) { --- > if (nodePtr->typePtr) 2063c2085,2086 < } else { --- > else > { 2071,2075c2094 < /* < * old eat-it-up code: skip anything to the ACCESS keyword: < */ < < while ((syntax = ReadKeyword(fp, keyword)) != ACCESS) --- > while ((syntax = ReadKeyword(fp, keyword)) != ACCESS) /* skip ahead to ACCESS clause */ 2079,2080c2098,2101 < } else if (syntax == ASN1_INTEGER || syntax == ASN1_OCTET_STRING) { < --- > } > else > if (syntax == ASN1_INTEGER || syntax == ASN1_OCTET_STRING) > { 2082,2087c2103,2106 < < /* < * if the syntax found is INTEGER, there may follow the enums for a < * textual description of the integer value; extract - don't skip. < */ < --- > /* ------------------------------------------------------------------*/ > /* if the syntax found is INTEGER, there may follow the enums for a */ > /* textual description of the integer value; extract - don't skip. */ > /* ------------------------------------------------------------------*/ 2090,2093c2109,2111 < /* < * We may get something like ``{ foo ( 99), ... }'' or < * ``(0..99)'' or nothing. < */ --- > /* ------------------------------------------------------------------------*/ > /* We may get something like ``{ foo ( 99), ... }'' or``(0..99)'' or nothing. */ > /* ------------------------------------------------------------------------*/ 2096c2114 < if (syntax == LEFTBRACKET) { --- > if (syntax == LEFTBRACKET) 2098c2116,2117 < } else if (syntax == LEFTPAREN) { --- > else > if (syntax == LEFTPAREN) { 2101,2106c2120,2123 < if ((baseType != ASN1_OCTET_STRING) || < ((baseType == ASN1_OCTET_STRING) && < ((syntax = ReadKeyword(fp, keyword)) != EOF) && < (syntax == SIZE) && < ((syntax = ReadKeyword(fp, keyword)) != EOF) && < (syntax == LEFTPAREN))) { --- > if ((baseType != ASN1_OCTET_STRING) || ((baseType == ASN1_OCTET_STRING) && > ((syntax = ReadKeyword(fp, keyword)) != EOF) && (syntax == SIZE) && > ((syntax = ReadKeyword(fp, keyword)) != EOF) && (syntax == LEFTPAREN))) > { 2110c2127,2128 < (syntax != RIGHTPAREN)))) { --- > (syntax != RIGHTPAREN)))) > { 2136,2141c2154,2159 < /* < * We simply skip up to the ACCESS key, like the old version < * did: wrong, but effective... < */ < < while (syntax != ACCESS) { --- > /* ------------------------------------------------------------*/ > /* We simply skip up to the ACCESS key, like the old version */ > /* did: wrong, but effective... */ > /* ------------------------------------------------------------*/ > while (syntax != ACCESS) > { 2143c2161 < if (syntax == EOF) { --- > if (syntax == EOF) 2146,2148d2163 < } < < if (restrictions && *restrictions) { 2149a2165,2167 > if (restrictions && *restrictions) > { > /* ---------------------------------------------------- */ 2150a2169 > /* ---------------------------------------------------- */ 2153c2172 < if (islower(nodePtr->label[0])) { --- > if (islower(nodePtr->label[0])) 2155c2174 < } --- > 2164,2166d2182 < } else if (syntax == ASN1_SEQUENCE) { < if ((syntax = ReadKeyword(fp, keyword)) == ASN1_SEQUENCE_OF) { < nodePtr->syntax = syntax; 2168c2184,2190 < while (syntax != ACCESS) { --- > else > if (syntax == ASN1_SEQUENCE) > { > if ((syntax = ReadKeyword(fp, keyword)) == ASN1_SEQUENCE_OF) > nodePtr->syntax = syntax; > while (syntax != ACCESS) > { 2170c2192 < if (syntax == EOF) { --- > if (syntax == EOF) 2174,2180c2196,2197 < /* we are fine. now continue below with the ACCESS mode: */ < } else { < < /* < * old eat-it-up code: skip anything to the ACCESS keyword: < */ < --- > else > { 2186,2188c2203,2205 < /* < * next keyword defines ACCESS mode for object < */ --- > /* ------------------------------------------- */ > /* next keyword defines ACCESS mode for object */ > /* ------------------------------------------- */ 2191c2208,2209 < if (syntax < READONLY || syntax > NOACCESS) { --- > if (syntax < READONLY || syntax > NOACCESS) > { 2197c2215,2216 < switch (syntax) { --- > switch (syntax) > { 2217,2219c2236,2238 < /* < * next keyword must be STATUS < */ --- > /* -----------------------------*/ > /* next keyword must be STATUS */ > /* -----------------------------*/ 2224,2226d2242 < /* < * next keyword defines status of object < */ 2227a2244,2246 > /* --------------------------------------*/ > /* next keyword defines status of object */ > /* --------------------------------------*/ 2229c2248,2249 < if (syntax < MANDATORY || syntax > DEPRECATED) { --- > if (syntax < MANDATORY || syntax > DEPRECATED) > { 2234c2254,2256 < switch (syntax) { --- > > switch (syntax) > { 2245c2267,2268 < if (nodePtr->typePtr && nodePtr->typePtr->macro == TNM_MIB_OBJECTTYPE) { --- > if (nodePtr->typePtr && nodePtr->typePtr->macro == TNM_MIB_OBJECTTYPE)

> {

Patch to tnm/snmp/tnmMibFrozen.c ================================

239c239,240 < * and counts the number of enums, tcs and nodes to be saved. --- > * and counts the number of enum/range restrictions, > * tcs and nodes to be saved. 242c243 < * Returns the number of enums, tcs and nodes. --- > * Returns the number of enums/range restrictions, tcs and nodes. 260c261,267 < for (ptr = nodePtr; ptr; (*numNodes)++, ptr = ptr->nextPtr) { --- > > #ifdef DUNF_DEBUG1 > printf ("\n\n--------- Analyzing ------------\n"); > #endif > > for (ptr = nodePtr; ptr; (*numNodes)++, ptr = ptr->nextPtr) > { 266c273,274 < if (ptr->typePtr) { --- > if (ptr->typePtr) > { 272,275c280,288 < if (ptr->typePtr->restKind == TNM_MIB_REST_ENUMS) { < for (restPtr = ptr->typePtr->restList; < restPtr; < (*numEnums)++, restPtr = restPtr->nextPtr) { --- > if (ptr->typePtr->restKind == TNM_MIB_REST_ENUMS || ptr->typePtr->restKind == TNM_MIB_REST_RANGE ) /*DUNF-FIX*/ > { > > #ifdef DUNF_DEBUG1 > printf (" Found restrict. for %s:%s \n",ptr->label,ptr->typePtr->name); > #endif > > for (restPtr = ptr->typePtr->restList; restPtr; (*numEnums)++, restPtr = restPtr->nextPtr) > if (typePtr->restKind == TNM_MIB_REST_ENUMS) /* DUNF-FIX */ 280d292 < } 282c294,295 < typePtr != tnmMibTypeSaveMark; typePtr = typePtr->nextPtr) { --- > typePtr != tnmMibTypeSaveMark; typePtr = typePtr->nextPtr) > { 283a297 > 288,291c302,315 < if (typePtr->restKind == TNM_MIB_REST_ENUMS) { < for (restPtr = typePtr->restList; < restPtr; < (*numEnums)++, restPtr = restPtr->nextPtr) { --- > > /* ___________________________________________________________________________* / > /* DUNF-FIX.. SaveData() traverses the list and writes restriction records as */ > /* it encounters them, however only enums were counted here so that record */ > /* count was incorrectly zero for any Range Restrictions */ > /* ___________________________________________________________________________* / > > if (typePtr->restKind == TNM_MIB_REST_ENUMS || typePtr->restKind == TNM_MIB_REST_RANGE ) /*DUNF-FIX*/ > { > #ifdef DUNF_DEBUG1 > printf (" Found restrict. for %s \n",typePtr->name); > #endif > for (restPtr = typePtr->restList;restPtr; (*numEnums)++, restPtr = restPtr->nextPtr) > if (typePtr->restKind == TNM_MIB_REST_ENUMS) /* DUNF-FIX */ 295d318 < } 322c345,346 < if (restKind == TNM_MIB_REST_ENUMS) { --- > if (restKind == TNM_MIB_REST_ENUMS) > { 363c387,389 < if (typePtr->restList) { --- > > if (typePtr->restList) > { 456c482,490 < for (nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) { --- > > #ifdef DUNF_DEBUG1 > printf ("-----------------------\n"); > printf (" Expected restrictions %d \n",numEnums); > printf ("-----------------------\n"); > #endif > > for (nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) > { 458c492,497 < for (ePtr = nPtr->typePtr->restList; ePtr; ePtr = ePtr->nextPtr) { --- > > for (ePtr = nPtr->typePtr->restList; ePtr; ePtr = ePtr->nextPtr) > { > #ifdef DUNF_DEBUG1 > printf ("Writing restriction for node:type %s:%s\n",nPtr->label,nPtr->typePtr->name); > #endif 463,464c502,510 < for (tPtr=tnmMibTypeList; tPtr != tnmMibTypeSaveMark; tPtr = tPtr->nextPtr) { < for (ePtr = tPtr->restList; ePtr; ePtr = ePtr->nextPtr) { --- > > > for (tPtr=tnmMibTypeList; tPtr != tnmMibTypeSaveMark; tPtr = tPtr->nextPtr) > { > for (ePtr = tPtr->restList; ePtr; ePtr = ePtr->nextPtr) > { > #ifdef DUNF_DEBUG1 > printf ("Writing restriction for type %s\n",tPtr->name); > #endif 474,475c520,533 < for (i = 0, nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) { < if (nPtr->typePtr) { --- > > #ifdef DUNF_DEBUG1 > printf ("----------------------\n"); > printf (" Expected TCs %d\n",numTCs); > printf ("----------------------\n"); > #endif > > for (i = 0, nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) > { > if (nPtr->typePtr) > { > #ifdef DUNF_DEBUG1 > printf ("Writing node:Type %s:%s\n",nPtr->label,nPtr->typePtr->name); > #endif 479c537,542 < for (tPtr=tnmMibTypeList; tPtr != tnmMibTypeSaveMark; tPtr = tPtr->nextPtr) { --- > > for (tPtr=tnmMibTypeList; tPtr != tnmMibTypeSaveMark; tPtr = tPtr->nextPtr) > { > #ifdef DUNF_DEBUG1 > printf ("Writing Type %s\n",tPtr->name); > #endif 486a550,554 > #ifdef DUNF_DEBUG1 > printf ("-------------------\n"); > printf (" Expected Nodes %d\n",numNodes); > printf ("-------------------\n"); > #endif 488c556,560 < for (i = 0, nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) { --- > for (i = 0, nPtr = nodePtr; nPtr; nPtr = nPtr->nextPtr) > { > #ifdef DUNF_DEBUG1 > printf ("Writing Node %s\n",nPtr->label); > #endif 490a563,567 > > #ifdef DUNF_DEBUG1 > printf ("\n\n"); > #endif > 579,581c656,658 < if (strcmp(pool, TNM_VERSION) != 0) { < TnmWriteLogMessage(NULL, TNM_LOG_DEBUG, < "wrong .idy file version...\n"); --- > if (strcmp(pool, TNM_VERSION) != 0) > { > TnmWriteLogMessage(NULL, TNM_LOG_DEBUG,"wrong .idy file version...\n"); 589,591c666,668 < if (1 != fread((char *) &numEnums, sizeof(numEnums), 1, fp)) { < TnmWriteLogMessage(NULL, TNM_LOG_DEBUG, < "error reading enum counter...\n"); --- > if (1 != fread((char *) &numEnums, sizeof(numEnums), 1, fp)) > { > TnmWriteLogMessage(NULL, TNM_LOG_DEBUG, "error reading enum counter...\n"); 595c672,673 < if (numEnums > 0) { --- > if (numEnums > 0) > { 599,601c677,680 < if (numEnums != fread(enums, sizeof(TnmMibRest), numEnums, fp)) { < TnmWriteLogMessage(NULL, TNM_LOG_DEBUG, < "error reading enums...\n"); --- > > if (numEnums != fread(enums, sizeof(TnmMibRest), numEnums, fp)) > { > TnmWriteLogMessage(NULL, TNM_LOG_DEBUG,"error reading enums...\n"); 610c689,690 < for (i = 0, restPtr = enums; i < numEnums; i++, restPtr++) { --- > for (i = 0, restPtr = enums; i < numEnums; i++, restPtr++) > {

Patch to tnm/snmp/tnmSnmpSend.c ================================

<523c523,524 < engineID = Tcl_GetStringFromObj(session->engineID, &engineIDLength); --- > engineID = Tcl_GetByteArrayFromObj(session->engineID, &engineIDLength); /*DUNF-FIX*/ > 602c603,604 < engineID = Tcl_GetStringFromObj(session->engineID, &engineIDLength); --- > engineID = Tcl_GetByteArrayFromObj(session->engineID, &engineIDLength); /*DUNF-FIX*/ > 605a608 > 738a742 > -- !! This message is brought to you via the `tkined & scotty' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>. !! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 15:27:59 MET