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