📄 a00146.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>uIP 1.0: uIP device driver functions</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="classes.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul></div><h1>uIP device driver functions<br><small>[<a class="el" href="a00150.html">The uIP TCP/IP stack</a>]</small></h1><hr><a name="_details"></a><h2>Detailed Description</h2>These functions are used by a network device driver for interacting with uIP. <p><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Defines</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Process an incoming packet. <a href="#ga4360412ee9350fba725f98a137169fe"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(conn)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Periodic processing for a connection identified by its number. <a href="#g1024f8a5fa65e82bf848b2e6590d9628"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gfd5ebb56a1bd1da9878aa886a2075e80"></a><!-- doxytag: member="uipdevfunc::uip_conn_active" ref="gfd5ebb56a1bd1da9878aa886a2075e80" args="(conn)" -->#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#gfd5ebb56a1bd1da9878aa886a2075e80">uip_conn_active</a>(conn) (<a class="el" href="a00150.html#gf703683056d2bfa5c81fa157dcb20fe2">uip_conns</a>[conn].tcpstateflags != UIP_CLOSED)</td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#gbaf0bb2b6a4424b4eb69e45e457c2583">uip_periodic_conn</a>(conn)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Perform periodic processing for a connection identified by a pointer to its structure. <a href="#gbaf0bb2b6a4424b4eb69e45e457c2583"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#gf20aaf4292cb0d2a1b10bc0a568b51fa">uip_poll_conn</a>(conn)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Reuqest that a particular connection should be polled. <a href="#gf20aaf4292cb0d2a1b10bc0a568b51fa"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">uip_udp_periodic</a>(conn)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Periodic processing for a UDP connection identified by its number. <a href="#g2c64c8c36bc84f9336f6a2184ea51883"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#gf5c2ad5acf3cc23b8262e9ba6a15136b">uip_udp_periodic_conn</a>(conn)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Periodic processing for a UDP connection identified by a pointer to its structure. <a href="#gf5c2ad5acf3cc23b8262e9ba6a15136b"></a><br></td></tr><tr><td colspan="2"><br><h2>Variables</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00146.html#gb81e78f890dbbee50c533a9734b74fd9">uip_buf</a> [UIP_BUFSIZE+2]</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">The uIP packet buffer. <a href="#gb81e78f890dbbee50c533a9734b74fd9"></a><br></td></tr></table><hr><h2>Define Documentation</h2><a class="anchor" name="ga4360412ee9350fba725f98a137169fe"></a><!-- doxytag: member="uip.h::uip_input" ref="ga4360412ee9350fba725f98a137169fe" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define uip_input </td> <td class="md" valign="top">( </td> </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Process an incoming packet. <p>This function should be called when the device driver has received a packet from the network. The packet from the device driver must be present in the uip_buf buffer, and the length of the packet should be placed in the uip_len variable.<p>When the function returns, there may be an outbound packet placed in the uip_buf packet buffer. If so, the uip_len variable is set to the length of the packet. If no packet is to be sent out, the uip_len variable is set to 0.<p>The usual way of calling the function is presented by the source code below. <div class="fragment"><pre class="fragment"> <a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = devicedriver_poll(); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { <a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>(); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { devicedriver_send(); } }</pre></div><p><dl compact><dt><b>Note:</b></dt><dd>If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the uIP ARP code before calling this function: <div class="fragment"><pre class="fragment"><span class="preprocessor"> #define BUF ((struct uip_eth_hdr *)&uip_buf[0])</span><span class="preprocessor"></span> <a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = ethernet_devicedrver_poll(); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { <span class="keywordflow">if</span>(<a class="code" href="a00150.html#g24f52ac52d6e714cb04a5aa01be3bdd0">BUF</a>->type == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(<a class="code" href="a00152.html#g03d140db75de3d3cdfbbab1c4fed8d8d">UIP_ETHTYPE_IP</a>)) { <a class="code" href="a00152.html#g737337d6a51e31b236c8233d024138a8">uip_arp_ipin</a>(); <a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>(); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { <a class="code" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a>(); ethernet_devicedriver_send(); } } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="a00150.html#g24f52ac52d6e714cb04a5aa01be3bdd0">BUF</a>->type == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(<a class="code" href="a00152.html#g3e1562e8a6de32268e5df92a52152f91">UIP_ETHTYPE_ARP</a>)) { <a class="code" href="a00152.html#g902c4a360134096224bc2655f623aa5f">uip_arp_arpin</a>(); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { ethernet_devicedriver_send(); } }</pre></div> </dd></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00042.html#a73">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a93">example-mainloop-without-arp.c</a>.</dl><p>Definition at line <a class="el" href="a00202.html#l00257">257</a> of file <a class="el" href="a00202.html">uip.h</a>. </td> </tr></table><a class="anchor" name="g1024f8a5fa65e82bf848b2e6590d9628"></a><!-- doxytag: member="uip.h::uip_periodic" ref="g1024f8a5fa65e82bf848b2e6590d9628" args="(conn)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define uip_periodic </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">conn </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Periodic processing for a connection identified by its number. <p>This function does the necessary periodic processing (timers, polling) for a uIP TCP conneciton, and should be called when the periodic uIP timer goes off. It should be called for every connection, regardless of whether they are open of closed.<p>When the function returns, it may have an outbound packet waiting for service in the uIP packet buffer, and if so the uip_len variable is set to a value larger than zero. The device driver should be called to send out the packet.<p>The ususal way of calling the function is through a for() loop like this: <div class="fragment"><pre class="fragment"> <span class="keywordflow">for</span>(i = 0; i < <a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; ++i) { <a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { devicedriver_send(); } }</pre></div><p><dl compact><dt><b>Note:</b></dt><dd>If you are writing a uIP device driver that needs ARP (Address Resolution Protocol), e.g., when running uIP over Ethernet, you will need to call the <a class="el" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out()</a> function before calling the device driver: <div class="fragment"><pre class="fragment"> <span class="keywordflow">for</span>(i = 0; i < UIP_CONNS; ++i) { <a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i); <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { <a class="code" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a>(); ethernet_devicedriver_send(); } }</pre></div></dd></dl><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>conn</em> </td><td>The number of the connection which is to be periodically polled. </td></tr> </table></dl><dl compact><dt><b>Examples: </b></dt><dd><a class="el" href="a00042.html#a80">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a97">example-mainloop-without-arp.c</a>.</dl><p>Definition at line <a class="el" href="a00202.html#l00301">301</a> of file <a class="el" href="a00202.html">uip.h</a>. </td> </tr></table><a class="anchor" name="gbaf0bb2b6a4424b4eb69e45e457c2583"></a><!-- doxytag: member="uip.h::uip_periodic_conn" ref="gbaf0bb2b6a4424b4eb69e45e457c2583" args="(conn)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">#define uip_periodic_conn </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">conn </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -