Newer
Older
ubixos / doc / html / ethernetif_8c-source.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>UbixOS V2: src/sys/net/netif/ethernetif.c Source File</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.7 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="dir_897b6a2d7bab147dd1db58381aad3984.html">src</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_832905b1f7f5feaf61a306b40c0ac817.html">sys</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_da977d215fccd664f66e7711fda26f76.html">net</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_becc64c1c5cdfab2e137aa1ca4b91e6b.html">netif</a></div>
<h1>ethernetif.c</h1><a href="ethernetif_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2001, Swedish Institute of Computer Science.</span>
<a name="l00003"></a>00003 <span class="comment"> * All rights reserved. </span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Redistribution and use in source and binary forms, with or without </span>
<a name="l00006"></a>00006 <span class="comment"> * modification, are permitted provided that the following conditions </span>
<a name="l00007"></a>00007 <span class="comment"> * are met: </span>
<a name="l00008"></a>00008 <span class="comment"> * 1. Redistributions of source code must retain the above copyright </span>
<a name="l00009"></a>00009 <span class="comment"> *    notice, this list of conditions and the following disclaimer. </span>
<a name="l00010"></a>00010 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright </span>
<a name="l00011"></a>00011 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the </span>
<a name="l00012"></a>00012 <span class="comment"> *    documentation and/or other materials provided with the distribution. </span>
<a name="l00013"></a>00013 <span class="comment"> * 3. Neither the name of the Institute nor the names of its contributors </span>
<a name="l00014"></a>00014 <span class="comment"> *    may be used to endorse or promote products derived from this software </span>
<a name="l00015"></a>00015 <span class="comment"> *    without specific prior written permission. </span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND </span>
<a name="l00018"></a>00018 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </span>
<a name="l00019"></a>00019 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE </span>
<a name="l00020"></a>00020 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE </span>
<a name="l00021"></a>00021 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </span>
<a name="l00022"></a>00022 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS </span>
<a name="l00023"></a>00023 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) </span>
<a name="l00024"></a>00024 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT </span>
<a name="l00025"></a>00025 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY </span>
<a name="l00026"></a>00026 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF </span>
<a name="l00027"></a>00027 <span class="comment"> * SUCH DAMAGE. </span>
<a name="l00028"></a>00028 <span class="comment"> *</span>
<a name="l00029"></a>00029 <span class="comment"> * This file is part of the lwIP TCP/IP stack.</span>
<a name="l00030"></a>00030 <span class="comment"> * </span>
<a name="l00031"></a>00031 <span class="comment"> * Author: Adam Dunkels &lt;adam@sics.se&gt;</span>
<a name="l00032"></a>00032 <span class="comment"> *</span>
<a name="l00033"></a>00033 <span class="comment"> * $Id: ethernetif_8c-source.html 88 2016-01-12 00:11:29Z reddawg $</span>
<a name="l00034"></a>00034 <span class="comment"> */</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="comment">/*</span>
<a name="l00037"></a>00037 <span class="comment"> * This file is a skeleton for developing Ethernet network interface</span>
<a name="l00038"></a>00038 <span class="comment"> * drivers for lwIP. Add code to the low_level functions and do a</span>
<a name="l00039"></a>00039 <span class="comment"> * search-and-replace for the word "ethernetif" to replace it with</span>
<a name="l00040"></a>00040 <span class="comment"> * something that better describes your network interface.</span>
<a name="l00041"></a>00041 <span class="comment"> */</span>
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;<a class="code" href="types_8h.html">ubixos/types.h</a>&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;<a class="code" href="sched_8h.html">ubixos/sched.h</a>&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;<a class="code" href="kmalloc_8h.html">lib/kmalloc.h</a>&gt;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;<a class="code" href="kprintf_8h.html">lib/kprintf.h</a>&gt;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &lt;<a class="code" href="device_8old_8h.html">sys/device.old.h</a>&gt;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;<a class="code" href="ne2k_8h.html">isa/ne2k.h</a>&gt;</span>
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">net/debug.h</a>"</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="preprocessor">#include "<a class="code" href="opt_8h.html">net/opt.h</a>"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "<a class="code" href="def_8h.html">net/def.h</a>"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "<a class="code" href="mem_8h.html">net/mem.h</a>"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "<a class="code" href="pbuf_8h.html">net/pbuf.h</a>"</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "<a class="code" href="sys_8h.html">net/sys.h</a>"</span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="preprocessor">#include "<a class="code" href="arp_8h.html">netif/arp.h</a>"</span>
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="comment">/* Define those to better describe your network interface. */</span>
<a name="l00062"></a><a class="code" href="ethernetif_8c.html#cd9e3df20507d5f895e80477aef74555">00062</a> <span class="preprocessor">#define IFNAME0 'e'</span>
<a name="l00063"></a><a class="code" href="ethernetif_8c.html#43b130296861cb255f1ad5b8c3787fd1">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define IFNAME1 'd'</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span>
<a name="l00065"></a><a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">00065</a> <span class="keyword">struct </span><a class="code" href="structnicBuffer.html">nicBuffer</a> *<a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a> = 0x0;
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="structethernetif.html">00067</a> <span class="keyword">struct </span><a class="code" href="structethernetif.html">ethernetif</a> {
<a name="l00068"></a><a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">00068</a>   <span class="keyword">struct </span><a class="code" href="structeth__addr.html">eth_addr</a> *<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>;
<a name="l00069"></a>00069   <span class="comment">/* Add whatever per-interface state that is needed here. */</span>
<a name="l00070"></a>00070 };
<a name="l00071"></a>00071 
<a name="l00072"></a><a class="code" href="ethernetif_8c.html#6aac26114a085a1a287b32941ecd009e">00072</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code" href="structeth__addr.html">eth_addr</a> <a class="code" href="ethernetif_8c.html#6aac26114a085a1a287b32941ecd009e">ethbroadcast</a> = {{0xff,0xff,0xff,0xff,0xff,0xff}};
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="comment">/* Forward declarations. */</span>
<a name="l00075"></a>00075 <span class="keyword">static</span> <span class="keywordtype">void</span>  <a class="code" href="ethernetif_8c.html#687c1030eeb3939b9aa8e1a0811c301a">ethernetif_input</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>);
<a name="l00076"></a>00076 <span class="keyword">static</span> <a class="code" href="err_8h.html#b7190f3da5c85931fc059e0312bc1407">err_t</a> <a class="code" href="ethernetif_8c.html#eb49a49ab62789d8e32fddf180d52ebf">ethernetif_output</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>, <span class="keyword">struct</span> <a class="code" href="structpbuf.html">pbuf</a> *p, <span class="keyword">struct</span> <a class="code" href="structip__addr.html">ip_addr</a> *ipaddr);
<a name="l00077"></a>00077 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="ethernetif_8c.html#e1cb890e22f516c0106d5c6c8e07ab74">ethernetif_thread</a>();
<a name="l00078"></a><a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">00078</a> <span class="keyword">struct </span><a class="code" href="structdevice.html">device</a> *<a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a> = 0x0;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00081"></a><a class="code" href="ethernetif_8c.html#15915c49a70d85ff1c6af793cda34419">00081</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="ethernetif_8c.html#15915c49a70d85ff1c6af793cda34419">low_level_init</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>) {
<a name="l00082"></a>00082   <span class="keyword">struct </span><a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a>;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084   ethernetif = netif-&gt;<a class="code" href="structnetif.html#809cc57c0dff09c5c9ae45b02c2002f3">state</a>;
<a name="l00085"></a>00085   <a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a> = (<span class="keyword">struct </span><a class="code" href="structdevice.html">device</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structdevice.html">device</a>));
<a name="l00086"></a>00086   <a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a>-&gt;<a class="code" href="structdevice.html#9467302b748ed3627bae8e3ecee7af87">ioAddr</a> = 0x280;
<a name="l00087"></a>00087   <a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a>-&gt;<a class="code" href="structdevice.html#893bc785f272d1fedb2b4c14e31a7f35">irq</a>    = 0x10;
<a name="l00088"></a>00088   
<a name="l00089"></a>00089   <span class="comment">/* Obtain MAC address from network interface. */</span>
<a name="l00090"></a>00090   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[0] = 0x00;
<a name="l00091"></a>00091   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[1] = 0x00;
<a name="l00092"></a>00092   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[2] = 0xC0;
<a name="l00093"></a>00093   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[3] = 0x97;
<a name="l00094"></a>00094   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[4] = 0xC6;
<a name="l00095"></a>00095   ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[5] = 0x93;
<a name="l00096"></a>00096 
<a name="l00097"></a>00097   <span class="comment">/* Do whatever else is needed to initialize interface. */</span>  
<a name="l00098"></a>00098   <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"NETIF: [0x%X:0x%X]\n"</span>,netif,<a class="code" href="ethernetif_8c.html#e1cb890e22f516c0106d5c6c8e07ab74">ethernetif_thread</a>);
<a name="l00099"></a>00099   <a class="code" href="sys_8h.html#eb9b7d7cea295be85b0b0ddb7c9fe566">sys_thread_new</a>(<a class="code" href="ethernetif_8c.html#e1cb890e22f516c0106d5c6c8e07ab74">ethernetif_thread</a>, netif);
<a name="l00100"></a>00100  
<a name="l00101"></a>00101   }
<a name="l00102"></a>00102 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00103"></a>00103 <span class="comment">/*</span>
<a name="l00104"></a>00104 <span class="comment"> * low_level_output():</span>
<a name="l00105"></a>00105 <span class="comment"> *</span>
<a name="l00106"></a>00106 <span class="comment"> * Should do the actual transmission of the packet. The packet is</span>
<a name="l00107"></a>00107 <span class="comment"> * contained in the pbuf that is passed to the function. This pbuf</span>
<a name="l00108"></a>00108 <span class="comment"> * might be chained.</span>
<a name="l00109"></a>00109 <span class="comment"> *</span>
<a name="l00110"></a>00110 <span class="comment"> */</span>
<a name="l00111"></a>00111 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00112"></a>00112 
<a name="l00113"></a><a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">00113</a> <span class="keyword">static</span> <a class="code" href="err_8h.html#b7190f3da5c85931fc059e0312bc1407">err_t</a> <a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">low_level_output</a>(<span class="keyword">struct</span> <a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a>, <span class="keyword">struct</span> <a class="code" href="structpbuf.html">pbuf</a> *p) {
<a name="l00114"></a>00114   <span class="keyword">struct </span><a class="code" href="structpbuf.html">pbuf</a> *q;
<a name="l00115"></a>00115   <span class="keywordtype">char</span> <a class="code" href="structbuf.html">buf</a>[1500];
<a name="l00116"></a>00116   <span class="keywordtype">char</span> *bufptr = 0x0;
<a name="l00117"></a>00117 
<a name="l00118"></a>00118   <a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a>-&gt;<a class="code" href="structdevice.html#9467302b748ed3627bae8e3ecee7af87">ioAddr</a> = 0x280;
<a name="l00119"></a>00119   <a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a>-&gt;<a class="code" href="structdevice.html#893bc785f272d1fedb2b4c14e31a7f35">irq</a>    = 10;
<a name="l00120"></a>00120 
<a name="l00121"></a>00121   bufptr = &amp;buf[0];
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   <span class="keywordflow">for</span>(q = p; q != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>; q = q-&gt;<a class="code" href="structpbuf.html#5e5763c94fd18d78937b0b58ce7df341">next</a>) {
<a name="l00124"></a>00124     <a class="code" href="lib_8h.html#04bffce8d62dbb1e8e4e80a5fcdfed9a">bcopy</a>(q-&gt;<a class="code" href="structpbuf.html#8d32dc3e964369d4eec638fc37fbc460">payload</a>, bufptr, q-&gt;<a class="code" href="structpbuf.html#238f00a0024a32992599c9d1abf9bb44">len</a>);
<a name="l00125"></a>00125     bufptr += q-&gt;<a class="code" href="structpbuf.html#238f00a0024a32992599c9d1abf9bb44">len</a>;
<a name="l00126"></a>00126     }
<a name="l00127"></a>00127   <a class="code" href="ne2k_8h.html#f6446fd497eb16b637ebed77c7a0aeaf">PCtoNIC</a>(<a class="code" href="ethernetif_8c.html#cf6a82c73e7a9d99293d9ce0b8837faf">dev</a>,buf,p-&gt;<a class="code" href="structpbuf.html#3b42932c0b26c9ff2b8fe88bd25fb127">tot_len</a>);
<a name="l00128"></a>00128   <span class="comment">//kprintf("Sending Data[%i]\n",p-&gt;tot_len); </span>
<a name="l00129"></a>00129   <span class="keywordflow">return</span> <a class="code" href="err_8h.html#98c763adfeea8e9831c46ec269e47ae9">ERR_OK</a>;
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00134"></a>00134 <span class="comment">/*</span>
<a name="l00135"></a>00135 <span class="comment"> * low_level_input():</span>
<a name="l00136"></a>00136 <span class="comment"> *</span>
<a name="l00137"></a>00137 <span class="comment"> * Should allocate a pbuf and transfer the bytes of the incoming</span>
<a name="l00138"></a>00138 <span class="comment"> * packet from the interface into the pbuf.</span>
<a name="l00139"></a>00139 <span class="comment"> *</span>
<a name="l00140"></a>00140 <span class="comment"> */</span>
<a name="l00141"></a>00141 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00142"></a><a class="code" href="ethernetif_8c.html#70bd3f580cdc400e75161e9751944836">00142</a> <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structpbuf.html">pbuf</a> *<a class="code" href="ethernetif_8c.html#70bd3f580cdc400e75161e9751944836">low_level_input</a>(<span class="keyword">struct</span> <a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a>) {
<a name="l00143"></a>00143   <span class="keyword">struct </span><a class="code" href="structpbuf.html">pbuf</a> *p, *q;
<a name="l00144"></a>00144   <a class="code" href="types_8h.html#3b65128d2644e9b80cec9a69bfa7e094">uInt16</a> <a class="code" href="structpbuf.html#238f00a0024a32992599c9d1abf9bb44">len</a>;
<a name="l00145"></a>00145   <span class="keywordtype">char</span> *bufptr;
<a name="l00146"></a>00146   <span class="keywordtype">char</span> *<a class="code" href="structbuf.html">buf</a>;
<a name="l00147"></a>00147 
<a name="l00148"></a>00148   len = <a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a>-&gt;<a class="code" href="structnicBuffer.html#959ee09a7a6fc875f3d5d651576f37c4">length</a>;
<a name="l00149"></a>00149   bufptr = <a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a>-&gt;<a class="code" href="structnicBuffer.html#9679b6c2e76a7617884e422c11aa3eac">buffer</a>;
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 
<a name="l00152"></a>00152   <span class="comment">/* We allocate a pbuf chain of pbufs from the pool. */</span>
<a name="l00153"></a>00153   p = <a class="code" href="pbuf_8h.html#bb6c8efa7f7739e71cb286c6dd4a47ef">pbuf_alloc</a>(<a class="code" href="pbuf_8h.html#ee1baa59bb2f85ba575b5a8619ac1ebfb4de441e737330558b609a990cd17346">PBUF_LINK</a>, len, <a class="code" href="pbuf_8h.html#b3c589840cc5a202e7278f41463f97e7e969347127387b9b59a23ccd24b76d21">PBUF_POOL</a>);
<a name="l00154"></a>00154 
<a name="l00155"></a>00155   <span class="keywordflow">if</span>(p != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00156"></a>00156     <span class="comment">/* We iterate over the pbuf chain until we have read the entire</span>
<a name="l00157"></a>00157 <span class="comment">       packet into the pbuf. */</span>
<a name="l00158"></a>00158     <span class="comment">//bufptr = &amp;buf[0];</span>
<a name="l00159"></a>00159     <span class="keywordflow">for</span>(q = p; q != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>; q = q-&gt;<a class="code" href="structpbuf.html#5e5763c94fd18d78937b0b58ce7df341">next</a>) {
<a name="l00160"></a>00160       <span class="comment">/* Read enough bytes to fill this pbuf in the chain. The</span>
<a name="l00161"></a>00161 <span class="comment">         avaliable data in the pbuf is given by the q-&gt;len</span>
<a name="l00162"></a>00162 <span class="comment">         variable. */</span>
<a name="l00163"></a>00163       <span class="comment">/* read data into(q-&gt;payload, q-&gt;len); */</span>
<a name="l00164"></a>00164       <a class="code" href="lib_8h.html#04bffce8d62dbb1e8e4e80a5fcdfed9a">bcopy</a>(bufptr, q-&gt;<a class="code" href="structpbuf.html#8d32dc3e964369d4eec638fc37fbc460">payload</a>, q-&gt;<a class="code" href="structpbuf.html#238f00a0024a32992599c9d1abf9bb44">len</a>);
<a name="l00165"></a>00165       buf = q-&gt;<a class="code" href="structpbuf.html#8d32dc3e964369d4eec638fc37fbc460">payload</a>;
<a name="l00166"></a>00166       bufptr += q-&gt;<a class="code" href="structpbuf.html#238f00a0024a32992599c9d1abf9bb44">len</a>;
<a name="l00167"></a>00167     }
<a name="l00168"></a>00168     <span class="comment">/* acknowledge that packet has been read(); */</span>
<a name="l00169"></a>00169   } <span class="keywordflow">else</span> {
<a name="l00170"></a>00170     <span class="comment">/* drop packet(); */</span>
<a name="l00171"></a>00171   }
<a name="l00172"></a>00172   <span class="keywordflow">return</span> p;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00177"></a>00177 <span class="comment">/*</span>
<a name="l00178"></a>00178 <span class="comment"> * ethernetif_output():</span>
<a name="l00179"></a>00179 <span class="comment"> *</span>
<a name="l00180"></a>00180 <span class="comment"> * This function is called by the TCP/IP stack when an IP packet</span>
<a name="l00181"></a>00181 <span class="comment"> * should be sent. It calls the function called low_level_output() to</span>
<a name="l00182"></a>00182 <span class="comment"> * do the actuall transmission of the packet.</span>
<a name="l00183"></a>00183 <span class="comment"> *</span>
<a name="l00184"></a>00184 <span class="comment"> */</span>
<a name="l00185"></a>00185 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00186"></a><a class="code" href="ethernetif_8c.html#eb49a49ab62789d8e32fddf180d52ebf">00186</a> <span class="keyword">static</span> <a class="code" href="err_8h.html#b7190f3da5c85931fc059e0312bc1407">err_t</a> <a class="code" href="ethernetif_8c.html#eb49a49ab62789d8e32fddf180d52ebf">ethernetif_output</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>, <span class="keyword">struct</span> <a class="code" href="structpbuf.html">pbuf</a> *p, <span class="keyword">struct</span> <a class="code" href="structip__addr.html">ip_addr</a> *ipaddr) {
<a name="l00187"></a>00187   <span class="keyword">struct </span><a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a>;
<a name="l00188"></a>00188   <span class="keyword">struct </span><a class="code" href="structpbuf.html">pbuf</a> *q;
<a name="l00189"></a>00189   <span class="keyword">struct </span><a class="code" href="structeth__hdr.html">eth_hdr</a> *ethhdr;
<a name="l00190"></a>00190   <span class="keyword">struct </span><a class="code" href="structeth__addr.html">eth_addr</a> *dest, mcastaddr;
<a name="l00191"></a>00191   <span class="keyword">struct </span><a class="code" href="structip__addr.html">ip_addr</a> *queryaddr;
<a name="l00192"></a>00192   <a class="code" href="err_8h.html#b7190f3da5c85931fc059e0312bc1407">err_t</a> err;
<a name="l00193"></a>00193   <a class="code" href="types_8h.html#a4e0f27a9aca905e340c06d2dcae843c">uInt8</a> i;
<a name="l00194"></a>00194   
<a name="l00195"></a>00195   ethernetif = netif-&gt;<a class="code" href="structnetif.html#809cc57c0dff09c5c9ae45b02c2002f3">state</a>;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 
<a name="l00198"></a>00198   <span class="comment">/* Make room for Ethernet header. */</span>
<a name="l00199"></a>00199   <span class="keywordflow">if</span>(<a class="code" href="pbuf_8h.html#c83243784ae907d307b4ac444282ccc5">pbuf_header</a>(p, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structeth__hdr.html">eth_hdr</a>)) != 0) {
<a name="l00200"></a>00200     <span class="comment">/* The pbuf_header() call shouldn't fail, but we allocate an extra</span>
<a name="l00201"></a>00201 <span class="comment">       pbuf just in case. */</span>
<a name="l00202"></a>00202     q = <a class="code" href="pbuf_8h.html#bb6c8efa7f7739e71cb286c6dd4a47ef">pbuf_alloc</a>(<a class="code" href="pbuf_8h.html#ee1baa59bb2f85ba575b5a8619ac1ebfb4de441e737330558b609a990cd17346">PBUF_LINK</a>, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> eth_hdr), <a class="code" href="pbuf_8h.html#b3c589840cc5a202e7278f41463f97e7c5e9f28455bca98944a030d4b84ecfab">PBUF_RAM</a>);
<a name="l00203"></a>00203     <span class="keywordflow">if</span>(q == <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00204"></a>00204       <span class="keywordflow">return</span> <a class="code" href="err_8h.html#6ab63185cc5dff3c50c61d99bdf98369">ERR_MEM</a>;
<a name="l00205"></a>00205     }
<a name="l00206"></a>00206     <a class="code" href="pbuf_8h.html#831c9a72bda1d3bd4c7b96f5a0e3b891">pbuf_chain</a>(q, p);
<a name="l00207"></a>00207     p = q;
<a name="l00208"></a>00208   }
<a name="l00209"></a>00209 
<a name="l00210"></a>00210   <span class="comment">/* Construct Ethernet header. Start with looking up deciding which</span>
<a name="l00211"></a>00211 <span class="comment">     MAC address to use as a destination address. Broadcasts and</span>
<a name="l00212"></a>00212 <span class="comment">     multicasts are special, all other addresses are looked up in the</span>
<a name="l00213"></a>00213 <span class="comment">     ARP table. */</span>
<a name="l00214"></a>00214   queryaddr = ipaddr;
<a name="l00215"></a>00215   <span class="keywordflow">if</span>(<a class="code" href="ipv4_2ip__addr_8h.html#0d51c2bb5f2af51392540af1c5df511a">ip_addr_isany</a>(ipaddr) ||
<a name="l00216"></a>00216      <a class="code" href="ipv4_2ip__addr_8h.html#ae42518ced1dbfbc55034642012055e9">ip_addr_isbroadcast</a>(ipaddr, &amp;(netif-&gt;<a class="code" href="structnetif.html#c4b9556c67758bde9a2b29f57f3e8cf2">netmask</a>))) {
<a name="l00217"></a>00217     dest = (<span class="keyword">struct </span><a class="code" href="structeth__addr.html">eth_addr</a> *)&amp;<a class="code" href="ethernetif_8c.html#6aac26114a085a1a287b32941ecd009e">ethbroadcast</a>;
<a name="l00218"></a>00218   } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="ipv4_2ip__addr_8h.html#312e629c950c8e0add5b5e5897334beb">ip_addr_ismulticast</a>(ipaddr)) {
<a name="l00219"></a>00219     <span class="comment">/* Hash IP multicast address to MAC address. */</span>
<a name="l00220"></a>00220     mcastaddr.addr[0] = 0x01;
<a name="l00221"></a>00221     mcastaddr.addr[1] = 0x0;
<a name="l00222"></a>00222     mcastaddr.addr[2] = 0x5e;
<a name="l00223"></a>00223     mcastaddr.addr[3] = <a class="code" href="ipv4_2ip__addr_8h.html#ee091caef24dd1705876bb8dbe28035c">ip4_addr2</a>(ipaddr) &amp; 0x7f;
<a name="l00224"></a>00224     mcastaddr.addr[4] = <a class="code" href="ipv4_2ip__addr_8h.html#ead691bee580ea8111b70e67cf971c40">ip4_addr3</a>(ipaddr);
<a name="l00225"></a>00225     mcastaddr.addr[5] = <a class="code" href="ipv4_2ip__addr_8h.html#78cbf5c1fd832f909f755c4cc9036f02">ip4_addr4</a>(ipaddr);
<a name="l00226"></a>00226     dest = &amp;mcastaddr;
<a name="l00227"></a>00227   } <span class="keywordflow">else</span> {
<a name="l00228"></a>00228     <span class="keywordflow">if</span>(<a class="code" href="ipv4_2ip__addr_8h.html#f656f30425e386d96d0e1a1b2dcb3952">ip_addr_maskcmp</a>(ipaddr, &amp;(netif-&gt;<a class="code" href="structnetif.html#d666097c02e7d7e82ea838b0c721470d">ip_addr</a>), &amp;(netif-&gt;<a class="code" href="structnetif.html#c4b9556c67758bde9a2b29f57f3e8cf2">netmask</a>))) {
<a name="l00229"></a>00229       <span class="comment">/* Use destination IP address if the destination is on the same</span>
<a name="l00230"></a>00230 <span class="comment">         subnet as we are. */</span>
<a name="l00231"></a>00231       queryaddr = ipaddr;
<a name="l00232"></a>00232     } <span class="keywordflow">else</span> {
<a name="l00233"></a>00233       <span class="comment">/* Otherwise we use the default router as the address to send</span>
<a name="l00234"></a>00234 <span class="comment">         the Ethernet frame to. */</span>
<a name="l00235"></a>00235       queryaddr = &amp;(netif-&gt;<a class="code" href="structnetif.html#abb83f0808c4b1bf23e5a16bc4e486a8">gw</a>);
<a name="l00236"></a>00236     }
<a name="l00237"></a>00237     dest = <a class="code" href="arp_8h.html#eec8fff4f036cca2ac1b5635fa46d21b">arp_lookup</a>(queryaddr);
<a name="l00238"></a>00238   }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 
<a name="l00241"></a>00241   <span class="comment">/* If the arp_lookup() didn't find an address, we send out an ARP</span>
<a name="l00242"></a>00242 <span class="comment">     query for the IP address. */</span>
<a name="l00243"></a>00243   <span class="keywordflow">if</span>(dest == <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00244"></a>00244     q = <a class="code" href="arp_8h.html#9d1287b9a80c370797b2ac5c63f70e2e">arp_query</a>(netif, ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>, queryaddr);
<a name="l00245"></a>00245     <span class="keywordflow">if</span>(q != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00246"></a>00246       err = <a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">low_level_output</a>(ethernetif, q);
<a name="l00247"></a>00247       <a class="code" href="pbuf_8h.html#334112aa2ac402c254d604c0dbbbb746">pbuf_free</a>(q);
<a name="l00248"></a>00248       <span class="keywordflow">return</span> err;
<a name="l00249"></a>00249     }
<a name="l00250"></a>00250     <span class="keywordflow">return</span> <a class="code" href="err_8h.html#6ab63185cc5dff3c50c61d99bdf98369">ERR_MEM</a>;
<a name="l00251"></a>00251   }
<a name="l00252"></a>00252   ethhdr = p-&gt;<a class="code" href="structpbuf.html#8d32dc3e964369d4eec638fc37fbc460">payload</a>;
<a name="l00253"></a>00253 
<a name="l00254"></a>00254   <span class="keywordflow">for</span>(i = 0; i &lt; 6; i++) {
<a name="l00255"></a>00255     ethhdr-&gt;dest.addr[i] = dest-&gt;addr[i];
<a name="l00256"></a>00256     ethhdr-&gt;src.addr[i] = ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>-&gt;addr[i];
<a name="l00257"></a>00257   }
<a name="l00258"></a>00258   
<a name="l00259"></a>00259   ethhdr-&gt;type = <a class="code" href="ipv4_2inet_8h.html#b7fffd06ef1d1a7d34f99eedbb9f44dd">htons</a>(<a class="code" href="arp_8h.html#392234c1299a5f5c264e511d88a66e56">ETHTYPE_IP</a>);
<a name="l00260"></a>00260   
<a name="l00261"></a>00261   <span class="keywordflow">return</span> <a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">low_level_output</a>(ethernetif, p);
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00265"></a>00265 <span class="comment">/*</span>
<a name="l00266"></a>00266 <span class="comment"> * ethernetif_input():</span>
<a name="l00267"></a>00267 <span class="comment"> *</span>
<a name="l00268"></a>00268 <span class="comment"> * This function should be called when a packet is ready to be read</span>
<a name="l00269"></a>00269 <span class="comment"> * from the interface. It uses the function low_level_input() that</span>
<a name="l00270"></a>00270 <span class="comment"> * should handle the actual reception of bytes from the network</span>
<a name="l00271"></a>00271 <span class="comment"> * interface.</span>
<a name="l00272"></a>00272 <span class="comment"> *</span>
<a name="l00273"></a>00273 <span class="comment"> */</span>
<a name="l00274"></a>00274 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00275"></a><a class="code" href="ethernetif_8c.html#687c1030eeb3939b9aa8e1a0811c301a">00275</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="ethernetif_8c.html#687c1030eeb3939b9aa8e1a0811c301a">ethernetif_input</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>) {
<a name="l00276"></a>00276   <span class="keyword">struct </span><a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a> = 0x0;
<a name="l00277"></a>00277   <span class="keyword">struct </span><a class="code" href="structeth__hdr.html">eth_hdr</a> *ethhdr = 0x0;
<a name="l00278"></a>00278   <span class="keyword">struct </span><a class="code" href="structpbuf.html">pbuf</a> *p = 0x0;
<a name="l00279"></a>00279 
<a name="l00280"></a>00280   ethernetif = netif-&gt;<a class="code" href="structnetif.html#809cc57c0dff09c5c9ae45b02c2002f3">state</a>;
<a name="l00281"></a>00281  
<a name="l00282"></a>00282   p = <a class="code" href="ethernetif_8c.html#70bd3f580cdc400e75161e9751944836">low_level_input</a>(ethernetif);
<a name="l00283"></a>00283 
<a name="l00284"></a>00284   <span class="keywordflow">if</span>(p != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00285"></a>00285 
<a name="l00286"></a>00286     ethhdr = p-&gt;<a class="code" href="structpbuf.html#8d32dc3e964369d4eec638fc37fbc460">payload</a>;
<a name="l00287"></a>00287     
<a name="l00288"></a>00288     <span class="keywordflow">switch</span>(<a class="code" href="ipv4_2inet_8h.html#b7fffd06ef1d1a7d34f99eedbb9f44dd">htons</a>(ethhdr-&gt;type)) {
<a name="l00289"></a>00289     <span class="keywordflow">case</span> <a class="code" href="arp_8h.html#392234c1299a5f5c264e511d88a66e56">ETHTYPE_IP</a>:
<a name="l00290"></a>00290       <a class="code" href="arp_8h.html#916d08dbb8f4a38e1e904a8a018b000c">arp_ip_input</a>(netif, p);
<a name="l00291"></a>00291       <a class="code" href="pbuf_8h.html#c83243784ae907d307b4ac444282ccc5">pbuf_header</a>(p, -14);
<a name="l00292"></a>00292       netif-&gt;<a class="code" href="structnetif.html#6a3101eb624d17937618618a57e2e570">input</a>(p, netif);
<a name="l00293"></a>00293       <span class="keywordflow">break</span>;
<a name="l00294"></a>00294     <span class="keywordflow">case</span> <a class="code" href="arp_8h.html#dbc208bed02b2900ca2639a25d3f6198">ETHTYPE_ARP</a>:
<a name="l00295"></a>00295       p = <a class="code" href="arp_8h.html#57a25dd51cf73f048ad5364ecc2f040b">arp_arp_input</a>(netif, ethernetif-&gt;<a class="code" href="structethernetif.html#8f3049366ffe182fd1d4e0e2ce4542d7">ethaddr</a>, p);
<a name="l00296"></a>00296       <span class="keywordflow">if</span>(p != <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00297"></a>00297         <a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">low_level_output</a>(ethernetif, p);
<a name="l00298"></a>00298         <a class="code" href="pbuf_8h.html#334112aa2ac402c254d604c0dbbbb746">pbuf_free</a>(p);
<a name="l00299"></a>00299       }
<a name="l00300"></a>00300       <span class="keywordflow">break</span>;
<a name="l00301"></a>00301     <span class="keywordflow">default</span>:
<a name="l00302"></a>00302       <a class="code" href="pbuf_8h.html#334112aa2ac402c254d604c0dbbbb746">pbuf_free</a>(p);
<a name="l00303"></a>00303       <span class="keywordflow">break</span>;
<a name="l00304"></a>00304     }
<a name="l00305"></a>00305   }
<a name="l00306"></a>00306 }
<a name="l00307"></a>00307 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00308"></a>00308 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00309"></a><a class="code" href="ethernetif_8c.html#c94d6bae5aaeab8f812a6809ba4a6367">00309</a> <a class="code" href="ethernetif_8c.html#c94d6bae5aaeab8f812a6809ba4a6367">arp_timer</a>(<span class="keywordtype">void</span> *arg)
<a name="l00310"></a>00310 {
<a name="l00311"></a>00311   <a class="code" href="arp_8h.html#2cc298ed4c68289160da1376faf20938">arp_tmr</a>();
<a name="l00312"></a>00312   <a class="code" href="sys_8h.html#eb917c25d96a51e1998478b9e6e78a44">sys_timeout</a>(<a class="code" href="arp_8h.html#aa3d8ed1eb1129f518345e37b38cfc37">ARP_TMR_INTERVAL</a>, (<a class="code" href="sys_8h.html#1aa9ee90811cc556b2011559ae4154a8">sys_timeout_handler</a>)<a class="code" href="ethernetif_8c.html#c94d6bae5aaeab8f812a6809ba4a6367">arp_timer</a>, <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00313"></a>00313 }
<a name="l00314"></a>00314 
<a name="l00315"></a>00315 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00316"></a>00316 <span class="comment">/*</span>
<a name="l00317"></a>00317 <span class="comment"> * ethernetif_init():</span>
<a name="l00318"></a>00318 <span class="comment"> *</span>
<a name="l00319"></a>00319 <span class="comment"> * Should be called at the beginning of the program to set up the</span>
<a name="l00320"></a>00320 <span class="comment"> * network interface. It calls the function low_level_init() to do the</span>
<a name="l00321"></a>00321 <span class="comment"> * actual setup of the hardware.</span>
<a name="l00322"></a>00322 <span class="comment"> *</span>
<a name="l00323"></a>00323 <span class="comment"> */</span>
<a name="l00324"></a>00324 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00325"></a><a class="code" href="ethernetif_8c.html#64753cb7324510825069062660f10926">00325</a> <span class="keywordtype">void</span> <a class="code" href="ethernetif_8h.html#64753cb7324510825069062660f10926">ethernetif_init</a>(<span class="keyword">struct</span> <a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a>) {
<a name="l00326"></a>00326   <span class="keyword">struct </span><a class="code" href="structethernetif.html">ethernetif</a> *<a class="code" href="structethernetif.html">ethernetif</a>;
<a name="l00327"></a>00327     
<a name="l00328"></a>00328   ethernetif = <a class="code" href="mem_8h.html#932aa40d85b14cb7331625e012d12335">mem_malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> ethernetif));
<a name="l00329"></a>00329   netif-&gt;<a class="code" href="structnetif.html#809cc57c0dff09c5c9ae45b02c2002f3">state</a> = ethernetif;
<a name="l00330"></a>00330   netif-&gt;<a class="code" href="structnetif.html#32fca6ffd28bb9af3f891a378827a67e">name</a>[0] = <a class="code" href="ethernetif_8c.html#cd9e3df20507d5f895e80477aef74555">IFNAME0</a>;
<a name="l00331"></a>00331   netif-&gt;<a class="code" href="structnetif.html#32fca6ffd28bb9af3f891a378827a67e">name</a>[1] = <a class="code" href="ethernetif_8c.html#43b130296861cb255f1ad5b8c3787fd1">IFNAME1</a>;
<a name="l00332"></a>00332   netif-&gt;<a class="code" href="structnetif.html#b180ab98b90830ed15503822405e5a23">output</a> = <a class="code" href="ethernetif_8c.html#eb49a49ab62789d8e32fddf180d52ebf">ethernetif_output</a>;
<a name="l00333"></a>00333   netif-&gt;<a class="code" href="structnetif.html#bf9e416b29a3de59c78b141b8eed37cc">linkoutput</a> = (<span class="keywordtype">void</span> *)<a class="code" href="ethernetif_8c.html#a15293088795817d91d7ecdcfbcb7799">low_level_output</a>;
<a name="l00334"></a>00334   
<a name="l00335"></a>00335   ethernetif-&gt;ethaddr = (<span class="keyword">struct </span><a class="code" href="structeth__addr.html">eth_addr</a> *)&amp;(netif-&gt;<a class="code" href="structnetif.html#18e73df74457dd1cb02d61d24e3ba924">hwaddr</a>[0]);
<a name="l00336"></a>00336   
<a name="l00337"></a>00337   <a class="code" href="ethernetif_8c.html#15915c49a70d85ff1c6af793cda34419">low_level_init</a>(netif);
<a name="l00338"></a>00338   <a class="code" href="arp_8h.html#c8ad5a32790d172fcec2eac97a87ee9f">arp_init</a>();
<a name="l00339"></a>00339 
<a name="l00340"></a>00340   <a class="code" href="sys_8h.html#eb917c25d96a51e1998478b9e6e78a44">sys_timeout</a>(<a class="code" href="arp_8h.html#aa3d8ed1eb1129f518345e37b38cfc37">ARP_TMR_INTERVAL</a>, (<a class="code" href="sys_8h.html#1aa9ee90811cc556b2011559ae4154a8">sys_timeout_handler</a>)<a class="code" href="ethernetif_8c.html#c94d6bae5aaeab8f812a6809ba4a6367">arp_timer</a>, <a class="code" href="def_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00341"></a>00341   }
<a name="l00342"></a>00342 
<a name="l00343"></a>00343 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00344"></a>00344 
<a name="l00345"></a><a class="code" href="ethernetif_8c.html#877b1f0a593d5d3c6e1d10624ee7a0fb">00345</a> <span class="keywordtype">void</span> <a class="code" href="ethernetif_8c.html#e1cb890e22f516c0106d5c6c8e07ab74">ethernetif_thread</a>(<span class="keywordtype">void</span> *arg) {
<a name="l00346"></a>00346   <span class="keyword">struct </span><a class="code" href="structnetif.html">netif</a> *<a class="code" href="structnetif.html">netif</a> = 0x0;
<a name="l00347"></a>00347  
<a name="l00348"></a>00348   netif = arg;
<a name="l00349"></a>00349   
<a name="l00350"></a>00350   <span class="keywordflow">while</span> (1) {
<a name="l00351"></a>00351     <a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a> = <a class="code" href="ne2k_8h.html#954f14d0270247855900254097728c57">ne2kGetBuffer</a>();
<a name="l00352"></a>00352     <span class="keywordflow">if</span> (<a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a> &amp;&amp; <a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a>-&gt;<a class="code" href="structnicBuffer.html#959ee09a7a6fc875f3d5d651576f37c4">length</a> &gt; 0x0) {
<a name="l00353"></a>00353       <a class="code" href="ethernetif_8c.html#687c1030eeb3939b9aa8e1a0811c301a">ethernetif_input</a>(netif);  
<a name="l00354"></a>00354       }
<a name="l00355"></a>00355     }
<a name="l00356"></a>00356   <a class="code" href="ne2k_8h.html#64fadb818ec0d7f27ef04cbceac2a828">ne2kFreeBuffer</a>(<a class="code" href="ethernetif_8c.html#4a11421d92a3c6d8d9fae9db3bb9f299">tmpBuf</a>);
<a name="l00357"></a>00357   }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Dec 12 08:52:07 2006 for UbixOS V2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>