UIPEthernet library for Arduino IDE, Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32,Nordic nRF51,Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API. Compiled and tested on Nucleo-F302R8. Master repository is: https://github.com/UIPEthernet/UIPEthernet/

Committer:
cassyarduino
Date:
Wed Dec 21 16:58:10 2016 +0100
Revision:
0:e3fb1267e3c3
initial release

Who changed what in which revision?

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