?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{FILE START}

library

?curdirlinks? - Rev 6

?prevdifflink? - Blame - ?getfile?

<!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>Procyon AVRlib: net/arp.h Source File</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000001.html">net</a></div>
<h1>arp.h</h1><a href="arp_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file arp.h \brief ARP Protocol Library. */</span>
00002 <span class="comment">//*****************************************************************************</span>
00003 <span class="comment">//</span>
00004 <span class="comment">// File Name    : 'arp.h'</span>
00005 <span class="comment">// Title        : ARP Protocol Library</span>
00006 <span class="comment">// Author       : Pascal Stang</span>
00007 <span class="comment">// Created      : 9/7/2004</span>
00008 <span class="comment">// Revised      : 7/3/2005</span>
00009 <span class="comment">// Version      : 0.1</span>
00010 <span class="comment">// Target MCU   : Atmel AVR series</span>
00011 <span class="comment">// Editor Tabs  : 4</span>
00012 <span class="comment">//</span><span class="comment"></span>
00013 <span class="comment">/// \ingroup network</span>
00014 <span class="comment">/// \defgroup arp ARP Protocol Library (arp.c)</span>
00015 <span class="comment">/// \code #include "net/arp.h" \endcode</span>
00016 <span class="comment">/// \par Description</span>
00017 <span class="comment">///     To send anything over ethernet (or most any other physical network)</span>
00018 <span class="comment">///     a packet must be addressed to a physical network node address, often</span>
00019 <span class="comment">///     called a MAC/hardware/ethernet address.  This MAC address identifies</span>
00020 <span class="comment">///     a specific interface (like the ethernet card in your computer) on the</span>
00021 <span class="comment">///     network.</span>
00022 <span class="comment">///         ARP (Address Resolution Protocol) assists in mapping IP addresses to </span>
00023 <span class="comment">///     the MAC addresses required to actually get data to its destination.</span>
00024 <span class="comment">///     In other words, an IP address is not enough to send information over</span>
00025 <span class="comment">///     ethernet.  You need the MAC address of the network interface/card that</span>
00026 <span class="comment">///     "owns" that IP address.  ARP maintains a table mapping IP addresses to</span>
00027 <span class="comment">///     MAC addresses.  This table can be filled by both listening to</span>
00028 <span class="comment">///     traffic on the network, as well as making specific ARP requests if</span>
00029 <span class="comment">///     an IP&lt;-&gt;MAC mapping is not in the table.</span>
00030 <span class="comment">///     </span>
00031 <span class="comment">/// \note This code is currently below version 1.0, and therefore is considered</span>
00032 <span class="comment">/// to be lacking in some functionality or documentation, or may not be fully</span>
00033 <span class="comment">/// tested.  Nonetheless, you can expect most functions to work.</span>
00034 <span class="comment">///</span>
00035 <span class="comment"></span><span class="comment">//  This code is distributed under the GNU Public License</span>
00036 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>
00037 <span class="comment">//*****************************************************************************</span><span class="comment"></span>
00038 <span class="comment">//@{</span>
00039 <span class="comment"></span>
00040 <span class="preprocessor">#ifndef ARP_H</span>
00041 <span class="preprocessor"></span><span class="preprocessor">#define ARP_H</span>
00042 <span class="preprocessor"></span>
00043 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
00044 <span class="preprocessor">#include "<a class="code" href="net_8h.html">net.h</a>"</span>
00045 
00046 <span class="preprocessor">#ifndef ARP_TABLE_SIZE</span>
00047 <span class="preprocessor"></span><span class="preprocessor">#define ARP_TABLE_SIZE  8</span>
00048 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00049 <span class="preprocessor"></span>
00050 <span class="preprocessor">#ifndef ARP_CACHE_TIME_TO_LIVE</span>
00051 <span class="preprocessor"></span><span class="preprocessor">#define ARP_CACHE_TIME_TO_LIVE  100</span>
00052 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00053 <span class="preprocessor"></span>
00054 <span class="comment">//#define ARP_DEBUG_PRINT</span>
00055 
00056 <span class="comment"></span>
00057 <span class="comment">/*! Initialize ARP system.</span>
00058 <span class="comment">    Clears ARP table and prepares it for use. This is typically done</span>
00059 <span class="comment">    once at program initialization. */</span>
00060 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga0">arpInit</a>(<span class="keywordtype">void</span>);
00061 <span class="comment"></span>
00062 <span class="comment">/*! Set IP and Ethernet hardware/MAC address.</span>
00063 <span class="comment">    This must be done before valid replies can be generated for ARP</span>
00064 <span class="comment">    requests. Typically done once at program initialization. */</span>
00065 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga1">arpSetAddress</a>(<span class="keyword">struct</span> netEthAddr* myeth, uint32_t myip);
00066 <span class="comment"></span>
00067 <span class="comment">/*! Processes incoming ARP packets.</span>
00068 <span class="comment">    This function is to be called when an ARP type packet has arrived</span>
00069 <span class="comment">    over the network.  If the packet type is an ARP request for us,</span>
00070 <span class="comment">    an ARP reply will be generated and sent. */</span>
00071 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga2">arpArpIn</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, <span class="keyword">struct</span> netEthArpHeader* packet);
00072 <span class="comment"></span>
00073 <span class="comment">/*! Process incoming IP packets to harvest IP&lt;-&gt;MAC relationships.</span>
00074 <span class="comment">    This function should be called when IP packets are received over the</span>
00075 <span class="comment">    network.  It does nothing more than harvest the IP&lt;-&gt;MAC address</span>
00076 <span class="comment">    relationships from the ethernet and IP header of the packet.  The</span>
00077 <span class="comment">    packet is not changed nor processed.  Nothing is sent on the network.</span>
00078 <span class="comment">    Use of this command is not required, but it is a good way to</span>
00079 <span class="comment">    automatically fill the ARP table with information about nodes that are</span>
00080 <span class="comment">    active on the network.</span>
00081 <span class="comment">    </span>
00082 <span class="comment">    \warning On very busy or heavily populated netorks, this can quickly</span>
00083 <span class="comment">    fill the ARP table with unnecessary entries, and/or cause some CPU load.</span>
00084 <span class="comment">*/</span>
00085 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga3">arpIpIn</a>(<span class="keyword">struct</span> netEthIpHeader* packet);
00086 <span class="comment"></span>
00087 <span class="comment">/*! Process outgoing IP packet to fill in ethernet header information.</span>
00088 <span class="comment">    To be sent on a network, an IP packet must have the correct ethernet</span>
00089 <span class="comment">    header information appended to the front.  This function will fill</span>
00090 <span class="comment">    in this information.</span>
00091 <span class="comment">    </span>
00092 <span class="comment">    A physical destination IP address argument is needed to support</span>
00093 <span class="comment">    sending to a gateway (i.e. when a packet is destined for a node that</span>
00094 <span class="comment">    is not on this network, IP addressing is as usual, but we phyiscally</span>
00095 <span class="comment">    send the packet to the gateway's ethernet address/interface).</span>
00096 <span class="comment">  </span>
00097 <span class="comment">    \warning Technically, if an IP&lt;-&gt;MAC address mapping is not in the</span>
00098 <span class="comment">    ARP table, then the IP packet should be held while an ARP request is</span>
00099 <span class="comment">    made, and the reply received.  However, in single-threaded ram-limited</span>
00100 <span class="comment">    embedded systems, such a holdup is unacceptable.  This function instead</span>
00101 <span class="comment">    sends the packet as an ethernet broadcast if a mapping cannot be found.</span>
00102 <span class="comment"></span>
00103 <span class="comment">    \todo Send the packet broadcast AND send an ARP request, if a mapping</span>
00104 <span class="comment">    is not found.</span>
00105 <span class="comment">*/</span>
00106 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga4">arpIpOut</a>(<span class="keyword">struct</span> netEthIpHeader* packet, uint32_t phyDstIp);
00107 <span class="comment"></span>
00108 <span class="comment">/*! Periodic ARP cache maintenance.</span>
00109 <span class="comment">    This function is to be called once per second and will slowly </span>
00110 <span class="comment">    expire old ARP cache entries. */</span>
00111 <span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga5">arpTimer</a>(<span class="keywordtype">void</span>);
00112 
00113 <span class="comment"></span>
00114 <span class="comment">/*! Check if this IP address is present in the ARP cache. Internal function.</span>
00115 <span class="comment">    If IP address is found, function returns index of entry.  If not found,</span>
00116 <span class="comment">    returns -1. */</span>
00117 <span class="keywordtype">int</span> <a class="code" href="group__arp.html#ga6">arpMatchIp</a>(uint32_t ipaddr);
00118 <span class="comment"></span>
00119 <span class="comment">//! Print diagnotic information about ARP packet.</span>
00120 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga7">arpPrintHeader</a>(<span class="keyword">struct</span> netArpHeader* packet);<span class="comment"></span>
00121 <span class="comment">//! Print diagnotic information about ARP cache.</span>
00122 <span class="comment"></span><span class="keywordtype">void</span> <a class="code" href="group__arp.html#ga8">arpPrintTable</a>(<span class="keywordtype">void</span>);
00123 
00124 <span class="preprocessor">#endif</span>
00125 <span class="preprocessor"></span><span class="comment">//@}</span>
</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
{FILE END}
{FOOTER START}

Powered by WebSVN v2.8.3