Closed stadvar closed 2 years ago
Hi @stadvar
The function of the snmp.ObjectType
constant is to define the SMIv2 "base types" ("ObjectSyntax" from the SNMPv2-SMI MIB in RFC 2578) and the SMIv2 textual conventions of the SNMP-TC MIB (RFC 2579), along with the BER tag for these (and for some RFC 3416 response exceptions).
"HexString" is not in these categories, and as such doesn't belong in the snmp.ObjectType
constant.
According to the Net-SNMP "snmpset" man page:
... 's', 'x', 'd' and 'b' are all different ways of specifying an OCTET STRING value...
So in this library you'd use the snmp.ObjectType.OctetString
type for this, and put the hex string into a Buffer
. So for your example, you could use these varbinds in a session.set()
call:
const varbinds = [
{
oid: '1.3.6.1.2.1.17.7.1.4.3.1.2.3',
type: snmp.ObjectType.OctetString,
value: Buffer.from('2517ffa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'hex')
}, {
oid: '1.3.6.1.2.1.17.7.1.4.3.1.4.3',
type: snmp.ObjectType.OctetString,
value: Buffer.from('2517ff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'hex')
}
];
Got it. It works, thanks.
Hello. Is there any possibility to add HexString constant to snmp.ObjectType? For example i need to do snmpset HexString to my switch (Linksys SPS224G4) like this: snmpset -v 2c -c private 192.168.1.101 1.3.6.1.2.1.17.7.1.4.3.1.2.3 x 2517ffa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1.3.6.1.2.1.17.7.1.4.3.1.4.3 x 2517ff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000