smart-green-house/rtt-uart-nb/rt-thread/components/net/uip/doc/html/a00043.html

83 lines
7.2 KiB
HTML
Raw Normal View History

2023-10-28 18:00:47 +08:00
<!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: example-mainloop-without-arp.c</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&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;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>example-mainloop-without-arp.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include "<a class="code" href="a00139.html">uip_arp.h</a>"</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include "network-device.h"</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "httpd.h"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="a00130.html">timer.h</a>"</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00008"></a>00008 <span class="keywordtype">int</span>
<a name="l00009"></a>00009 main(<span class="keywordtype">void</span>)
<a name="l00010"></a>00010 {
<a name="l00011"></a>00011 <span class="keywordtype">int</span> i;
<a name="l00012"></a>00012 <a name="a84"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a name="l00013"></a>00013 <span class="keyword">struct </span><a name="_a85"></a><a class="code" href="a00087.html">timer</a> periodic_timer;
<a name="l00014"></a>00014
<a name="l00015"></a>00015 <a name="a86"></a><a class="code" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a>(&amp;periodic_timer, <a name="a87"></a><a class="code" href="a00157.html#ge3ced0551b26c9b99cb45a86f34d100a">CLOCK_SECOND</a> / 2);
<a name="l00016"></a>00016
<a name="l00017"></a>00017 network_device_init();
<a name="l00018"></a>00018 <a name="a88"></a><a class="code" href="a00145.html#gc48ed5f0d27721ef62a3ed02a5ad8d2e">uip_init</a>();
<a name="l00019"></a>00019
<a name="l00020"></a>00020 <a name="a89"></a><a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(ipaddr, 192,168,0,2);
<a name="l00021"></a>00021 <a name="a90"></a><a class="code" href="a00144.html#g12b467f314489259dd718228d0827a51">uip_sethostaddr</a>(ipaddr);
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <a name="a91"></a><a class="code" href="a00164.html#gc364305cee969a0be43c071722b136e6">httpd_init</a>();
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="keywordflow">while</span>(1) {
<a name="l00026"></a>00026 <a name="a92"></a><a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = network_device_read();
<a name="l00027"></a>00027 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00028"></a>00028 <a name="a93"></a><a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>();
<a name="l00029"></a>00029 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00030"></a>00030 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00031"></a>00031 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00032"></a>00032 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00033"></a>00033 network_device_send();
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a name="a94"></a><a class="code" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a>(&amp;periodic_timer)) {
<a name="l00036"></a>00036 <a name="a95"></a><a class="code" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a>(&amp;periodic_timer);
<a name="l00037"></a>00037 <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a96"></a><a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; i++) {
<a name="l00038"></a>00038 <a name="a97"></a><a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i);
<a name="l00039"></a>00039 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00040"></a>00040 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00041"></a>00041 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00042"></a>00042 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00043"></a>00043 network_device_send();
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#if UIP_UDP</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span> <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a98"></a><a class="code" href="a00153.html#g196379ceb1219a99f4495e41ccc9bbfb">UIP_UDP_CONNS</a>; i++) {
<a name="l00049"></a>00049 <a name="a99"></a><a class="code" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">uip_udp_periodic</a>(i);
<a name="l00050"></a>00050 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00051"></a>00051 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00052"></a>00052 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00053"></a>00053 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00054"></a>00054 network_device_send();
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span>
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 <span class="keywordflow">return</span> 0;
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 <span class="comment">/*---------------------------------------------------------------------------*/</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>