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