Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers libDHCPv6_server.h Source File

libDHCPv6_server.h

00001 /*
00002  * Copyright (c) 2014-2015, 2017-2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * \file libDHCPv6_server.h
00020  * \brief Add short description about this file!!!
00021  *
00022  */
00023 
00024 #ifndef LIBDHCPV6_SERVER_H_
00025 #define LIBDHCPV6_SERVER_H_
00026 #ifdef HAVE_DHCPV6_SERVER
00027 #include "ns_list.h"
00028 
00029 #include "libDHCPv6/libDHCPv6.h"
00030 
00031 typedef void (dhcp_address_prefer_remove_cb)(int8_t interfaceId, uint8_t *targetAddress, void *prefix_info);
00032 
00033 typedef struct dhcpv6_alloacted_address_entry_s {
00034     uint8_t             nonTemporalAddress[16];
00035     uint8_t             linkId[8];  /*!< Services UL64 */
00036     uint16_t            linkType;
00037     uint32_t            iaID;
00038     uint32_t            T0;
00039     uint32_t            T1;
00040     uint32_t            preferredLifetime;
00041     uint32_t            lifetime;
00042     ns_list_link_t      link;               /*!< List link entry */
00043 } dhcpv6_alloacted_address_entry_t;
00044 
00045 typedef NS_LIST_HEAD (dhcpv6_alloacted_address_entry_t, link) dhcpv6_alloacted_address_list_t;
00046 
00047 typedef struct thread_dhcpv6_server_data_s {
00048     uint8_t           prefix[8];    /*!< Services Prefix */
00049     uint16_t          maxSuppertedClients;
00050     uint32_t          clientIdSequence;     /*!< Define  */
00051     dhcpv6_alloacted_address_list_t allocatedAddressList;
00052     ns_list_link_t      link;               /*!< List link entry */
00053 } dhcpv6_server_data_entry_t;
00054 
00055 typedef struct dhcp_address_cache_update {
00056     uint8_t *allocatedAddress;
00057     bool    allocatedNewAddress;
00058     uint32_t validLifeTime;
00059 } dhcp_address_cache_update_t;
00060 
00061 typedef bool (dhcp_address_add_notify_cb)(int8_t interfaceId, dhcp_address_cache_update_t *address_info, void *route_src);
00062 
00063 typedef struct dhcpv6_gua_server_entry_s {
00064     int8_t                          interfaceId;
00065     bool                            enableAddressAutonous;
00066     uint16_t                        socketInstance_id;
00067     uint8_t                         guaPrefix[8];
00068     uint8_t                         serverDynamic_DUID_length;
00069     uint32_t                        maxSuppertedClients;
00070     uint32_t                        clientIdDefaultSuffics;
00071     uint32_t                        clientIdSequence;       /*!< Define  */
00072     uint32_t                        validLifetime;
00073     dhcp_duid_options_params_t      serverDUID;
00074     uint8_t                         *serverDynamic_DUID;
00075     dhcp_address_prefer_remove_cb   *removeCb;
00076     dhcp_address_add_notify_cb *addCb;
00077     dhcpv6_alloacted_address_list_t allocatedAddressList;
00078     ns_list_link_t      link;                   /*!< List link entry */
00079 } dhcpv6_gua_server_entry_s;
00080 
00081 bool libdhcpv6_gua_server_list_empty(void);
00082 dhcpv6_gua_server_entry_s *libdhcpv6_gua_server_allocate(uint8_t *prefix, int8_t interfaceId, uint8_t *serverDUID, uint16_t serverDUIDType);
00083 int libdhcpv6_server_duid_set(dhcpv6_gua_server_entry_s *server_info, uint8_t *duid_ptr, uint16_t duid_type, uint8_t duid_length);
00084 void libdhcpv6_gua_server_free_by_prefix_and_interfaceid(uint8_t *prefix, int8_t interfaceId);
00085 void libdhcpv6_gua_servers_time_update(uint32_t timeUpdateInSeconds);
00086 void libdhcpv6_address_rm_from_allocated_list(dhcpv6_gua_server_entry_s *serverInfo, const uint8_t *address);
00087 dhcpv6_alloacted_address_entry_t *libdhcpv6_address_get_from_allocated_list(dhcpv6_gua_server_entry_s *serverInfo, const uint8_t *address);
00088 dhcpv6_gua_server_entry_s *libdhcpv6_server_data_get_by_prefix_and_interfaceid(int8_t interfaceId, const uint8_t *prefixPtr);
00089 dhcpv6_gua_server_entry_s *libdhcpv6_server_data_get_by_prefix_and_socketinstance(uint16_t socketInstance, uint8_t *prefixPtr);
00090 dhcpv6_alloacted_address_entry_t *libdhcpv6_address_allocated_list_scan(dhcpv6_gua_server_entry_s *serverInfo, uint8_t *euid64, uint16_t linkType, uint32_t iaID, uint32_t T0, uint32_t T1, bool allocateNew);
00091 #else
00092 #define libdhcpv6_gua_server_list_empty() true
00093 #define libdhcpv6_server_data_get_by_prefix_and_interfaceid(interfaceId, prefixPtr) NULL
00094 #define libdhcpv6_server_data_get_by_prefix_and_socketinstance(socketInstance, prefixPtr) NULL
00095 #define libdhcpv6_gua_server_allocate(prefix, interfaceId, serverDUID, serverDUIDType) NULL
00096 #define libdhcpv6_gua_server_free_by_prefix_and_interfaceid(prefix, interfaceId) ((void)0)
00097 #define libdhcpv6_gua_servers_time_update(timeUpdateInSeconds) ((void)0)
00098 #define libdhcpv6_gua_server_free_by_interfaceid(interfaceId) ((void)0)
00099 #define libdhcpv6_address_get_from_allocated_list(serverInfo, address) NULL
00100 #define libdhcpv6_address_rm_from_allocated_list(serverInfo, address) ((void)0)
00101 #define libdhcpv6_address_allocated_list_scan( serverInfo, linkId, linkType, iaID, T0, T1, allocateNew) NULL
00102 #endif
00103 
00104 #endif /* LIBDHCPV6_SERVER_H_ */