xref: /minix3/minix/lib/liblwip/dist/src/include/lwip/autoip.h (revision 5d5fbe79c1b60734f34c69330aec5496644e8651)
1*5d5fbe79SDavid van Moolenbroek /**
2*5d5fbe79SDavid van Moolenbroek  * @file
3*5d5fbe79SDavid van Moolenbroek  *
4*5d5fbe79SDavid van Moolenbroek  * AutoIP Automatic LinkLocal IP Configuration
5*5d5fbe79SDavid van Moolenbroek  */
6*5d5fbe79SDavid van Moolenbroek 
7*5d5fbe79SDavid van Moolenbroek /*
8*5d5fbe79SDavid van Moolenbroek  *
9*5d5fbe79SDavid van Moolenbroek  * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
10*5d5fbe79SDavid van Moolenbroek  * All rights reserved.
11*5d5fbe79SDavid van Moolenbroek  *
12*5d5fbe79SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without modification,
13*5d5fbe79SDavid van Moolenbroek  * are permitted provided that the following conditions are met:
14*5d5fbe79SDavid van Moolenbroek  *
15*5d5fbe79SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright notice,
16*5d5fbe79SDavid van Moolenbroek  *    this list of conditions and the following disclaimer.
17*5d5fbe79SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce the above copyright notice,
18*5d5fbe79SDavid van Moolenbroek  *    this list of conditions and the following disclaimer in the documentation
19*5d5fbe79SDavid van Moolenbroek  *    and/or other materials provided with the distribution.
20*5d5fbe79SDavid van Moolenbroek  * 3. The name of the author may not be used to endorse or promote products
21*5d5fbe79SDavid van Moolenbroek  *    derived from this software without specific prior written permission.
22*5d5fbe79SDavid van Moolenbroek  *
23*5d5fbe79SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24*5d5fbe79SDavid van Moolenbroek  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25*5d5fbe79SDavid van Moolenbroek  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26*5d5fbe79SDavid van Moolenbroek  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27*5d5fbe79SDavid van Moolenbroek  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28*5d5fbe79SDavid van Moolenbroek  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29*5d5fbe79SDavid van Moolenbroek  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30*5d5fbe79SDavid van Moolenbroek  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31*5d5fbe79SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32*5d5fbe79SDavid van Moolenbroek  * OF SUCH DAMAGE.
33*5d5fbe79SDavid van Moolenbroek  *
34*5d5fbe79SDavid van Moolenbroek  * Author: Dominik Spies <kontakt@dspies.de>
35*5d5fbe79SDavid van Moolenbroek  *
36*5d5fbe79SDavid van Moolenbroek  * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
37*5d5fbe79SDavid van Moolenbroek  * with RFC 3927.
38*5d5fbe79SDavid van Moolenbroek  *
39*5d5fbe79SDavid van Moolenbroek  */
40*5d5fbe79SDavid van Moolenbroek 
41*5d5fbe79SDavid van Moolenbroek #ifndef LWIP_HDR_AUTOIP_H
42*5d5fbe79SDavid van Moolenbroek #define LWIP_HDR_AUTOIP_H
43*5d5fbe79SDavid van Moolenbroek 
44*5d5fbe79SDavid van Moolenbroek #include "lwip/opt.h"
45*5d5fbe79SDavid van Moolenbroek 
46*5d5fbe79SDavid van Moolenbroek #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
47*5d5fbe79SDavid van Moolenbroek 
48*5d5fbe79SDavid van Moolenbroek #include "lwip/netif.h"
49*5d5fbe79SDavid van Moolenbroek /* #include "lwip/udp.h" */
50*5d5fbe79SDavid van Moolenbroek #include "lwip/etharp.h"
51*5d5fbe79SDavid van Moolenbroek 
52*5d5fbe79SDavid van Moolenbroek #ifdef __cplusplus
53*5d5fbe79SDavid van Moolenbroek extern "C" {
54*5d5fbe79SDavid van Moolenbroek #endif
55*5d5fbe79SDavid van Moolenbroek 
56*5d5fbe79SDavid van Moolenbroek /** AutoIP Timing */
57*5d5fbe79SDavid van Moolenbroek #define AUTOIP_TMR_INTERVAL      100
58*5d5fbe79SDavid van Moolenbroek #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
59*5d5fbe79SDavid van Moolenbroek 
60*5d5fbe79SDavid van Moolenbroek /** AutoIP state information per netif */
61*5d5fbe79SDavid van Moolenbroek struct autoip
62*5d5fbe79SDavid van Moolenbroek {
63*5d5fbe79SDavid van Moolenbroek   /** the currently selected, probed, announced or used LL IP-Address */
64*5d5fbe79SDavid van Moolenbroek   ip4_addr_t llipaddr;
65*5d5fbe79SDavid van Moolenbroek   /** current AutoIP state machine state */
66*5d5fbe79SDavid van Moolenbroek   u8_t state;
67*5d5fbe79SDavid van Moolenbroek   /** sent number of probes or announces, dependent on state */
68*5d5fbe79SDavid van Moolenbroek   u8_t sent_num;
69*5d5fbe79SDavid van Moolenbroek   /** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
70*5d5fbe79SDavid van Moolenbroek   u16_t ttw;
71*5d5fbe79SDavid van Moolenbroek   /** ticks until a conflict can be solved by defending */
72*5d5fbe79SDavid van Moolenbroek   u8_t lastconflict;
73*5d5fbe79SDavid van Moolenbroek   /** total number of probed/used Link Local IP-Addresses */
74*5d5fbe79SDavid van Moolenbroek   u8_t tried_llipaddr;
75*5d5fbe79SDavid van Moolenbroek };
76*5d5fbe79SDavid van Moolenbroek 
77*5d5fbe79SDavid van Moolenbroek 
78*5d5fbe79SDavid van Moolenbroek void autoip_set_struct(struct netif *netif, struct autoip *autoip);
79*5d5fbe79SDavid van Moolenbroek /** Remove a struct autoip previously set to the netif using autoip_set_struct() */
80*5d5fbe79SDavid van Moolenbroek #define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0)
81*5d5fbe79SDavid van Moolenbroek err_t autoip_start(struct netif *netif);
82*5d5fbe79SDavid van Moolenbroek err_t autoip_stop(struct netif *netif);
83*5d5fbe79SDavid van Moolenbroek void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
84*5d5fbe79SDavid van Moolenbroek void autoip_tmr(void);
85*5d5fbe79SDavid van Moolenbroek void autoip_network_changed(struct netif *netif);
86*5d5fbe79SDavid van Moolenbroek u8_t autoip_supplied_address(const struct netif *netif);
87*5d5fbe79SDavid van Moolenbroek 
88*5d5fbe79SDavid van Moolenbroek /* for lwIP internal use by ip4.c */
89*5d5fbe79SDavid van Moolenbroek u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);
90*5d5fbe79SDavid van Moolenbroek 
91*5d5fbe79SDavid van Moolenbroek #define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
92*5d5fbe79SDavid van Moolenbroek 
93*5d5fbe79SDavid van Moolenbroek #ifdef __cplusplus
94*5d5fbe79SDavid van Moolenbroek }
95*5d5fbe79SDavid van Moolenbroek #endif
96*5d5fbe79SDavid van Moolenbroek 
97*5d5fbe79SDavid van Moolenbroek #endif /* LWIP_IPV4 && LWIP_AUTOIP */
98*5d5fbe79SDavid van Moolenbroek 
99*5d5fbe79SDavid van Moolenbroek #endif /* LWIP_HDR_AUTOIP_H */
100