Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 87b89b73c41f4440bb86afd421c7548f > files > 119

libnl-devel-1.1-14.fc14.x86_64.rpm

<!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"/>
<title>libnl: Cache</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libnl&#160;<span id="projectnumber">1.1</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</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><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#groups">Modules</a>  </div>
  <div class="headertitle">
<h1>Cache</h1>  </div>
<div class="ingroups"><a class="el" href="group__cache__mngt.html">Caching</a></div></div>
<div class="contents">
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="groups"></a>
Modules</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__object.html">Object</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache__api.html">Cache Implementation</a></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Access Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga47554223760ce5293c5c3dc8bf07cac8">nl_cache_nitems</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of items in the cache.  <a href="#ga47554223760ce5293c5c3dc8bf07cac8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga57a3c518ce67e5e1db978a6eb039413f">nl_cache_nitems_filter</a> (struct nl_cache *cache, struct nl_object *filter)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of items matching a filter in the cache.  <a href="#ga57a3c518ce67e5e1db978a6eb039413f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga921e4e1d4781714a47ad4c00e8a3bed2">nl_cache_is_empty</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns <b>true</b> if the cache is empty.  <a href="#ga921e4e1d4781714a47ad4c00e8a3bed2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structnl__cache__ops.html">nl_cache_ops</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga20673ac0b3b5717b38e71dad37e2cb93">nl_cache_get_ops</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the operations set of the cache.  <a href="#ga20673ac0b3b5717b38e71dad37e2cb93"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_object *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga2d7a6e36cf61c536b0b664afa04fe001">nl_cache_get_first</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the first element in the cache.  <a href="#ga2d7a6e36cf61c536b0b664afa04fe001"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_object *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gac0767be207d9a57600939544da48c33f">nl_cache_get_last</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the last element in the cache.  <a href="#gac0767be207d9a57600939544da48c33f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_object *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga22a6394070bffe8df63b81d0cb0a4dc2">nl_cache_get_next</a> (struct nl_object *obj)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the next element in the cache.  <a href="#ga22a6394070bffe8df63b81d0cb0a4dc2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_object *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga683817f4551540a0e035f76bb40696fb">nl_cache_get_prev</a> (struct nl_object *obj)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the previous element in the cache.  <a href="#ga683817f4551540a0e035f76bb40696fb"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Cache Creation/Deletion</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_cache *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga9520ae0f2158db3c081f34c851d92252">nl_cache_alloc</a> (struct <a class="el" href="structnl__cache__ops.html">nl_cache_ops</a> *ops)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate an empty cache.  <a href="#ga9520ae0f2158db3c081f34c851d92252"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_cache *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga8f50f55c63db05b184645ee6bff23649">nl_cache_alloc_name</a> (const char *kind)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate an empty cache based on type name.  <a href="#ga8f50f55c63db05b184645ee6bff23649"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_cache *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga5ea44d636362abb91193084ec71a2668">nl_cache_subset</a> (struct nl_cache *orig, struct nl_object *filter)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate a new cache containing a subset of a cache.  <a href="#ga5ea44d636362abb91193084ec71a2668"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gad22be4bd392afc8daca60a80f24a277b">nl_cache_clear</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Clear a cache.  <a href="#gad22be4bd392afc8daca60a80f24a277b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga530c896db26d72001d011114b1e6cfaa">nl_cache_free</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Free a cache.  <a href="#ga530c896db26d72001d011114b1e6cfaa"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Cache Modifications</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga5edfe88c7223702e3fbb909584bd87db">nl_cache_add</a> (struct nl_cache *cache, struct nl_object *obj)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Add object to a cache.  <a href="#ga5edfe88c7223702e3fbb909584bd87db"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gaf4b615bcbd1fb764bcb01c980a7ed3c4">nl_cache_move</a> (struct nl_cache *cache, struct nl_object *obj)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Move object from one cache to another.  <a href="#gaf4b615bcbd1fb764bcb01c980a7ed3c4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga8d1f1d2c3b355a7f129d9cd6f7da2b52">nl_cache_remove</a> (struct nl_object *obj)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Removes an object from a cache.  <a href="#ga8d1f1d2c3b355a7f129d9cd6f7da2b52"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct nl_object *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga746f17a6442477f1dbd6513de884000a">nl_cache_search</a> (struct nl_cache *cache, struct nl_object *needle)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Search for an object in a cache.  <a href="#ga746f17a6442477f1dbd6513de884000a"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Synchronization</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga2fd14cd1dc39ee624c518e15dfe61f82">nl_cache_request_full_dump</a> (struct nl_handle *handle, struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Request a full dump from the kernel to fill a cache.  <a href="#ga2fd14cd1dc39ee624c518e15dfe61f82"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa256cc9aa81537729c40801f673a91f6"></a><!-- doxytag: member="cache::__cache_pickup" ref="gaa256cc9aa81537729c40801f673a91f6" args="(struct nl_handle *handle, struct nl_cache *cache, struct nl_parser_param *param)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>__cache_pickup</b> (struct nl_handle *handle, struct nl_cache *cache, struct <a class="el" href="structnl__parser__param.html">nl_parser_param</a> *param)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gae9ee72b56b5d3e215403105c858b9479">nl_cache_pickup</a> (struct nl_handle *handle, struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Pickup a netlink dump response and put it into a cache.  <a href="#gae9ee72b56b5d3e215403105c858b9479"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gac6ff9aadabb1c180dd9ac72ddf8dd3c7"></a><!-- doxytag: member="cache::nl_cache_include" ref="gac6ff9aadabb1c180dd9ac72ddf8dd3c7" args="(struct nl_cache *cache, struct nl_object *obj, change_func_t change_cb)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>nl_cache_include</b> (struct nl_cache *cache, struct nl_object *obj, change_func_t change_cb)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae390262e0f000bef57c495733b2380a9"></a><!-- doxytag: member="cache::nl_cache_resync" ref="gae390262e0f000bef57c495733b2380a9" args="(struct nl_handle *handle, struct nl_cache *cache, change_func_t change_cb)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>nl_cache_resync</b> (struct nl_handle *handle, struct nl_cache *cache, change_func_t change_cb)</td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Parsing</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga6fb98385ab2fb543b1720ce84ab559db">nl_cache_parse_and_add</a> (struct nl_cache *cache, struct nl_msg *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse a netlink message and add it to the cache.  <a href="#ga6fb98385ab2fb543b1720ce84ab559db"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gaf5bd584017847e6ef69ec36739a6aaf0">nl_cache_refill</a> (struct nl_handle *handle, struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">(Re)fill a cache with the contents in the kernel.  <a href="#gaf5bd584017847e6ef69ec36739a6aaf0"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Utillities</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#gaf72b8b81e5b84440bb7534c8cd00b9d2">nl_cache_mark_all</a> (struct nl_cache *cache)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Mark all objects in a cache.  <a href="#gaf72b8b81e5b84440bb7534c8cd00b9d2"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Dumping</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga8e7a06ddf0139ee1c9304721793772d1">nl_cache_dump</a> (struct nl_cache *cache, struct <a class="el" href="structnl__dump__params.html">nl_dump_params</a> *params)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Dump all elements of a cache.  <a href="#ga8e7a06ddf0139ee1c9304721793772d1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga5d7082fb0e848926ef73bd531187d50f">nl_cache_dump_filter</a> (struct nl_cache *cache, struct <a class="el" href="structnl__dump__params.html">nl_dump_params</a> *params, struct nl_object *filter)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Dump all elements of a cache (filtered).  <a href="#ga5d7082fb0e848926ef73bd531187d50f"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Iterators</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga3a0cdf3c64b41a601ee693abea8b9a17">nl_cache_foreach</a> (struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Call a callback on each element of the cache.  <a href="#ga3a0cdf3c64b41a601ee693abea8b9a17"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cache.html#ga5f0cc9367329f85137b2191c2889d41c">nl_cache_foreach_filter</a> (struct nl_cache *cache, struct nl_object *filter, void(*cb)(struct nl_object *, void *), void *arg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Call a callback on each element of the cache (filtered).  <a href="#ga5f0cc9367329f85137b2191c2889d41c"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<div class="fragment"><pre class="fragment">   Cache Management             |    | Type Specific Cache Operations
                                      
                                |    | +----------------+ +------------+
                                       | request update | | msg_parser |
                                |    | +----------------+ +------------+
                                     +- - - - -^- - - - - - - -^- -|- - - -
    nl_cache_update:            |              |               |   |
          1) --------- co_request_update ------+               |   |
                                |                              |   |
          2) destroy old cache     +----------- pp_cb ---------|---+
                                |  |                           |
          3) ---------- <a class="code" href="group__nl.html#ga1bb066e1772b89f79fe1d76a4ef243a6" title="Receive a set of messages from a netlink socket.">nl_recvmsgs</a> ----------+   +- cb_valid -+
             +--------------+   |  |          |   |
             | <a class="code" href="group__cache.html#ga5edfe88c7223702e3fbb909584bd87db" title="Add object to a cache.">nl_cache_add</a> |&lt;-----+   + - - -v- -|- - - - - - - - - - -
             +--------------+   |      | +-------------+
                                         | <a class="code" href="group__nl.html#ga1bb066e1772b89f79fe1d76a4ef243a6" title="Receive a set of messages from a netlink socket.">nl_recvmsgs</a> |
                                |      | +-----|-^-----+
                                           +---v-|---+
                                |      |   | <a class="code" href="group__nl.html#ga060acc8371fdb242c5ae3d5b761d28e1" title="Receive data from netlink socket.">nl_recv</a> |
                                           +---------+
                                |      |                 Core Netlink
</pre></div> <hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga47554223760ce5293c5c3dc8bf07cac8"></a><!-- doxytag: member="cache.c::nl_cache_nitems" ref="ga47554223760ce5293c5c3dc8bf07cac8" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_nitems </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache handle </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00058">58</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">return</span> cache-&gt;c_nitems;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga57a3c518ce67e5e1db978a6eb039413f"></a><!-- doxytag: member="cache.c::nl_cache_nitems_filter" ref="ga57a3c518ce67e5e1db978a6eb039413f" args="(struct nl_cache *cache, struct nl_object *filter)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_nitems_filter </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>filter</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache object. </td></tr>
    <tr><td class="paramname">filter</td><td>Filter object. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00068">68</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00313">nl_object_match_filter()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span><a class="code" href="structnl__object__ops.html" title="Object Operations.">nl_object_ops</a> *ops;
        <span class="keyword">struct </span>nl_object *obj;
        <span class="keywordtype">int</span> nitems = 0;

        <span class="keywordflow">if</span> (cache-&gt;c_ops == NULL)
                BUG();

        ops = cache-&gt;c_ops-&gt;co_obj_ops;
        
        nl_list_for_each_entry(obj, &amp;cache-&gt;c_items, ce_list) {
                <span class="keywordflow">if</span> (filter &amp;&amp; !<a class="code" href="group__object.html#gad4d9124deaff34511d03f3b73fef040c" title="Match a filter against an object.">nl_object_match_filter</a>(obj, filter))
                        <span class="keywordflow">continue</span>;

                nitems++;
        }

        <span class="keywordflow">return</span> nitems;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga921e4e1d4781714a47ad4c00e8a3bed2"></a><!-- doxytag: member="cache.c::nl_cache_is_empty" ref="ga921e4e1d4781714a47ad4c00e8a3bed2" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_is_empty </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to check </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><em>true</em> if the cache is empty, otherwise <b>false</b> is returned. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00094">94</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">return</span> nl_list_empty(&amp;cache-&gt;c_items);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga20673ac0b3b5717b38e71dad37e2cb93"></a><!-- doxytag: member="cache.c::nl_cache_get_ops" ref="ga20673ac0b3b5717b38e71dad37e2cb93" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structnl__cache__ops.html">nl_cache_ops</a>* nl_cache_get_ops </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache handle </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00103">103</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">return</span> cache-&gt;c_ops;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga2d7a6e36cf61c536b0b664afa04fe001"></a><!-- doxytag: member="cache.c::nl_cache_get_first" ref="ga2d7a6e36cf61c536b0b664afa04fe001" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_object* nl_cache_get_first </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache handle </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00112">112</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">if</span> (nl_list_empty(&amp;cache-&gt;c_items))
                <span class="keywordflow">return</span> NULL;

        <span class="keywordflow">return</span> nl_list_entry(cache-&gt;c_items.next,
                             <span class="keyword">struct</span> nl_object, ce_list);
}
</pre></div>
</div>
</div>
<a class="anchor" id="gac0767be207d9a57600939544da48c33f"></a><!-- doxytag: member="cache.c::nl_cache_get_last" ref="gac0767be207d9a57600939544da48c33f" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_object* nl_cache_get_last </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache handle </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00125">125</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">if</span> (nl_list_empty(&amp;cache-&gt;c_items))
                <span class="keywordflow">return</span> NULL;

        <span class="keywordflow">return</span> nl_list_entry(cache-&gt;c_items.prev,
                             <span class="keyword">struct</span> nl_object, ce_list);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga22a6394070bffe8df63b81d0cb0a4dc2"></a><!-- doxytag: member="cache.c::nl_cache_get_next" ref="ga22a6394070bffe8df63b81d0cb0a4dc2" args="(struct nl_object *obj)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_object* nl_cache_get_next </td>
          <td>(</td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">obj</td><td>current object </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00138">138</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">if</span> (nl_list_at_tail(obj, &amp;obj-&gt;ce_cache-&gt;c_items, ce_list))
                <span class="keywordflow">return</span> NULL;
        <span class="keywordflow">else</span>
                <span class="keywordflow">return</span> nl_list_entry(obj-&gt;ce_list.next,
                                     <span class="keyword">struct</span> nl_object, ce_list);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga683817f4551540a0e035f76bb40696fb"></a><!-- doxytag: member="cache.c::nl_cache_get_prev" ref="ga683817f4551540a0e035f76bb40696fb" args="(struct nl_object *obj)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_object* nl_cache_get_prev </td>
          <td>(</td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">obj</td><td>current object </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00151">151</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">if</span> (nl_list_at_head(obj, &amp;obj-&gt;ce_cache-&gt;c_items, ce_list))
                <span class="keywordflow">return</span> NULL;
        <span class="keywordflow">else</span>
                <span class="keywordflow">return</span> nl_list_entry(obj-&gt;ce_list.prev,
                                     <span class="keyword">struct</span> nl_object, ce_list);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga9520ae0f2158db3c081f34c851d92252"></a><!-- doxytag: member="cache.c::nl_cache_alloc" ref="ga9520ae0f2158db3c081f34c851d92252" args="(struct nl_cache_ops *ops)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_cache* nl_cache_alloc </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structnl__cache__ops.html">nl_cache_ops</a> *&#160;</td>
          <td class="paramname"><em>ops</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ops</td><td>cache operations to base the cache on</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A newly allocated and initialized cache. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00173">173</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>Referenced by <a class="el" href="lookup_8c_source.html#l00183">flnl_result_alloc_cache()</a>, <a class="el" href="ct_8c_source.html#l00407">nfnl_ct_alloc_cache()</a>, <a class="el" href="cache_8c_source.html#l00196">nl_cache_alloc_name()</a>, <a class="el" href="cache__mngr_8c_source.html#l00209">nl_cache_mngr_add()</a>, <a class="el" href="cache_8c_source.html#l00215">nl_cache_subset()</a>, <a class="el" href="class_8c_source.html#l00184">rtnl_class_alloc_cache()</a>, <a class="el" href="classifier_8c_source.html#l00295">rtnl_cls_alloc_cache()</a>, <a class="el" href="link_8c_source.html#l00869">rtnl_link_alloc_cache()</a>, <a class="el" href="neigh_8c_source.html#l00534">rtnl_neigh_alloc_cache()</a>, <a class="el" href="neightbl_8c_source.html#l00407">rtnl_neightbl_alloc_cache()</a>, <a class="el" href="qdisc_8c_source.html#l00384">rtnl_qdisc_alloc_cache()</a>, <a class="el" href="route_8c_source.html#l00241">rtnl_route_alloc_cache()</a>, and <a class="el" href="rule_8c_source.html#l00449">rtnl_rule_alloc_cache_by_family()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_cache *cache;

        cache = calloc(1, <span class="keyword">sizeof</span>(*cache));
        <span class="keywordflow">if</span> (!cache) {
                nl_errno(ENOMEM);
                <span class="keywordflow">return</span> NULL;
        }

        nl_init_list_head(&amp;cache-&gt;c_items);
        cache-&gt;c_ops = ops;

        NL_DBG(2, <span class="stringliteral">&quot;Allocated cache %p &lt;%s&gt;.\n&quot;</span>, cache, nl_cache_name(cache));

        <span class="keywordflow">return</span> cache;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga8f50f55c63db05b184645ee6bff23649"></a><!-- doxytag: member="cache.c::nl_cache_alloc_name" ref="ga8f50f55c63db05b184645ee6bff23649" args="(const char *kind)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_cache* nl_cache_alloc_name </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>kind</em></td><td>)</td>
          <td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">kind</td><td>Name of cache type </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A newly allocated and initialized cache. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00196">196</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00173">nl_cache_alloc()</a>, and <a class="el" href="cache__mngt_8c_source.html#l00036">nl_cache_ops_lookup()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span><a class="code" href="structnl__cache__ops.html" title="Cache Operations.">nl_cache_ops</a> *ops;

        ops = <a class="code" href="group__cache__mngt.html#ga7657cf661e569b4b43842a82e409b5fd" title="Lookup the set cache operations of a certain cache type.">nl_cache_ops_lookup</a>(kind);
        <span class="keywordflow">if</span> (!ops) {
                nl_error(ENOENT, <span class="stringliteral">&quot;Unable to lookup cache \&quot;%s\&quot;&quot;</span>, kind);
                <span class="keywordflow">return</span> NULL;
        }

        <span class="keywordflow">return</span> <a class="code" href="group__cache.html#ga9520ae0f2158db3c081f34c851d92252" title="Allocate an empty cache.">nl_cache_alloc</a>(ops);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga5ea44d636362abb91193084ec71a2668"></a><!-- doxytag: member="cache.c::nl_cache_subset" ref="ga5ea44d636362abb91193084ec71a2668" args="(struct nl_cache *orig, struct nl_object *filter)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_cache* nl_cache_subset </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>orig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>filter</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">orig</td><td>Original cache to be based on </td></tr>
    <tr><td class="paramname">filter</td><td>Filter defining the subset to be filled into new cache </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A newly allocated cache or NULL. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00215">215</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00302">nl_cache_add()</a>, <a class="el" href="cache_8c_source.html#l00173">nl_cache_alloc()</a>, and <a class="el" href="object_8c_source.html#l00313">nl_object_match_filter()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_cache *cache;
        <span class="keyword">struct </span><a class="code" href="structnl__object__ops.html" title="Object Operations.">nl_object_ops</a> *ops;
        <span class="keyword">struct </span>nl_object *obj;

        <span class="keywordflow">if</span> (!filter)
                BUG();

        cache = <a class="code" href="group__cache.html#ga9520ae0f2158db3c081f34c851d92252" title="Allocate an empty cache.">nl_cache_alloc</a>(orig-&gt;c_ops);
        <span class="keywordflow">if</span> (!cache)
                <span class="keywordflow">return</span> NULL;

        ops = orig-&gt;c_ops-&gt;co_obj_ops;

        nl_list_for_each_entry(obj, &amp;orig-&gt;c_items, ce_list) {
                <span class="keywordflow">if</span> (!<a class="code" href="group__object.html#gad4d9124deaff34511d03f3b73fef040c" title="Match a filter against an object.">nl_object_match_filter</a>(obj, filter))
                        <span class="keywordflow">continue</span>;

                <a class="code" href="group__cache.html#ga5edfe88c7223702e3fbb909584bd87db" title="Add object to a cache.">nl_cache_add</a>(cache, obj);
        }

        <span class="keywordflow">return</span> cache;
}
</pre></div>
</div>
</div>
<a class="anchor" id="gad22be4bd392afc8daca60a80f24a277b"></a><!-- doxytag: member="cache.c::nl_cache_clear" ref="gad22be4bd392afc8daca60a80f24a277b" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_clear </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to clear</td></tr>
  </table>
  </dd>
</dl>
<p>Removes all elements of a cache. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00247">247</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00356">nl_cache_remove()</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00265">nl_cache_free()</a>, and <a class="el" href="cache_8c_source.html#l00662">nl_cache_refill()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_object *obj, *tmp;

        NL_DBG(1, <span class="stringliteral">&quot;Clearing cache %p &lt;%s&gt;...\n&quot;</span>, cache, nl_cache_name(cache));

        nl_list_for_each_entry_safe(obj, tmp, &amp;cache-&gt;c_items, ce_list)
                <a class="code" href="group__cache.html#ga8d1f1d2c3b355a7f129d9cd6f7da2b52" title="Removes an object from a cache.">nl_cache_remove</a>(obj);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga530c896db26d72001d011114b1e6cfaa"></a><!-- doxytag: member="cache.c::nl_cache_free" ref="ga530c896db26d72001d011114b1e6cfaa" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_free </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to free.</td></tr>
  </table>
  </dd>
</dl>
<p>Removes all elements of a cache and frees all memory.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Use this function if you are working with allocated caches. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00265">265</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00247">nl_cache_clear()</a>.</p>

<p>Referenced by <a class="el" href="ctrl_8c_source.html#l00238">genl_ctrl_resolve()</a>, <a class="el" href="cache__mngr_8c_source.html#l00209">nl_cache_mngr_add()</a>, <a class="el" href="class_8c_source.html#l00184">rtnl_class_alloc_cache()</a>, <a class="el" href="classifier_8c_source.html#l00295">rtnl_cls_alloc_cache()</a>, <a class="el" href="link_8c_source.html#l00869">rtnl_link_alloc_cache()</a>, <a class="el" href="neigh_8c_source.html#l00534">rtnl_neigh_alloc_cache()</a>, <a class="el" href="neightbl_8c_source.html#l00407">rtnl_neightbl_alloc_cache()</a>, and <a class="el" href="qdisc_8c_source.html#l00384">rtnl_qdisc_alloc_cache()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <a class="code" href="group__cache.html#gad22be4bd392afc8daca60a80f24a277b" title="Clear a cache.">nl_cache_clear</a>(cache);
        NL_DBG(1, <span class="stringliteral">&quot;Freeing cache %p &lt;%s&gt;...\n&quot;</span>, cache, nl_cache_name(cache));
        free(cache);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga5edfe88c7223702e3fbb909584bd87db"></a><!-- doxytag: member="cache.c::nl_cache_add" ref="ga5edfe88c7223702e3fbb909584bd87db" args="(struct nl_cache *cache, struct nl_object *obj)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_add </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>obj</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to add object to </td></tr>
    <tr><td class="paramname">obj</td><td>Object to be added to the cache</td></tr>
  </table>
  </dd>
</dl>
<p>Adds the given object to the specified cache. The object is cloned if it has been added to another cache already.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 or a negative error code. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00302">302</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00095">nl_object_clone()</a>, and <a class="el" href="object_8c_source.html#l00162">nl_object_get()</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00215">nl_cache_subset()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_object *<span class="keyword">new</span>;

        <span class="keywordflow">if</span> (cache-&gt;c_ops-&gt;co_obj_ops != obj-&gt;ce_ops)
                <span class="keywordflow">return</span> nl_error(EINVAL, <span class="stringliteral">&quot;Object mismatches cache type&quot;</span>);

        <span class="keywordflow">if</span> (!nl_list_empty(&amp;obj-&gt;ce_list)) {
                <span class="keyword">new</span> = <a class="code" href="group__object.html#ga90d86d45c53d2be6ba927bec662159d7" title="Allocate a new object and copy all data from an existing object.">nl_object_clone</a>(obj);
                <span class="keywordflow">if</span> (!<span class="keyword">new</span>)
                        <span class="keywordflow">return</span> nl_errno(ENOMEM);
        } <span class="keywordflow">else</span> {
                <a class="code" href="group__object.html#gabd5767ac47ec6f09d1ac643f44eb8bfd" title="Acquire a reference on a object.">nl_object_get</a>(obj);
                <span class="keyword">new</span> = obj;
        }

        <span class="keywordflow">return</span> __cache_add(cache, <span class="keyword">new</span>);
}
</pre></div>
</div>
</div>
<a class="anchor" id="gaf4b615bcbd1fb764bcb01c980a7ed3c4"></a><!-- doxytag: member="cache.c::nl_cache_move" ref="gaf4b615bcbd1fb764bcb01c980a7ed3c4" args="(struct nl_cache *cache, struct nl_object *obj)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_move </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>obj</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to move object to. </td></tr>
    <tr><td class="paramname">obj</td><td>Object subject to be moved</td></tr>
  </table>
  </dd>
</dl>
<p>Removes the given object from its associated cache if needed and adds it to the new cache.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success or a negative error code. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00331">331</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00356">nl_cache_remove()</a>, and <a class="el" href="object_8c_source.html#l00162">nl_object_get()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordflow">if</span> (cache-&gt;c_ops-&gt;co_obj_ops != obj-&gt;ce_ops)
                <span class="keywordflow">return</span> nl_error(EINVAL, <span class="stringliteral">&quot;Object mismatches cache type&quot;</span>);

        NL_DBG(3, <span class="stringliteral">&quot;Moving object %p to cache %p\n&quot;</span>, obj, cache);
        
        <span class="comment">/* Acquire reference, if already in a cache this will be</span>
<span class="comment">         * reverted during removal */</span>
        <a class="code" href="group__object.html#gabd5767ac47ec6f09d1ac643f44eb8bfd" title="Acquire a reference on a object.">nl_object_get</a>(obj);

        <span class="keywordflow">if</span> (!nl_list_empty(&amp;obj-&gt;ce_list))
                <a class="code" href="group__cache.html#ga8d1f1d2c3b355a7f129d9cd6f7da2b52" title="Removes an object from a cache.">nl_cache_remove</a>(obj);

        <span class="keywordflow">return</span> __cache_add(cache, obj);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga8d1f1d2c3b355a7f129d9cd6f7da2b52"></a><!-- doxytag: member="cache.c::nl_cache_remove" ref="ga8d1f1d2c3b355a7f129d9cd6f7da2b52" args="(struct nl_object *obj)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_remove </td>
          <td>(</td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">obj</td><td>Object to remove from its cache</td></tr>
  </table>
  </dd>
</dl>
<p>Removes the object <code>obj</code> from the cache it is assigned to, since an object can only be assigned to one cache at a time, the cache must ne be passed along with it. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00356">356</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00173">nl_object_put()</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00247">nl_cache_clear()</a>, <a class="el" href="cache_8c_source.html#l00331">nl_cache_move()</a>, and <a class="el" href="object_8c_source.html#l00133">nl_object_free()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_cache *cache = obj-&gt;ce_cache;

        <span class="keywordflow">if</span> (cache == NULL)
                <span class="keywordflow">return</span>;

        nl_list_del(&amp;obj-&gt;ce_list);
        obj-&gt;ce_cache = NULL;
        <a class="code" href="group__object.html#ga9905da094bf4c03cf4ac78aeaa86a12b" title="Release a reference from an object.">nl_object_put</a>(obj);
        cache-&gt;c_nitems--;

        NL_DBG(1, <span class="stringliteral">&quot;Deleted %p from cache %p &lt;%s&gt;.\n&quot;</span>,
               obj, cache, nl_cache_name(cache));
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga746f17a6442477f1dbd6513de884000a"></a><!-- doxytag: member="cache.c::nl_cache_search" ref="ga746f17a6442477f1dbd6513de884000a" args="(struct nl_cache *cache, struct nl_object *needle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct nl_object* nl_cache_search </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>needle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [read]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to search in. </td></tr>
    <tr><td class="paramname">needle</td><td>Object to look for.</td></tr>
  </table>
  </dd>
</dl>
<p>Iterates over the cache and looks for an object with identical identifiers as the needle.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Reference to object or NULL if not found. </dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>The returned object must be returned via <a class="el" href="group__object.html#ga9905da094bf4c03cf4ac78aeaa86a12b" title="Release a reference from an object.">nl_object_put()</a>. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00383">383</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00162">nl_object_get()</a>, and <a class="el" href="object_8c_source.html#l00258">nl_object_identical()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_object *obj;

        nl_list_for_each_entry(obj, &amp;cache-&gt;c_items, ce_list) {
                <span class="keywordflow">if</span> (<a class="code" href="group__object.html#gaab17e2f7a53ad9eb9cae3d0a60e41074" title="Check if the identifiers of two objects are identical.">nl_object_identical</a>(obj, needle)) {
                        <a class="code" href="group__object.html#gabd5767ac47ec6f09d1ac643f44eb8bfd" title="Acquire a reference on a object.">nl_object_get</a>(obj);
                        <span class="keywordflow">return</span> obj;
                }
        }

        <span class="keywordflow">return</span> NULL;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga2fd14cd1dc39ee624c518e15dfe61f82"></a><!-- doxytag: member="cache.c::nl_cache_request_full_dump" ref="ga2fd14cd1dc39ee624c518e15dfe61f82" args="(struct nl_handle *handle, struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_request_full_dump </td>
          <td>(</td>
          <td class="paramtype">struct nl_handle *&#160;</td>
          <td class="paramname"><em>handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">handle</td><td>Netlink handle </td></tr>
    <tr><td class="paramname">cache</td><td>Cache subjected to be filled.</td></tr>
  </table>
  </dd>
</dl>
<p>Send a dumping request to the kernel causing it to dump all objects related to the specified cache to the netlink socket.</p>
<p>Use <a class="el" href="group__cache.html#gae9ee72b56b5d3e215403105c858b9479" title="Pickup a netlink dump response and put it into a cache.">nl_cache_pickup()</a> to read the objects from the socket and fill them into a cache. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00417">417</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00662">nl_cache_refill()</a>.</p>
<div class="fragment"><pre class="fragment">{
        NL_DBG(2, <span class="stringliteral">&quot;Requesting dump from kernel for cache %p &lt;%s&gt;...\n&quot;</span>,
                  cache, nl_cache_name(cache));

        <span class="keywordflow">if</span> (cache-&gt;c_ops-&gt;co_request_update == NULL)
                <span class="keywordflow">return</span> nl_error(EOPNOTSUPP, <span class="stringliteral">&quot;Operation not supported&quot;</span>);

        <span class="keywordflow">return</span> cache-&gt;c_ops-&gt;co_request_update(cache, handle);
}
</pre></div>
</div>
</div>
<a class="anchor" id="gae9ee72b56b5d3e215403105c858b9479"></a><!-- doxytag: member="cache.c::nl_cache_pickup" ref="gae9ee72b56b5d3e215403105c858b9479" args="(struct nl_handle *handle, struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_pickup </td>
          <td>(</td>
          <td class="paramtype">struct nl_handle *&#160;</td>
          <td class="paramname"><em>handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">handle</td><td>Netlink handle. </td></tr>
    <tr><td class="paramname">cache</td><td>Cache to put items into.</td></tr>
  </table>
  </dd>
</dl>
<p>Waits for netlink messages to arrive, parses them and puts them into the specified cache.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success or a negative error code. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00487">487</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>Referenced by <a class="el" href="lookup_8c_source.html#l00263">flnl_lookup()</a>, and <a class="el" href="cache_8c_source.html#l00662">nl_cache_refill()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span><a class="code" href="structnl__parser__param.html">nl_parser_param</a> p = {
                .pp_cb = pickup_cb,
                .pp_arg = cache,
        };

        <span class="keywordflow">return</span> __cache_pickup(handle, cache, &amp;p);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga6fb98385ab2fb543b1720ce84ab559db"></a><!-- doxytag: member="cache.c::nl_cache_parse_and_add" ref="ga6fb98385ab2fb543b1720ce84ab559db" args="(struct nl_cache *cache, struct nl_msg *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_parse_and_add </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_msg *&#160;</td>
          <td class="paramname"><em>msg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to add element to </td></tr>
    <tr><td class="paramname">msg</td><td>netlink message</td></tr>
  </table>
  </dd>
</dl>
<p>Parses a netlink message by calling the cache specific message parser and adds the new element to the cache.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 or a negative error code. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00642">642</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="msg_8c_source.html#l00643">nlmsg_hdr()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span><a class="code" href="structnl__parser__param.html">nl_parser_param</a> p = {
                .pp_cb = pickup_cb,
                .pp_arg = cache,
        };

        <span class="keywordflow">return</span> nl_cache_parse(cache-&gt;c_ops, NULL, <a class="code" href="group__msg.html#gaa5f29579d86d2bdab26c312b44b56de7" title="Return actual netlink message.">nlmsg_hdr</a>(msg), &amp;p);
}
</pre></div>
</div>
</div>
<a class="anchor" id="gaf5bd584017847e6ef69ec36739a6aaf0"></a><!-- doxytag: member="cache.c::nl_cache_refill" ref="gaf5bd584017847e6ef69ec36739a6aaf0" args="(struct nl_handle *handle, struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int nl_cache_refill </td>
          <td>(</td>
          <td class="paramtype">struct nl_handle *&#160;</td>
          <td class="paramname"><em>handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">handle</td><td>netlink handle </td></tr>
    <tr><td class="paramname">cache</td><td>cache to update</td></tr>
  </table>
  </dd>
</dl>
<p>Clears the specified cache and fills it with the current state in the kernel.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 or a negative error code. </dd></dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00662">662</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00247">nl_cache_clear()</a>, <a class="el" href="cache_8c_source.html#l00487">nl_cache_pickup()</a>, and <a class="el" href="cache_8c_source.html#l00417">nl_cache_request_full_dump()</a>.</p>

<p>Referenced by <a class="el" href="ct_8c_source.html#l00407">nfnl_ct_alloc_cache()</a>, <a class="el" href="cache__mngr_8c_source.html#l00209">nl_cache_mngr_add()</a>, <a class="el" href="class_8c_source.html#l00184">rtnl_class_alloc_cache()</a>, <a class="el" href="classifier_8c_source.html#l00295">rtnl_cls_alloc_cache()</a>, <a class="el" href="link_8c_source.html#l00869">rtnl_link_alloc_cache()</a>, <a class="el" href="neigh_8c_source.html#l00534">rtnl_neigh_alloc_cache()</a>, <a class="el" href="neightbl_8c_source.html#l00407">rtnl_neightbl_alloc_cache()</a>, <a class="el" href="qdisc_8c_source.html#l00384">rtnl_qdisc_alloc_cache()</a>, <a class="el" href="route_8c_source.html#l00241">rtnl_route_alloc_cache()</a>, and <a class="el" href="rule_8c_source.html#l00449">rtnl_rule_alloc_cache_by_family()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordtype">int</span> err;

        err = <a class="code" href="group__cache.html#ga2fd14cd1dc39ee624c518e15dfe61f82" title="Request a full dump from the kernel to fill a cache.">nl_cache_request_full_dump</a>(handle, cache);
        <span class="keywordflow">if</span> (err &lt; 0)
                <span class="keywordflow">return</span> err;

        NL_DBG(2, <span class="stringliteral">&quot;Upading cache %p &lt;%s&gt;, request sent, waiting for dump...\n&quot;</span>,
               cache, nl_cache_name(cache));
        <a class="code" href="group__cache.html#gad22be4bd392afc8daca60a80f24a277b" title="Clear a cache.">nl_cache_clear</a>(cache);

        <span class="keywordflow">return</span> <a class="code" href="group__cache.html#gae9ee72b56b5d3e215403105c858b9479" title="Pickup a netlink dump response and put it into a cache.">nl_cache_pickup</a>(handle, cache);
}
</pre></div>
</div>
</div>
<a class="anchor" id="gaf72b8b81e5b84440bb7534c8cd00b9d2"></a><!-- doxytag: member="cache.c::nl_cache_mark_all" ref="gaf72b8b81e5b84440bb7534c8cd00b9d2" args="(struct nl_cache *cache)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_mark_all </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>Cache to mark all objects in </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00688">688</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00210">nl_object_mark()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_object *obj;

        NL_DBG(2, <span class="stringliteral">&quot;Marking all objects in cache %p &lt;%s&gt;...\n&quot;</span>,
                  cache, nl_cache_name(cache));

        nl_list_for_each_entry(obj, &amp;cache-&gt;c_items, ce_list)
                <a class="code" href="group__object.html#gadbc633bb8ae194050473818e0484613d" title="Add mark to object.">nl_object_mark</a>(obj);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga8e7a06ddf0139ee1c9304721793772d1"></a><!-- doxytag: member="cache.c::nl_cache_dump" ref="ga8e7a06ddf0139ee1c9304721793772d1" args="(struct nl_cache *cache, struct nl_dump_params *params)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_dump </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnl__dump__params.html">nl_dump_params</a> *&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to dump </td></tr>
    <tr><td class="paramname">params</td><td>dumping parameters</td></tr>
  </table>
  </dd>
</dl>
<p>Dumps all elements of the <em>cache</em> to the file descriptor <em>fd</em>. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00713">713</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00727">nl_cache_dump_filter()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <a class="code" href="group__cache.html#ga5d7082fb0e848926ef73bd531187d50f" title="Dump all elements of a cache (filtered).">nl_cache_dump_filter</a>(cache, params, NULL);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga5d7082fb0e848926ef73bd531187d50f"></a><!-- doxytag: member="cache.c::nl_cache_dump_filter" ref="ga5d7082fb0e848926ef73bd531187d50f" args="(struct nl_cache *cache, struct nl_dump_params *params, struct nl_object *filter)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_dump_filter </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnl__dump__params.html">nl_dump_params</a> *&#160;</td>
          <td class="paramname"><em>params</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>filter</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to dump </td></tr>
    <tr><td class="paramname">params</td><td>dumping parameters (optional) </td></tr>
    <tr><td class="paramname">filter</td><td>filter object</td></tr>
  </table>
  </dd>
</dl>
<p>Dumps all elements of the <em>cache</em> to the file descriptor <em>fd</em> given they match the given filter <em>filter</em>. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00727">727</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="types_8h_source.html#l00041">nl_dump_params::dp_type</a>, <a class="el" href="types_8h_source.html#l00023">NL_DUMP_FULL</a>, <a class="el" href="object_8c_source.html#l00313">nl_object_match_filter()</a>, and <a class="el" href="object-api_8h_source.html#l00307">nl_object_ops::oo_dump</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00713">nl_cache_dump()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordtype">int</span> type = params ? params-&gt;<a class="code" href="structnl__dump__params.html#ae36d840078202bf028a6611d2e1f4ea5" title="Specifies the type of dump that is requested.">dp_type</a> : <a class="code" href="group__utils.html#ggacfb5566c73f0965c5241d7d49bc717e9a1445106c7af529b2c99ee289fbcd3179" title="Dump all attributes but no statistics.">NL_DUMP_FULL</a>;
        <span class="keyword">struct </span><a class="code" href="structnl__object__ops.html" title="Object Operations.">nl_object_ops</a> *ops;
        <span class="keyword">struct </span>nl_object *obj;

        NL_DBG(2, <span class="stringliteral">&quot;Dumping cache %p &lt;%s&gt; filter %p\n&quot;</span>,
               cache, nl_cache_name(cache), filter);

        <span class="keywordflow">if</span> (type &gt; NL_DUMP_MAX || type &lt; 0)
                BUG();

        <span class="keywordflow">if</span> (cache-&gt;c_ops == NULL)
                BUG();

        ops = cache-&gt;c_ops-&gt;co_obj_ops;
        <span class="keywordflow">if</span> (!ops-&gt;<a class="code" href="structnl__object__ops.html#a0a3d28af43d7f75cda0b8cbc23ad7432" title="Dumping functions.">oo_dump</a>[type])
                <span class="keywordflow">return</span>;

        nl_list_for_each_entry(obj, &amp;cache-&gt;c_items, ce_list) {
                <span class="keywordflow">if</span> (filter &amp;&amp; !<a class="code" href="group__object.html#gad4d9124deaff34511d03f3b73fef040c" title="Match a filter against an object.">nl_object_match_filter</a>(obj, filter))
                        <span class="keywordflow">continue</span>;

                NL_DBG(4, <span class="stringliteral">&quot;Dumping object %p...\n&quot;</span>, obj);
                dump_from_ops(obj, params);
        }
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga3a0cdf3c64b41a601ee693abea8b9a17"></a><!-- doxytag: member="cache.c::nl_cache_foreach" ref="ga3a0cdf3c64b41a601ee693abea8b9a17" args="(struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_foreach </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(struct nl_object *, void *)&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to iterate on </td></tr>
    <tr><td class="paramname">cb</td><td>callback function </td></tr>
    <tr><td class="paramname">arg</td><td>argument passed to callback function</td></tr>
  </table>
  </dd>
</dl>
<p>Calls a callback function <em>cb</em> on each element of the <em>cache</em>. The argument <em>arg</em> is passed on the callback function. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00773">773</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="cache_8c_source.html#l00790">nl_cache_foreach_filter()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <a class="code" href="group__cache.html#ga5f0cc9367329f85137b2191c2889d41c" title="Call a callback on each element of the cache (filtered).">nl_cache_foreach_filter</a>(cache, NULL, cb, arg);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga5f0cc9367329f85137b2191c2889d41c"></a><!-- doxytag: member="cache.c::nl_cache_foreach_filter" ref="ga5f0cc9367329f85137b2191c2889d41c" args="(struct nl_cache *cache, struct nl_object *filter, void(*cb)(struct nl_object *, void *), void *arg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nl_cache_foreach_filter </td>
          <td>(</td>
          <td class="paramtype">struct nl_cache *&#160;</td>
          <td class="paramname"><em>cache</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct nl_object *&#160;</td>
          <td class="paramname"><em>filter</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(struct nl_object *, void *)&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">cache</td><td>cache to iterate on </td></tr>
    <tr><td class="paramname">filter</td><td>filter object </td></tr>
    <tr><td class="paramname">cb</td><td>callback function </td></tr>
    <tr><td class="paramname">arg</td><td>argument passed to callback function</td></tr>
  </table>
  </dd>
</dl>
<p>Calls a callback function <em>cb</em> on each element of the <em>cache</em> that matches the <em>filter</em>. The argument <em>arg</em> is passed on to the callback function. </p>

<p>Definition at line <a class="el" href="cache_8c_source.html#l00790">790</a> of file <a class="el" href="cache_8c_source.html">cache.c</a>.</p>

<p>References <a class="el" href="object_8c_source.html#l00313">nl_object_match_filter()</a>.</p>

<p>Referenced by <a class="el" href="cache_8c_source.html#l00773">nl_cache_foreach()</a>, <a class="el" href="class__obj_8c_source.html#l00177">rtnl_class_foreach_child()</a>, <a class="el" href="class__obj_8c_source.html#l00202">rtnl_class_foreach_cls()</a>, <a class="el" href="qdisc__obj_8c_source.html#l00139">rtnl_qdisc_foreach_child()</a>, and <a class="el" href="qdisc__obj_8c_source.html#l00165">rtnl_qdisc_foreach_cls()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keyword">struct </span>nl_object *obj, *tmp;
        <span class="keyword">struct </span><a class="code" href="structnl__object__ops.html" title="Object Operations.">nl_object_ops</a> *ops;

        <span class="keywordflow">if</span> (cache-&gt;c_ops == NULL)
                BUG();

        ops = cache-&gt;c_ops-&gt;co_obj_ops;

        nl_list_for_each_entry_safe(obj, tmp, &amp;cache-&gt;c_items, ce_list) {
                <span class="keywordflow">if</span> (filter &amp;&amp; !<a class="code" href="group__object.html#gad4d9124deaff34511d03f3b73fef040c" title="Match a filter against an object.">nl_object_match_filter</a>(obj, filter))
                        <span class="keywordflow">continue</span>;

                cb(obj, arg);
        }
}
</pre></div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Mar 21 2011 for libnl by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>