blob: 174b537abd3ef1bf1c363e71f4a93d24d2ec0cb0 [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: System initalization</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('sys_init.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="headertitle">
<div class="title">System initalization </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>A truly complete and generic sequence for initializing the lwIP stack cannot be given because it depends on additional initializations for your runtime environment (e.g. timers).</p>
<p>We can give you some idea on how to proceed when using the raw API. We assume a configuration using a single Ethernet netif and the UDP and TCP transport layers, IPv4 and the DHCP client.</p>
<p>Call these functions in the order of appearance:</p>
<ul>
<li><a class="el" href="group__lwip__nosys.html#ga0c1a18439524d2f4a5e51d25c0ca2ce9">lwip_init()</a>: Initialize the lwIP stack and all of its subsystems.</li>
<li><p class="startli">netif_add(struct netif *netif, ...): Adds your network interface to the netif_list. Allocate a struct netif and pass a pointer to this structure as the first argument. Give pointers to cleared <a class="el" href="structip__addr.html">ip_addr</a> structures when using DHCP, or fill them with sane numbers otherwise. The state pointer may be NULL.</p>
<p class="startli">The init function pointer must point to a initialization function for your Ethernet netif interface. The following code illustrates its use.</p>
</li>
</ul>
<div class="fragment"><div class="line"><a class="code" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> netif_if_init(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>)</div><div class="line">{</div><div class="line"> u8_t i;</div><div class="line"> </div><div class="line"> <span class="keywordflow">for</span> (i = 0; i &lt; ETHARP_HWADDR_LEN; i++) {</div><div class="line"> netif-&gt;<a class="code" href="structnetif.html#aee967965d999fc1a4c40a66709304e69">hwaddr</a>[i] = some_eth_addr[i];</div><div class="line"> }</div><div class="line"> init_my_eth_device();</div><div class="line"> <span class="keywordflow">return</span> <a class="code" href="group__infrastructure__errors.html#ggae2e66c7d13afc90ffecd6151680fbadcaa26c163b80b1f6786ca81dadc14b00fb">ERR_OK</a>;</div><div class="line">}</div></div><!-- fragment --><p>For Ethernet drivers, the input function pointer must point to the lwIP function <a class="el" href="group__lwip__nosys.html#ga6a10c58b82c56d02c48b3cfa2c2494ff">ethernet_input()</a> declared in "netif/etharp.h". Other drivers must use <a class="el" href="group__lwip__nosys.html#ga3c420dab0c6760df099a2d688fa42a26">ip_input()</a> declared in "lwip/ip.h".</p>
<ul>
<li><a class="el" href="group__netif.html#gac90f290edd005238d62aa94c4ac9dea3">netif_set_default(struct netif *netif)</a> Registers the default network interface.</li>
<li><a class="el" href="group__netif.html#gae0d2975f189277990e9d5276fdd9e9ea">netif_set_link_up(struct netif *netif)</a> This is the hardware link state; e.g. whether cable is plugged for wired Ethernet interface. This function must be called even if you don't know the current state. Having link up and link down events is optional but DHCP and IPv6 discover benefit well from those events.</li>
<li><a class="el" href="group__netif.html#gaf19693be401a265a52d2a56c65753121">netif_set_up(struct netif *netif)</a> This is the administrative (= software) state of the netif, when the netif is fully configured this function must be called.</li>
<li><a class="el" href="group__dhcp4.html#ga0c50968d9811aa2aa67fadc0885d744f">dhcp_start(struct netif *netif)</a> Creates a new DHCP client for this interface on the first call. You can peek in the netif-&gt;dhcp struct for the actual DHCP status.</li>
<li><a class="el" href="group__lwip__nosys.html#ga83cffdf69ab60fd0eba9d17d363f9883">sys_check_timeouts()</a> When the system is running, you have to periodically call <a class="el" href="group__lwip__nosys.html#ga83cffdf69ab60fd0eba9d17d363f9883">sys_check_timeouts()</a> which will handle all timers for all protocols in the stack; add this to your main loop or equivalent. </li>
</ul>
</div></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>