Current File : //usr/share/doc/net-snmp/html/null_8c_source.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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>net-snmp: null.c Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">net-snmp
   &#160;<span id="projectnumber">5.4.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">null.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;net-snmp/net-snmp-config.h&gt;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#if HAVE_STRING_H</span>
<a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#else</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#include &lt;strings.h&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#endif</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;net-snmp/net-snmp-includes.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;net-snmp/agent/net-snmp-agent-includes.h&gt;</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;net-snmp/agent/null.h&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="keywordtype">int</span>
<a name="l00015"></a>00015 netsnmp_register_null(oid * loc, <span class="keywordtype">size_t</span> loc_len)
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017     <span class="keywordflow">return</span> netsnmp_register_null_context(loc, loc_len, NULL);
<a name="l00018"></a>00018 }
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keywordtype">int</span>
<a name="l00021"></a>00021 netsnmp_register_null_context(oid * loc, <span class="keywordtype">size_t</span> loc_len,
<a name="l00022"></a>00022                               <span class="keyword">const</span> <span class="keywordtype">char</span> *contextName)
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024     <a class="code" href="structnetsnmp__handler__registration__s.html" title="Root registration info.">netsnmp_handler_registration</a> *reginfo;
<a name="l00025"></a>00025     reginfo = <a class="code" href="group__util.html#ga9cd013bb193de5048149afeb9d94e424" title="Mallocs memory of sizeof(t), zeros it and returns a pointer to it.">SNMP_MALLOC_TYPEDEF</a>(<a class="code" href="structnetsnmp__handler__registration__s.html" title="Root registration info.">netsnmp_handler_registration</a>);
<a name="l00026"></a>00026     reginfo-&gt;<a class="code" href="structnetsnmp__handler__registration__s.html#ab932303bcdd9ee47ad6cefd77d9a4123" title="for mrTable listings, and other uses">handlerName</a> = strdup(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00027"></a>00027     reginfo-&gt;<a class="code" href="structnetsnmp__handler__registration__s.html#a264722b6b9385237fbcb5f8bc144d470" title="where are we registered at?">rootoid</a> = loc;
<a name="l00028"></a>00028     reginfo-&gt;rootoid_len = loc_len;
<a name="l00029"></a>00029     reginfo-&gt;<a class="code" href="structnetsnmp__handler__registration__s.html#a4ef77cb16c8094af69cdd67a654ebfa3" title="handler details">handler</a> =
<a name="l00030"></a>00030         <a class="code" href="group__handler.html#ga169c1653d481ed3d7df0c1795d99ca0c" title="creates a netsnmp_mib_handler structure given a name and a access method.">netsnmp_create_handler</a>(<span class="stringliteral">&quot;null&quot;</span>, netsnmp_null_handler);
<a name="l00031"></a>00031     <span class="keywordflow">if</span> (contextName)
<a name="l00032"></a>00032         reginfo-&gt;<a class="code" href="structnetsnmp__handler__registration__s.html#a6e58555978e555e87b07c535eae4313d" title="NULL = default context.">contextName</a> = strdup(contextName);
<a name="l00033"></a>00033     reginfo-&gt;modes = HANDLER_CAN_DEFAULT;
<a name="l00034"></a>00034     <span class="keywordflow">return</span> <a class="code" href="group__handler.html#gacdbdb9d74898a5bf04b0992ea0316aa4" title="register a handler, as defined by the netsnmp_handler_registration pointer.">netsnmp_register_handler</a>(reginfo);
<a name="l00035"></a>00035 }
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="keywordtype">int</span>
<a name="l00038"></a>00038 netsnmp_null_handler(<a class="code" href="structnetsnmp__mib__handler__s.html" title="the mib handler structure to be registered">netsnmp_mib_handler</a> *handler,
<a name="l00039"></a>00039                      <a class="code" href="structnetsnmp__handler__registration__s.html" title="Root registration info.">netsnmp_handler_registration</a> *reginfo,
<a name="l00040"></a>00040                      <a class="code" href="structnetsnmp__agent__request__info__s.html" title="The agent transaction request structure.">netsnmp_agent_request_info</a> *reqinfo,
<a name="l00041"></a>00041                      <a class="code" href="structnetsnmp__request__info__s.html" title="The netsnmp request info structure.">netsnmp_request_info</a> *requests)
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043     DEBUGMSGTL((<span class="stringliteral">&quot;helper:null&quot;</span>, <span class="stringliteral">&quot;Got request\n&quot;</span>));
<a name="l00044"></a>00044 
<a name="l00045"></a>00045     DEBUGMSGTL((<span class="stringliteral">&quot;helper:null&quot;</span>, <span class="stringliteral">&quot;  oid:&quot;</span>));
<a name="l00046"></a>00046     DEBUGMSGOID((<span class="stringliteral">&quot;helper:null&quot;</span>, requests-&gt;<a class="code" href="structnetsnmp__request__info__s.html#a455d87f6b7178fe19ea564c60c0ccb6f" title="variable bindings">requestvb</a>-&gt;<a class="code" href="structvariable__list.html#a7b5bdda01921550d24ea53033ce76146" title="Object identifier of variable.">name</a>,
<a name="l00047"></a>00047                  requests-&gt;<a class="code" href="structnetsnmp__request__info__s.html#a455d87f6b7178fe19ea564c60c0ccb6f" title="variable bindings">requestvb</a>-&gt;<a class="code" href="structvariable__list.html#a089e5b1a422bf8e693510ff5408a57a7" title="number of subid&#39;s in name">name_length</a>));
<a name="l00048"></a>00048     DEBUGMSG((<span class="stringliteral">&quot;helper:null&quot;</span>, <span class="stringliteral">&quot;\n&quot;</span>));
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     <span class="keywordflow">switch</span> (reqinfo-&gt;mode) {
<a name="l00051"></a>00051     <span class="keywordflow">case</span> MODE_GETNEXT:
<a name="l00052"></a>00052     <span class="keywordflow">case</span> MODE_GETBULK:
<a name="l00053"></a>00053         <span class="keywordflow">return</span> SNMP_ERR_NOERROR;
<a name="l00054"></a>00054 
<a name="l00055"></a>00055     <span class="keywordflow">case</span> MODE_GET:
<a name="l00056"></a>00056         <a class="code" href="group__snmp__agent.html#gabdbcfb3c9e26c8dd657850053daae189" title="set error for all requests">netsnmp_request_set_error_all</a>(requests, SNMP_NOSUCHOBJECT);
<a name="l00057"></a>00057         <span class="keywordflow">return</span> SNMP_ERR_NOERROR;
<a name="l00058"></a>00058 
<a name="l00059"></a>00059     <span class="keywordflow">default</span>:
<a name="l00060"></a>00060         <a class="code" href="group__snmp__agent.html#gabdbcfb3c9e26c8dd657850053daae189" title="set error for all requests">netsnmp_request_set_error_all</a>(requests, SNMP_ERR_NOSUCHNAME);
<a name="l00061"></a>00061         <span class="keywordflow">return</span> SNMP_ERR_NOERROR;
<a name="l00062"></a>00062     }
<a name="l00063"></a>00063 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>