SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lorcansmith 0:2a53a4c3238c 1 /**
lorcansmith 0:2a53a4c3238c 2 * @file
lorcansmith 0:2a53a4c3238c 3 * AutoIP Automatic LinkLocal IP Configuration
lorcansmith 0:2a53a4c3238c 4 *
lorcansmith 0:2a53a4c3238c 5 */
lorcansmith 0:2a53a4c3238c 6
lorcansmith 0:2a53a4c3238c 7 /*
lorcansmith 0:2a53a4c3238c 8 *
lorcansmith 0:2a53a4c3238c 9 * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
lorcansmith 0:2a53a4c3238c 10 * All rights reserved.
lorcansmith 0:2a53a4c3238c 11 *
lorcansmith 0:2a53a4c3238c 12 * Redistribution and use in source and binary forms, with or without modification,
lorcansmith 0:2a53a4c3238c 13 * are permitted provided that the following conditions are met:
lorcansmith 0:2a53a4c3238c 14 *
lorcansmith 0:2a53a4c3238c 15 * 1. Redistributions of source code must retain the above copyright notice,
lorcansmith 0:2a53a4c3238c 16 * this list of conditions and the following disclaimer.
lorcansmith 0:2a53a4c3238c 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
lorcansmith 0:2a53a4c3238c 18 * this list of conditions and the following disclaimer in the documentation
lorcansmith 0:2a53a4c3238c 19 * and/or other materials provided with the distribution.
lorcansmith 0:2a53a4c3238c 20 * 3. The name of the author may not be used to endorse or promote products
lorcansmith 0:2a53a4c3238c 21 * derived from this software without specific prior written permission.
lorcansmith 0:2a53a4c3238c 22 *
lorcansmith 0:2a53a4c3238c 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
lorcansmith 0:2a53a4c3238c 24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
lorcansmith 0:2a53a4c3238c 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
lorcansmith 0:2a53a4c3238c 26 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
lorcansmith 0:2a53a4c3238c 27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
lorcansmith 0:2a53a4c3238c 28 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
lorcansmith 0:2a53a4c3238c 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
lorcansmith 0:2a53a4c3238c 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
lorcansmith 0:2a53a4c3238c 31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
lorcansmith 0:2a53a4c3238c 32 * OF SUCH DAMAGE.
lorcansmith 0:2a53a4c3238c 33 *
lorcansmith 0:2a53a4c3238c 34 * Author: Dominik Spies <kontakt@dspies.de>
lorcansmith 0:2a53a4c3238c 35 *
lorcansmith 0:2a53a4c3238c 36 * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
lorcansmith 0:2a53a4c3238c 37 * with RFC 3927.
lorcansmith 0:2a53a4c3238c 38 *
lorcansmith 0:2a53a4c3238c 39 *
lorcansmith 0:2a53a4c3238c 40 * Please coordinate changes and requests with Dominik Spies
lorcansmith 0:2a53a4c3238c 41 * <kontakt@dspies.de>
lorcansmith 0:2a53a4c3238c 42 */
lorcansmith 0:2a53a4c3238c 43
lorcansmith 0:2a53a4c3238c 44 /*******************************************************************************
lorcansmith 0:2a53a4c3238c 45 * USAGE:
lorcansmith 0:2a53a4c3238c 46 *
lorcansmith 0:2a53a4c3238c 47 * define LWIP_AUTOIP 1 in your lwipopts.h
lorcansmith 0:2a53a4c3238c 48 *
lorcansmith 0:2a53a4c3238c 49 * If you don't use tcpip.c (so, don't call, you don't call tcpip_init):
lorcansmith 0:2a53a4c3238c 50 * - First, call autoip_init().
lorcansmith 0:2a53a4c3238c 51 * - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces,
lorcansmith 0:2a53a4c3238c 52 * that should be defined in autoip.h.
lorcansmith 0:2a53a4c3238c 53 * I recommend a value of 100. The value must divide 1000 with a remainder almost 0.
lorcansmith 0:2a53a4c3238c 54 * Possible values are 1000, 500, 333, 250, 200, 166, 142, 125, 111, 100 ....
lorcansmith 0:2a53a4c3238c 55 *
lorcansmith 0:2a53a4c3238c 56 * Without DHCP:
lorcansmith 0:2a53a4c3238c 57 * - Call autoip_start() after netif_add().
lorcansmith 0:2a53a4c3238c 58 *
lorcansmith 0:2a53a4c3238c 59 * With DHCP:
lorcansmith 0:2a53a4c3238c 60 * - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h.
lorcansmith 0:2a53a4c3238c 61 * - Configure your DHCP Client.
lorcansmith 0:2a53a4c3238c 62 *
lorcansmith 0:2a53a4c3238c 63 */
lorcansmith 0:2a53a4c3238c 64
lorcansmith 0:2a53a4c3238c 65 #include "lwip/opt.h"
lorcansmith 0:2a53a4c3238c 66
lorcansmith 0:2a53a4c3238c 67 #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
lorcansmith 0:2a53a4c3238c 68
lorcansmith 0:2a53a4c3238c 69 #include "lwip/mem.h"
lorcansmith 0:2a53a4c3238c 70 #include "lwip/udp.h"
lorcansmith 0:2a53a4c3238c 71 #include "lwip/ip_addr.h"
lorcansmith 0:2a53a4c3238c 72 #include "lwip/netif.h"
lorcansmith 0:2a53a4c3238c 73 #include "lwip/autoip.h"
lorcansmith 0:2a53a4c3238c 74 #include "netif/etharp.h"
lorcansmith 0:2a53a4c3238c 75
lorcansmith 0:2a53a4c3238c 76 #include <stdlib.h>
lorcansmith 0:2a53a4c3238c 77 #include <string.h>
lorcansmith 0:2a53a4c3238c 78
lorcansmith 0:2a53a4c3238c 79 /* 169.254.0.0 */
lorcansmith 0:2a53a4c3238c 80 #define AUTOIP_NET 0xA9FE0000
lorcansmith 0:2a53a4c3238c 81 /* 169.254.1.0 */
lorcansmith 0:2a53a4c3238c 82 #define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100)
lorcansmith 0:2a53a4c3238c 83 /* 169.254.254.255 */
lorcansmith 0:2a53a4c3238c 84 #define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF)
lorcansmith 0:2a53a4c3238c 85
lorcansmith 0:2a53a4c3238c 86
lorcansmith 0:2a53a4c3238c 87 /** Pseudo random macro based on netif informations.
lorcansmith 0:2a53a4c3238c 88 * You could use "rand()" from the C Library if you define LWIP_AUTOIP_RAND in lwipopts.h */
lorcansmith 0:2a53a4c3238c 89 #ifndef LWIP_AUTOIP_RAND
lorcansmith 0:2a53a4c3238c 90 #define LWIP_AUTOIP_RAND(netif) ( (((u32_t)((netif->hwaddr[5]) & 0xff) << 24) | \
lorcansmith 0:2a53a4c3238c 91 ((u32_t)((netif->hwaddr[3]) & 0xff) << 16) | \
lorcansmith 0:2a53a4c3238c 92 ((u32_t)((netif->hwaddr[2]) & 0xff) << 8) | \
lorcansmith 0:2a53a4c3238c 93 ((u32_t)((netif->hwaddr[4]) & 0xff))) + \
lorcansmith 0:2a53a4c3238c 94 (netif->autoip?netif->autoip->tried_llipaddr:0))
lorcansmith 0:2a53a4c3238c 95 #endif /* LWIP_AUTOIP_RAND */
lorcansmith 0:2a53a4c3238c 96
lorcansmith 0:2a53a4c3238c 97 /**
lorcansmith 0:2a53a4c3238c 98 * Macro that generates the initial IP address to be tried by AUTOIP.
lorcansmith 0:2a53a4c3238c 99 * If you want to override this, define it to something else in lwipopts.h.
lorcansmith 0:2a53a4c3238c 100 */
lorcansmith 0:2a53a4c3238c 101 #ifndef LWIP_AUTOIP_CREATE_SEED_ADDR
lorcansmith 0:2a53a4c3238c 102 #define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \
lorcansmith 0:2a53a4c3238c 103 htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \
lorcansmith 0:2a53a4c3238c 104 ((u32_t)((u8_t)(netif->hwaddr[5]))) << 8)))
lorcansmith 0:2a53a4c3238c 105 #endif /* LWIP_AUTOIP_CREATE_SEED_ADDR */
lorcansmith 0:2a53a4c3238c 106
lorcansmith 0:2a53a4c3238c 107 /* static functions */
lorcansmith 0:2a53a4c3238c 108 static void autoip_handle_arp_conflict(struct netif *netif);
lorcansmith 0:2a53a4c3238c 109
lorcansmith 0:2a53a4c3238c 110 /* creates a pseudo random LL IP-Address for a network interface */
lorcansmith 0:2a53a4c3238c 111 static void autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr);
lorcansmith 0:2a53a4c3238c 112
lorcansmith 0:2a53a4c3238c 113 /* sends an ARP probe */
lorcansmith 0:2a53a4c3238c 114 static err_t autoip_arp_probe(struct netif *netif);
lorcansmith 0:2a53a4c3238c 115
lorcansmith 0:2a53a4c3238c 116 /* sends an ARP announce */
lorcansmith 0:2a53a4c3238c 117 static err_t autoip_arp_announce(struct netif *netif);
lorcansmith 0:2a53a4c3238c 118
lorcansmith 0:2a53a4c3238c 119 /* configure interface for use with current LL IP-Address */
lorcansmith 0:2a53a4c3238c 120 static err_t autoip_bind(struct netif *netif);
lorcansmith 0:2a53a4c3238c 121
lorcansmith 0:2a53a4c3238c 122 /* start sending probes for llipaddr */
lorcansmith 0:2a53a4c3238c 123 static void autoip_start_probing(struct netif *netif);
lorcansmith 0:2a53a4c3238c 124
lorcansmith 0:2a53a4c3238c 125 /**
lorcansmith 0:2a53a4c3238c 126 * Initialize this module
lorcansmith 0:2a53a4c3238c 127 */
lorcansmith 0:2a53a4c3238c 128 void
lorcansmith 0:2a53a4c3238c 129 autoip_init(void)
lorcansmith 0:2a53a4c3238c 130 {
lorcansmith 0:2a53a4c3238c 131 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_init()\n"));
lorcansmith 0:2a53a4c3238c 132 }
lorcansmith 0:2a53a4c3238c 133
lorcansmith 0:2a53a4c3238c 134 /** Set a statically allocated struct autoip to work with.
lorcansmith 0:2a53a4c3238c 135 * Using this prevents autoip_start to allocate it using mem_malloc.
lorcansmith 0:2a53a4c3238c 136 *
lorcansmith 0:2a53a4c3238c 137 * @param netif the netif for which to set the struct autoip
lorcansmith 0:2a53a4c3238c 138 * @param dhcp (uninitialised) dhcp struct allocated by the application
lorcansmith 0:2a53a4c3238c 139 */
lorcansmith 0:2a53a4c3238c 140 void
lorcansmith 0:2a53a4c3238c 141 autoip_set_struct(struct netif *netif, struct autoip *autoip)
lorcansmith 0:2a53a4c3238c 142 {
lorcansmith 0:2a53a4c3238c 143 LWIP_ASSERT("netif != NULL", netif != NULL);
lorcansmith 0:2a53a4c3238c 144 LWIP_ASSERT("autoip != NULL", autoip != NULL);
lorcansmith 0:2a53a4c3238c 145 LWIP_ASSERT("netif already has a struct autoip set", netif->autoip == NULL);
lorcansmith 0:2a53a4c3238c 146
lorcansmith 0:2a53a4c3238c 147 /* clear data structure */
lorcansmith 0:2a53a4c3238c 148 memset(autoip, 0, sizeof(struct autoip));
lorcansmith 0:2a53a4c3238c 149 /* autoip->state = AUTOIP_STATE_OFF; */
lorcansmith 0:2a53a4c3238c 150 netif->autoip = autoip;
lorcansmith 0:2a53a4c3238c 151 }
lorcansmith 0:2a53a4c3238c 152
lorcansmith 0:2a53a4c3238c 153 /** Restart AutoIP client and check the next address (conflict detected)
lorcansmith 0:2a53a4c3238c 154 *
lorcansmith 0:2a53a4c3238c 155 * @param netif The netif under AutoIP control
lorcansmith 0:2a53a4c3238c 156 */
lorcansmith 0:2a53a4c3238c 157 static void
lorcansmith 0:2a53a4c3238c 158 autoip_restart(struct netif *netif)
lorcansmith 0:2a53a4c3238c 159 {
lorcansmith 0:2a53a4c3238c 160 netif->autoip->tried_llipaddr++;
lorcansmith 0:2a53a4c3238c 161 autoip_start(netif);
lorcansmith 0:2a53a4c3238c 162 }
lorcansmith 0:2a53a4c3238c 163
lorcansmith 0:2a53a4c3238c 164 /**
lorcansmith 0:2a53a4c3238c 165 * Handle a IP address conflict after an ARP conflict detection
lorcansmith 0:2a53a4c3238c 166 */
lorcansmith 0:2a53a4c3238c 167 static void
lorcansmith 0:2a53a4c3238c 168 autoip_handle_arp_conflict(struct netif *netif)
lorcansmith 0:2a53a4c3238c 169 {
lorcansmith 0:2a53a4c3238c 170 /* Somehow detect if we are defending or retreating */
lorcansmith 0:2a53a4c3238c 171 unsigned char defend = 1; /* tbd */
lorcansmith 0:2a53a4c3238c 172
lorcansmith 0:2a53a4c3238c 173 if(defend) {
lorcansmith 0:2a53a4c3238c 174 if(netif->autoip->lastconflict > 0) {
lorcansmith 0:2a53a4c3238c 175 /* retreat, there was a conflicting ARP in the last
lorcansmith 0:2a53a4c3238c 176 * DEFEND_INTERVAL seconds
lorcansmith 0:2a53a4c3238c 177 */
lorcansmith 0:2a53a4c3238c 178 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 179 ("autoip_handle_arp_conflict(): we are defending, but in DEFEND_INTERVAL, retreating\n"));
lorcansmith 0:2a53a4c3238c 180
lorcansmith 0:2a53a4c3238c 181 /* TODO: close all TCP sessions */
lorcansmith 0:2a53a4c3238c 182 autoip_restart(netif);
lorcansmith 0:2a53a4c3238c 183 } else {
lorcansmith 0:2a53a4c3238c 184 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 185 ("autoip_handle_arp_conflict(): we are defend, send ARP Announce\n"));
lorcansmith 0:2a53a4c3238c 186 autoip_arp_announce(netif);
lorcansmith 0:2a53a4c3238c 187 netif->autoip->lastconflict = DEFEND_INTERVAL * AUTOIP_TICKS_PER_SECOND;
lorcansmith 0:2a53a4c3238c 188 }
lorcansmith 0:2a53a4c3238c 189 } else {
lorcansmith 0:2a53a4c3238c 190 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 191 ("autoip_handle_arp_conflict(): we do not defend, retreating\n"));
lorcansmith 0:2a53a4c3238c 192 /* TODO: close all TCP sessions */
lorcansmith 0:2a53a4c3238c 193 autoip_restart(netif);
lorcansmith 0:2a53a4c3238c 194 }
lorcansmith 0:2a53a4c3238c 195 }
lorcansmith 0:2a53a4c3238c 196
lorcansmith 0:2a53a4c3238c 197 /**
lorcansmith 0:2a53a4c3238c 198 * Create an IP-Address out of range 169.254.1.0 to 169.254.254.255
lorcansmith 0:2a53a4c3238c 199 *
lorcansmith 0:2a53a4c3238c 200 * @param netif network interface on which create the IP-Address
lorcansmith 0:2a53a4c3238c 201 * @param ipaddr ip address to initialize
lorcansmith 0:2a53a4c3238c 202 */
lorcansmith 0:2a53a4c3238c 203 static void
lorcansmith 0:2a53a4c3238c 204 autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr)
lorcansmith 0:2a53a4c3238c 205 {
lorcansmith 0:2a53a4c3238c 206 /* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255
lorcansmith 0:2a53a4c3238c 207 * compliant to RFC 3927 Section 2.1
lorcansmith 0:2a53a4c3238c 208 * We have 254 * 256 possibilities */
lorcansmith 0:2a53a4c3238c 209
lorcansmith 0:2a53a4c3238c 210 u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif));
lorcansmith 0:2a53a4c3238c 211 addr += netif->autoip->tried_llipaddr;
lorcansmith 0:2a53a4c3238c 212 addr = AUTOIP_NET | (addr & 0xffff);
lorcansmith 0:2a53a4c3238c 213 /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */
lorcansmith 0:2a53a4c3238c 214
lorcansmith 0:2a53a4c3238c 215 if (addr < AUTOIP_RANGE_START) {
lorcansmith 0:2a53a4c3238c 216 addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
lorcansmith 0:2a53a4c3238c 217 }
lorcansmith 0:2a53a4c3238c 218 if (addr > AUTOIP_RANGE_END) {
lorcansmith 0:2a53a4c3238c 219 addr -= AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
lorcansmith 0:2a53a4c3238c 220 }
lorcansmith 0:2a53a4c3238c 221 LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) &&
lorcansmith 0:2a53a4c3238c 222 (addr <= AUTOIP_RANGE_END));
lorcansmith 0:2a53a4c3238c 223 ip4_addr_set_u32(ipaddr, htonl(addr));
lorcansmith 0:2a53a4c3238c 224
lorcansmith 0:2a53a4c3238c 225 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 226 ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 227 (u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr),
lorcansmith 0:2a53a4c3238c 228 ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr)));
lorcansmith 0:2a53a4c3238c 229 }
lorcansmith 0:2a53a4c3238c 230
lorcansmith 0:2a53a4c3238c 231 /**
lorcansmith 0:2a53a4c3238c 232 * Sends an ARP probe from a network interface
lorcansmith 0:2a53a4c3238c 233 *
lorcansmith 0:2a53a4c3238c 234 * @param netif network interface used to send the probe
lorcansmith 0:2a53a4c3238c 235 */
lorcansmith 0:2a53a4c3238c 236 static err_t
lorcansmith 0:2a53a4c3238c 237 autoip_arp_probe(struct netif *netif)
lorcansmith 0:2a53a4c3238c 238 {
lorcansmith 0:2a53a4c3238c 239 return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, &ethbroadcast,
lorcansmith 0:2a53a4c3238c 240 (struct eth_addr *)netif->hwaddr, IP_ADDR_ANY, &ethzero,
lorcansmith 0:2a53a4c3238c 241 &netif->autoip->llipaddr, ARP_REQUEST);
lorcansmith 0:2a53a4c3238c 242 }
lorcansmith 0:2a53a4c3238c 243
lorcansmith 0:2a53a4c3238c 244 /**
lorcansmith 0:2a53a4c3238c 245 * Sends an ARP announce from a network interface
lorcansmith 0:2a53a4c3238c 246 *
lorcansmith 0:2a53a4c3238c 247 * @param netif network interface used to send the announce
lorcansmith 0:2a53a4c3238c 248 */
lorcansmith 0:2a53a4c3238c 249 static err_t
lorcansmith 0:2a53a4c3238c 250 autoip_arp_announce(struct netif *netif)
lorcansmith 0:2a53a4c3238c 251 {
lorcansmith 0:2a53a4c3238c 252 return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, &ethbroadcast,
lorcansmith 0:2a53a4c3238c 253 (struct eth_addr *)netif->hwaddr, &netif->autoip->llipaddr, &ethzero,
lorcansmith 0:2a53a4c3238c 254 &netif->autoip->llipaddr, ARP_REQUEST);
lorcansmith 0:2a53a4c3238c 255 }
lorcansmith 0:2a53a4c3238c 256
lorcansmith 0:2a53a4c3238c 257 /**
lorcansmith 0:2a53a4c3238c 258 * Configure interface for use with current LL IP-Address
lorcansmith 0:2a53a4c3238c 259 *
lorcansmith 0:2a53a4c3238c 260 * @param netif network interface to configure with current LL IP-Address
lorcansmith 0:2a53a4c3238c 261 */
lorcansmith 0:2a53a4c3238c 262 static err_t
lorcansmith 0:2a53a4c3238c 263 autoip_bind(struct netif *netif)
lorcansmith 0:2a53a4c3238c 264 {
lorcansmith 0:2a53a4c3238c 265 struct autoip *autoip = netif->autoip;
lorcansmith 0:2a53a4c3238c 266 ip_addr_t sn_mask, gw_addr;
lorcansmith 0:2a53a4c3238c 267
lorcansmith 0:2a53a4c3238c 268 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 269 ("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 270 (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num,
lorcansmith 0:2a53a4c3238c 271 ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr),
lorcansmith 0:2a53a4c3238c 272 ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr)));
lorcansmith 0:2a53a4c3238c 273
lorcansmith 0:2a53a4c3238c 274 IP4_ADDR(&sn_mask, 255, 255, 0, 0);
lorcansmith 0:2a53a4c3238c 275 IP4_ADDR(&gw_addr, 0, 0, 0, 0);
lorcansmith 0:2a53a4c3238c 276
lorcansmith 0:2a53a4c3238c 277 netif_set_ipaddr(netif, &autoip->llipaddr);
lorcansmith 0:2a53a4c3238c 278 netif_set_netmask(netif, &sn_mask);
lorcansmith 0:2a53a4c3238c 279 netif_set_gw(netif, &gw_addr);
lorcansmith 0:2a53a4c3238c 280
lorcansmith 0:2a53a4c3238c 281 /* bring the interface up */
lorcansmith 0:2a53a4c3238c 282 netif_set_up(netif);
lorcansmith 0:2a53a4c3238c 283
lorcansmith 0:2a53a4c3238c 284 return ERR_OK;
lorcansmith 0:2a53a4c3238c 285 }
lorcansmith 0:2a53a4c3238c 286
lorcansmith 0:2a53a4c3238c 287 /**
lorcansmith 0:2a53a4c3238c 288 * Start AutoIP client
lorcansmith 0:2a53a4c3238c 289 *
lorcansmith 0:2a53a4c3238c 290 * @param netif network interface on which start the AutoIP client
lorcansmith 0:2a53a4c3238c 291 */
lorcansmith 0:2a53a4c3238c 292 err_t
lorcansmith 0:2a53a4c3238c 293 autoip_start(struct netif *netif)
lorcansmith 0:2a53a4c3238c 294 {
lorcansmith 0:2a53a4c3238c 295 struct autoip *autoip = netif->autoip;
lorcansmith 0:2a53a4c3238c 296 err_t result = ERR_OK;
lorcansmith 0:2a53a4c3238c 297
lorcansmith 0:2a53a4c3238c 298 if(netif_is_up(netif)) {
lorcansmith 0:2a53a4c3238c 299 netif_set_down(netif);
lorcansmith 0:2a53a4c3238c 300 }
lorcansmith 0:2a53a4c3238c 301
lorcansmith 0:2a53a4c3238c 302 /* Set IP-Address, Netmask and Gateway to 0 to make sure that
lorcansmith 0:2a53a4c3238c 303 * ARP Packets are formed correctly
lorcansmith 0:2a53a4c3238c 304 */
lorcansmith 0:2a53a4c3238c 305 ip_addr_set_zero(&netif->ip_addr);
lorcansmith 0:2a53a4c3238c 306 ip_addr_set_zero(&netif->netmask);
lorcansmith 0:2a53a4c3238c 307 ip_addr_set_zero(&netif->gw);
lorcansmith 0:2a53a4c3238c 308
lorcansmith 0:2a53a4c3238c 309 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 310 ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0],
lorcansmith 0:2a53a4c3238c 311 netif->name[1], (u16_t)netif->num));
lorcansmith 0:2a53a4c3238c 312 if(autoip == NULL) {
lorcansmith 0:2a53a4c3238c 313 /* no AutoIP client attached yet? */
lorcansmith 0:2a53a4c3238c 314 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 315 ("autoip_start(): starting new AUTOIP client\n"));
lorcansmith 0:2a53a4c3238c 316 autoip = (struct autoip *)mem_malloc(sizeof(struct autoip));
lorcansmith 0:2a53a4c3238c 317 if(autoip == NULL) {
lorcansmith 0:2a53a4c3238c 318 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 319 ("autoip_start(): could not allocate autoip\n"));
lorcansmith 0:2a53a4c3238c 320 return ERR_MEM;
lorcansmith 0:2a53a4c3238c 321 }
lorcansmith 0:2a53a4c3238c 322 memset(autoip, 0, sizeof(struct autoip));
lorcansmith 0:2a53a4c3238c 323 /* store this AutoIP client in the netif */
lorcansmith 0:2a53a4c3238c 324 netif->autoip = autoip;
lorcansmith 0:2a53a4c3238c 325 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip"));
lorcansmith 0:2a53a4c3238c 326 } else {
lorcansmith 0:2a53a4c3238c 327 autoip->state = AUTOIP_STATE_OFF;
lorcansmith 0:2a53a4c3238c 328 autoip->ttw = 0;
lorcansmith 0:2a53a4c3238c 329 autoip->sent_num = 0;
lorcansmith 0:2a53a4c3238c 330 ip_addr_set_zero(&autoip->llipaddr);
lorcansmith 0:2a53a4c3238c 331 autoip->lastconflict = 0;
lorcansmith 0:2a53a4c3238c 332 }
lorcansmith 0:2a53a4c3238c 333
lorcansmith 0:2a53a4c3238c 334 autoip_create_addr(netif, &(autoip->llipaddr));
lorcansmith 0:2a53a4c3238c 335 autoip_start_probing(netif);
lorcansmith 0:2a53a4c3238c 336
lorcansmith 0:2a53a4c3238c 337 return result;
lorcansmith 0:2a53a4c3238c 338 }
lorcansmith 0:2a53a4c3238c 339
lorcansmith 0:2a53a4c3238c 340 static void
lorcansmith 0:2a53a4c3238c 341 autoip_start_probing(struct netif *netif)
lorcansmith 0:2a53a4c3238c 342 {
lorcansmith 0:2a53a4c3238c 343 struct autoip *autoip = netif->autoip;
lorcansmith 0:2a53a4c3238c 344
lorcansmith 0:2a53a4c3238c 345 autoip->state = AUTOIP_STATE_PROBING;
lorcansmith 0:2a53a4c3238c 346 autoip->sent_num = 0;
lorcansmith 0:2a53a4c3238c 347 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 348 ("autoip_start_probing(): changing state to PROBING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 349 ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr),
lorcansmith 0:2a53a4c3238c 350 ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr)));
lorcansmith 0:2a53a4c3238c 351
lorcansmith 0:2a53a4c3238c 352 /* time to wait to first probe, this is randomly
lorcansmith 0:2a53a4c3238c 353 * choosen out of 0 to PROBE_WAIT seconds.
lorcansmith 0:2a53a4c3238c 354 * compliant to RFC 3927 Section 2.2.1
lorcansmith 0:2a53a4c3238c 355 */
lorcansmith 0:2a53a4c3238c 356 autoip->ttw = (u16_t)(LWIP_AUTOIP_RAND(netif) % (PROBE_WAIT * AUTOIP_TICKS_PER_SECOND));
lorcansmith 0:2a53a4c3238c 357
lorcansmith 0:2a53a4c3238c 358 /*
lorcansmith 0:2a53a4c3238c 359 * if we tried more then MAX_CONFLICTS we must limit our rate for
lorcansmith 0:2a53a4c3238c 360 * accquiring and probing address
lorcansmith 0:2a53a4c3238c 361 * compliant to RFC 3927 Section 2.2.1
lorcansmith 0:2a53a4c3238c 362 */
lorcansmith 0:2a53a4c3238c 363 if(autoip->tried_llipaddr > MAX_CONFLICTS) {
lorcansmith 0:2a53a4c3238c 364 autoip->ttw = RATE_LIMIT_INTERVAL * AUTOIP_TICKS_PER_SECOND;
lorcansmith 0:2a53a4c3238c 365 }
lorcansmith 0:2a53a4c3238c 366 }
lorcansmith 0:2a53a4c3238c 367
lorcansmith 0:2a53a4c3238c 368 /**
lorcansmith 0:2a53a4c3238c 369 * Handle a possible change in the network configuration.
lorcansmith 0:2a53a4c3238c 370 *
lorcansmith 0:2a53a4c3238c 371 * If there is an AutoIP address configured, take the interface down
lorcansmith 0:2a53a4c3238c 372 * and begin probing with the same address.
lorcansmith 0:2a53a4c3238c 373 */
lorcansmith 0:2a53a4c3238c 374 void
lorcansmith 0:2a53a4c3238c 375 autoip_network_changed(struct netif *netif)
lorcansmith 0:2a53a4c3238c 376 {
lorcansmith 0:2a53a4c3238c 377 if (netif->autoip && netif->autoip->state != AUTOIP_STATE_OFF) {
lorcansmith 0:2a53a4c3238c 378 netif_set_down(netif);
lorcansmith 0:2a53a4c3238c 379 autoip_start_probing(netif);
lorcansmith 0:2a53a4c3238c 380 }
lorcansmith 0:2a53a4c3238c 381 }
lorcansmith 0:2a53a4c3238c 382
lorcansmith 0:2a53a4c3238c 383 /**
lorcansmith 0:2a53a4c3238c 384 * Stop AutoIP client
lorcansmith 0:2a53a4c3238c 385 *
lorcansmith 0:2a53a4c3238c 386 * @param netif network interface on which stop the AutoIP client
lorcansmith 0:2a53a4c3238c 387 */
lorcansmith 0:2a53a4c3238c 388 err_t
lorcansmith 0:2a53a4c3238c 389 autoip_stop(struct netif *netif)
lorcansmith 0:2a53a4c3238c 390 {
lorcansmith 0:2a53a4c3238c 391 netif->autoip->state = AUTOIP_STATE_OFF;
lorcansmith 0:2a53a4c3238c 392 netif_set_down(netif);
lorcansmith 0:2a53a4c3238c 393 return ERR_OK;
lorcansmith 0:2a53a4c3238c 394 }
lorcansmith 0:2a53a4c3238c 395
lorcansmith 0:2a53a4c3238c 396 /**
lorcansmith 0:2a53a4c3238c 397 * Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds
lorcansmith 0:2a53a4c3238c 398 */
lorcansmith 0:2a53a4c3238c 399 void
lorcansmith 0:2a53a4c3238c 400 autoip_tmr()
lorcansmith 0:2a53a4c3238c 401 {
lorcansmith 0:2a53a4c3238c 402 struct netif *netif = netif_list;
lorcansmith 0:2a53a4c3238c 403 /* loop through netif's */
lorcansmith 0:2a53a4c3238c 404 while (netif != NULL) {
lorcansmith 0:2a53a4c3238c 405 /* only act on AutoIP configured interfaces */
lorcansmith 0:2a53a4c3238c 406 if (netif->autoip != NULL) {
lorcansmith 0:2a53a4c3238c 407 if(netif->autoip->lastconflict > 0) {
lorcansmith 0:2a53a4c3238c 408 netif->autoip->lastconflict--;
lorcansmith 0:2a53a4c3238c 409 }
lorcansmith 0:2a53a4c3238c 410
lorcansmith 0:2a53a4c3238c 411 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 412 ("autoip_tmr() AutoIP-State: %"U16_F", ttw=%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 413 (u16_t)(netif->autoip->state), netif->autoip->ttw));
lorcansmith 0:2a53a4c3238c 414
lorcansmith 0:2a53a4c3238c 415 switch(netif->autoip->state) {
lorcansmith 0:2a53a4c3238c 416 case AUTOIP_STATE_PROBING:
lorcansmith 0:2a53a4c3238c 417 if(netif->autoip->ttw > 0) {
lorcansmith 0:2a53a4c3238c 418 netif->autoip->ttw--;
lorcansmith 0:2a53a4c3238c 419 } else {
lorcansmith 0:2a53a4c3238c 420 if(netif->autoip->sent_num >= PROBE_NUM) {
lorcansmith 0:2a53a4c3238c 421 netif->autoip->state = AUTOIP_STATE_ANNOUNCING;
lorcansmith 0:2a53a4c3238c 422 netif->autoip->sent_num = 0;
lorcansmith 0:2a53a4c3238c 423 netif->autoip->ttw = ANNOUNCE_WAIT * AUTOIP_TICKS_PER_SECOND;
lorcansmith 0:2a53a4c3238c 424 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 425 ("autoip_tmr(): changing state to ANNOUNCING: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 426 ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr),
lorcansmith 0:2a53a4c3238c 427 ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr)));
lorcansmith 0:2a53a4c3238c 428 } else {
lorcansmith 0:2a53a4c3238c 429 autoip_arp_probe(netif);
lorcansmith 0:2a53a4c3238c 430 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 431 ("autoip_tmr() PROBING Sent Probe\n"));
lorcansmith 0:2a53a4c3238c 432 netif->autoip->sent_num++;
lorcansmith 0:2a53a4c3238c 433 /* calculate time to wait to next probe */
lorcansmith 0:2a53a4c3238c 434 netif->autoip->ttw = (u16_t)((LWIP_AUTOIP_RAND(netif) %
lorcansmith 0:2a53a4c3238c 435 ((PROBE_MAX - PROBE_MIN) * AUTOIP_TICKS_PER_SECOND) ) +
lorcansmith 0:2a53a4c3238c 436 PROBE_MIN * AUTOIP_TICKS_PER_SECOND);
lorcansmith 0:2a53a4c3238c 437 }
lorcansmith 0:2a53a4c3238c 438 }
lorcansmith 0:2a53a4c3238c 439 break;
lorcansmith 0:2a53a4c3238c 440
lorcansmith 0:2a53a4c3238c 441 case AUTOIP_STATE_ANNOUNCING:
lorcansmith 0:2a53a4c3238c 442 if(netif->autoip->ttw > 0) {
lorcansmith 0:2a53a4c3238c 443 netif->autoip->ttw--;
lorcansmith 0:2a53a4c3238c 444 } else {
lorcansmith 0:2a53a4c3238c 445 if(netif->autoip->sent_num == 0) {
lorcansmith 0:2a53a4c3238c 446 /* We are here the first time, so we waited ANNOUNCE_WAIT seconds
lorcansmith 0:2a53a4c3238c 447 * Now we can bind to an IP address and use it.
lorcansmith 0:2a53a4c3238c 448 *
lorcansmith 0:2a53a4c3238c 449 * autoip_bind calls netif_set_up. This triggers a gratuitous ARP
lorcansmith 0:2a53a4c3238c 450 * which counts as an announcement.
lorcansmith 0:2a53a4c3238c 451 */
lorcansmith 0:2a53a4c3238c 452 autoip_bind(netif);
lorcansmith 0:2a53a4c3238c 453 } else {
lorcansmith 0:2a53a4c3238c 454 autoip_arp_announce(netif);
lorcansmith 0:2a53a4c3238c 455 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
lorcansmith 0:2a53a4c3238c 456 ("autoip_tmr() ANNOUNCING Sent Announce\n"));
lorcansmith 0:2a53a4c3238c 457 }
lorcansmith 0:2a53a4c3238c 458 netif->autoip->ttw = ANNOUNCE_INTERVAL * AUTOIP_TICKS_PER_SECOND;
lorcansmith 0:2a53a4c3238c 459 netif->autoip->sent_num++;
lorcansmith 0:2a53a4c3238c 460
lorcansmith 0:2a53a4c3238c 461 if(netif->autoip->sent_num >= ANNOUNCE_NUM) {
lorcansmith 0:2a53a4c3238c 462 netif->autoip->state = AUTOIP_STATE_BOUND;
lorcansmith 0:2a53a4c3238c 463 netif->autoip->sent_num = 0;
lorcansmith 0:2a53a4c3238c 464 netif->autoip->ttw = 0;
lorcansmith 0:2a53a4c3238c 465 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
lorcansmith 0:2a53a4c3238c 466 ("autoip_tmr(): changing state to BOUND: %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
lorcansmith 0:2a53a4c3238c 467 ip4_addr1_16(&netif->autoip->llipaddr), ip4_addr2_16(&netif->autoip->llipaddr),
lorcansmith 0:2a53a4c3238c 468 ip4_addr3_16(&netif->autoip->llipaddr), ip4_addr4_16(&netif->autoip->llipaddr)));
lorcansmith 0:2a53a4c3238c 469 }
lorcansmith 0:2a53a4c3238c 470 }
lorcansmith 0:2a53a4c3238c 471 break;
lorcansmith 0:2a53a4c3238c 472 }
lorcansmith 0:2a53a4c3238c 473 }
lorcansmith 0:2a53a4c3238c 474 /* proceed to next network interface */
lorcansmith 0:2a53a4c3238c 475 netif = netif->next;
lorcansmith 0:2a53a4c3238c 476 }
lorcansmith 0:2a53a4c3238c 477 }
lorcansmith 0:2a53a4c3238c 478
lorcansmith 0:2a53a4c3238c 479 /**
lorcansmith 0:2a53a4c3238c 480 * Handles every incoming ARP Packet, called by etharp_arp_input.
lorcansmith 0:2a53a4c3238c 481 *
lorcansmith 0:2a53a4c3238c 482 * @param netif network interface to use for autoip processing
lorcansmith 0:2a53a4c3238c 483 * @param hdr Incoming ARP packet
lorcansmith 0:2a53a4c3238c 484 */
lorcansmith 0:2a53a4c3238c 485 void
lorcansmith 0:2a53a4c3238c 486 autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
lorcansmith 0:2a53a4c3238c 487 {
lorcansmith 0:2a53a4c3238c 488 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_arp_reply()\n"));
lorcansmith 0:2a53a4c3238c 489 if ((netif->autoip != NULL) && (netif->autoip->state != AUTOIP_STATE_OFF)) {
lorcansmith 0:2a53a4c3238c 490 /* when ip.src == llipaddr && hw.src != netif->hwaddr
lorcansmith 0:2a53a4c3238c 491 *
lorcansmith 0:2a53a4c3238c 492 * when probing ip.dst == llipaddr && hw.src != netif->hwaddr
lorcansmith 0:2a53a4c3238c 493 * we have a conflict and must solve it
lorcansmith 0:2a53a4c3238c 494 */
lorcansmith 0:2a53a4c3238c 495 ip_addr_t sipaddr, dipaddr;
lorcansmith 0:2a53a4c3238c 496 struct eth_addr netifaddr;
lorcansmith 0:2a53a4c3238c 497 netifaddr.addr[0] = netif->hwaddr[0];
lorcansmith 0:2a53a4c3238c 498 netifaddr.addr[1] = netif->hwaddr[1];
lorcansmith 0:2a53a4c3238c 499 netifaddr.addr[2] = netif->hwaddr[2];
lorcansmith 0:2a53a4c3238c 500 netifaddr.addr[3] = netif->hwaddr[3];
lorcansmith 0:2a53a4c3238c 501 netifaddr.addr[4] = netif->hwaddr[4];
lorcansmith 0:2a53a4c3238c 502 netifaddr.addr[5] = netif->hwaddr[5];
lorcansmith 0:2a53a4c3238c 503
lorcansmith 0:2a53a4c3238c 504 /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without
lorcansmith 0:2a53a4c3238c 505 * structure packing (not using structure copy which breaks strict-aliasing rules).
lorcansmith 0:2a53a4c3238c 506 */
lorcansmith 0:2a53a4c3238c 507 IPADDR2_COPY(&sipaddr, &hdr->sipaddr);
lorcansmith 0:2a53a4c3238c 508 IPADDR2_COPY(&dipaddr, &hdr->dipaddr);
lorcansmith 0:2a53a4c3238c 509
lorcansmith 0:2a53a4c3238c 510 if ((netif->autoip->state == AUTOIP_STATE_PROBING) ||
lorcansmith 0:2a53a4c3238c 511 ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) &&
lorcansmith 0:2a53a4c3238c 512 (netif->autoip->sent_num == 0))) {
lorcansmith 0:2a53a4c3238c 513 /* RFC 3927 Section 2.2.1:
lorcansmith 0:2a53a4c3238c 514 * from beginning to after ANNOUNCE_WAIT
lorcansmith 0:2a53a4c3238c 515 * seconds we have a conflict if
lorcansmith 0:2a53a4c3238c 516 * ip.src == llipaddr OR
lorcansmith 0:2a53a4c3238c 517 * ip.dst == llipaddr && hw.src != own hwaddr
lorcansmith 0:2a53a4c3238c 518 */
lorcansmith 0:2a53a4c3238c 519 if ((ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) ||
lorcansmith 0:2a53a4c3238c 520 (ip_addr_cmp(&dipaddr, &netif->autoip->llipaddr) &&
lorcansmith 0:2a53a4c3238c 521 !eth_addr_cmp(&netifaddr, &hdr->shwaddr))) {
lorcansmith 0:2a53a4c3238c 522 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
lorcansmith 0:2a53a4c3238c 523 ("autoip_arp_reply(): Probe Conflict detected\n"));
lorcansmith 0:2a53a4c3238c 524 autoip_restart(netif);
lorcansmith 0:2a53a4c3238c 525 }
lorcansmith 0:2a53a4c3238c 526 } else {
lorcansmith 0:2a53a4c3238c 527 /* RFC 3927 Section 2.5:
lorcansmith 0:2a53a4c3238c 528 * in any state we have a conflict if
lorcansmith 0:2a53a4c3238c 529 * ip.src == llipaddr && hw.src != own hwaddr
lorcansmith 0:2a53a4c3238c 530 */
lorcansmith 0:2a53a4c3238c 531 if (ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr) &&
lorcansmith 0:2a53a4c3238c 532 !eth_addr_cmp(&netifaddr, &hdr->shwaddr)) {
lorcansmith 0:2a53a4c3238c 533 LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
lorcansmith 0:2a53a4c3238c 534 ("autoip_arp_reply(): Conflicting ARP-Packet detected\n"));
lorcansmith 0:2a53a4c3238c 535 autoip_handle_arp_conflict(netif);
lorcansmith 0:2a53a4c3238c 536 }
lorcansmith 0:2a53a4c3238c 537 }
lorcansmith 0:2a53a4c3238c 538 }
lorcansmith 0:2a53a4c3238c 539 }
lorcansmith 0:2a53a4c3238c 540
lorcansmith 0:2a53a4c3238c 541 #endif /* LWIP_AUTOIP */