xref: /btstack/3rd-party/lwip/core/src/include/lwip/autoip.h (revision 97dc5e692c7d94a280158af58036a0efee5b0e56)
1 /**
2  * @file
3  *
4  * AutoIP Automatic LinkLocal IP Configuration
5  */
6 
7 /*
8  *
9  * Copyright (c) 2007 Dominik Spies <[email protected]>
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,
13  * are permitted provided that the following conditions are met:
14  *
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.
22  *
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
32  * OF SUCH DAMAGE.
33  *
34  * Author: Dominik Spies <[email protected]>
35  *
36  * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
37  * with RFC 3927.
38  *
39  */
40 
41 #ifndef LWIP_HDR_AUTOIP_H
42 #define LWIP_HDR_AUTOIP_H
43 
44 #include "lwip/opt.h"
45 
46 #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
47 
48 #include "lwip/netif.h"
49 /* #include "lwip/udp.h" */
50 #include "lwip/etharp.h"
51 #include "lwip/acd.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /** AutoIP state information per netif */
58 struct autoip
59 {
60   /** the currently selected, probed, announced or used LL IP-Address */
61   ip4_addr_t llipaddr;
62   /** current AutoIP state machine state */
63   u8_t state;
64   /** total number of probed/used Link Local IP-Addresses */
65   u8_t tried_llipaddr;
66   /** acd struct */
67   struct acd acd;
68 };
69 
70 
71 void autoip_set_struct(struct netif *netif, struct autoip *autoip);
72 /** Remove a struct autoip previously set to the netif using autoip_set_struct() */
73 #define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0)
74 err_t autoip_start(struct netif *netif);
75 err_t autoip_stop(struct netif *netif);
76 void autoip_network_changed_link_up(struct netif *netif);
77 void autoip_network_changed_link_down(struct netif *netif);
78 u8_t autoip_supplied_address(struct netif *netif);
79 
80 /* for lwIP internal use by ip4.c */
81 u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);
82 
83 #define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* LWIP_IPV4 && LWIP_AUTOIP */
90 
91 #endif /* LWIP_HDR_AUTOIP_H */
92