uIP 1.0 based webserver for LPC1114 + ENC28J60

Dependencies:   mbed TMP102

Committer:
ban4jp
Date:
Mon Jun 30 16:00:08 2014 +0000
Revision:
3:a2715e9c7737
Parent:
0:685224d2f66d
backported from Contiki 2.7

Who changed what in which revision?

UserRevisionLine numberNew 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 *
ban4jp 0:685224d2f66d 49 */
ban4jp 0:685224d2f66d 50
ban4jp 0:685224d2f66d 51 #ifndef __UIP_ARP_H__
ban4jp 0:685224d2f66d 52 #define __UIP_ARP_H__
ban4jp 0:685224d2f66d 53
ban4jp 0:685224d2f66d 54 #include "uip.h"
ban4jp 0:685224d2f66d 55
ban4jp 0:685224d2f66d 56
ban4jp 0:685224d2f66d 57
ban4jp 0:685224d2f66d 58 /**
ban4jp 0:685224d2f66d 59 * The Ethernet header.
ban4jp 0:685224d2f66d 60 */
ban4jp 0:685224d2f66d 61 struct uip_eth_hdr {
ban4jp 0:685224d2f66d 62 struct uip_eth_addr dest;
ban4jp 0:685224d2f66d 63 struct uip_eth_addr src;
ban4jp 3:a2715e9c7737 64 uint16_t type;
ban4jp 0:685224d2f66d 65 };
ban4jp 0:685224d2f66d 66
ban4jp 3:a2715e9c7737 67 #define UIP_ETHTYPE_ARP 0x0806
ban4jp 3:a2715e9c7737 68 #define UIP_ETHTYPE_IP 0x0800
ban4jp 3:a2715e9c7737 69 #define UIP_ETHTYPE_IPV6 0x86dd
ban4jp 0:685224d2f66d 70
ban4jp 0:685224d2f66d 71
ban4jp 0:685224d2f66d 72 /* The uip_arp_init() function must be called before any of the other
ban4jp 0:685224d2f66d 73 ARP functions. */
ban4jp 0:685224d2f66d 74 void uip_arp_init(void);
ban4jp 0:685224d2f66d 75
ban4jp 0:685224d2f66d 76 /* The uip_arp_ipin() function should be called whenever an IP packet
ban4jp 0:685224d2f66d 77 arrives from the Ethernet. This function refreshes the ARP table or
ban4jp 0:685224d2f66d 78 inserts a new mapping if none exists. The function assumes that an
ban4jp 0:685224d2f66d 79 IP packet with an Ethernet header is present in the uip_buf buffer
ban4jp 0:685224d2f66d 80 and that the length of the packet is in the uip_len variable. */
ban4jp 0:685224d2f66d 81 /*void uip_arp_ipin(void);*/
ban4jp 0:685224d2f66d 82 #define uip_arp_ipin()
ban4jp 0:685224d2f66d 83
ban4jp 0:685224d2f66d 84 /* The uip_arp_arpin() should be called when an ARP packet is received
ban4jp 0:685224d2f66d 85 by the Ethernet driver. This function also assumes that the
ban4jp 0:685224d2f66d 86 Ethernet frame is present in the uip_buf buffer. When the
ban4jp 0:685224d2f66d 87 uip_arp_arpin() function returns, the contents of the uip_buf
ban4jp 0:685224d2f66d 88 buffer should be sent out on the Ethernet if the uip_len variable
ban4jp 0:685224d2f66d 89 is > 0. */
ban4jp 0:685224d2f66d 90 void uip_arp_arpin(void);
ban4jp 0:685224d2f66d 91
ban4jp 0:685224d2f66d 92 /* The uip_arp_out() function should be called when an IP packet
ban4jp 0:685224d2f66d 93 should be sent out on the Ethernet. This function creates an
ban4jp 0:685224d2f66d 94 Ethernet header before the IP header in the uip_buf buffer. The
ban4jp 0:685224d2f66d 95 Ethernet header will have the correct Ethernet MAC destination
ban4jp 0:685224d2f66d 96 address filled in if an ARP table entry for the destination IP
ban4jp 0:685224d2f66d 97 address (or the IP address of the default router) is present. If no
ban4jp 0:685224d2f66d 98 such table entry is found, the IP packet is overwritten with an ARP
ban4jp 0:685224d2f66d 99 request and we rely on TCP to retransmit the packet that was
ban4jp 0:685224d2f66d 100 overwritten. In any case, the uip_len variable holds the length of
ban4jp 0:685224d2f66d 101 the Ethernet frame that should be transmitted. */
ban4jp 0:685224d2f66d 102 void uip_arp_out(void);
ban4jp 0:685224d2f66d 103
ban4jp 0:685224d2f66d 104 /* The uip_arp_timer() function should be called every ten seconds. It
ban4jp 0:685224d2f66d 105 is responsible for flushing old entries in the ARP table. */
ban4jp 0:685224d2f66d 106 void uip_arp_timer(void);
ban4jp 0:685224d2f66d 107
ban4jp 0:685224d2f66d 108 /** @} */
ban4jp 0:685224d2f66d 109
ban4jp 0:685224d2f66d 110 /**
ban4jp 0:685224d2f66d 111 * \addtogroup uipconffunc
ban4jp 0:685224d2f66d 112 * @{
ban4jp 0:685224d2f66d 113 */
ban4jp 0:685224d2f66d 114
ban4jp 0:685224d2f66d 115
ban4jp 0:685224d2f66d 116 /**
ban4jp 0:685224d2f66d 117 * Specifiy the Ethernet MAC address.
ban4jp 0:685224d2f66d 118 *
ban4jp 0:685224d2f66d 119 * The ARP code needs to know the MAC address of the Ethernet card in
ban4jp 0:685224d2f66d 120 * order to be able to respond to ARP queries and to generate working
ban4jp 0:685224d2f66d 121 * Ethernet headers.
ban4jp 0:685224d2f66d 122 *
ban4jp 0:685224d2f66d 123 * \note This macro only specifies the Ethernet MAC address to the ARP
ban4jp 0:685224d2f66d 124 * code. It cannot be used to change the MAC address of the Ethernet
ban4jp 0:685224d2f66d 125 * card.
ban4jp 0:685224d2f66d 126 *
ban4jp 0:685224d2f66d 127 * \param eaddr A pointer to a struct uip_eth_addr containing the
ban4jp 0:685224d2f66d 128 * Ethernet MAC address of the Ethernet card.
ban4jp 0:685224d2f66d 129 *
ban4jp 0:685224d2f66d 130 * \hideinitializer
ban4jp 0:685224d2f66d 131 */
ban4jp 3:a2715e9c7737 132 #define uip_setethaddr(eaddr) do {uip_lladdr.addr[0] = eaddr.addr[0]; \
ban4jp 3:a2715e9c7737 133 uip_lladdr.addr[1] = eaddr.addr[1];\
ban4jp 3:a2715e9c7737 134 uip_lladdr.addr[2] = eaddr.addr[2];\
ban4jp 3:a2715e9c7737 135 uip_lladdr.addr[3] = eaddr.addr[3];\
ban4jp 3:a2715e9c7737 136 uip_lladdr.addr[4] = eaddr.addr[4];\
ban4jp 3:a2715e9c7737 137 uip_lladdr.addr[5] = eaddr.addr[5];} while(0)
ban4jp 0:685224d2f66d 138
ban4jp 0:685224d2f66d 139 /** @} */
ban4jp 3:a2715e9c7737 140
ban4jp 0:685224d2f66d 141
ban4jp 0:685224d2f66d 142 #endif /* __UIP_ARP_H__ */
ban4jp 3:a2715e9c7737 143 /** @} */