I have played around with the code at [http://www.righto.com/pc/snmp.html
] to get values from an SNMP device. At the moment that seems to be working OK.
My problem comes in attempting to update the device. The code sample came with a SNMPset method that can update an integer value on the device. I need to update integers and octstrings. I've modified the code from :
asnValue.asnType = ASN_INTEGER;
asnValue.asnValue.number = value;
asnValue.asnType = ASN_OCTETSTRING;
asnValue.asnValue.str = value;
However the .str data type is AsnOctetString. The number data type was integer so I could just supply this a int variable.
There is no Text property of the AsnOctetString only a stream which is a IntPtr. I guess I need to set this to the pointer of the string that has the data I want to send to the device.
How can I do this? I've tried the fixed statement but I get compiler errors with the following code :
AsnOctetString asnOctetString = new AsnOctetString();
string setValue = "Sample String Value" ;
fixed( char* p = setValue )
asnOctetString.stream = p ;
asnValue.asnValue.str = asnOctetString;
Points will be awarded to the person who crack this, perhaps extra points for someone who can give the a polished method!