1 /***************************************************************************/ /** 2 * @file sl_net_dns.h 3 ******************************************************************************* 4 * # License 5 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> 6 ******************************************************************************* 7 * 8 * SPDX-License-Identifier: Zlib 9 * 10 * The licensor of this software is Silicon Laboratories Inc. 11 * 12 * This software is provided 'as-is', without any express or implied 13 * warranty. In no event will the authors be held liable for any damages 14 * arising from the use of this software. 15 * 16 * Permission is granted to anyone to use this software for any purpose, 17 * including commercial applications, and to alter it and redistribute it 18 * freely, subject to the following restrictions: 19 * 20 * 1. The origin of this software must not be misrepresented; you must not 21 * claim that you wrote the original software. If you use this software 22 * in a product, an acknowledgment in the product documentation would be 23 * appreciated but is not required. 24 * 2. Altered source versions must be plainly marked as such, and must not be 25 * misrepresented as being the original software. 26 * 3. This notice may not be removed or altered from any source distribution. 27 * 28 ******************************************************************************/ 29 30 #pragma once 31 32 #include "sl_ip_types.h" 33 #include "sl_status.h" 34 #include "sl_net_constants.h" 35 36 /** \addtogroup SL_NET_TYPES Types 37 * @{ */ 38 39 /** 40 * @brief Structure to hold DNS server addresses for configuration. 41 * 42 * @details 43 * This structure contains pointers to the primary and secondary DNS server addresses. 44 * It is used as a parameter in the sl_net_set_dns_server function to set the DNS server IP addresses. 45 */ 46 typedef struct { 47 sl_ip_address_t *primary_server_address; ///< Primary DNS server address 48 sl_ip_address_t *secondary_server_address; ///< Secondary DNS server address 49 } sl_net_dns_address_t; 50 51 /** @} */ 52 53 /** 54 * \addtogroup NET_INTERFACE_FUNCTIONS Network Interface 55 * \ingroup SL_NET_FUNCTIONS 56 * @{ */ 57 58 /** 59 * @brief 60 * Resolve the given host name to an IP address. 61 * 62 * @details 63 * This function resolves a host name to its corresponding IP address. It requires 64 * the DNS client feature to be enabled in the TCP/IP feature bitmap before calling. 65 * 66 67 * 68 * @pre Pre-conditions: 69 * - The [SL_SI91X_TCP_IP_FEAT_DNS_CLIENT](../wiseconnect-api-reference-guide-si91x-driver/si91-x-tcp-ip-feature-bitmap#sl-si91-x-tcp-ip-feat-dns-client) bit should be enabled in the TCP/IP feature bitmap. 70 * 71 * @param[in] host_name 72 * Host name that needs to be resolved. 73 * @param[in] timeout 74 * Timeout in milliseconds. 75 * - If the timeout value is greater than zero, the caller will be blocked until the timeout period to get the response. 76 * - If the value is zero, the response will be sent through @ref sl_net_event_handler_t. 77 * 78 * @param[in] dns_resolution_ip 79 * DNS resolution by IP of type @ref sl_net_dns_resolution_ip_type_t. 80 * @param[out] ip_address 81 * IP address object to store resolved IP address of type [sl_ip_address_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-ip-address-t). 82 * 83 * @return 84 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 85 */ 86 sl_status_t sl_net_dns_resolve_hostname(const char *host_name, 87 const uint32_t timeout, 88 const sl_net_dns_resolution_ip_type_t dns_resolution_ip, 89 sl_ip_address_t *ip_address); 90 91 /** 92 * @brief 93 * Sets DNS server IP addresses. 94 * 95 * @details 96 * This function configures the DNS server IP addresses for the specified network interface. 97 * 98 * If both primary and secondary server addresses are NULL, the DNS mode will be set to DHCP. 99 * Otherwise, the DNS mode will be set to static. 100 * 101 * @pre Pre-conditions: 102 * - The [SL_SI91X_TCP_IP_FEAT_DNS_CLIENT](../wiseconnect-api-reference-guide-si91x-driver/si91-x-tcp-ip-feature-bitmap#sl-si91-x-tcp-ip-feat-dns-client) bit should be enabled in the TCP/IP feature bitmap. 103 * 104 * @param[in] interface 105 * The network interface of type @ref sl_net_interface_t. 106 * 107 * @param[in] address 108 * The structure containing the primary and secondary server addresses of type @ref sl_net_dns_address_t. 109 * 110 * @return 111 * sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details. 112 */ 113 sl_status_t sl_net_set_dns_server(sl_net_interface_t interface, const sl_net_dns_address_t *address); 114 115 /** @} */ 116