Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dhcp6.h Source File

dhcp6.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  *
00004  * DHCPv6 client: IPv6 address autoconfiguration as per
00005  * RFC 3315 (stateful DHCPv6) and
00006  * RFC 3736 (stateless DHCPv6).
00007  */
00008 
00009 /*
00010  * Copyright (c) 2018 Simon Goldschmidt
00011  * All rights reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without modification,
00014  * are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  * 2. Redistributions in binary form must reproduce the above copyright notice,
00019  *    this list of conditions and the following disclaimer in the documentation
00020  *    and/or other materials provided with the distribution.
00021  * 3. The name of the author may not be used to endorse or promote products
00022  *    derived from this software without specific prior written permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00025  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00026  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00027  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00028  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00029  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00032  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00033  * OF SUCH DAMAGE.
00034  *
00035  * This file is part of the lwIP TCP/IP stack.
00036  *
00037  * Author: Simon Goldschmidt <goldsimon@gmx.de>
00038  */
00039 
00040 #ifndef LWIP_HDR_IP6_DHCP6_H
00041 #define LWIP_HDR_IP6_DHCP6_H
00042 
00043 #include "lwip/opt.h"
00044 
00045 #if LWIP_IPV6_DHCP6  /* don't build if not configured for use in lwipopts.h */
00046 
00047 #include "lwip/err.h"
00048 #include "lwip/netif.h"
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 
00054 /** period (in milliseconds) of the application calling dhcp6_tmr() */
00055 #define DHCP6_TIMER_MSECS   500
00056 
00057 struct dhcp6
00058 {
00059   /** transaction identifier of last sent request */
00060   u32_t xid;
00061   /** track PCB allocation state */
00062   u8_t pcb_allocated;
00063   /** current DHCPv6 state machine state */
00064   u8_t state;
00065   /** retries of current request */
00066   u8_t tries;
00067   /** if request config is triggered while another action is active, this keeps track of it */
00068   u8_t request_config_pending;
00069   /** #ticks with period DHCP6_TIMER_MSECS for request timeout */
00070   u16_t request_timeout;
00071 #if LWIP_IPV6_DHCP6_STATEFUL
00072   /* @todo: add more members here to keep track of stateful DHCPv6 data, like lease times */
00073 #endif /* LWIP_IPV6_DHCP6_STATEFUL */
00074 };
00075 
00076 void dhcp6_set_struct(struct netif *netif, struct dhcp6 *dhcp6);
00077 /** Remove a struct dhcp6 previously set to the netif using dhcp6_set_struct() */
00078 #define dhcp6_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6, NULL)
00079 void dhcp6_cleanup(struct netif *netif);
00080 
00081 err_t dhcp6_enable_stateful(struct netif *netif);
00082 err_t dhcp6_enable_stateless(struct netif *netif);
00083 void dhcp6_disable(struct netif *netif);
00084 
00085 void dhcp6_tmr(void);
00086 
00087 void dhcp6_nd6_ra_trigger(struct netif *netif, u8_t managed_addr_config, u8_t other_config);
00088 
00089 #if LWIP_DHCP6_GET_NTP_SRV
00090 /** This function must exist, in other to add offered NTP servers to
00091  * the NTP (or SNTP) engine.
00092  * See LWIP_DHCP6_MAX_NTP_SERVERS */
00093 extern void dhcp6_set_ntp_servers(u8_t num_ntp_servers, const ip_addr_t* ntp_server_addrs);
00094 #endif /* LWIP_DHCP6_GET_NTP_SRV */
00095 
00096 #define netif_dhcp6_data(netif) ((struct dhcp6*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6))
00097 
00098 #ifdef __cplusplus
00099 }
00100 #endif
00101 
00102 #endif /* LWIP_IPV6_DHCP6 */
00103 
00104 #endif /* LWIP_HDR_IP6_DHCP6_H */