mbed OS5

Fork of UIPEthernet by Zoltan Hudak

Committer:
pilotak
Date:
Sun Aug 06 16:01:26 2017 +0000
Revision:
9:e55652bed36c
Parent:
8:4acb22344932
mBed OS5

Who changed what in which revision?

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