[prev in list] [next in list] [prev in thread] [next in thread] 

List:       net-snmp-coders
Subject:    Re: Which error code to choose?
From:       "Giuseppe Modugno" <g.modugno () elettronika ! it>
Date:       2011-05-17 15:15:54
Message-ID: 4DD2AD4A.19683.1DA47A6 () g ! modugno ! elettronika ! it
[Download RAW message or body]

[Attachment #2 (Multipart/Alternative)]


On 17 May 2011 at 11:04, Robert Story wrote:
> On Tue, 17 May 2011 09:05:05 +0200 Giuseppe wrote:
> GM> 2. Variables that are meaningful only if an optional hardware is 
> GM> installed in the electronic equipment. In this case, if the optional 
> GM> hardware is not present, I can't associate a value for related 
> GM> variables. Should I return an error code to GET and SET requests? 
> GM> Which error codes? SNMP_ERR_GENERR?
> GM> In the first I tried SNMP_ERR_RESOURCEUNAVAILABLE, but I think it is 
> GM> for other purposes.
> 
> For scalars, set the varbind to SNMP_NOSUCHOBJECT, eg
> 
>   netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
> 
> For table objects, use SNMP_NOSUCHINSTANCE.
> 
> Make sure you do not return an error from the function.

Now I understand.  The handler should returns always 
SNMP_ERR_NOERROR, but the variable should be marked with an error 
code with netsnmp_set_request_error().

Thank you for point me that.  I have tried returning the error from 
the handler and I had snmpwalk stopped at that OID.  Does 
netsnmp_set_request_error() solve the problem and let snmpwalk to 
cross the entire tree, even in presence of errors for some 
variables?


> GM> 3. Variables that are related to hardware sub-sections in the 
> GM> machine. What should I return if this sub-section stop communicating 
> GM> with the agent (for a mulfunction)? Which error code to choose?
> 
> SNMP_ERR_RESOURCEUNAVAILABLE.

Should I use netsnmp_set_request_error() as above, or should I 
return this error from the handler function?


[Attachment #5 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
</head>
<body>
<div align="left">
<font face="Courier New" size="2">
<span style=" font-size:10pt">
On 17 May 2011 at 11:04, Robert Story wrote:</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; On Tue, 17 May 2011 09:05:05 +0200 Giuseppe wrote:</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; 2. Variables that are meaningful only if an optional hardware is </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; installed in the electronic equipment. In this case, if the optional </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; hardware is not present, I can't associate a value for related </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; variables. Should I return an error code to GET and SET requests? </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; Which error codes? SNMP_ERR_GENERR?</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; In the first I tried SNMP_ERR_RESOURCEUNAVAILABLE, but I think it is </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; for other purposes.</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; For scalars, set the varbind to SNMP_NOSUCHOBJECT, eg</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt;&#160;&#160; netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; For table objects, use SNMP_NOSUCHINSTANCE.</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; Make sure you do not return an error from the function.</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier New" size="2">
<span style=" font-size:10pt">
Now I understand.&#160; The handler should returns always 
SNMP_ERR_NOERROR, but the variable should be marked with an error 
code with netsnmp_set_request_error().</span></font>
</div>
<div align="left">
<font face="Courier New" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier New" size="2">
<span style=" font-size:10pt">
Thank you for point me that.&#160; I have tried returning the error from 
the handler and I had snmpwalk stopped at that OID.&#160; Does 
netsnmp_set_request_error() solve the problem and let snmpwalk to 
cross the entire tree, even in presence of errors for some 
variables?</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; 3. Variables that are related to hardware sub-sections in the </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; machine. What should I return if this sub-section stop communicating </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; GM&gt; with the agent (for a mulfunction)? Which error code to choose?</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; </span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
&gt; SNMP_ERR_RESOURCEUNAVAILABLE.</span></font>
</div>
<div align="left">
<font face="Courier New" color="#7f0000" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier New" size="2">
<span style=" font-size:10pt">
Should I use netsnmp_set_request_error() as above, or should I 
return this error from the handler function?</span></font>
</div>
<div align="left">
&nbsp;</div>
</body>
</html>


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic