These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

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