Handling set request...
Frank Fock
Frank.Fock____t-online.de
Tue Jul 31 02:53:38 CEST 2001
Nick,
Please find my comments inline:
Nick Woods wrote:
> 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:
>
Please make sure that you always call the corresponding superclass
method if you override one of the below methods.
>
> virtual int commit_set_request(Request*, int);
Override this method to implement the actions you want to
take if the object is SET, but do not forget to call the super class
commit_set_request in order to backup the undo value and set the
cache value of the object correctly.
>
> virtual int prepare_set_request(Request*, int&);
This can be overriden to implement sanity checks on the supplied value.
>
> virtual int undo_set_request(Request*, int&);
Override this when you need to take any actions when a commit is
undone.
>
> virtual void cleanup_set_request(Request*, int&);
Is called to free any resources allocated during prepare and commit
phase.
>
> virtual boolean value_ok(const Vbx&) { return TRUE; }
Can be overriden to check supplied values for WRONG_VALUE
errors. (Can also be done in prepare_set_request)
>
>
> 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.
>
Did you read the AGENT++v2.x documentation already? There is an
example for setting an object. You can find it at http://www.agentpp.com
>
> -----------------
> int atmInterfaceMyNeighborIfName::prepare_set_request(Request* req, int&
> ind)
> {
> int status;
Check if superclass has already detected an error.
>
> if ((status = SimMibLeaf::prepare_set_request(req, ind)) !=
> SNMP_ERROR_SUCCESS) return status;
>
Check whether supplied OCTET STRING has a length between
0 and 255 bytes.
>
> 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;
> }
Best regards,
Frank
More information about the AGENTPP
mailing list