1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 3<title>uIP 1.0: example-mainloop-without-arp.c</title> 4<link href="doxygen.css" rel="stylesheet" type="text/css"> 5<link href="tabs.css" rel="stylesheet" type="text/css"> 6</head><body> 7<!-- Generated by Doxygen 1.4.6 --> 8<div class="tabs"> 9 <ul> 10 <li><a href="main.html"><span>Main Page</span></a></li> 11 <li><a href="modules.html"><span>Modules</span></a></li> 12 <li><a href="classes.html"><span>Data Structures</span></a></li> 13 <li><a href="files.html"><span>Files</span></a></li> 14 <li><a href="examples.html"><span>Examples</span></a></li> 15 </ul></div> 16<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> 17<a name="l00002"></a>00002 <span class="preprocessor">#include "<a class="code" href="a00139.html">uip_arp.h</a>"</span> 18<a name="l00003"></a>00003 <span class="preprocessor">#include "network-device.h"</span> 19<a name="l00004"></a>00004 <span class="preprocessor">#include "httpd.h"</span> 20<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="a00130.html">timer.h</a>"</span> 21<a name="l00006"></a>00006 22<a name="l00007"></a>00007 <span class="comment">/*---------------------------------------------------------------------------*/</span> 23<a name="l00008"></a>00008 <span class="keywordtype">int</span> 24<a name="l00009"></a>00009 main(<span class="keywordtype">void</span>) 25<a name="l00010"></a>00010 { 26<a name="l00011"></a>00011 <span class="keywordtype">int</span> i; 27<a name="l00012"></a>00012 <a name="a84"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr; 28<a name="l00013"></a>00013 <span class="keyword">struct </span><a name="_a85"></a><a class="code" href="a00087.html">timer</a> periodic_timer; 29<a name="l00014"></a>00014 30<a name="l00015"></a>00015 <a name="a86"></a><a class="code" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a>(&periodic_timer, <a name="a87"></a><a class="code" href="a00157.html#ge3ced0551b26c9b99cb45a86f34d100a">CLOCK_SECOND</a> / 2); 31<a name="l00016"></a>00016 32<a name="l00017"></a>00017 network_device_init(); 33<a name="l00018"></a>00018 <a name="a88"></a><a class="code" href="a00145.html#gc48ed5f0d27721ef62a3ed02a5ad8d2e">uip_init</a>(); 34<a name="l00019"></a>00019 35<a name="l00020"></a>00020 <a name="a89"></a><a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(ipaddr, 192,168,0,2); 36<a name="l00021"></a>00021 <a name="a90"></a><a class="code" href="a00144.html#g12b467f314489259dd718228d0827a51">uip_sethostaddr</a>(ipaddr); 37<a name="l00022"></a>00022 38<a name="l00023"></a>00023 <a name="a91"></a><a class="code" href="a00164.html#gc364305cee969a0be43c071722b136e6">httpd_init</a>(); 39<a name="l00024"></a>00024 40<a name="l00025"></a>00025 <span class="keywordflow">while</span>(1) { 41<a name="l00026"></a>00026 <a name="a92"></a><a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = network_device_read(); 42<a name="l00027"></a>00027 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { 43<a name="l00028"></a>00028 <a name="a93"></a><a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>(); 44<a name="l00029"></a>00029 <span class="comment">/* If the above function invocation resulted in data that</span> 45<a name="l00030"></a>00030 <span class="comment"> should be sent out on the network, the global variable</span> 46<a name="l00031"></a>00031 <span class="comment"> uip_len is set to a value > 0. */</span> 47<a name="l00032"></a>00032 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { 48<a name="l00033"></a>00033 network_device_send(); 49<a name="l00034"></a>00034 } 50<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>(&periodic_timer)) { 51<a name="l00036"></a>00036 <a name="a95"></a><a class="code" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a>(&periodic_timer); 52<a name="l00037"></a>00037 <span class="keywordflow">for</span>(i = 0; i < <a name="a96"></a><a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; i++) { 53<a name="l00038"></a>00038 <a name="a97"></a><a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i); 54<a name="l00039"></a>00039 <span class="comment">/* If the above function invocation resulted in data that</span> 55<a name="l00040"></a>00040 <span class="comment"> should be sent out on the network, the global variable</span> 56<a name="l00041"></a>00041 <span class="comment"> uip_len is set to a value > 0. */</span> 57<a name="l00042"></a>00042 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { 58<a name="l00043"></a>00043 network_device_send(); 59<a name="l00044"></a>00044 } 60<a name="l00045"></a>00045 } 61<a name="l00046"></a>00046 62<a name="l00047"></a>00047 <span class="preprocessor">#if UIP_UDP</span> 63<a name="l00048"></a>00048 <span class="preprocessor"></span> <span class="keywordflow">for</span>(i = 0; i < <a name="a98"></a><a class="code" href="a00153.html#g196379ceb1219a99f4495e41ccc9bbfb">UIP_UDP_CONNS</a>; i++) { 64<a name="l00049"></a>00049 <a name="a99"></a><a class="code" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">uip_udp_periodic</a>(i); 65<a name="l00050"></a>00050 <span class="comment">/* If the above function invocation resulted in data that</span> 66<a name="l00051"></a>00051 <span class="comment"> should be sent out on the network, the global variable</span> 67<a name="l00052"></a>00052 <span class="comment"> uip_len is set to a value > 0. */</span> 68<a name="l00053"></a>00053 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> > 0) { 69<a name="l00054"></a>00054 network_device_send(); 70<a name="l00055"></a>00055 } 71<a name="l00056"></a>00056 } 72<a name="l00057"></a>00057 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span> 73<a name="l00058"></a>00058 } 74<a name="l00059"></a>00059 } 75<a name="l00060"></a>00060 <span class="keywordflow">return</span> 0; 76<a name="l00061"></a>00061 } 77<a name="l00062"></a>00062 <span class="comment">/*---------------------------------------------------------------------------*/</span> 78</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by 79<a href="http://www.doxygen.org/index.html"> 80<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address> 81</body> 82</html> 83