...
for (i = 0; i < (int) newNameLen; i++) {
temp_struct->name[i] = (char) name[i + snmpTargetAddrOIDLen];
}
temp_struct->name[newNameLen] = '\0';
temp_struct->rowStatus = SNMP_ROW_NOTREADY;
...
After name is set 0.25, 0 is set as terminated. So there are two 0
(NULL) in a string.
So 0.25 can not be found.
I want to fix this. But how should I do?
If I fix this, will this fix take effect other mib files?
I search snmpTarget. And I found that SNMP-COMMUNITY-MIB.txt,SNMP-
NOTIFICATION-MIB.txt,DISMAN-EVENT- MIB.txt,SNMP-PROXY-MIB.txt depend
on it.
Anyone can discuss this with me?
Zhuyj
Can the above method work?
Zhu Yanjun
Zhuyj
On Wed, Jul 10, 2013 at 10:34:05AM +0800, zhuyj wrote:root@localhost:/root> snmpset -v 2c -c public 192.168.2.15 .1.3.6.1.6.3.12.1.2.1.9.0.25 i 5 SNMP-TARGET-MIB::snmpTargetAddrRowStatus.'..' = INTEGER: createAndWait(5) root@localhost:/root> snmpget -v 2c -c NETMAN 192.168.2.15 .1.3.6.1.6.3.12.1.2.1.9.0.25 i 5 snmp_build: unknown failuresnmpget: Error building ASN.1 representation (Can't build OID for variable) Notice that there is no error when setting, only when trying to get.That is natural. You are setting one object to the value 5, but you are trying to get 3 objects, 1.3.6.1.6.3.12.1.2.1.9.0.25, i, and 5. snmpget complains that it cannot build the ASN.1 representation for the object 5, which is quite correct as the first element of an object identifier must be 0 or 1. What you want is just snmpget -v 2c -c NETMAN 192.168.2.15 .1.3.6.1.6.3.12.1.2.1.9.0.25 I admit that the error message could have been clearer. /Niels
snmpTargetAddrName OBJECT-TYPE
SYNTAX SnmpAdminString (SIZE(1..32))
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"The locally arbitrary, but unique identifier associated
with this snmpTargetAddrEntry."
::= { snmpTargetAddrEntry 1 }
The type of snmpTargetAddrName is SnmpAdminString.I found that SNMP-COMMUNITY-MIB.txt,SNMP- NOTIFICATION-MIB.txt,DISMAN-
EVENT- MIB.txt,SNMP-PROXY-MIB.txt depend on snmpTargetMIB.txt.
Does this patch make difference on the above mibs?
Zhuyj
Hi, Magnus && Niels
Thanks for your help! I am testing your patch. This patch can solve the
most problems.
But Ihave a question, is this a bug? I mean that '0' in snmpAdminString
is a bug, or not?
Would you like to discuss this with me?
The use of control codes should be avoided.
... implementations must be prepared to
encounter any code point from 0x00000000 ...
zhuyj
On 07/10/2013 04:53 PM, Magnus Fromreide wrote:
> On Wed, 2013-07-10 at 10:34 +0800, zhuyj wrote:
>> Hi,
>>
>> Attempting to create a new entry with a zero index fails silently.
> Ok, You want to index your entry with the string <NUL><EM>.
>
> The mess up is, just as usual, that people believes that <NUL> is a
> string terminator. That is wrong.
>
> Your idea of using \xff as a string terminator is, while not wrong (\xff
> is forbidden in utf-8 strings), confusing for a casual reader of the
> code.
>
> The correct solution is to store the length of the passed in octet
> sequence.
>
> A completely untested patch against master is attached.
>
> Does it help you?
>
> Note - the rename of name to nameData and get_addrForName to
> get_addrForName2 was to make it easier to find unconverted code.
>
> /MF
>
>> root@localhost:/root> snmpset -v 2c -c public 192.168.2.15
>> .1.3.6.1.6.3.12.1.2.1.9.0.25 i 5
>> SNMP-TARGET-MIB::snmpTargetAddrRowStatus.'..' = INTEGER: createAndWait(5)
>> root@localhost:/root> snmpget -v 2c -c NETMAN 192.168.2.15
>> .1.3.6.1.6.3.12.1.2.1.9.0.25 i 5
>> snmp_build: unknown failuresnmpget: Error building ASN.1 representation
>> (Can't build OID for variable)
>>
>> Notice that there is no error when setting, only when trying to get.
>>
>> The version:
>>
>> usr@ubuntu1004:~$ snmpset --version
>> NET-SNMP version: 5.7.2
>> usr@ubuntu1004:~$ snmpget --version
>> NET-SNMP version: 5.7.2
>> usr@ubuntu1004:~$ snmpd --version
>>
>> NET-SNMP version: 5.7.2
>> Web: http://www.net-snmp.org/
>> Email: net-snm...@lists.sourceforge.net
>>
>> I want to support 0.25 in snmpAdminString. What should I pay attention to?
>>
>> Best regards.
>>
>> zhuyj
>>