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

206 lines
15 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: uIP Address Resolution Protocol</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>uIP Address Resolution Protocol<br>
<small>
[<a class="el" href="a00150.html">The uIP TCP/IP stack</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
The Address Resolution Protocol ARP is used for mapping between IP addresses and link level addresses such as the Ethernet MAC addresses.
<p>
ARP uses broadcast queries to ask for the link level address of a known IP address and the host which is configured with the IP address for which the query was meant, will respond with its link level address.<p>
<dl compact><dt><b>Note:</b></dt><dd>This ARP implementation only supports Ethernet. </dd></dl>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Files</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00139.html">uip_arp.h</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Macros and definitions for the ARP module. <br></td></tr>
<p>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00138.html">uip_arp.c</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Implementation of the ARP Address Resolution Protocol. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00090.html">uip_eth_hdr</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The Ethernet header. <a href="a00090.html#_details">More...</a><br></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="g3e1562e8a6de32268e5df92a52152f91"></a><!-- doxytag: member="uiparp::UIP_ETHTYPE_ARP" ref="g3e1562e8a6de32268e5df92a52152f91" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g3e1562e8a6de32268e5df92a52152f91">UIP_ETHTYPE_ARP</a>&nbsp;&nbsp;&nbsp;0x0806</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g03d140db75de3d3cdfbbab1c4fed8d8d"></a><!-- doxytag: member="uiparp::UIP_ETHTYPE_IP" ref="g03d140db75de3d3cdfbbab1c4fed8d8d" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g03d140db75de3d3cdfbbab1c4fed8d8d">UIP_ETHTYPE_IP</a>&nbsp;&nbsp;&nbsp;0x0800</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gbb558f3a9b1ec015e83c314aba694e35"></a><!-- doxytag: member="uiparp::UIP_ETHTYPE_IP6" ref="gbb558f3a9b1ec015e83c314aba694e35" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#gbb558f3a9b1ec015e83c314aba694e35">UIP_ETHTYPE_IP6</a>&nbsp;&nbsp;&nbsp;0x86dd</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g737337d6a51e31b236c8233d024138a8"></a><!-- doxytag: member="uiparp::uip_arp_ipin" ref="g737337d6a51e31b236c8233d024138a8" args="()" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g737337d6a51e31b236c8233d024138a8">uip_arp_ipin</a>()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g7a7c46ffaba30477b8c9e3e61bd2e106"></a><!-- doxytag: member="uiparp::ARP_REQUEST" ref="g7a7c46ffaba30477b8c9e3e61bd2e106" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g7a7c46ffaba30477b8c9e3e61bd2e106">ARP_REQUEST</a>&nbsp;&nbsp;&nbsp;1</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g06ba7b414e718081998f2814090debf1"></a><!-- doxytag: member="uiparp::ARP_REPLY" ref="g06ba7b414e718081998f2814090debf1" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g06ba7b414e718081998f2814090debf1">ARP_REPLY</a>&nbsp;&nbsp;&nbsp;2</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gbb56b549f7ab4d86e1cc39b8afc70d1e"></a><!-- doxytag: member="uiparp::ARP_HWTYPE_ETH" ref="gbb56b549f7ab4d86e1cc39b8afc70d1e" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#gbb56b549f7ab4d86e1cc39b8afc70d1e">ARP_HWTYPE_ETH</a>&nbsp;&nbsp;&nbsp;1</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g24f52ac52d6e714cb04a5aa01be3bdd0"></a><!-- doxytag: member="uiparp::BUF" ref="g24f52ac52d6e714cb04a5aa01be3bdd0" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g24f52ac52d6e714cb04a5aa01be3bdd0">BUF</a>&nbsp;&nbsp;&nbsp;((struct arp_hdr *)&amp;<a class="el" href="a00150.html#gb81e78f890dbbee50c533a9734b74fd9">uip_buf</a>[0])</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g9f2196e2705036869611962425e404bf"></a><!-- doxytag: member="uiparp::IPBUF" ref="g9f2196e2705036869611962425e404bf" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g9f2196e2705036869611962425e404bf">IPBUF</a>&nbsp;&nbsp;&nbsp;((struct ethip_hdr *)&amp;<a class="el" href="a00150.html#gb81e78f890dbbee50c533a9734b74fd9">uip_buf</a>[0])</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g2d9d28afa353f662b9bb5234fc419f72"></a><!-- doxytag: member="uiparp::uip_arp_init" ref="g2d9d28afa353f662b9bb5234fc419f72" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g2d9d28afa353f662b9bb5234fc419f72">uip_arp_init</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize the ARP module. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g902c4a360134096224bc2655f623aa5f">uip_arp_arpin</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">ARP processing for incoming ARP packets. <a href="#g902c4a360134096224bc2655f623aa5f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Prepend Ethernet header to an outbound IP packet and see if we need to send out an ARP request. <a href="#g54b27e45df15e10a0eb1a3e3a91417d2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g058a8e6025f67b021862281f1911fcef">uip_arp_timer</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Periodic ARP processing function. <a href="#g058a8e6025f67b021862281f1911fcef"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g499bb98a0b4ae9a98553ede81317606d"></a><!-- doxytag: member="uiparp::uip_ethaddr" ref="g499bb98a0b4ae9a98553ede81317606d" args="" -->
<a class="el" href="a00089.html">uip_eth_addr</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00152.html#g499bb98a0b4ae9a98553ede81317606d">uip_ethaddr</a></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g902c4a360134096224bc2655f623aa5f"></a><!-- doxytag: member="uip_arp.h::uip_arp_arpin" ref="g902c4a360134096224bc2655f623aa5f" args="(void)" --><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 uip_arp_arpin </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">void&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
ARP processing for incoming ARP packets.
<p>
This function should be called by the device driver when an ARP packet has been received. The function will act differently depending on the ARP packet type: if it is a reply for a request that we previously sent out, the ARP cache will be filled in with the values from the ARP reply. If the incoming ARP packet is an ARP request for our IP address, an ARP reply packet is created and put into the uip_buf[] buffer.<p>
When the function returns, the value of the global variable uip_len indicates whether the device driver should send out a packet or not. If uip_len is zero, no packet should be sent. If uip_len is non-zero, it contains the length of the outbound packet that is present in the uip_buf[] buffer.<p>
This function expects an ARP packet with a prepended Ethernet header in the uip_buf[] buffer, and the length of the packet in the global variable uip_len. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00042.html#a76">example-mainloop-with-arp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00204.html#l00278">278</a> of file <a class="el" href="a00204.html">uip_arp.c</a>.
<p>
References <a class="el" href="a00202.html#l01543">uip_eth_addr::addr</a>, <a class="el" href="a00204.html#l00095">ARP_REPLY</a>, <a class="el" href="a00204.html#l00094">ARP_REQUEST</a>, <a class="el" href="a00201.html#l00226">BUF</a>, <a class="el" href="a00202.html#l01070">HTONS</a>, <a class="el" href="a00201.html#l00135">uip_ethaddr</a>, <a class="el" href="a00205.html#l00069">UIP_ETHTYPE_ARP</a>, <a class="el" href="a00201.html#l00110">uip_hostaddr</a>, <a class="el" href="a00202.html#l00911">uip_ipaddr_cmp</a>, and <a class="el" href="a00201.html#l00155">uip_len</a>. </td>
</tr>
</table>
<a class="anchor" name="g54b27e45df15e10a0eb1a3e3a91417d2"></a><!-- doxytag: member="uip_arp.h::uip_arp_out" ref="g54b27e45df15e10a0eb1a3e3a91417d2" args="(void)" --><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 uip_arp_out </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">void&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Prepend Ethernet header to an outbound IP packet and see if we need to send out an ARP request.
<p>
This function should be called before sending out an IP packet. The function checks the destination IP address of the IP packet to see what Ethernet MAC address that should be used as a destination MAC address on the Ethernet.<p>
If the destination IP address is in the local network (determined by logical ANDing of netmask and our IP address), the function checks the ARP cache to see if an entry for the destination IP address is found. If so, an Ethernet header is prepended and the function returns. If no ARP cache entry is found for the destination IP address, the packet in the uip_buf[] is replaced by an ARP request packet for the IP address. The IP packet is dropped and it is assumed that they higher level protocols (e.g., TCP) eventually will retransmit the dropped packet.<p>
If the destination IP address is not on the local network, the IP address of the default router is used instead.<p>
When the function returns, a packet is present in the uip_buf[] buffer, and the length of the packet is in the global variable uip_len. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00042.html#a74">example-mainloop-with-arp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00204.html#l00354">354</a> of file <a class="el" href="a00204.html">uip_arp.c</a>.
<p>
References <a class="el" href="a00202.html#l01543">uip_eth_addr::addr</a>, <a class="el" href="a00204.html#l00117">IPBUF</a>, <a class="el" href="a00206.html#l00349">UIP_ARPTAB_SIZE</a>, <a class="el" href="a00201.html#l00110">uip_draddr</a>, <a class="el" href="a00201.html#l00110">uip_hostaddr</a>, <a class="el" href="a00202.html#l00911">uip_ipaddr_cmp</a>, <a class="el" href="a00202.html#l00882">uip_ipaddr_copy</a>, and <a class="el" href="a00202.html#l00941">uip_ipaddr_maskcmp</a>. </td>
</tr>
</table>
<a class="anchor" name="g058a8e6025f67b021862281f1911fcef"></a><!-- doxytag: member="uip_arp.h::uip_arp_timer" ref="g058a8e6025f67b021862281f1911fcef" args="(void)" --><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 uip_arp_timer </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">void&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Periodic ARP processing function.
<p>
This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00042.html#a83">example-mainloop-with-arp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00204.html#l00142">142</a> of file <a class="el" href="a00204.html">uip_arp.c</a>.
<p>
References <a class="el" href="a00206.html#l00358">UIP_ARP_MAXAGE</a>, and <a class="el" href="a00206.html#l00349">UIP_ARPTAB_SIZE</a>. </td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 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>