Using the net-snmp library to set/get custom MIB value on printer

"Nick Bartolotti" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi,
 
Using NET-SNMP package version 5.4.2.1 on Windows XP x64 + all updates and service packs.  AMD Athalon 64 bit CPU.  2 GB RAM.  Sorry if this arrives as HTML mail, using OWA...
 
Background:
 
When using the above package to get/set a private MIB on a multi-function printer the results are exactly what I'd expect.  Reading returns 3, setting the integer value to 4 reboots the printer.  I have scripted this functionality to reboot several dozen printers nightly.  This solution works but because the MIB is private I can't distribute the script as the MIB is shown in plain text.
 
As a starting point to making a more secure distribution I created a Win32 console app based on the tutorial sample found at http://www.net-snmp.org/wiki/index.php/TUT:Simple_Application and linking with the libraries found in the 5.4.2.1 distribution.
 
The app works correctly to read the MIB (identical response as snmpget command line util) but fails when writing to the MIB with the value 4.
 
At first I was getting a -61 return value because I was passing the fourth parameter incorrectly:
 
char x = '4';
int r = snmp_add_var(pdu, anOID, anOID_len, ASN_INTEGER, &x);
 
I then looked at the source code for snmpset and changed the code:
 
char x = '4';
char i = 'i';
// int r = snmp_add_var(pdu, anOID, anOID_len, ASN_INTEGER, &x);
int r = snmp_add_var(pdu, anOID, anOID_len, i, &x);

Now I get -56 as the return.
 
My C is a bit rusty; am I forgetting something fundamental here?
 
Is -56 (SNMPERR_BAD_NAME) an error returned from the printer or an error from the library?
 
What might I be doing wrong here?  Could the error value indicate that the OID is not recognized by the printer?
 
Thanks,
NB

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.