1 | /**
|
---|
2 | * @file
|
---|
3 | *
|
---|
4 | * DHCPv6 client: IPv6 address autoconfiguration as per
|
---|
5 | * RFC 3315 (stateful DHCPv6) and
|
---|
6 | * RFC 3736 (stateless DHCPv6).
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (c) 2018 Simon Goldschmidt
|
---|
11 | * All rights reserved.
|
---|
12 | *
|
---|
13 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
14 | * are permitted provided that the following conditions are met:
|
---|
15 | *
|
---|
16 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
17 | * this list of conditions and the following disclaimer.
|
---|
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
19 | * this list of conditions and the following disclaimer in the documentation
|
---|
20 | * and/or other materials provided with the distribution.
|
---|
21 | * 3. The name of the author may not be used to endorse or promote products
|
---|
22 | * derived from this software without specific prior written permission.
|
---|
23 | *
|
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
---|
25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
---|
27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
---|
29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
---|
33 | * OF SUCH DAMAGE.
|
---|
34 | *
|
---|
35 | * This file is part of the lwIP TCP/IP stack.
|
---|
36 | *
|
---|
37 | * Author: Simon Goldschmidt <goldsimon@gmx.de>
|
---|
38 | */
|
---|
39 |
|
---|
40 | #ifndef LWIP_HDR_IP6_DHCP6_H
|
---|
41 | #define LWIP_HDR_IP6_DHCP6_H
|
---|
42 |
|
---|
43 | #include "lwip/opt.h"
|
---|
44 |
|
---|
45 | #if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */
|
---|
46 |
|
---|
47 | #include "lwip/err.h"
|
---|
48 | #include "lwip/netif.h"
|
---|
49 |
|
---|
50 | #ifdef __cplusplus
|
---|
51 | extern "C" {
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | /** period (in milliseconds) of the application calling dhcp6_tmr() */
|
---|
55 | #define DHCP6_TIMER_MSECS 500
|
---|
56 |
|
---|
57 | struct dhcp6
|
---|
58 | {
|
---|
59 | /** transaction identifier of last sent request */
|
---|
60 | u32_t xid;
|
---|
61 | /** track PCB allocation state */
|
---|
62 | u8_t pcb_allocated;
|
---|
63 | /** current DHCPv6 state machine state */
|
---|
64 | u8_t state;
|
---|
65 | /** retries of current request */
|
---|
66 | u8_t tries;
|
---|
67 | /** if request config is triggered while another action is active, this keeps track of it */
|
---|
68 | u8_t request_config_pending;
|
---|
69 | /** #ticks with period DHCP6_TIMER_MSECS for request timeout */
|
---|
70 | u16_t request_timeout;
|
---|
71 | #if LWIP_IPV6_DHCP6_STATEFUL
|
---|
72 | /* @todo: add more members here to keep track of stateful DHCPv6 data, like lease times */
|
---|
73 | #endif /* LWIP_IPV6_DHCP6_STATEFUL */
|
---|
74 | };
|
---|
75 |
|
---|
76 | void dhcp6_set_struct(struct netif *netif, struct dhcp6 *dhcp6);
|
---|
77 | /** Remove a struct dhcp6 previously set to the netif using dhcp6_set_struct() */
|
---|
78 | #define dhcp6_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6, NULL)
|
---|
79 | void dhcp6_cleanup(struct netif *netif);
|
---|
80 |
|
---|
81 | err_t dhcp6_enable_stateful(struct netif *netif);
|
---|
82 | err_t dhcp6_enable_stateless(struct netif *netif);
|
---|
83 | void dhcp6_disable(struct netif *netif);
|
---|
84 |
|
---|
85 | void dhcp6_tmr(void);
|
---|
86 |
|
---|
87 | void dhcp6_nd6_ra_trigger(struct netif *netif, u8_t managed_addr_config, u8_t other_config);
|
---|
88 |
|
---|
89 | #if LWIP_DHCP6_GET_NTP_SRV
|
---|
90 | /** This function must exist, in other to add offered NTP servers to
|
---|
91 | * the NTP (or SNTP) engine.
|
---|
92 | * See LWIP_DHCP6_MAX_NTP_SERVERS */
|
---|
93 | extern void dhcp6_set_ntp_servers(u8_t num_ntp_servers, const ip_addr_t* ntp_server_addrs);
|
---|
94 | #endif /* LWIP_DHCP6_GET_NTP_SRV */
|
---|
95 |
|
---|
96 | #define netif_dhcp6_data(netif) ((struct dhcp6*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6))
|
---|
97 |
|
---|
98 | #ifdef __cplusplus
|
---|
99 | }
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | #endif /* LWIP_IPV6_DHCP6 */
|
---|
103 |
|
---|
104 | #endif /* LWIP_HDR_IP6_DHCP6_H */
|
---|