Sophie

Sophie

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

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: Management</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="#nested-classes">Data Structures</a> &#124;
<a href="#groups">Modules</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<h1>Management</h1>  </div>
<div class="ingroups"><a class="el" href="group__genl.html">Generic Netlink</a></div></div>
<div class="contents">
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structgenl__cmd.html">genl_cmd</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Generic Netlink Command.  <a href="structgenl__cmd.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structgenl__ops.html">genl_ops</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Generic Netlink Operations.  <a href="structgenl__ops.html#_details">More...</a><br/></td></tr>
<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__ctrl.html">Controller</a></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga5aeced5f4d5270304efd96c28c67606f"></a><!-- doxytag: member="genl_mngt::genl_op2name" ref="ga5aeced5f4d5270304efd96c28c67606f" args="(int family, int op, char *buf, size_t len)" -->
char *&#160;</td><td class="memItemRight" valign="bottom"><b>genl_op2name</b> (int family, int op, char *buf, size_t len)</td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Register/Unregister</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__genl__mngt.html#ga090500dc23450349a7c2861fb3ae5f54">genl_register</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">Register generic netlink operations.  <a href="#ga090500dc23450349a7c2861fb3ae5f54"></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__genl__mngt.html#ga3fa959e2873bd588fbef31d0dabbf014">genl_unregister</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">Unregister generic netlink operations.  <a href="#ga3fa959e2873bd588fbef31d0dabbf014"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="member-group"></a>
Resolving ID/Name</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa1b921abecd5d28c313640cbe3b7222c"></a><!-- doxytag: member="genl_mngt::genl_ops_resolve" ref="gaa1b921abecd5d28c313640cbe3b7222c" args="(struct nl_handle *handle, struct genl_ops *ops)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>genl_ops_resolve</b> (struct nl_handle *handle, struct <a class="el" href="structgenl__ops.html">genl_ops</a> *ops)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab087aec2a4cb2835587a3cc73fd96b67"></a><!-- doxytag: member="genl_mngt::genl_mngt_resolve" ref="gab087aec2a4cb2835587a3cc73fd96b67" args="(struct nl_handle *handle)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>genl_mngt_resolve</b> (struct nl_handle *handle)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<dl class="user"><dt><b>1) Registering a generic netlink module</b></dt><dd><div class="fragment"><pre class="fragment"><span class="preprocessor"> #include &lt;netlink/genl/mngt.h&gt;</span>

 <span class="comment">// First step is to define all the commands being used in</span>
 <span class="comment">// particular generic netlink family. The ID and name are</span>
 <span class="comment">// mandatory to be filled out. A callback function and</span>
 <span class="comment">// most the attribute policy that comes with it must be</span>
 <span class="comment">// defined for commands expected to be issued towards</span>
 <span class="comment">// userspace.</span>
 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structgenl__cmd.html" title="Generic Netlink Command.">genl_cmd</a> foo_cmds[] = {
        {
                .<a class="code" href="structgenl__cmd.html#a44973cc65dbac22f07415820d33bc75e" title="Unique command identifier.">c_id</a>           = FOO_CMD_NEW,
                .c_name         = <span class="stringliteral">&quot;NEWFOO&quot;</span> ,
                .c_maxattr      = FOO_ATTR_MAX,
                .c_attr_policy  = foo_policy,
                .c_msg_parser   = foo_msg_parser,
        },
        {
                .c_id           = FOO_CMD_DEL,
                .c_name         = <span class="stringliteral">&quot;DELFOO&quot;</span> ,
        },
 };

 <span class="comment">// The list of commands must then be integrated into a</span>
 <span class="comment">// struct genl_ops serving as handle for this particular</span>
 <span class="comment">// family.</span>
 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structgenl__ops.html" title="Generic Netlink Operations.">genl_ops</a> my_genl_ops = {
        .o_cmds                 = foo_cmds,
        .o_ncmds                = ARRAY_SIZE(foo_cmds),
 };

 <span class="comment">// Using the above struct genl_ops an arbitary number of</span>
 <span class="comment">// cache handles can be associated to it.</span>
 <span class="comment">//</span>
 <span class="comment">// The macro GENL_HDRSIZE() must be used to specify the</span>
 <span class="comment">// length of the header to automatically take headers on</span>
 <span class="comment">// generic layers into account.</span>
 <span class="comment">//</span>
 <span class="comment">// The macro GENL_FAMILY() is used to represent the generic</span>
 <span class="comment">// netlink family id.</span>
 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structnl__cache__ops.html" title="Cache Operations.">nl_cache_ops</a> genl_foo_ops = {
        .co_name                = <span class="stringliteral">&quot;genl/foo&quot;</span>,
        .co_hdrsize             = GENL_HDRSIZE(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> my_hdr)),
        .co_msgtypes            = GENL_FAMILY(GENL_ID_GENERATE, <span class="stringliteral">&quot;foo&quot;</span>),
        .co_genl                = &amp;my_genl_ops,
        .co_protocol            = NETLINK_GENERIC,
        .co_request_update      = foo_request_update,
        .co_obj_ops             = &amp;genl_foo_ops,
 };

 <span class="comment">// Finally each cache handle for a generic netlink family</span>
 <span class="comment">// must be registered using genl_register().</span>
 <span class="keyword">static</span> <span class="keywordtype">void</span> __init foo_init(<span class="keywordtype">void</span>)
 {
        <a class="code" href="group__genl__mngt.html#ga090500dc23450349a7c2861fb3ae5f54" title="Register generic netlink operations.">genl_register</a>(&amp;genl_foo_ops);
 }

 <span class="comment">// ... respectively unregsted again.</span>
 <span class="keyword">static</span> <span class="keywordtype">void</span> __exit foo_exit(<span class="keywordtype">void</span>)
 {
        <a class="code" href="group__genl__mngt.html#ga3fa959e2873bd588fbef31d0dabbf014" title="Unregister generic netlink operations.">genl_unregister</a>(&amp;genl_foo_ops);
 }
</pre></div> </dd></dl>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga090500dc23450349a7c2861fb3ae5f54"></a><!-- doxytag: member="mngt.c::genl_register" ref="ga090500dc23450349a7c2861fb3ae5f54" args="(struct nl_cache_ops *ops)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int genl_register </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></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 </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="mngt_8c_source.html#l00172">172</a> of file <a class="el" href="mngt_8c_source.html">mngt.c</a>.</p>

<p>References <a class="el" href="cache-api_8h_source.html#l00182">nl_cache_ops::co_msg_parser</a>, <a class="el" href="cache-api_8h_source.html#l00131">nl_msgtype::mt_id</a>, <a class="el" href="cache-api_8h_source.html#l00137">nl_msgtype::mt_name</a>, and <a class="el" href="cache__mngt_8c_source.html#l00127">nl_cache_mngt_register()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <span class="keywordtype">int</span> err;

        <span class="keywordflow">if</span> (ops-&gt;co_protocol != NETLINK_GENERIC) {
                err = nl_error(EINVAL, <span class="stringliteral">&quot;cache operations not for protocol &quot;</span> \
                               <span class="stringliteral">&quot;NETLINK_GENERIC (protocol=%s)&quot;</span>,
                               ops-&gt;co_protocol);
                <span class="keywordflow">goto</span> errout;
        }

        <span class="keywordflow">if</span> (ops-&gt;co_hdrsize &lt; GENL_HDRSIZE(0)) {
                err = nl_error(EINVAL, <span class="stringliteral">&quot;co_hdrsize too short, probably &quot;</span> \
                               <span class="stringliteral">&quot;not including genlmsghdr, minsize=%d&quot;</span>,
                               GENL_HDRSIZE(0));
                <span class="keywordflow">goto</span> errout;
        }

        <span class="keywordflow">if</span> (ops-&gt;co_genl == NULL) {
                err = nl_error(EINVAL, <span class="stringliteral">&quot;co_genl is NULL, must provide &quot;</span> \
                               <span class="stringliteral">&quot;valid genl operations&quot;</span>);
                <span class="keywordflow">goto</span> errout;
        }

        ops-&gt;co_genl-&gt;o_cache_ops = ops;
        ops-&gt;co_genl-&gt;o_name = ops-&gt;co_msgtypes[0].<a class="code" href="structnl__msgtype.html#a8a50cfe0a76d4bbe95473f5d2a3a5b96" title="Name of operation for human-readable printing.">mt_name</a>;
        ops-&gt;co_genl-&gt;o_family = ops-&gt;co_msgtypes[0].<a class="code" href="structnl__msgtype.html#a2b51527c3258ef4231b84d856a7c4164" title="Netlink message type.">mt_id</a>;
        ops-&gt;<a class="code" href="structnl__cache__ops.html#aeea6ef6813bb58a76c3d44454271678f" title="Called whenever a message was received that needs to be parsed.">co_msg_parser</a> = genl_msg_parser;

        <span class="comment">/* FIXME: check for dup */</span>

        nl_list_add_tail(&amp;ops-&gt;co_genl-&gt;o_list, &amp;genl_ops_list);

        err = <a class="code" href="group__cache__mngt.html#ga390eeb1fa61634cf1c216792c6df63c3" title="Register a set of cache operations.">nl_cache_mngt_register</a>(ops);
errout:
        <span class="keywordflow">return</span> err;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ga3fa959e2873bd588fbef31d0dabbf014"></a><!-- doxytag: member="mngt.c::genl_unregister" ref="ga3fa959e2873bd588fbef31d0dabbf014" args="(struct nl_cache_ops *ops)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void genl_unregister </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></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 </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="mngt_8c_source.html#l00214">214</a> of file <a class="el" href="mngt_8c_source.html">mngt.c</a>.</p>

<p>References <a class="el" href="cache__mngt_8c_source.html#l00157">nl_cache_mngt_unregister()</a>.</p>
<div class="fragment"><pre class="fragment">{
        <a class="code" href="group__cache__mngt.html#ga09f56b767b3868b7e0cf8559863dde77" title="Unregister a set of cache operations.">nl_cache_mngt_unregister</a>(ops);
        nl_list_del(&amp;ops-&gt;co_genl-&gt;o_list);
}
</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>