00001 00018 /* 00019 * Copyright (c) 2001-2003, Adam Dunkels. 00020 * All rights reserved. 00021 * 00022 * Redistribution and use in source and binary forms, with or without 00023 * modification, are permitted provided that the following conditions 00024 * are met: 00025 * 1. Redistributions of source code must retain the above copyright 00026 * notice, this list of conditions and the following disclaimer. 00027 * 2. Redistributions in binary form must reproduce the above copyright 00028 * notice, this list of conditions and the following disclaimer in the 00029 * documentation and/or other materials provided with the distribution. 00030 * 3. The name of the author may not be used to endorse or promote 00031 * products derived from this software without specific prior 00032 * written permission. 00033 * 00034 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00035 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00036 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00037 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00038 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00039 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00040 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00041 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00042 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00043 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00045 * 00046 * This file is part of the uIP TCP/IP stack. 00047 * 00048 * $Id: uip_arp.h,v 1.5 2006/06/11 21:46:39 adam Exp $ 00049 * 00050 */ 00051 00052 #ifndef __UIP_ARP_H__ 00053 #define __UIP_ARP_H__ 00054 00055 #include "uip.h" 00056 00057 00058 extern struct uip_eth_addr uip_ethaddr; 00059 00063 #ifdef __ICCARM__ 00064 #pragma pack(1) 00065 #endif 00066 00067 struct uip_eth_hdr { 00068 struct uip_eth_addr dest; 00069 struct uip_eth_addr src; 00070 u16_t type; 00071 }PACK_STRUCT_END; 00072 00073 #ifdef __ICCARM__ 00074 #pragma pack() 00075 #endif 00076 00077 #define UIP_ETHTYPE_ARP 0x0806 00078 #define UIP_ETHTYPE_IP 0x0800 00079 #define UIP_ETHTYPE_IP6 0x86dd 00080 00081 00082 /* The uip_arp_init() function must be called before any of the other 00083 ARP functions. */ 00084 void uip_arp_init(void); 00085 00086 /* The uip_arp_ipin() function should be called whenever an IP packet 00087 arrives from the Ethernet. This function refreshes the ARP table or 00088 inserts a new mapping if none exists. The function assumes that an 00089 IP packet with an Ethernet header is present in the uip_buf buffer 00090 and that the length of the packet is in the uip_len variable. */ 00091 void uip_arp_ipin(void); 00092 //#define uip_arp_ipin() 00093 00094 /* The uip_arp_arpin() should be called when an ARP packet is received 00095 by the Ethernet driver. This function also assumes that the 00096 Ethernet frame is present in the uip_buf buffer. When the 00097 uip_arp_arpin() function returns, the contents of the uip_buf 00098 buffer should be sent out on the Ethernet if the uip_len variable 00099 is > 0. */ 00100 void uip_arp_arpin(void); 00101 00102 /* The uip_arp_out() function should be called when an IP packet 00103 should be sent out on the Ethernet. This function creates an 00104 Ethernet header before the IP header in the uip_buf buffer. The 00105 Ethernet header will have the correct Ethernet MAC destination 00106 address filled in if an ARP table entry for the destination IP 00107 address (or the IP address of the default router) is present. If no 00108 such table entry is found, the IP packet is overwritten with an ARP 00109 request and we rely on TCP to retransmit the packet that was 00110 overwritten. In any case, the uip_len variable holds the length of 00111 the Ethernet frame that should be transmitted. */ 00112 void uip_arp_out(void); 00113 00114 /* The uip_arp_timer() function should be called every ten seconds. It 00115 is responsible for flushing old entries in the ARP table. */ 00116 void uip_arp_timer(void); 00117 00142 #define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \ 00143 uip_ethaddr.addr[1] = eaddr.addr[1];\ 00144 uip_ethaddr.addr[2] = eaddr.addr[2];\ 00145 uip_ethaddr.addr[3] = eaddr.addr[3];\ 00146 uip_ethaddr.addr[4] = eaddr.addr[4];\ 00147 uip_ethaddr.addr[5] = eaddr.addr[5];} while(0) 00148 00152 #endif /* __UIP_ARP_H__ */