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 #if defined ( __CC_ARM ) 00068 __packed 00069 #elif defined ( __GNUC__ ) 00070 __attribute__ ((__packed__)) 00071 #endif 00072 struct uip_eth_hdr { 00073 struct uip_eth_addr dest; 00074 struct uip_eth_addr src; 00075 u16_t type; 00076 }/*PACK_STRUCT_END*/; 00077 00078 #ifdef __ICCARM__ 00079 #pragma pack() 00080 #endif 00081 00082 #define UIP_ETHTYPE_ARP 0x0806 00083 #define UIP_ETHTYPE_IP 0x0800 00084 #define UIP_ETHTYPE_IP6 0x86dd 00085 00086 00087 /* The uip_arp_init() function must be called before any of the other 00088 ARP functions. */ 00089 void uip_arp_init(void); 00090 00091 /* The uip_arp_ipin() function should be called whenever an IP packet 00092 arrives from the Ethernet. This function refreshes the ARP table or 00093 inserts a new mapping if none exists. The function assumes that an 00094 IP packet with an Ethernet header is present in the uip_buf buffer 00095 and that the length of the packet is in the uip_len variable. */ 00096 void uip_arp_ipin(void); 00097 //#define uip_arp_ipin() 00098 00099 /* The uip_arp_arpin() should be called when an ARP packet is received 00100 by the Ethernet driver. This function also assumes that the 00101 Ethernet frame is present in the uip_buf buffer. When the 00102 uip_arp_arpin() function returns, the contents of the uip_buf 00103 buffer should be sent out on the Ethernet if the uip_len variable 00104 is > 0. */ 00105 void uip_arp_arpin(void); 00106 00107 /* The uip_arp_out() function should be called when an IP packet 00108 should be sent out on the Ethernet. This function creates an 00109 Ethernet header before the IP header in the uip_buf buffer. The 00110 Ethernet header will have the correct Ethernet MAC destination 00111 address filled in if an ARP table entry for the destination IP 00112 address (or the IP address of the default router) is present. If no 00113 such table entry is found, the IP packet is overwritten with an ARP 00114 request and we rely on TCP to retransmit the packet that was 00115 overwritten. In any case, the uip_len variable holds the length of 00116 the Ethernet frame that should be transmitted. */ 00117 void uip_arp_out(void); 00118 00119 /* The uip_arp_timer() function should be called every ten seconds. It 00120 is responsible for flushing old entries in the ARP table. */ 00121 void uip_arp_timer(void); 00122 00147 #define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \ 00148 uip_ethaddr.addr[1] = eaddr.addr[1];\ 00149 uip_ethaddr.addr[2] = eaddr.addr[2];\ 00150 uip_ethaddr.addr[3] = eaddr.addr[3];\ 00151 uip_ethaddr.addr[4] = eaddr.addr[4];\ 00152 uip_ethaddr.addr[5] = eaddr.addr[5];} while(0) 00153 00157 #endif /* __UIP_ARP_H__ */
1.5.8