Contiki 2.6
|
00001 /** 00002 * \addtogroup uip 00003 * @{ 00004 */ 00005 00006 /** 00007 * \addtogroup uiparp 00008 * @{ 00009 */ 00010 00011 /** 00012 * \file 00013 * Macros and definitions for the ARP module. 00014 * \author Adam Dunkels <adam@dunkels.com> 00015 */ 00016 00017 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.2 2006/08/26 23:58:45 oliverschmidt Exp $ 00049 * 00050 */ 00051 00052 #ifndef __UIP_ARP_H__ 00053 #define __UIP_ARP_H__ 00054 00055 #include "net/uip.h" 00056 00057 00058 CCIF extern struct uip_eth_addr uip_ethaddr; 00059 00060 /** 00061 * The Ethernet header. 00062 */ 00063 struct uip_eth_hdr { 00064 struct uip_eth_addr dest; 00065 struct uip_eth_addr src; 00066 uint16_t type; 00067 }; 00068 00069 #define UIP_ETHTYPE_ARP 0x0806 00070 #define UIP_ETHTYPE_IP 0x0800 00071 #define UIP_ETHTYPE_IPV6 0x86dd 00072 00073 00074 /* The uip_arp_init() function must be called before any of the other 00075 ARP functions. */ 00076 void uip_arp_init(void); 00077 00078 /* The uip_arp_ipin() function should be called whenever an IP packet 00079 arrives from the Ethernet. This function refreshes the ARP table or 00080 inserts a new mapping if none exists. The function assumes that an 00081 IP packet with an Ethernet header is present in the uip_buf buffer 00082 and that the length of the packet is in the uip_len variable. */ 00083 /*void uip_arp_ipin(void);*/ 00084 #define uip_arp_ipin() 00085 00086 /* The uip_arp_arpin() should be called when an ARP packet is received 00087 by the Ethernet driver. This function also assumes that the 00088 Ethernet frame is present in the uip_buf buffer. When the 00089 uip_arp_arpin() function returns, the contents of the uip_buf 00090 buffer should be sent out on the Ethernet if the uip_len variable 00091 is > 0. */ 00092 void uip_arp_arpin(void); 00093 00094 /* The uip_arp_out() function should be called when an IP packet 00095 should be sent out on the Ethernet. This function creates an 00096 Ethernet header before the IP header in the uip_buf buffer. The 00097 Ethernet header will have the correct Ethernet MAC destination 00098 address filled in if an ARP table entry for the destination IP 00099 address (or the IP address of the default router) is present. If no 00100 such table entry is found, the IP packet is overwritten with an ARP 00101 request and we rely on TCP to retransmit the packet that was 00102 overwritten. In any case, the uip_len variable holds the length of 00103 the Ethernet frame that should be transmitted. */ 00104 void uip_arp_out(void); 00105 00106 /* The uip_arp_timer() function should be called every ten seconds. It 00107 is responsible for flushing old entries in the ARP table. */ 00108 void uip_arp_timer(void); 00109 00110 /** @} */ 00111 00112 /** 00113 * \addtogroup uipconffunc 00114 * @{ 00115 */ 00116 00117 00118 /** 00119 * Specifiy the Ethernet MAC address. 00120 * 00121 * The ARP code needs to know the MAC address of the Ethernet card in 00122 * order to be able to respond to ARP queries and to generate working 00123 * Ethernet headers. 00124 * 00125 * \note This macro only specifies the Ethernet MAC address to the ARP 00126 * code. It cannot be used to change the MAC address of the Ethernet 00127 * card. 00128 * 00129 * \param eaddr A pointer to a struct uip_eth_addr containing the 00130 * Ethernet MAC address of the Ethernet card. 00131 * 00132 * \hideinitializer 00133 */ 00134 #define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \ 00135 uip_ethaddr.addr[1] = eaddr.addr[1];\ 00136 uip_ethaddr.addr[2] = eaddr.addr[2];\ 00137 uip_ethaddr.addr[3] = eaddr.addr[3];\ 00138 uip_ethaddr.addr[4] = eaddr.addr[4];\ 00139 uip_ethaddr.addr[5] = eaddr.addr[5];} while(0) 00140 00141 /** @} */ 00142 00143 00144 #endif /* __UIP_ARP_H__ */ 00145 /** @} */