<!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: ARP Protocol Library (arp.c)</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 Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>ARP Protocol Library (arp.c)<br>
<small>
[<a class="el" href="group__network.html">Network Library</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #include "<a class="code" href="arp_8h.html">net/arp.h</a>"</span>
</pre></div> <dl compact><dt><b>Description</b></dt><dd>To send anything over ethernet (or most any other physical network) a packet must be addressed to a physical network node address, often called a MAC/hardware/ethernet address. This MAC address identifies a specific interface (like the ethernet card in your computer) on the network. ARP (Address Resolution Protocol) assists in mapping IP addresses to the MAC addresses required to actually get data to its destination. In other words, an IP address is not enough to send information over ethernet. You need the MAC address of the network interface/card that "owns" that IP address. ARP maintains a table mapping IP addresses to MAC addresses. This table can be filled by both listening to traffic on the network, as well as making specific ARP requests if an IP<->MAC mapping is not in the table.</dd></dl>
<dl compact><dt><b>Note:</b></dt><dd>This code is currently below version 1.0, and therefore is considered to be lacking in some functionality or documentation, or may not be fully tested. Nonetheless, you can expect most functions to work. </dd></dl>
<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"><a class="anchor" name="ga9" doxytag="arp::ARP_TABLE_SIZE"></a>
#define </td><td class="memItemRight" valign="bottom"><b>ARP_TABLE_SIZE</b> 8</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga10" doxytag="arp::ARP_CACHE_TIME_TO_LIVE"></a>
#define </td><td class="memItemRight" valign="bottom"><b>ARP_CACHE_TIME_TO_LIVE</b> 100</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga0">arpInit</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga1">arpSetAddress</a> (struct netEthAddr *myeth, uint32_t myip)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga2">arpArpIn</a> (unsigned int len, struct netEthArpHeader *packet)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga3">arpIpIn</a> (struct netEthIpHeader *packet)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga4">arpIpOut</a> (struct netEthIpHeader *packet, uint32_t phyDstIp)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga5">arpTimer</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga6">arpMatchIp</a> (uint32_t ipaddr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga7" doxytag="arp::arpPrintHeader"></a>
void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga7">arpPrintHeader</a> (struct netArpHeader *packet)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Print diagnotic information about ARP packet. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga8" doxytag="arp::arpPrintTable"></a>
void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__arp.html#ga8">arpPrintTable</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Print diagnotic information about ARP cache. <br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ga2" doxytag="arp.h::arpArpIn"></a><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">void arpArpIn </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">unsigned int </td>
<td class="mdname" nowrap> <em>len</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>struct netEthArpHeader * </td>
<td class="mdname" nowrap> <em>packet</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Processes incoming ARP packets. This function is to be called when an ARP type packet has arrived over the network. If the packet type is an ARP request for us, an ARP reply will be generated and sent.
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00054">54</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga0" doxytag="arp.h::arpInit"></a><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">void arpInit </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </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>
Initialize ARP system. Clears ARP table and prepares it for use. This is typically done once at program initialization.
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00036">36</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga3" doxytag="arp.h::arpIpIn"></a><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">void arpIpIn </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">struct netEthIpHeader * </td>
<td class="mdname1" valign="top" nowrap> <em>packet</em> </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 incoming IP packets to harvest IP<->MAC relationships. This function should be called when IP packets are received over the network. It does nothing more than harvest the IP<->MAC address relationships from the ethernet and IP header of the packet. The packet is not changed nor processed. Nothing is sent on the network. Use of this command is not required, but it is a good way to automatically fill the ARP table with information about nodes that are active on the network.<p>
<dl compact><dt><b>Warning:</b></dt><dd>On very busy or heavily populated netorks, this can quickly fill the ARP table with unnecessary entries, and/or cause some CPU load. </dd></dl>
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00090">90</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga4" doxytag="arp.h::arpIpOut"></a><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">void arpIpOut </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">struct netEthIpHeader * </td>
<td class="mdname" nowrap> <em>packet</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>uint32_t </td>
<td class="mdname" nowrap> <em>phyDstIp</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Process outgoing IP packet to fill in ethernet header information. To be sent on a network, an IP packet must have the correct ethernet header information appended to the front. This function will fill in this information.<p>
A physical destination IP address argument is needed to support sending to a gateway (i.e. when a packet is destined for a node that is not on this network, IP addressing is as usual, but we phyiscally send the packet to the gateway's ethernet address/interface).<p>
<dl compact><dt><b>Warning:</b></dt><dd>Technically, if an IP<->MAC address mapping is not in the ARP table, then the IP packet should be held while an ARP request is made, and the reply received. However, in single-threaded ram-limited embedded systems, such a holdup is unacceptable. This function instead sends the packet as an ethernet broadcast if a mapping cannot be found.</dd></dl>
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00122">122</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga6" doxytag="arp.h::arpMatchIp"></a><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">int arpMatchIp </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">uint32_t </td>
<td class="mdname1" valign="top" nowrap> <em>ipaddr</em> </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>
Check if this IP address is present in the ARP cache. Internal function. If IP address is found, function returns index of entry. If not found, returns -1.
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00167">167</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga1" doxytag="arp.h::arpSetAddress"></a><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">void arpSetAddress </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">struct netEthAddr * </td>
<td class="mdname" nowrap> <em>myeth</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>uint32_t </td>
<td class="mdname" nowrap> <em>myip</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Set IP and Ethernet hardware/MAC address. This must be done before valid replies can be generated for ARP requests. Typically done once at program initialization.
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00047">47</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<a class="anchor" name="ga5" doxytag="arp.h::arpTimer"></a><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">void arpTimer </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </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 ARP cache maintenance. This function is to be called once per second and will slowly expire old ARP cache entries.
<p>
Definition at line <a class="el" href="arp_8c-source.html#l00154">154</a> of file <a class="el" href="arp_8c-source.html">arp.c</a>. </td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:09 2006 for Procyon AVRlib by
<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>
|