scotty-2.0.2 agent: bugs regarding instances

Robert Premuz (rpremuz@srce.hr)
Thu, 22 Feb 1996 18:15:54 +0100 (MET)

Hello,

It seems to me that there are two more bugs in scotty-2.0.2 when
working in agent mode.

My system environment:
tcsh% uname -a
SunOS malik 5.4 Generic_101945-10 sun4m sparc

First, when an instance is created for a not-accessible MIB object,
Scotty reports an empty error message. In the SNMP_CreateInst
function in the snmp/snmpInst.c file there is the following piece of
code:

access = nodePtr->access;
if (access == M_NOACCESS) {
Tcl_AppendResult (interp, "object \"", label, "\" is not accessible",
TCL_STATIC);
goto errorExit;
}

I haven't debugged this to see why it doesn't do what is expected.

Second, an agent created in SNMPv2 mode should response to a get
request with exceptional values for variables which don't have
instances in the agent. Unfortunately, scotty does not response with
exceptional values, but with some zero values. (I've tried this case
only for SNMPv2C session.)

In the GetRequest function in the snmp/snmpAgent.c file there is the
following piece of code:

/*
* SNMPv1 handles this case by sending back an error PDU
* while SNMPv2 uses exceptions. We create an exception
* varbind to reflect the error types defined in RFC 1448.
*/

if (session->version == SNMPv1) {
response->error_status = E_NOSUCHNAME;
snmpStats.snmpOutNoSuchNames++;
goto varBindError;
}

Tcl_DStringStartSublist (&response->varbind);
Tcl_DStringAppendElement (&response->varbind, inVarBindPtr[i].soid);
if (request->type == SNMP_GET) {
MIB_Node *nodePtr = MIB_FindNode (inVarBindPtr[i].soid,
NULL, 0);
if (!nodePtr || nodePtr->childPtr) {
Tcl_DStringAppendElement (&response->varbind,
"noSuchObject");
} else {
Tcl_DStringAppendElement (&response->varbind,
"noSuchInstance");
}
} else {
Tcl_DStringAppendElement (&response->varbind, "endOfMibView");
}

I haven't debugged this to see why it doesn't do what is expected.

You can try to run the example agent and manager scripts at the end
of the message to experience the bugs.

Looking forward to your replys.

v
-- rpr. : Robert Premuz
Internet: rpremuz@malik.srce.hr * Voice at home: +385 (0)1 687564

----------------------------------------------------------------------
#! /usr/local/bin/scotty -f
#
# example_agent.tcl based on scotty-2.0.2

mib load unix.mib ;# fsIdentifier
snmp alias sessOpts {-port 12345 -agent ""}
set agent [snmp session -alias sessOpts -version SNMPv2C]

$agent bind "" begin {puts "Received an %T PDU. Varbinds:\n%V"}

# This tries creating the instance for a not-accessible MIB object.
# It returns an empty error message.
#
if [catch {$agent instance fsIdentifier fsIdentifier.0 0} errMssg] {
puts stderr "Error in $argv0: \"$errMssg\"\nBacktrace:\n$errorInfo"
}

$agent instance fsIdentifier.0 fsIdentifier.0 0

puts "Waiting SNMP events"
----------------------------------------------------------------------

----------------------------------------------------------------------
#! /usr/local/bin/scotty -f
#
# example_manager.tcl based on scotty-2.0.2

# Show SNMP response returned from the agent.
#
proc show_response { varbinds requestID sessionID error_status error_index
peer_addr peer_port packet_type } {
puts "Request ID = $requestID ; Packet type = $packet_type"
puts "Error status = $error_status ; Error index = $error_index"

foreach varbind $varbinds {
set variableName [ mib name [ lindex $varbind 0 ] ]
set variableValue [ lindex $varbind 2 ]
puts "Variable $variableName = \"$variableValue\""
}
}

mib load unix.mib ;# fsIdentifier
snmp alias sessOpts { -port 12345 -retries 5 -timeout 20 }
set sess [snmp session -alias sessOpts -version SNMPv2C]

set varlist {fsIdentifier.0 fsIdentifier.9 fsName.9}
$sess get $varlist {show_response {%V} {%R} {%S} {%E} {%I} {%A} {%P} {%T}}
snmp wait
exit
----------------------------------------------------------------------