source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifiHD/src/SOFTWARE_FRAMEWORK/SERVICES/LWIP/lwip-1.3.2/src/include/ipv4/lwip/autoip.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 4.4 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/**
4 * @file
5 *
6 * AutoIP Automatic LinkLocal IP Configuration
7 */
8
9/*
10 *
11 * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright notice,
18 *    this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 *    this list of conditions and the following disclaimer in the documentation
21 *    and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 *    derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
28 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 * OF SUCH DAMAGE.
35 *
36 * Author: Dominik Spies <kontakt@dspies.de>
37 *
38 * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
39 * with RFC 3927.
40 *
41 *
42 * Please coordinate changes and requests with Dominik Spies
43 * <kontakt@dspies.de>
44 */
45 
46#ifndef __LWIP_AUTOIP_H__
47#define __LWIP_AUTOIP_H__
48
49#include "lwip/opt.h"
50
51#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
52
53#include "lwip/netif.h"
54#include "lwip/udp.h"
55#include "netif/etharp.h"
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/* AutoIP Timing */
62#define AUTOIP_TMR_INTERVAL      100
63#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
64
65/* RFC 3927 Constants */
66#define PROBE_WAIT               1   /* second   (initial random delay)                 */
67#define PROBE_MIN                1   /* second   (minimum delay till repeated probe)    */
68#define PROBE_MAX                2   /* seconds  (maximum delay till repeated probe)    */
69#define PROBE_NUM                3   /*          (number of probe packets)              */
70#define ANNOUNCE_NUM             2   /*          (number of announcement packets)       */
71#define ANNOUNCE_INTERVAL        2   /* seconds  (time between announcement packets)    */
72#define ANNOUNCE_WAIT            2   /* seconds  (delay before announcing)              */
73#define MAX_CONFLICTS            10  /*          (max conflicts before rate limiting)   */
74#define RATE_LIMIT_INTERVAL      60  /* seconds  (delay between successive attempts)    */
75#define DEFEND_INTERVAL          10  /* seconds  (min. wait between defensive ARPs)     */
76
77/* AutoIP client states */
78#define AUTOIP_STATE_OFF         0
79#define AUTOIP_STATE_PROBING     1
80#define AUTOIP_STATE_ANNOUNCING  2
81#define AUTOIP_STATE_BOUND       3
82
83struct autoip
84{
85  struct ip_addr llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
86  u8_t state;               /* current AutoIP state machine state */
87  u8_t sent_num;            /* sent number of probes or announces, dependent on state */
88  u16_t ttw;                /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
89  u8_t lastconflict;        /* ticks until a conflict can be solved by defending */
90  u8_t tried_llipaddr;      /* total number of probed/used Link Local IP-Addresses */
91};
92
93
94/** Init srand, has to be called before entering mainloop */
95void autoip_init(void);
96
97/** Start AutoIP client */
98err_t autoip_start(struct netif *netif);
99
100/** Stop AutoIP client */
101err_t autoip_stop(struct netif *netif);
102
103/** Handles every incoming ARP Packet, called by etharp_arp_input */
104void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
105
106/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
107void autoip_tmr(void);
108
109/** Handle a possible change in the network configuration */
110void autoip_network_changed(struct netif *netif);
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif /* LWIP_AUTOIP */
117
118#endif /* __LWIP_AUTOIP_H__ */
Note: See TracBrowser for help on using the repository browser.