Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51_Vdd TextLCD BME280
DNS.h
00001 /* 00002 * Copyright (c) 2018 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef DNS_H 00018 #define DNS_H 00019 00020 class DNS { 00021 public: 00022 00023 /** Translate a hostname to an IP address with specific version. 00024 * 00025 * The hostname may be either a domain name or an IP address. If the 00026 * hostname is an IP address, no network transactions will be performed. 00027 * 00028 * If no stack-specific DNS resolution is provided, the hostname 00029 * will be resolve using a UDP socket on the stack. 00030 * 00031 * @param host Hostname to resolve. 00032 * @param address Pointer to a SocketAddress to store the result. 00033 * @param version IP version of address to resolve, NSAPI_UNSPEC indicates 00034 * version is chosen by the stack (defaults to NSAPI_UNSPEC). 00035 * @return NSAPI_ERROR_OK on success, negative error code on failure. 00036 */ 00037 virtual nsapi_error_t gethostbyname(const char *host, 00038 SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC ) = 0; 00039 00040 /** Hostname translation callback for gethostbyname_async. 00041 * 00042 * The callback is called after DNS resolution completes, or a failure occurs. 00043 * 00044 * Callback should not take more than 10ms to execute, otherwise it might 00045 * prevent underlying thread processing. A portable user of the callback 00046 * should not make calls to network operations due to stack size limitations. 00047 * The callback should not perform expensive operations such as socket recv/send 00048 * calls or blocking operations. 00049 * 00050 * @param result NSAPI_ERROR_OK on success, negative error code on failure. 00051 * @param address On success, destination for the host SocketAddress. 00052 */ 00053 typedef mbed::Callback<void (nsapi_error_t result, SocketAddress *address)> hostbyname_cb_t; 00054 00055 /** Translate a hostname to an IP address (asynchronous). 00056 * 00057 * The hostname may be either a domain name or an IP address. If the 00058 * hostname is an IP address, no network transactions will be performed. 00059 * 00060 * If no stack-specific DNS resolution is provided, the hostname 00061 * will be resolved using a UDP socket on the stack. 00062 * 00063 * The call is non-blocking. The result of the DNS operation is returned by the callback. 00064 * If this function returns failure, the callback will not be called. If it is successful, 00065 * (the IP address was found from the DNS cache), the callback will be called 00066 * before the function returns. 00067 * 00068 * @param host Hostname to resolve. 00069 * @param callback Callback that is called to return the result. 00070 * @param version IP version of address to resolve. NSAPI_UNSPEC indicates that the 00071 * version is chosen by the stack (defaults to NSAPI_UNSPEC). 00072 * @return NSAPI_ERROR_OK on immediate success, 00073 * negative error code on immediate failure or 00074 * a positive unique ID that represents the hostname translation operation 00075 * and can be passed to cancel. 00076 */ 00077 virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, 00078 nsapi_version_t version = NSAPI_UNSPEC ) = 0; 00079 00080 /** Cancel asynchronous hostname translation. 00081 * 00082 * When translation is canceled, callback is not called. 00083 * 00084 * @param id Unique ID of the hostname translation operation returned by gethostbyname_async. 00085 * @return NSAPI_ERROR_OK on success, negative error code on failure. 00086 */ 00087 virtual nsapi_error_t gethostbyname_async_cancel(int id) = 0; 00088 00089 /** Add a domain name server to list of servers to query. 00090 * 00091 * @param address DNS server host address. 00092 * @return NSAPI_ERROR_OK on success, negative error code on failure. 00093 */ 00094 virtual nsapi_error_t add_dns_server(const SocketAddress &address) = 0; 00095 }; 00096 00097 #endif
Generated on Tue Jul 12 2022 15:15:43 by
