snmpSet bug
Lukasz Szczepankowski
lukasz____nnu.com
Thu Jun 28 18:48:00 CEST 2001
I have been trying to use the snmpSet utility from the
consoleExamples in the SNMP++v3 package, and I found a
couple of problems with this example.
An if statement that determines the community
name from a command line argument (around line 318)
looks like this:
if ( strstr( argv[x],"-c")!=0) {
ptr = argv[x]; ptr++; ptr++;
community = ptr;
continue;
}
Searching for the "-c" string in the argument will
return a result not only for the community name argument,
but also for the context name (option "-cn")
and context engine id (option "-ce").
An easy fix would be to replace this code with:
if ( strstr( argv[x],"-c")!=0 &&
strstr( argv[x],"-cn")==0 &&
strstr( argv[x],"-ce")==0) {
ptr = argv[x]; ptr++; ptr++;
community = ptr;
continue;
}
A second problem is with sending the context name and the
context engine id as a part of the pdu. The set_context_name()
and set_context_engine_id() functions are called only on the
pdu used for the snmp get operation (lines 455 and 456), which
is used to determine the type of the snmp object.
A second pdu object is created for the snmp set operation
(called setpdu), which does not contain the context information,
and so it fails to set the new value.
The lines:
setpdu.set_context_name(contextName);
setpdu.set_context_engine_id(contextEngineID);
should be added, for example, after line 517.
Best Regards,
Lukasz Szczepankowski
NetNearU Corporation
http://www.nnu.com
More information about the AGENTPP
mailing list