ban4jp -
/
uIP-1-0_webserver
uIP 1.0 based webserver for LPC1114 + ENC28J60
Embed:
(wiki syntax)
Show/hide line numbers
uip_arp.h
Go to the documentation of this file.
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 * 00049 */ 00050 00051 #ifndef __UIP_ARP_H__ 00052 #define __UIP_ARP_H__ 00053 00054 #include "uip.h" 00055 00056 00057 00058 /** 00059 * The Ethernet header. 00060 */ 00061 struct uip_eth_hdr { 00062 struct uip_eth_addr dest; 00063 struct uip_eth_addr src; 00064 uint16_t type; 00065 }; 00066 00067 #define UIP_ETHTYPE_ARP 0x0806 00068 #define UIP_ETHTYPE_IP 0x0800 00069 #define UIP_ETHTYPE_IPV6 0x86dd 00070 00071 00072 /* The uip_arp_init() function must be called before any of the other 00073 ARP functions. */ 00074 void uip_arp_init(void); 00075 00076 /* The uip_arp_ipin() function should be called whenever an IP packet 00077 arrives from the Ethernet. This function refreshes the ARP table or 00078 inserts a new mapping if none exists. The function assumes that an 00079 IP packet with an Ethernet header is present in the uip_buf buffer 00080 and that the length of the packet is in the uip_len variable. */ 00081 /*void uip_arp_ipin(void);*/ 00082 #define uip_arp_ipin() 00083 00084 /* The uip_arp_arpin() should be called when an ARP packet is received 00085 by the Ethernet driver. This function also assumes that the 00086 Ethernet frame is present in the uip_buf buffer. When the 00087 uip_arp_arpin() function returns, the contents of the uip_buf 00088 buffer should be sent out on the Ethernet if the uip_len variable 00089 is > 0. */ 00090 void uip_arp_arpin(void); 00091 00092 /* The uip_arp_out() function should be called when an IP packet 00093 should be sent out on the Ethernet. This function creates an 00094 Ethernet header before the IP header in the uip_buf buffer. The 00095 Ethernet header will have the correct Ethernet MAC destination 00096 address filled in if an ARP table entry for the destination IP 00097 address (or the IP address of the default router) is present. If no 00098 such table entry is found, the IP packet is overwritten with an ARP 00099 request and we rely on TCP to retransmit the packet that was 00100 overwritten. In any case, the uip_len variable holds the length of 00101 the Ethernet frame that should be transmitted. */ 00102 void uip_arp_out(void); 00103 00104 /* The uip_arp_timer() function should be called every ten seconds. It 00105 is responsible for flushing old entries in the ARP table. */ 00106 void uip_arp_timer(void); 00107 00108 /** @} */ 00109 00110 /** 00111 * \addtogroup uipconffunc 00112 * @{ 00113 */ 00114 00115 00116 /** 00117 * Specifiy the Ethernet MAC address. 00118 * 00119 * The ARP code needs to know the MAC address of the Ethernet card in 00120 * order to be able to respond to ARP queries and to generate working 00121 * Ethernet headers. 00122 * 00123 * \note This macro only specifies the Ethernet MAC address to the ARP 00124 * code. It cannot be used to change the MAC address of the Ethernet 00125 * card. 00126 * 00127 * \param eaddr A pointer to a struct uip_eth_addr containing the 00128 * Ethernet MAC address of the Ethernet card. 00129 * 00130 * \hideinitializer 00131 */ 00132 #define uip_setethaddr(eaddr) do {uip_lladdr.addr[0] = eaddr.addr[0]; \ 00133 uip_lladdr.addr[1] = eaddr.addr[1];\ 00134 uip_lladdr.addr[2] = eaddr.addr[2];\ 00135 uip_lladdr.addr[3] = eaddr.addr[3];\ 00136 uip_lladdr.addr[4] = eaddr.addr[4];\ 00137 uip_lladdr.addr[5] = eaddr.addr[5];} while(0) 00138 00139 /** @} */ 00140 00141 00142 #endif /* __UIP_ARP_H__ */ 00143 /** @} */
Generated on Tue Jul 12 2022 12:52:12 by 1.7.2