[AGENT++] reporting an error from MibTable::update(Request*)

Frank Fock fock at agentpp.com
Fri Mar 16 00:10:40 CET 2007


Hello Razvan,

The code below is OK, except that you should return a gen(Vb)Err
instead. See RFC 3416 §4.2.1 for details.

For the "update" method, you can indeed set the error index
to 1.

Best regards,
Frank


Razvan Cojocaru wrote:
> Hello.
> 
> For MibLeaves, I employ the following strategy for reporting an error if
> I cannot retrieve the value associated with the OID:
> 
> void get_request(Request* req, int ind)
> {
> 	try {
> 		*((SNMPTYPE *)value) = get_value_from_socket();
> 	} catch(... /* socket exceptions */) {
> 		req->set_error_index(ind);
> 		req->set_error_status(SNMP_ERROR_RESOURCE_UNAVAIL);
> 	}
> 	MibLeaf::get_request(req, ind);
> }
> 
> Does that look about right? But for MibTable::update(Request *req), I
> don't have an index parameter. Since I'm constructing dynamic tables, I
> have to report an error for the same case as the MibLeaf above (socket
> errors, and so on). How then do I properly report an error from
> MibTable::update(Request* req)? Is it enough to just do
> req->set_error_status(SNMP_ERROR_RESOURCE_UNAVAIL), or do I also have to
> do req->set_error_index(1) or something similar?
> 
> Thanks.
> 
> 

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the AGENTPP mailing list