Hello all,
I was playing around with the code example for set SNMP. I noticed that “strings” and “strings” which contain an octet string have the same data type: OCTET STRING.
Here I was able to send normal strings to a service without problems and got a “success” back. However, when I tried to send a “real” octet string I only got a
Request status = SNMP: Cannot modify variable: Bad Value.
So I wanted to ask how such an octet string has to be formatted.
Mine is as follows (without final “\0”)
char* buf = “FF FF FF 03 00 05 5D 99 0A 1C C0 B1”
It was checkt and added to the vb object it is as follows:
Snmp_pp::OctetStr octetstr(buf);
if (octetstr.valid()) {
vb.set_value(octetstr);
}
pdu += vb;
status = snmp.set(pdu, *target);
(I still don’t know how to properly indent )
In another thread here in the forum I saw that an octet can also be separated with “:” instead of spaces or, that it is lowercase. So I wanted to ask if this could be relevant.
I checked the content of the octet string with a different programm I wrote using net-snmp. I guess, that I either use the “set” function wrongly for “real” octet strings or my string isn’t properly formatted.
Hello AGENTPP,
thank you for your reply.
Right now I am getting the following output (the formatted octet string seems to contain some strange non-printable characters):
Maybe it will help to find a solution if I try to explain what I am trying to imitate.
When I try to test my target from the command line, I use the following command. (From net-snmp project)
snmpset -v1 -c user XX.XXX.XX.XXX 1.3.6.1.4.1.1206.4.2.3.6.3.0 x “FF FF FF 03 00 05 0A A1 0A 1C C0 B1”
Here I am just trying to send a hex coded string to the targets address. The “x” indicates a “Hex String” and the payload can be, but not has to be null terminated. From this, I thought it would be sufficient to just send the string as is to the target.
the code with OctetStr::from_hex_string() should work. From the error string "SNMP: Cannot perform operation, General Error" with the value #define SNMP_ERROR_GENERAL_VB_ERR 5 //!< General VB error, see error index I would assume that your Vb object is not properly created.
Are all the different HEX Strings from your posts valid values?
Hello,
I had just written a huge wall of text in which I had completely described my problem and my setup. Why I had two different strings in my posts. I told myself everything again and went through my code and the posts here again.
What can I say. I think I should buy myself a duck.
This is how to use the from_hex_string(char* str) function properly(in my case):
I think what confused me, besides my not yet develloped C++ skills, was that the documentation states, that the from_hex_string() function expects a const OctetStr& hex_String, but in my case worked with a char* hex_String
Thank you for your answers and time! If I can somehow buy you a coffee, you are welcome to message me.