Handling set request...
Nick Woods
nwoods____pivia.com
Mon Jul 30 20:23:32 CEST 2001
I have a class derived from MibLeaf that currently handles get requests
by overriding the get_request function to set the value variable after
performing a callback to my application code that actually returns the
correct value. I'm not 100% sure if this is the best approach since it
does cause an extra copy of every variable that I am monitoring to
exist, but it does seem to work correctly.
What I really want to do now is provide a similar set of functionality
to handle SNMP set requests. I noticed a set of virtual functions in
MibLeaf that seem to deal with SNMP set requests. They are as follows:
virtual int commit_set_request(Request*, int);
virtual int prepare_set_request(Request*, int&);
virtual int undo_set_request(Request*, int&);
virtual void cleanup_set_request(Request*, int&);
virtual boolean value_ok(const Vbx&) { return TRUE; }
I was hoping that someone could tell me which functions I would need to
override and to provide a correct SNMP set operation that would handle
the request and pass the changed data to a callback function of mine.
In searching through the agent++ code I noticed the atm_mib example
overriding the prepare_set_request function and doing something with the
value. Any explanation of exactly what the following code snippet is
doing and if there is anything else that I need to do to get this all
working would be much apprecitated.
-----------------
int atmInterfaceMyNeighborIfName::prepare_set_request(Request* req, int&
ind)
{
int status;
if ((status = SimMibLeaf::prepare_set_request(req, ind)) !=
SNMP_ERROR_SUCCESS) return status;
Vb vb(req->get_value(ind));
OctetStr v;
vb.get_value(v);
if (!(((v.len() >= 0) && (v.len() <= 255))))
return SNMP_ERROR_WRONG_LENGTH;
return SNMP_ERROR_SUCCESS;
}
-------------
Thanks,
Nick Woods
More information about the AGENTPP
mailing list