blob: 092ca0b31e90faac6b5489324e41dfe11b0c2fa9 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: SNMPv2c/v3 agent</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">lwIP
&#160;<span id="projectnumber">2.1.2</span>
</div>
<div id="projectbrief">Lightweight IP stack</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__snmp.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#groups">Modules</a> </div>
<div class="headertitle">
<div class="title">SNMPv2c/v3 agent<div class="ingroups"><a class="el" href="group__apps.html">Applications</a></div></div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:group__snmp__core"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__snmp__core.html">Core</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__snmp__traps"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__snmp__traps.html">Traps</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__snmp__mib2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__snmp__mib2.html">MIB2</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__snmp__opts"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__snmp__opts.html">Options</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>SNMPv2c and SNMPv3 compatible agent<br />
There is also a MIB compiler and a MIB viewer in lwIP contrib repository (lwip-contrib/apps/LwipMibCompiler).<br />
The agent implements the most important MIB2 MIBs including IPv6 support (interfaces, UDP, TCP, SNMP, ICMP, SYSTEM). IP MIB is an older version without IPv6 statistics (TODO).<br />
Rewritten by Martin Hentschel <a href="#" onclick="location.href='mai'+'lto:'+'inf'+'o@'+'cl-'+'so'+'ft.'+'de'; return false;">info@<span style="display: none;">.nosp@m.</span>cl-s<span style="display: none;">.nosp@m.</span>oft.d<span style="display: none;">.nosp@m.</span>e</a> and Dirk Ziegelmeier <a href="#" onclick="location.href='mai'+'lto:'+'dzi'+'eg'+'el@'+'gm'+'x.d'+'e'; return false;">dzieg<span style="display: none;">.nosp@m.</span>el@g<span style="display: none;">.nosp@m.</span>mx.de</a><br />
</p><h1>0 Agent Capabilities </h1>
<h2>Features: </h2>
<ul>
<li>SNMPv2c support.</li>
<li>SNMPv3 support (a port to ARM mbedtls is provided, LWIP_SNMP_V3_MBEDTLS option).</li>
<li>Low RAM usage - no memory pools, stack only.</li>
<li>MIB2 implementation is separated from SNMP stack.</li>
<li>Support for multiple MIBs (<a class="el" href="group__snmp__core.html#ga29c76474971f25d038fd486447c70e21">snmp_set_mibs()</a> call) - e.g. for private MIB.</li>
<li>Simple and generic API for MIB implementation.</li>
<li>Comfortable node types and helper functions for scalar arrays and tables.</li>
<li>Counter64, bit and truthvalue datatype support.</li>
<li>Callbacks for SNMP writes e.g. to implement persistency.</li>
<li>Runs on two APIs: RAW and netconn.</li>
<li>Async API is gone - the stack now supports netconn API instead, so blocking operations can be done in MIB calls. SNMP runs in a worker thread when netconn API is used.</li>
<li>Simplified thread sync support for MIBs - useful when MIBs need to access variables shared with other threads where no locking is possible. Used in MIB2 to access lwIP stats from lwIP thread.</li>
</ul>
<h2>MIB compiler (code generator): </h2>
<ul>
<li>Provided in lwIP contrib repository.</li>
<li>Written in C#. MIB viewer used Windows Forms.</li>
<li>Developed on Windows with Visual Studio 2010.</li>
<li>Can be compiled and used on all platforms with <a href="http://www.monodevelop.com/">http://www.monodevelop.com/</a>.</li>
<li>Based on a heavily modified version of of SharpSnmpLib (a4bd05c6afb4) (<a href="https://sharpsnmplib.codeplex.com/SourceControl/network/forks/Nemo157/MIBParserUpdate">https://sharpsnmplib.codeplex.com/SourceControl/network/forks/Nemo157/MIBParserUpdate</a>).</li>
<li>MIB parser, C file generation framework and LWIP code generation are cleanly separated, which means the code may be useful as a base for code generation of other SNMP agents.</li>
</ul>
<h2>Notes: </h2>
<ul>
<li>Stack and MIB compiler were used to implement a Profinet device. Compiled/implemented MIBs: LLDP-MIB, LLDP-EXT-DOT3-MIB, LLDP-EXT-PNO-MIB.</li>
</ul>
<h2>SNMPv1 per RFC1157 and SNMPv2c per RFC 3416 </h2>
<p>Note the S in SNMP stands for "Simple". Note that "Simple" is relative. SNMP is simple compared to the complex ISO network management protocols CMIP (Common Management Information Protocol) and CMOT (CMip Over Tcp).</p>
<h2>SNMPv3 </h2>
<p>When SNMPv3 is used, several functions from <a class="el" href="snmpv3_8h.html">snmpv3.h</a> must be implemented by the user. This is mainly user management and persistence handling. The sample provided in lwip-contrib is insecure, don't use it in production systems, especially the missing persistence for engine boots variable simplifies replay attacks.</p>
<h2>MIB II </h2>
<p>The standard lwIP stack management information base. This is a required MIB, so this is always enabled. The groups EGP, CMOT and transmission are disabled by default.</p>
<p>Most mib-2 objects are not writable except: sysName, sysLocation, sysContact, snmpEnableAuthenTraps. Writing to or changing the ARP and IP address and route tables is not possible.</p>
<p>Note lwIP has a very limited notion of IP routing. It currently doen't have a route table and doesn't have a notion of the U,G,H flags. Instead lwIP uses the interface list with only one default interface acting as a single gateway interface (G) for the default route.</p>
<p>The agent returns a "virtual table" with the default route 0.0.0.0 for the default interface and network routes (no H) for each network interface in the netif_list. All routes are considered to be up (U).</p>
<h2>Loading additional MIBs </h2>
<p>MIBs can only be added in compile-time, not in run-time.</p>
<h1>1 Building the Agent </h1>
<p>First of all you'll need to add the following define to your local lwipopts.h: #define LWIP_SNMP 1</p>
<p>and add the source files your makefile.</p>
<p>Note you'll might need to adapt you network driver to update the mib2 variables for your interface.</p>
<h1>2 Running the Agent </h1>
<p>The following function calls must be made in your program to actually get the SNMP agent running.</p>
<p>Before starting the agent you should supply pointers for sysContact, sysLocation, and snmpEnableAuthenTraps. You can do this by calling</p>
<ul>
<li><a class="el" href="group__snmp__mib2.html#gaf96002d9d10bcae27a95b2367674249e">snmp_mib2_set_syscontact()</a></li>
<li><a class="el" href="group__snmp__mib2.html#ga4248e004a27344b7260574c3a51882f2">snmp_mib2_set_syslocation()</a></li>
<li><a class="el" href="group__snmp__traps.html#gacaf816ff917f7b7e5d00ed6c9f79b51c">snmp_set_auth_traps_enabled()</a></li>
</ul>
<p>You can register a callback which is called on successful write access: <a class="el" href="group__snmp__core.html#gaff6a6b39322e92862ab55cfcddfe254b">snmp_set_write_callback()</a>.</p>
<p>Additionally you may want to set</p>
<ul>
<li><a class="el" href="group__snmp__mib2.html#gacde87dc1d3bd669b19d834b028f490cc">snmp_mib2_set_sysdescr()</a></li>
<li><a class="el" href="group__snmp__core.html#gacc71ac857bf9215f06a624dda09abe3a">snmp_set_device_enterprise_oid()</a></li>
<li><a class="el" href="group__snmp__mib2.html#gae7ce98a6ecc0bb92aaa2b330599a2db7">snmp_mib2_set_sysname()</a></li>
</ul>
<p>Also before starting the agent you need to setup one or more trap destinations using these calls:</p>
<ul>
<li><a class="el" href="group__snmp__traps.html#gab101505be59778cf0f2f1ac40bcf3f32">snmp_trap_dst_enable()</a></li>
<li><a class="el" href="group__snmp__traps.html#ga15e4afbf80ed2260850842e6608c6d86">snmp_trap_dst_ip_set()</a></li>
</ul>
<p>If you need more than MIB2, set the MIBs you want to use by <a class="el" href="group__snmp__core.html#ga29c76474971f25d038fd486447c70e21">snmp_set_mibs()</a>.</p>
<p>Finally, enable the agent by calling <a class="el" href="snmp__netconn_8c.html#ga4d88f2fc7655280384131d543e0d83e5">snmp_init()</a> </p>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
</ul>
</div>
</body>
</html>