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