Code Search for Developers
 
 
  

cmu__compat_8c-source.html from net-snmp at Krugle


Show cmu__compat_8c-source.html syntax highlighted

<!--#set var="section" value="development" -->
<!--#include virtual="/page-top.html" -->
<!-- CONTENT START -->
  <!-- Generated by Doxygen 1.3.9.1 -->

  <div class="qindex">
    <a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class=
    "qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class=
    "qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <a class=
    "qindex" href="examples.html">Examples</a>
  </div>

  <div class="nav">
    <a class="el" href="dir_000005.html">snmplib</a>
  </div>

  <h1>cmu_compat.c</h1>

  <div class="fragment">
    <pre class="fragment">
00001 <span class="preprocessor">#include &lt;net-snmp/net-snmp-config.h&gt;</span>
00002 
00003 <span class="preprocessor">#ifdef CMU_COMPATIBLE</span>
00004 
00005 <span class="preprocessor">#include &lt;net-snmp/mib_api.h&gt;</span>
00006 <span class="preprocessor">#include &lt;net-snmp/pdu_api.h&gt;</span>
00007 <span class="preprocessor">#include &lt;net-snmp/session_api.h&gt;</span>
00008 
00009 <span class="keywordtype">int</span>
00010 mib_TxtToOid(<span class="keywordtype">char</span> *Buf, oid ** OidP, size_t * LenP)
00011 {
00012     <span class="keywordflow">return</span> <a class="code" href=
"group__mib__utilities.html#ga62">read_objid</a>(Buf, *OidP, LenP);
00013 }
00014 
00015 <span class="keywordtype">int</span>
00016 mib_OidToTxt(oid * O, size_t OidLen, <span class="keywordtype">char</span> *Buf, size_t BufLen)
00017 {
00018     _sprint_objid(Buf, O, OidLen);
00019     <span class="keywordflow">return</span> 1;
00020 }
00021 
00022 
00023 <span class="comment">/*</span>
00024 <span class="comment"> * cmu_snmp_parse - emulate CMU library's snmp_parse.</span>
00025 <span class="comment"> *</span>
00026 <span class="comment"> * Parse packet, storing results into PDU.</span>
00027 <span class="comment"> * Returns community string if success, NULL if fail.</span>
00028 <span class="comment"> * WARNING: may return a zero length community string.</span>
00029 <span class="comment"> *</span>
00030 <span class="comment"> * Note:</span>
00031 <span class="comment"> * Some CMU-aware apps call init_mib(), but do not</span>
00032 <span class="comment"> * initialize a session.</span>
00033 <span class="comment"> * Check Reqid to make sure that this module is initialized.</span>
00034 <span class="comment"> */</span>
00035 
00036 u_char         *
00037 cmu_snmp_parse(<a class="code" href="structsnmp__session.html">netsnmp_session</a> * session,
00038                <a class="code" href="structsnmp__pdu.html">netsnmp_pdu</a> *pdu, u_char * data, size_t length)
00039 {
00040     u_char         *bufp = NULL;
00041 
00042     snmp_sess_init(session);    <span class="comment">/* gimme a break! */</span>
00043 
00044     <span class="keywordflow">switch</span> (pdu-&gt;<a class="code" href="structsnmp__pdu.html#o0">version</a>) {
00045     <span class="keywordflow">case</span> SNMP_VERSION_1:
00046     <span class="keywordflow">case</span> SNMP_VERSION_2c:
00047     <span class="keywordflow">case</span> SNMP_DEFAULT_VERSION:
00048         <span class="keywordflow">break</span>;
00049     <span class="keywordflow">default</span>:
00050         <span class="keywordflow">return</span> NULL;
00051     }
00052 <span class="preprocessor">#ifndef NO_INTERNAL_VARLIST</span>
00053     <span class="keywordflow">if</span> (snmp_parse(0, session, pdu, data, length) != SNMP_ERR_NOERROR) {
00054         <span class="keywordflow">return</span> NULL;
00055     }
00056 <span class="preprocessor">#else</span>
00057     <span class="comment">/*</span>
00058 <span class="comment">     * while there are two versions of variable_list:</span>
00059 <span class="comment">     * use an internal variable list for snmp_parse;</span>
00060 <span class="comment">     * clone the result.</span>
00061 <span class="comment">     */</span>
00062     <span class="keywordflow">if</span> (1) {
00063         <a class="code" href="structsnmp__pdu.html">netsnmp_pdu</a>    *snmp_clone_pdu(<a class="code" href=
"structsnmp__pdu.html">netsnmp_pdu</a> *);
00064         <a class="code" href="structsnmp__pdu.html">netsnmp_pdu</a>    *snmp_2clone_pdu(<a class="code" href=
"structsnmp__pdu.html">netsnmp_pdu</a> *from_pdu,
00065                                         <a class="code" href="structsnmp__pdu.html">netsnmp_pdu</a> *to_pdu);
00066 
00067         <a class="code" href="structsnmp__pdu.html">netsnmp_pdu</a>    *ipdu;
00068         ipdu = snmp_clone_pdu(pdu);
00069         <span class="keywordflow">if</span> (snmp_parse(0, session, ipdu, data, length) != SNMP_ERR_NOERROR) {
00070             snmp_free_internal_pdu(ipdu);
00071             <span class="keywordflow">return</span> NULL;
00072         }
00073         pdu = snmp_2clone_pdu(ipdu, pdu);
00074         snmp_free_internal_pdu(ipdu);
00075     }
00076 <span class="preprocessor">#endif                          </span><span class="comment">/* NO_INTERNAL_VAR_LIST */</span>
00077 
00078     <span class="comment">/*</span>
00079 <span class="comment">     * Add a null to meet the caller's expectations. </span>
00080 <span class="comment">     */</span>
00081 
00082     bufp = (u_char *) malloc(1 + pdu-&gt;<a class="code" href="structsnmp__pdu.html#o19">community_len</a>);
00083     <span class="keywordflow">if</span> (bufp &amp;&amp; pdu-&gt;<a class="code" href=
"structsnmp__pdu.html#o19">community_len</a>) {
00084         memcpy(bufp, pdu-&gt;<a class="code" href="structsnmp__pdu.html#o18">community</a>, pdu-&gt;<a class="code" href=
"structsnmp__pdu.html#o19">community_len</a>);
00085         bufp[pdu-&gt;<a class="code" href="structsnmp__pdu.html#o19">community_len</a>] = <span class=
"charliteral">'\0'</span>;
00086     }
00087     <span class="keywordflow">return</span> (bufp);
00088 }
00089 
00090 
00091 <span class="preprocessor">#endif                          </span><span class="comment">/* CMU_COMPATIBLE */</span>
</pre>
  </div>
  <hr size="1" />

  <address style="align: right;">
    <small>Generated on Fri Dec 30 13:47:44 2005 for net-snmp by&nbsp; <a href="http://www.doxygen.org/index.html"><img src=
    "doxygen.png" alt="doxygen" align="middle" border="0" /></a> 1.3.9.1</small>
  </address>
<!-- CONTENT END -->
<!--#include virtual="/page-bottom.html" -->





See more files for this project here

net-snmp

net-snmp provides tools and libraries relating to the Simple Network\r\nManagement Protocol including: An extensible agent, An SNMP library,\r\ntools to request or set information from SNMP agents, tools to\r\ngenerate and handle SNMP traps, etc.\r\n

Project homepage: http://sourceforge.net/projects/net-snmp
Programming language(s): C,Perl,Shell Script
License: other

  mfd/
  acconfig_8h-source.html
  acconfig_8h.html
  agent_2snmp__perl_8c-source.html
  agent__callbacks_8h-source.html
  agent__callbacks_8h.html
  agent__handler_8c-source.html
  agent__handler_8c.html
  agent__handler_8h-source.html
  agent__handler_8h.html
  agent__index_8c-source.html
  agent__index_8c.html
  agent__index_8h-source.html
  agent__index_8h.html
  agent__module__config_8h-source.html
  agent__read__config_8c-source.html
  agent__read__config_8c.html
  agent__read__config_8h-source.html
  agent__read__config_8h.html
  agent__registry_8c-source.html
  agent__registry_8c.html
  agent__registry_8h-source.html
  agent__registry_8h.html
  agent__trap_8c-source.html
  agent__trap_8c.html
  agent__trap_8h-source.html
  agent__trap_8h.html
  all__helpers_8c-source.html
  all__helpers_8h-source.html
  annotated.html
  asn1_8c-source.html
  asn1_8h-source.html
  auto__nlist_8c-source.html
  auto__nlist_8c.html
  auto__nlist_8h-source.html
  auto__nlist_8h.html
  autonlist_8h-source.html
  autonlist_8h.html
  baby__steps_8c-source.html
  baby__steps_8h-source.html
  blah.html
  bulk__to__next_8c-source.html
  bulk__to__next_8h-source.html
  cache__handler_8c-source.html
  cache__handler_8h-source.html
  callback_8c-source.html
  callback_8h-source.html
  check__varbind_8c-source.html
  check__varbind_8h-source.html
  cmu__compat_8c-source.html
  cmu__compat_8h-source.html
  config_8h-source.html
  config_8h.html
  config__api_8h-source.html
  container_8c-source.html
  container_8h-source.html
  container__binary__array_8c-source.html
  container__binary__array_8h-source.html
  container__iterator_8c-source.html
  container__iterator_8h-source.html
  container__list__ssll_8c-source.html
  container__list__ssll_8h-source.html
  container__null_8c-source.html
  container__null_8h-source.html
  data__list_8c-source.html
  data__list_8h-source.html
  data__set_8c-example.html
  data__set_8c-source.html
  data__set_8h-source.html
  debug__handler_8c-source.html
  debug__handler_8h-source.html
  default__store_8c-source.html
  default__store_8h-source.html
  default_store.html
  definitions_8h-source.html
  delayed__instance_8c-example.html
  delayed__instance_8c-source.html
  delayed__instance_8h-source.html
  deprecated.html
  dir_000000.html
  dir_000001.html
  dir_000002.html
  dir_000003.html
  dir_000004.html
  dir_000005.html
  dir_000006.html
  dir_000007.html
  dir_000008.html
  doxygen.css
  doxygen.gif
  doxygen.png
  ds__agent_8h-source.html
  ds__agent_8h.html
  example_8c-source.html
  example_8h-source.html
  examples.html
  factory_8h-source.html
  fd__event__manager_8c-source.html
  fd__event__manager_8h-source.html
  file__utils_8c-source.html
  file__utils_8h-source.html
  files.html