ban4jp -
/
uIP-1-0_webserver
uIP 1.0 based webserver for LPC1114 + ENC28J60
uip/uip_arp.h@0:685224d2f66d, 2014-06-14 (annotated)
- Committer:
- ban4jp
- Date:
- Sat Jun 14 16:02:21 2014 +0000
- Revision:
- 0:685224d2f66d
- Child:
- 3:a2715e9c7737
initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ban4jp | 0:685224d2f66d | 1 | /** |
ban4jp | 0:685224d2f66d | 2 | * \addtogroup uip |
ban4jp | 0:685224d2f66d | 3 | * @{ |
ban4jp | 0:685224d2f66d | 4 | */ |
ban4jp | 0:685224d2f66d | 5 | |
ban4jp | 0:685224d2f66d | 6 | /** |
ban4jp | 0:685224d2f66d | 7 | * \addtogroup uiparp |
ban4jp | 0:685224d2f66d | 8 | * @{ |
ban4jp | 0:685224d2f66d | 9 | */ |
ban4jp | 0:685224d2f66d | 10 | |
ban4jp | 0:685224d2f66d | 11 | /** |
ban4jp | 0:685224d2f66d | 12 | * \file |
ban4jp | 0:685224d2f66d | 13 | * Macros and definitions for the ARP module. |
ban4jp | 0:685224d2f66d | 14 | * \author Adam Dunkels <adam@dunkels.com> |
ban4jp | 0:685224d2f66d | 15 | */ |
ban4jp | 0:685224d2f66d | 16 | |
ban4jp | 0:685224d2f66d | 17 | |
ban4jp | 0:685224d2f66d | 18 | /* |
ban4jp | 0:685224d2f66d | 19 | * Copyright (c) 2001-2003, Adam Dunkels. |
ban4jp | 0:685224d2f66d | 20 | * All rights reserved. |
ban4jp | 0:685224d2f66d | 21 | * |
ban4jp | 0:685224d2f66d | 22 | * Redistribution and use in source and binary forms, with or without |
ban4jp | 0:685224d2f66d | 23 | * modification, are permitted provided that the following conditions |
ban4jp | 0:685224d2f66d | 24 | * are met: |
ban4jp | 0:685224d2f66d | 25 | * 1. Redistributions of source code must retain the above copyright |
ban4jp | 0:685224d2f66d | 26 | * notice, this list of conditions and the following disclaimer. |
ban4jp | 0:685224d2f66d | 27 | * 2. Redistributions in binary form must reproduce the above copyright |
ban4jp | 0:685224d2f66d | 28 | * notice, this list of conditions and the following disclaimer in the |
ban4jp | 0:685224d2f66d | 29 | * documentation and/or other materials provided with the distribution. |
ban4jp | 0:685224d2f66d | 30 | * 3. The name of the author may not be used to endorse or promote |
ban4jp | 0:685224d2f66d | 31 | * products derived from this software without specific prior |
ban4jp | 0:685224d2f66d | 32 | * written permission. |
ban4jp | 0:685224d2f66d | 33 | * |
ban4jp | 0:685224d2f66d | 34 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
ban4jp | 0:685224d2f66d | 35 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
ban4jp | 0:685224d2f66d | 36 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ban4jp | 0:685224d2f66d | 37 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
ban4jp | 0:685224d2f66d | 38 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
ban4jp | 0:685224d2f66d | 39 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
ban4jp | 0:685224d2f66d | 40 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
ban4jp | 0:685224d2f66d | 41 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
ban4jp | 0:685224d2f66d | 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
ban4jp | 0:685224d2f66d | 43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
ban4jp | 0:685224d2f66d | 44 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ban4jp | 0:685224d2f66d | 45 | * |
ban4jp | 0:685224d2f66d | 46 | * This file is part of the uIP TCP/IP stack. |
ban4jp | 0:685224d2f66d | 47 | * |
ban4jp | 0:685224d2f66d | 48 | * $Id: uip_arp.h,v 1.5 2006/06/11 21:46:39 adam Exp $ |
ban4jp | 0:685224d2f66d | 49 | * |
ban4jp | 0:685224d2f66d | 50 | */ |
ban4jp | 0:685224d2f66d | 51 | |
ban4jp | 0:685224d2f66d | 52 | #ifndef __UIP_ARP_H__ |
ban4jp | 0:685224d2f66d | 53 | #define __UIP_ARP_H__ |
ban4jp | 0:685224d2f66d | 54 | |
ban4jp | 0:685224d2f66d | 55 | #include "uip.h" |
ban4jp | 0:685224d2f66d | 56 | |
ban4jp | 0:685224d2f66d | 57 | |
ban4jp | 0:685224d2f66d | 58 | extern struct uip_eth_addr uip_ethaddr; |
ban4jp | 0:685224d2f66d | 59 | |
ban4jp | 0:685224d2f66d | 60 | /** |
ban4jp | 0:685224d2f66d | 61 | * The Ethernet header. |
ban4jp | 0:685224d2f66d | 62 | */ |
ban4jp | 0:685224d2f66d | 63 | struct uip_eth_hdr { |
ban4jp | 0:685224d2f66d | 64 | struct uip_eth_addr dest; |
ban4jp | 0:685224d2f66d | 65 | struct uip_eth_addr src; |
ban4jp | 0:685224d2f66d | 66 | u16_t type; |
ban4jp | 0:685224d2f66d | 67 | }; |
ban4jp | 0:685224d2f66d | 68 | |
ban4jp | 0:685224d2f66d | 69 | #define UIP_ETHTYPE_ARP 0x0806 |
ban4jp | 0:685224d2f66d | 70 | #define UIP_ETHTYPE_IP 0x0800 |
ban4jp | 0:685224d2f66d | 71 | #define UIP_ETHTYPE_IP6 0x86dd |
ban4jp | 0:685224d2f66d | 72 | |
ban4jp | 0:685224d2f66d | 73 | |
ban4jp | 0:685224d2f66d | 74 | /* The uip_arp_init() function must be called before any of the other |
ban4jp | 0:685224d2f66d | 75 | ARP functions. */ |
ban4jp | 0:685224d2f66d | 76 | void uip_arp_init(void); |
ban4jp | 0:685224d2f66d | 77 | |
ban4jp | 0:685224d2f66d | 78 | /* The uip_arp_ipin() function should be called whenever an IP packet |
ban4jp | 0:685224d2f66d | 79 | arrives from the Ethernet. This function refreshes the ARP table or |
ban4jp | 0:685224d2f66d | 80 | inserts a new mapping if none exists. The function assumes that an |
ban4jp | 0:685224d2f66d | 81 | IP packet with an Ethernet header is present in the uip_buf buffer |
ban4jp | 0:685224d2f66d | 82 | and that the length of the packet is in the uip_len variable. */ |
ban4jp | 0:685224d2f66d | 83 | /*void uip_arp_ipin(void);*/ |
ban4jp | 0:685224d2f66d | 84 | #define uip_arp_ipin() |
ban4jp | 0:685224d2f66d | 85 | |
ban4jp | 0:685224d2f66d | 86 | /* The uip_arp_arpin() should be called when an ARP packet is received |
ban4jp | 0:685224d2f66d | 87 | by the Ethernet driver. This function also assumes that the |
ban4jp | 0:685224d2f66d | 88 | Ethernet frame is present in the uip_buf buffer. When the |
ban4jp | 0:685224d2f66d | 89 | uip_arp_arpin() function returns, the contents of the uip_buf |
ban4jp | 0:685224d2f66d | 90 | buffer should be sent out on the Ethernet if the uip_len variable |
ban4jp | 0:685224d2f66d | 91 | is > 0. */ |
ban4jp | 0:685224d2f66d | 92 | void uip_arp_arpin(void); |
ban4jp | 0:685224d2f66d | 93 | |
ban4jp | 0:685224d2f66d | 94 | /* The uip_arp_out() function should be called when an IP packet |
ban4jp | 0:685224d2f66d | 95 | should be sent out on the Ethernet. This function creates an |
ban4jp | 0:685224d2f66d | 96 | Ethernet header before the IP header in the uip_buf buffer. The |
ban4jp | 0:685224d2f66d | 97 | Ethernet header will have the correct Ethernet MAC destination |
ban4jp | 0:685224d2f66d | 98 | address filled in if an ARP table entry for the destination IP |
ban4jp | 0:685224d2f66d | 99 | address (or the IP address of the default router) is present. If no |
ban4jp | 0:685224d2f66d | 100 | such table entry is found, the IP packet is overwritten with an ARP |
ban4jp | 0:685224d2f66d | 101 | request and we rely on TCP to retransmit the packet that was |
ban4jp | 0:685224d2f66d | 102 | overwritten. In any case, the uip_len variable holds the length of |
ban4jp | 0:685224d2f66d | 103 | the Ethernet frame that should be transmitted. */ |
ban4jp | 0:685224d2f66d | 104 | void uip_arp_out(void); |
ban4jp | 0:685224d2f66d | 105 | |
ban4jp | 0:685224d2f66d | 106 | /* The uip_arp_timer() function should be called every ten seconds. It |
ban4jp | 0:685224d2f66d | 107 | is responsible for flushing old entries in the ARP table. */ |
ban4jp | 0:685224d2f66d | 108 | void uip_arp_timer(void); |
ban4jp | 0:685224d2f66d | 109 | |
ban4jp | 0:685224d2f66d | 110 | /** @} */ |
ban4jp | 0:685224d2f66d | 111 | |
ban4jp | 0:685224d2f66d | 112 | /** |
ban4jp | 0:685224d2f66d | 113 | * \addtogroup uipconffunc |
ban4jp | 0:685224d2f66d | 114 | * @{ |
ban4jp | 0:685224d2f66d | 115 | */ |
ban4jp | 0:685224d2f66d | 116 | |
ban4jp | 0:685224d2f66d | 117 | |
ban4jp | 0:685224d2f66d | 118 | /** |
ban4jp | 0:685224d2f66d | 119 | * Specifiy the Ethernet MAC address. |
ban4jp | 0:685224d2f66d | 120 | * |
ban4jp | 0:685224d2f66d | 121 | * The ARP code needs to know the MAC address of the Ethernet card in |
ban4jp | 0:685224d2f66d | 122 | * order to be able to respond to ARP queries and to generate working |
ban4jp | 0:685224d2f66d | 123 | * Ethernet headers. |
ban4jp | 0:685224d2f66d | 124 | * |
ban4jp | 0:685224d2f66d | 125 | * \note This macro only specifies the Ethernet MAC address to the ARP |
ban4jp | 0:685224d2f66d | 126 | * code. It cannot be used to change the MAC address of the Ethernet |
ban4jp | 0:685224d2f66d | 127 | * card. |
ban4jp | 0:685224d2f66d | 128 | * |
ban4jp | 0:685224d2f66d | 129 | * \param eaddr A pointer to a struct uip_eth_addr containing the |
ban4jp | 0:685224d2f66d | 130 | * Ethernet MAC address of the Ethernet card. |
ban4jp | 0:685224d2f66d | 131 | * |
ban4jp | 0:685224d2f66d | 132 | * \hideinitializer |
ban4jp | 0:685224d2f66d | 133 | */ |
ban4jp | 0:685224d2f66d | 134 | #define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \ |
ban4jp | 0:685224d2f66d | 135 | uip_ethaddr.addr[1] = eaddr.addr[1];\ |
ban4jp | 0:685224d2f66d | 136 | uip_ethaddr.addr[2] = eaddr.addr[2];\ |
ban4jp | 0:685224d2f66d | 137 | uip_ethaddr.addr[3] = eaddr.addr[3];\ |
ban4jp | 0:685224d2f66d | 138 | uip_ethaddr.addr[4] = eaddr.addr[4];\ |
ban4jp | 0:685224d2f66d | 139 | uip_ethaddr.addr[5] = eaddr.addr[5];} while(0) |
ban4jp | 0:685224d2f66d | 140 | |
ban4jp | 0:685224d2f66d | 141 | /** @} */ |
ban4jp | 0:685224d2f66d | 142 | /** @} */ |
ban4jp | 0:685224d2f66d | 143 | |
ban4jp | 0:685224d2f66d | 144 | #endif /* __UIP_ARP_H__ */ |