As nobody replied to my post on the same subject sent on Fri, 8 Mar
1996 17:13:31 +0100 (MET), I'm posting this again (has anybody
received it at least?).
This is a report of a bug in scotty-2.0.2 working in agent mode (this
time I suggest a patch for it). The agent mistakes in finding the next
instance in the case explained by the following example.
Suppose there is a MIB object called userID which is a column of a
conceptual table. The index of the table is defined as:
INDEX { IMPLIED userName }
where the syntax of the userName is:
SYNTAX DisplayString
and the DisplayString is a textual convention having the syntax:
SYNTAX OCTET STRING (SIZE (0..255))
Now, suppose the agent creates the following instances of the userID:
user-friendly name | OID
-----------------------------------------
userID.a | {userID 'a'}
userID.ab | {userID 'a' 'b'}
userID.abc | {userID 'a' 'b' 'c'}
userID.ac | {userID 'a' 'c'}
If, for example, a manager asks the agent for the next variable of the
userID object, the agent should reply userID.a . But, the scotty agent
replies userID.abc which is wrong because userID.a and userID.ab are
lexicographically previous to userID.abc .
The following patch is the output of
'diff -c snmpInst.c.orig snmpInst.c':
------------------------------cut-here--------------------------------
*** snmpInst.c.orig Wed Mar 20 16:01:38 1996
--- snmpInst.c Wed Mar 20 16:02:22 1996
***************
*** 301,306 ****
--- 301,308 ----
if (p->childPtr) {
if (len > 0 && p->subid == oid[0]) {
inst = TreeFindNext (p->childPtr, oid + 1, len - 1);
+ } else if (p->syntax) {
+ return p;
} else {
inst = TreeFindNext (p->childPtr, NULL, 0);
}
------------------------------cut-here--------------------------------
If you run the example agent and manager scripts at the end of the
message with and without the patch, you can experience the bug.
Regards,
v
-- rpr. : Robert B. Premuz
Internet: rpremuz@malik.srce.hr * Voice at home: +385 (0)1 687564
Here are the example scripts:
------------------------------cut-here--------------------------------
#! /usr/local/bin/scotty -f
#
# example_agent.tcl based on scotty-2.0.2
snmp alias sessOpts {-port 12345 -agent ""}
set agent [snmp session -alias sessOpts -version SNMPv2C]
mib load unix.mib
set users {a ab abc ac ace}
set id 0
foreach user $users {
set instID [mib scan userName $user]
$agent instance userID:$instID _userID($user) $id
incr id
}
puts "Waiting SNMP events"
------------------------------cut-here--------------------------------
------------------------------cut-here--------------------------------
#!/usr/local/bin/scotty -f
#
# example_manager.tcl based on scotty-2.0.2
proc show_varbinds {varbinds} {
foreach varbind $varbinds {
set varName [mib name [lindex $varbind 0]]
# Make the instance ID user friendly.
#
set subIds [split $varName "."]
set varName "[lindex $subIds 0]."
foreach subId [lrange $subIds 1 end] {
if {$subId < 32 || $subId > 255} {
append varName $subId
} else {
append varName [format "%c" $subId]
}
}
set varSyntax [lindex $varbind 1]
set varValue [lindex $varbind 2]
puts "($varSyntax) $varName = \"$varValue\""
}
}
snmp alias sessOpts {-port 12345 -retries 5 -timeout 300}
set sess [snmp session -alias sessOpts -version SNMPv2C]
mib load unix.mib ;# MIB definitions for userID, userName
set users {a ab abc ac ace}
foreach user $users {
puts "get on userID.$user returned:"
show_varbinds [$sess get "userID:[mib scan userName $user]"]
}
puts ""
puts "getnext on userID returned:"
show_varbinds [$sess getnext userID]
foreach user $users {
puts "getnext on userID.$user returned:"
show_varbinds [$sess getnext "userID:[mib scan userName $user]"]
}
puts ""
puts "walk on userID returned:"
$sess walk var userID {show_varbinds $var}
snmp wait
exit
------------------------------cut-here--------------------------------