[tkined] MIB Ranges code (alpha release)

Michael J. Long (mjlong@Summa4.COM)
Thu, 16 Oct 1997 09:18:33 -0400

I have completed the code to parse ranges out of MIB
files. I have uploaded the diffs against scotty-2.1.7.
The diffs were created by using the command 'diff -uNr'.
The diffs can be found at:
ftp://ftp.mindspring.com/pub/users/mjlong/scotty.diff

I have added a new option to the mib command, restrictions.
The syntax is as follows:
mib restricions ?-exact? restrictions label
Much the same [mib syntax] or [mib access] would be used.
The output for this command is a list. Here are some examples:
1. The syntax in the MIB is
INTEGER (0..127)
the output of [mib restrictions] would be
{range {0 127}}
2. The syntax in the MIB is
INTEGER {
up(1),
down(2),
testing(3)
}
the output of [mib restrictions] would be
{enum {up 1} {down 2} {testing 3}}
3. The syntax in the MIB is
INTEGER (1..10|15|20..30)
the output of [mib restrictions] would be
{range {1 10} {15} {20 30}}
4. The syntax in the MIB is
DisplayString (SIZE (0..255))
the output of [mib restrictions] would be
{range {0 255}}
NOTE: Even though this represents the size of
the data instead of the range of the data,
the output looks the same. The user must
use [mib syntax] to utilize this information
correctly.
That should give you the idea.

I also added the capability for negative numbers, binary and
hexadecimal encoded numbers (e.g., '101010101'b and '7fffffff'h).
I also corrected the annoying little bug that would give the
wrong line number in the MIB file (for a bad MIB file error).

I enhanced SNMP_DescribeMibNode to output Enumeration or Range
depending on what was appropriate.

A few things that I have not done yet:
- officially documented this behavior, this email is
the documenation for now
- verify the derived type's ramge is within the parent
type's range, i.e., I assume the MIB is written
correctly
- verify the sub-ranges do not overlap, e.g.,
( 1..15 | 10..20 ) would be invalid
- cleaned up the code, I still have a few things that
should be cleaned up to look "pretty"

One last thing, can reserved words, such as INTEGER, OCTET
STRING, etc. be mixed upper/lower case, or must they be all
uppercase?
The reason I am asking is because rfc1792.mib (line 14)
contains "size" instead of "SIZE" and the parser now
catches that as a 'bad mib format'.

Let me know what you think.

Michael J. Long

-- 
* Michael J. Long * #include <disclaimer.h>
*   Summa Four    * Work: mjlong@Summa4.COM
* Manchester, NH  * Play: mjlong@mindspring.com
--
!! 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.