Code Search for Developers
 
 
  

agent__index_8h.html from net-snmp at Krugle


Show agent__index_8h.html syntax highlighted

<!--#set var="section" value="development" -->
<!--#include virtual="/page-top.html" -->
<!-- CONTENT START -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>agent_index.h File Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.11 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>agent_index.h File Reference</h1>
<p>
<a href="agent__index_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Defines</h2></td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a0">ALLOCATE_THIS_INDEX</a>&nbsp;&nbsp;&nbsp;0x0</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a>&nbsp;&nbsp;&nbsp;0x1</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a2">ALLOCATE_NEW_INDEX</a>&nbsp;&nbsp;&nbsp;0x3</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a3">ANY_INTEGER_INDEX</a>&nbsp;&nbsp;&nbsp;-1</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a4">ANY_STRING_INDEX</a>&nbsp;&nbsp;&nbsp;NULL</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a5">ANY_OID_INDEX</a>&nbsp;&nbsp;&nbsp;NULL</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a6">INDEX_ERR_GENERR</a>&nbsp;&nbsp;&nbsp;-1</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a7">INDEX_ERR_WRONG_TYPE</a>&nbsp;&nbsp;&nbsp;-2</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a8">INDEX_ERR_NOT_ALLOCATED</a>&nbsp;&nbsp;&nbsp;-3</td></tr>
<tr><td nowrap align=right valign=top>#define&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a9">INDEX_ERR_WRONG_SESSION</a>&nbsp;&nbsp;&nbsp;-4</td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td nowrap align=right valign=top>char *&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a10">register_string_index</a> (oid *, size_t, char *)</td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a11">register_int_index</a> (oid *, size_t, int)</td></tr>
<tr><td nowrap align=right valign=top>variable_list *&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a12">register_oid_index</a> (oid *, size_t, oid *, size_t)</td></tr>
<tr><td nowrap align=right valign=top>variable_list *&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a13">register_index</a> (struct variable_list *, int, struct snmp_session *)</td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a14">release_index</a> (struct variable_list *)</td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a15">remove_index</a> (struct variable_list *, struct snmp_session *)</td></tr>
<tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a16">unregister_index_by_session</a> (struct snmp_session *)</td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="agent__index_8h.html#a17">unregister_index</a> (struct variable_list *, int, struct snmp_session *)</td></tr>
</table>
<hr><h2>Define Documentation</h2>
<a name="a1" doxytag="agent_index.h::ALLOCATE_ANY_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ALLOCATE_ANY_INDEX&nbsp;&nbsp;&nbsp;0x1
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00006">6</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a2" doxytag="agent_index.h::ALLOCATE_NEW_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ALLOCATE_NEW_INDEX&nbsp;&nbsp;&nbsp;0x3
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00007">7</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a0" doxytag="agent_index.h::ALLOCATE_THIS_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ALLOCATE_THIS_INDEX&nbsp;&nbsp;&nbsp;0x0
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00005">5</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a3" doxytag="agent_index.h::ANY_INTEGER_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ANY_INTEGER_INDEX&nbsp;&nbsp;&nbsp;-1
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00010">10</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a5" doxytag="agent_index.h::ANY_OID_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ANY_OID_INDEX&nbsp;&nbsp;&nbsp;NULL
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00012">12</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a4" doxytag="agent_index.h::ANY_STRING_INDEX"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define ANY_STRING_INDEX&nbsp;&nbsp;&nbsp;NULL
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00011">11</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a6" doxytag="agent_index.h::INDEX_ERR_GENERR"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define INDEX_ERR_GENERR&nbsp;&nbsp;&nbsp;-1
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00014">14</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a8" doxytag="agent_index.h::INDEX_ERR_NOT_ALLOCATED"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define INDEX_ERR_NOT_ALLOCATED&nbsp;&nbsp;&nbsp;-3
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00016">16</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a9" doxytag="agent_index.h::INDEX_ERR_WRONG_SESSION"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define INDEX_ERR_WRONG_SESSION&nbsp;&nbsp;&nbsp;-4
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00017">17</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<a name="a7" doxytag="agent_index.h::INDEX_ERR_WRONG_TYPE"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define INDEX_ERR_WRONG_TYPE&nbsp;&nbsp;&nbsp;-2
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8h-source.html#l00015">15</a> of file <a class="el" href="agent__index_8h-source.html">agent_index.h</a>.    </td>
  </tr>
</table>
<hr><h2>Function Documentation</h2>
<a name="a13" doxytag="agent_index.h::register_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> struct variable_list* register_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>struct variable_list *&nbsp;</td>
          <td class="mdname">&nbsp; <em>varbind</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname">&nbsp; <em>flags</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>struct snmp_session *&nbsp;</td>
          <td class="mdname">&nbsp; <em>ss</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00140">140</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.
<p>
Referenced by <a class="el" href="agent__index_8c-source.html#l00100">register_int_index</a>(), <a class="el" href="agent__index_8c-source.html#l00123">register_oid_index</a>(), and <a class="el" href="agent__index_8c-source.html#l00079">register_string_index</a>().
<p>
<div class="fragment"><pre>00141 {
00142     <font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *new_index, *idxptr, *idxptr2;
00143     <font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *prev_oid_ptr, *prev_idx_ptr;
00144     <font class="keywordtype">int</font> res, res2, i;
00145 
00146 <font class="preprocessor">#if defined(USING_AGENTX_SUBAGENT_MODULE) &amp;&amp; !defined(TESTING)</font>
00147     <font class="keywordflow">if</font> (ds_get_boolean(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a1">DS_AGENT_ROLE</a>) == <a class="code" href="snmpd_8h.html#a1">SUB_AGENT</a> )
00148         <font class="keywordflow">return</font>( agentx_register_index( ss, varbind, flags ));
00149 <font class="preprocessor">#endif</font>
00150                 <font class="comment">/* Look for the requested OID entry */</font>
00151     prev_oid_ptr = NULL;
00152     prev_idx_ptr = NULL;
00153     res  = 1;
00154     res2 = 1;
00155     <font class="keywordflow">for</font>( idxptr = <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> ; idxptr != NULL;
00156                          prev_oid_ptr = idxptr, idxptr = idxptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>) {
00157         <font class="keywordflow">if</font> ((res = snmp_oid_compare(varbind-&gt;name, varbind-&gt;name_length,
00158                                         idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;name,
00159                                         idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;name_length)) &lt;= 0 )
00160                 <font class="keywordflow">break</font>;
00161     }
00162 
00163                 <font class="comment">/*  Found the OID - now look at the registered indices */</font>
00164     <font class="keywordflow">if</font> ( res == 0 &amp;&amp; idxptr ) {
00165         <font class="keywordflow">if</font> ( varbind-&gt;type != idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;type )
00166             <font class="keywordflow">return</font> NULL;                <font class="comment">/* wrong type */</font>
00167 
00168                         <font class="comment">/*</font>
00169                          * If we've been asked for an arbitrary new value,
00170                          *      then find the end of the list.
00171                          * If we've been asked for any arbitrary value,
00172                          *      then look for an unused entry, and use that.
00173                          *      If there aren't any, continue as for new.
00174                          * Otherwise, locate the given value in the (sorted)
00175                          *      list of already allocated values
00176                          */
00177         <font class="keywordflow">if</font> ( flags &amp; <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a> ) {
00178             <font class="keywordflow">for</font>(idxptr2 = idxptr ; idxptr2 != NULL;
00179                  prev_idx_ptr = idxptr2, idxptr2 = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>) {
00180                 <font class="keywordflow">if</font> ( flags == <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a> &amp;&amp; idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> == NULL ) {
00181                     idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> = ss ;
00182                     <font class="keywordflow">return</font> idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>;
00183                 }
00184             }
00185         }
00186         <font class="keywordflow">else</font> {
00187             <font class="keywordflow">for</font>(idxptr2 = idxptr ; idxptr2 != NULL;
00188                  prev_idx_ptr = idxptr2, idxptr2 = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>) {
00189                 <font class="keywordflow">switch</font> ( varbind-&gt;type ) {
00190                     <font class="keywordflow">case</font> ASN_INTEGER:
00191                         res2 = (*varbind-&gt;val.integer - *idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.integer);
00192                         <font class="keywordflow">break</font>;
00193                     <font class="keywordflow">case</font> ASN_OCTET_STR:
00194                         i = SNMP_MIN(varbind-&gt;val_len, idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len);
00195                         res2 = memcmp(varbind-&gt;val.string, idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.string, i);
00196                         <font class="keywordflow">break</font>;
00197                     <font class="keywordflow">case</font> ASN_OBJECT_ID:
00198                         res2 = snmp_oid_compare(varbind-&gt;val.objid, varbind-&gt;val_len/<font class="keyword">sizeof</font>(oid),
00199                                         idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid,
00200                                         idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len/<font class="keyword">sizeof</font>(oid));
00201                         <font class="keywordflow">break</font>;
00202                     <font class="keywordflow">default</font>:
00203                         <font class="keywordflow">return</font> NULL;            <font class="comment">/* wrong type */</font>
00204                 }
00205                 <font class="keywordflow">if</font> ( res2 &lt;= 0 )
00206                     <font class="keywordflow">break</font>;
00207             }
00208             <font class="keywordflow">if</font> ( res2 == 0 )
00209                 <font class="keywordflow">return</font> NULL;                    <font class="comment">/* duplicate value */</font>
00210         }
00211     }
00212 
00213                 <font class="comment">/*</font>
00214                  * OK - we've now located where the new entry needs to
00215                  *      be fitted into the index registry tree          
00216                  * To recap:
00217                  *      'prev_oid_ptr' points to the head of the OID index
00218                  *          list prior to this one.  If this is null, then
00219                  *          it means that this is the first OID in the list.
00220                  *      'idxptr' points either to the head of this OID list,
00221                  *          or the next OID (if this is a new OID request)
00222                  *          These can be distinguished by the value of 'res'.
00223                  *
00224                  *      'prev_idx_ptr' points to the index entry that sorts
00225                  *          immediately prior to the requested value (if any).
00226                  *          If an arbitrary value is required, then this will
00227                  *          point to the last allocated index.
00228                  *          If this pointer is null, then either this is a new
00229                  *          OID request, or the requested value is the first
00230                  *          in the list.
00231                  *      'idxptr2' points to the next sorted index (if any)
00232                  *          but is not actually needed any more.
00233                  *
00234                  *  Clear?  Good!
00235                  *      I hope you've been paying attention.
00236                  *          There'll be a test later :-)
00237                  */
00238 
00239                 <font class="comment">/*</font>
00240                  *      We proceed by creating the new entry
00241                  *         (by copying the entry provided)
00242                  */
00243         new_index = (<font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *)calloc( 1, sizeof( struct snmp_index ));
00244         <font class="keywordflow">if</font> (new_index == NULL)
00245             <font class="keywordflow">return</font> NULL;
00246 
00247         <font class="keywordflow">if</font> (0 == snmp_varlist_add_variable(&amp;new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>,
00248                       varbind-&gt;name, 
00249                       varbind-&gt;name_length,
00250                       varbind-&gt;type,
00251                       varbind-&gt;val.string,
00252                       varbind-&gt;val_len))<font class="keyword"> </font>{
00253 <font class="comment">/*      if (snmp_clone_var( varbind, new_index-&gt;varbind ) != 0 ) */</font>
00254             free( new_index );
00255             <font class="keywordflow">return</font> NULL;
00256         }
00257         new_index-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> = ss;
00258 
00259         <font class="keywordflow">if</font> ( varbind-&gt;type == ASN_OCTET_STR &amp;&amp; flags == <a class="code" href="agent__index_8h.html#a0">ALLOCATE_THIS_INDEX</a> )
00260             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.string[new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len] = 0;
00261 
00262                 <font class="comment">/*</font>
00263                  * If we've been given a value, then we can use that, but
00264                  *    otherwise, we need to create a new value for this entry.
00265                  * Note that ANY_INDEX and NEW_INDEX are both covered by this
00266                  *   test (since NEW_INDEX &amp; ANY_INDEX = ANY_INDEX, remember?)
00267                  */
00268         <font class="keywordflow">if</font> ( flags &amp; <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a> ) {
00269             <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00270                 <font class="keywordflow">if</font> ( snmp_clone_var( prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>, new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a> ) != 0 )<font class="keyword"> </font>{
00271                     free( new_index );
00272                     <font class="keywordflow">return</font> NULL;
00273                 }
00274             }
00275             <font class="keywordflow">else</font>
00276                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.string = new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf;
00277 
00278             <font class="keywordflow">switch</font> ( varbind-&gt;type ) {
00279                 <font class="keywordflow">case</font> ASN_INTEGER:
00280                     <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00281                         (*new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.integer)++; 
00282                     }
00283                     <font class="keywordflow">else</font>
00284                         *(new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.integer) = 1;
00285                     new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len = <font class="keyword">sizeof</font>(long);
00286                     <font class="keywordflow">break</font>;
00287                 <font class="keywordflow">case</font> ASN_OCTET_STR:
00288                     <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00289                         i =  new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len-1;
00290                         <font class="keywordflow">while</font> ( new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf[ i ] == <font class="charliteral">'z'</font> ) {
00291                             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf[ i ] = <font class="charliteral">'a'</font>;
00292                             i--;
00293                             <font class="keywordflow">if</font> ( i &lt; 0 ) {
00294                                 i =  new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len;
00295                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf[ i ] = <font class="charliteral">'a'</font>;
00296                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf[ i+1 ] = 0;
00297                             }
00298                         }
00299                         new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf[ i ]++;
00300                     }
00301                     <font class="keywordflow">else</font>
00302                         strcpy((<font class="keywordtype">char</font> *)new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf, <font class="stringliteral">"aaaa"</font>);
00303                     new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len = strlen((<font class="keywordtype">char</font> *)new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;buf);
00304                     <font class="keywordflow">break</font>;
00305                 <font class="keywordflow">case</font> ASN_OBJECT_ID:
00306                     <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00307                         i =  prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len/<font class="keyword">sizeof</font>(oid) -1;
00308                         <font class="keywordflow">while</font> ( new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[ i ] == 255 ) {
00309                             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[ i ] = 1;
00310                             i--;
00311                             <font class="keywordflow">if</font> ( i == 0 &amp;&amp; new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[0] == 2 ) {
00312                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[ 0 ] = 1;
00313                                 i =  new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len/<font class="keyword">sizeof</font>(oid);
00314                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[ i ] = 0;
00315                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len += <font class="keyword">sizeof</font>(oid);
00316                             }
00317                         }
00318                         new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[ i ]++;
00319                     }
00320                     <font class="keywordflow">else</font> {
00321                         <font class="comment">/* If the requested OID name is small enough,</font>
00322                          *   append another OID (1) and use this as the
00323                          *   default starting value for new indexes.
00324                          */
00325                         <font class="keywordflow">if</font> ( (varbind-&gt;name_length+1) * <font class="keyword">sizeof</font>(oid) &lt;= 40 ) {
00326                             <font class="keywordflow">for</font> ( i = 0 ; i &lt; (int)varbind-&gt;name_length ; i++ )
00327                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[i] = varbind-&gt;name[i];
00328                             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[varbind-&gt;name_length] = 1;
00329                             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len =
00330                                         (varbind-&gt;name_length+1) * <font class="keyword">sizeof</font>(oid);
00331                         }
00332                         <font class="keywordflow">else</font> {
00333                             <font class="comment">/* Otherwise use '.1.1.1.1...' */</font>
00334                             i = 40/<font class="keyword">sizeof</font>(oid);
00335                             <font class="keywordflow">if</font> ( i &gt; 4 )
00336                                 i = 4;
00337                             new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len = i * (<font class="keyword">sizeof</font>(oid));
00338                             <font class="keywordflow">for</font> (i-- ; i&gt;=0 ; i-- )
00339                                 new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.objid[i] = 1;
00340                         }
00341                     }
00342                     <font class="keywordflow">break</font>;
00343                 <font class="keywordflow">default</font>:
00344                     snmp_free_var(new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>);
00345                     free( new_index );
00346                     <font class="keywordflow">return</font> NULL;        <font class="comment">/* Index type not supported */</font>
00347             }
00348         }
00349 
00350                 <font class="comment">/*</font>
00351                  * Right - we've set up the new entry.
00352                  * All that remains is to link it into the tree.
00353                  * There are a number of possible cases here,
00354                  *   so watch carefully.
00355                  */
00356         <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00357             new_index-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> = prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00358             new_index-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a> = prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>;
00359             prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> = new_index;
00360         }
00361         <font class="keywordflow">else</font> {
00362             <font class="keywordflow">if</font> ( res == 0 &amp;&amp; idxptr ) {
00363                 new_index-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> = idxptr;
00364                 new_index-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a> = idxptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>;
00365             }
00366             <font class="keywordflow">else</font> {
00367                 new_index-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> = NULL;
00368                 new_index-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a> = idxptr;
00369             }
00370 
00371             <font class="keywordflow">if</font> ( prev_oid_ptr ) {
00372                 <font class="keywordflow">while</font> ( prev_oid_ptr ) {
00373                     prev_oid_ptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a> = new_index;
00374                     prev_oid_ptr = prev_oid_ptr-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00375                 }
00376             }
00377             <font class="keywordflow">else</font>
00378                 <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> = new_index;
00379         }
00380     <font class="keywordflow">return</font> new_index-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>;
00381 }
</pre></div>    </td>
  </tr>
</table>
<a name="a11" doxytag="agent_index.h::register_int_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int register_int_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>oid *&nbsp;</td>
          <td class="mdname">&nbsp; <em>name</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname">&nbsp; <em>name_len</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname">&nbsp; <em>val</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00100">100</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00101 {
00102     <font class="keyword">struct </font>variable_list varbind, *res;
00103     
00104     memset( &amp;varbind, 0, <font class="keyword">sizeof</font>(<font class="keyword">struct</font> variable_list));
00105     varbind.type = ASN_INTEGER;
00106     snmp_set_var_objid( &amp;varbind, name, name_len );
00107     varbind.val.string = varbind.buf;
00108     <font class="keywordflow">if</font> ( val != <a class="code" href="agent__index_8h.html#a3">ANY_INTEGER_INDEX</a> ) {
00109         varbind.val_len = <font class="keyword">sizeof</font>(long);
00110         *varbind.val.integer = val;
00111         res = <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a0">ALLOCATE_THIS_INDEX</a>, main_session );
00112     }
00113     <font class="keywordflow">else</font>
00114         res = <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a>, main_session );
00115 
00116     <font class="keywordflow">if</font> ( res == NULL )
00117         <font class="keywordflow">return</font> -1;
00118     <font class="keywordflow">else</font>
00119         <font class="keywordflow">return</font> *res-&gt;val.integer;
00120 }
</pre></div>    </td>
  </tr>
</table>
<a name="a12" doxytag="agent_index.h::register_oid_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> struct variable_list* register_oid_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>oid *&nbsp;</td>
          <td class="mdname">&nbsp; <em>name</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname">&nbsp; <em>name_len</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>oid *&nbsp;</td>
          <td class="mdname">&nbsp; <em>value</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname">&nbsp; <em>value_len</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00123">123</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00125 {
00126     <font class="keyword">struct </font>variable_list varbind;
00127     
00128     memset( &amp;varbind, 0, <font class="keyword">sizeof</font>(<font class="keyword">struct</font> variable_list));
00129     varbind.type = ASN_OBJECT_ID;
00130     snmp_set_var_objid( &amp;varbind, name, name_len );
00131     <font class="keywordflow">if</font> ( value != <a class="code" href="agent__index_8h.html#a5">ANY_OID_INDEX</a> ) {
00132         snmp_set_var_value( &amp;varbind, (u_char*)value, value_len*<font class="keyword">sizeof</font>(oid) );
00133         <font class="keywordflow">return</font>( <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a0">ALLOCATE_THIS_INDEX</a>, main_session ));
00134     }
00135     <font class="keywordflow">else</font>
00136         <font class="keywordflow">return</font>( <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a>, main_session ));
00137 }
</pre></div>    </td>
  </tr>
</table>
<a name="a10" doxytag="agent_index.h::register_string_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> char* register_string_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>oid *&nbsp;</td>
          <td class="mdname">&nbsp; <em>name</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname">&nbsp; <em>name_len</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>char *&nbsp;</td>
          <td class="mdname">&nbsp; <em>cp</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00079">79</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00080 {
00081     <font class="keyword">struct </font>variable_list varbind, *res;
00082     
00083     memset( &amp;varbind, 0, <font class="keyword">sizeof</font>(<font class="keyword">struct</font> variable_list));
00084     varbind.type = ASN_OCTET_STR;
00085     snmp_set_var_objid( &amp;varbind, name, name_len );
00086     <font class="keywordflow">if</font> ( cp != <a class="code" href="agent__index_8h.html#a4">ANY_STRING_INDEX</a> ) {
00087         snmp_set_var_value( &amp;varbind, (u_char *)cp, strlen(cp) );
00088         res = <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a0">ALLOCATE_THIS_INDEX</a>, main_session );
00089     }
00090     <font class="keywordflow">else</font>
00091         res = <a class="code" href="agent__index_8h.html#a13">register_index</a>( &amp;varbind, <a class="code" href="agent__index_8h.html#a1">ALLOCATE_ANY_INDEX</a>, main_session );
00092 
00093     <font class="keywordflow">if</font> ( res == NULL )
00094         <font class="keywordflow">return</font> NULL;
00095     <font class="keywordflow">else</font>
00096         <font class="keywordflow">return</font> (<font class="keywordtype">char</font> *)res-&gt;val.string;
00097 }
</pre></div>    </td>
  </tr>
</table>
<a name="a14" doxytag="agent_index.h::release_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int release_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>struct variable_list *&nbsp;</td>
          <td class="mdname1">&nbsp; <em>varbind</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00388">388</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00389 {
00390     <font class="keywordflow">return</font>( <a class="code" href="agent__index_8h.html#a17">unregister_index</a>( varbind, TRUE, NULL ));
00391 }
</pre></div>    </td>
  </tr>
</table>
<a name="a15" doxytag="agent_index.h::remove_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int remove_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>struct variable_list *&nbsp;</td>
          <td class="mdname">&nbsp; <em>varbind</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>struct snmp_session *&nbsp;</td>
          <td class="mdname">&nbsp; <em>ss</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00398">398</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00399 {
00400     <font class="keywordflow">return</font>( <a class="code" href="agent__index_8h.html#a17">unregister_index</a>( varbind, FALSE, ss ));
00401 }
</pre></div>    </td>
  </tr>
</table>
<a name="a17" doxytag="agent_index.h::unregister_index"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int unregister_index </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>struct variable_list *&nbsp;</td>
          <td class="mdname">&nbsp; <em>varbind</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname">&nbsp; <em>remember</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>struct snmp_session *&nbsp;</td>
          <td class="mdname">&nbsp; <em>ss</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00415">415</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.
<p>
Referenced by <a class="el" href="agent__index_8c-source.html#l00388">release_index</a>(), and <a class="el" href="agent__index_8c-source.html#l00398">remove_index</a>().
<p>
<div class="fragment"><pre>00416 {
00417     <font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *idxptr, *idxptr2;
00418     <font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *prev_oid_ptr, *prev_idx_ptr;
00419     <font class="keywordtype">int</font> res, res2, i;
00420 
00421 <font class="preprocessor">#if defined(USING_AGENTX_SUBAGENT_MODULE) &amp;&amp; !defined(TESTING)</font>
00422     <font class="keywordflow">if</font> (ds_get_boolean(DS_APPLICATION_ID, <a class="code" href="ds__agent_8h.html#a1">DS_AGENT_ROLE</a>) == <a class="code" href="snmpd_8h.html#a1">SUB_AGENT</a> )
00423         <font class="keywordflow">return</font>( agentx_unregister_index( ss, varbind ));
00424 <font class="preprocessor">#endif</font>
00425                 <font class="comment">/* Look for the requested OID entry */</font>
00426     prev_oid_ptr = NULL;
00427     prev_idx_ptr = NULL;
00428     res  = 1;
00429     res2 = 1;
00430     <font class="keywordflow">for</font>( idxptr = <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> ; idxptr != NULL;
00431                          prev_oid_ptr = idxptr, idxptr = idxptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>) {
00432         <font class="keywordflow">if</font> ((res = snmp_oid_compare(varbind-&gt;name, varbind-&gt;name_length,
00433                                         idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;name,
00434                                         idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;name_length)) &lt;= 0 )
00435                 <font class="keywordflow">break</font>;
00436     }
00437 
00438     <font class="keywordflow">if</font> ( res != 0 )
00439         <font class="keywordflow">return</font> <a class="code" href="agent__index_8h.html#a8">INDEX_ERR_NOT_ALLOCATED</a>;
00440     <font class="keywordflow">if</font> ( varbind-&gt;type != idxptr-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;type )
00441         <font class="keywordflow">return</font> <a class="code" href="agent__index_8h.html#a7">INDEX_ERR_WRONG_TYPE</a>;
00442 
00443     <font class="keywordflow">for</font>(idxptr2 = idxptr ; idxptr2 != NULL;
00444                 prev_idx_ptr = idxptr2, idxptr2 = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>) {
00445         i = SNMP_MIN(varbind-&gt;val_len, idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val_len);
00446         res2 = memcmp(varbind-&gt;val.string, idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a>-&gt;val.string, i);
00447         <font class="keywordflow">if</font> ( res2 &lt;= 0 )
00448             <font class="keywordflow">break</font>;
00449     }
00450     <font class="keywordflow">if</font> ( res2 != 0 )
00451         <font class="keywordflow">return</font> <a class="code" href="agent__index_8h.html#a8">INDEX_ERR_NOT_ALLOCATED</a>;
00452     <font class="keywordflow">if</font> ( ss != idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> )
00453         <font class="keywordflow">return</font> <a class="code" href="agent__index_8h.html#a9">INDEX_ERR_WRONG_SESSION</a>;
00454 
00455                 <font class="comment">/*</font>
00456                  *  If this is a "normal" index unregistration,
00457                  *      mark the index entry as unused, but leave
00458                  *      it in situ.  This allows differentiation
00459                  *      between ANY_INDEX and NEW_INDEX
00460                  */
00461     <font class="keywordflow">if</font> ( remember ) {
00462         idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> = NULL;        <font class="comment">/* Unused index */</font>
00463         <font class="keywordflow">return</font> SNMP_ERR_NOERROR;
00464     }
00465                 <font class="comment">/*</font>
00466                  *  If this is a failed attempt to register a
00467                  *      number of indexes, the successful ones
00468                  *      must be removed completely.
00469                  */
00470     <font class="keywordflow">if</font> ( prev_idx_ptr ) {
00471         prev_idx_ptr-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00472     }
00473     <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( prev_oid_ptr ) {
00474         <font class="keywordflow">if</font> ( idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> )        <font class="comment">/* Use p_idx_ptr as a temp variable */</font>
00475             prev_idx_ptr = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00476         <font class="keywordflow">else</font>
00477             prev_idx_ptr = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>;
00478         <font class="keywordflow">while</font> ( prev_oid_ptr ) {
00479             prev_oid_ptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a> = prev_idx_ptr;
00480             prev_oid_ptr = prev_oid_ptr-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00481         }
00482     }
00483     <font class="keywordflow">else</font> {
00484         <font class="keywordflow">if</font> ( idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a> )
00485             <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>;
00486         <font class="keywordflow">else</font>
00487             <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>;
00488     }
00489     snmp_free_var( idxptr2-&gt;<a class="code" href="structsnmp__index.html#m0">varbind</a> );
00490     free( idxptr2 );
00491     <font class="keywordflow">return</font> SNMP_ERR_NOERROR;
00492 }
</pre></div>    </td>
  </tr>
</table>
<a name="a16" doxytag="agent_index.h::unregister_index_by_session"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void unregister_index_by_session </td>
          <td class="md">(&nbsp;</td>
          <td class="md" nowrap>struct snmp_session *&nbsp;</td>
          <td class="mdname1">&nbsp; <em>ss</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="agent__index_8c-source.html#l00404">404</a> of file <a class="el" href="agent__index_8c-source.html">agent_index.c</a>.<div class="fragment"><pre>00405 {
00406     <font class="keyword">struct </font><a class="code" href="structsnmp__index.html">snmp_index</a> *idxptr, *idxptr2;
00407     <font class="keywordflow">for</font>(idxptr = <a class="code" href="agent__index_8c.html#a0">snmp_index_head</a> ; idxptr != NULL; idxptr = idxptr-&gt;<a class="code" href="structsnmp__index.html#m2">next_oid</a>)
00408         <font class="keywordflow">for</font>(idxptr2 = idxptr ; idxptr2 != NULL; idxptr2 = idxptr2-&gt;<a class="code" href="structsnmp__index.html#m4">next_idx</a>)
00409             <font class="keywordflow">if</font> ( idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> == ss )
00410                 idxptr2-&gt;<a class="code" href="structsnmp__index.html#m1">session</a> = NULL;
00411 }
</pre></div>    </td>
  </tr>
</table>
<hr><address><small>Generated on Sat Nov 10 14:09:53 2001 for net-snmp by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.11 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2001</small></address>
</body>
</html>
<!--#include virtual="/sfbutton.html" -->
<!--#include virtual="/sfbutton.html" -->
<!-- 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