On 22 January 2013 21:21, Guillermo Veneranda <guillev...@gmail.com> wrote:
> I try what you say and... It's Works! :)

But of course, oh ye of little faith....

> Let's go now for the SET!

OK.
So go back to the code generated by mib2c.
Add the declaration of 'example1' as before,
and tweak the MODE_GET block to report this value
(directly, *not* read from the /tmp file just yet).

Now look at the other blocks - the ones that handle
SET processing.

At it's simplest, you just need to use two of these:
   MODE_SET_RESERVE1 and either
MODE_SET_ACTION or MODE_SET_COMMIT

The RESERVE1 code is probably OK as it stands.
It checks to see if the incoming assignment is an
integer value (as opposed to a string or an OID),
and complains if it's not.
    If your MIB object can only accept a particular
range of values (say 1 to 10), then this is the place
where you would check that the new value was OK,
and reject the request if it was out of range.

Acting on the assignment is simply a matter of
putting the new value into the 'example1' variable.
i.e.
     example1 =  *(request->requestvb->val.integer);

This operation is so simple that it cannot possibly fail
(at least as long as the 'request' structure is valid!),
so it can go in either ACTION or COMMIT.

Try that - with the other SET blocks left empty
(i.e.
     case MODE_SET_XXX;
         break;
)
Compile that into the agent as before - you should find
that you can issue an snmpset command for this object
and have the new value returned by a subsequent GET
or snmpwalk request.


Try that, and then come back, and we can talk about how
to extend this to saving the new value in a file.
   (Please note that this is *not* simply a matter of adding
    suitable   'fopen/write/fclose' calls - there are other
    considerations that need to be taken into account)

But get the basic SET processing working first,
and then we can move on to the next stage.

Dave

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to