takashi kadono
/
Nucleo_446
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/features/netsocket/DNS.h@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* |
kadonotakashi | 0:8fdf9a60065b | 2 | * Copyright (c) 2018 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 3 | * |
kadonotakashi | 0:8fdf9a60065b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 5 | * you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 6 | * You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 7 | * |
kadonotakashi | 0:8fdf9a60065b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 9 | * |
kadonotakashi | 0:8fdf9a60065b | 10 | * Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 13 | * See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 14 | * limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 15 | */ |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | #ifndef DNS_H |
kadonotakashi | 0:8fdf9a60065b | 18 | #define DNS_H |
kadonotakashi | 0:8fdf9a60065b | 19 | |
kadonotakashi | 0:8fdf9a60065b | 20 | class DNS { |
kadonotakashi | 0:8fdf9a60065b | 21 | public: |
kadonotakashi | 0:8fdf9a60065b | 22 | |
kadonotakashi | 0:8fdf9a60065b | 23 | /** Translates a hostname to an IP address with specific version |
kadonotakashi | 0:8fdf9a60065b | 24 | * |
kadonotakashi | 0:8fdf9a60065b | 25 | * The hostname may be either a domain name or an IP address. If the |
kadonotakashi | 0:8fdf9a60065b | 26 | * hostname is an IP address, no network transactions will be performed. |
kadonotakashi | 0:8fdf9a60065b | 27 | * |
kadonotakashi | 0:8fdf9a60065b | 28 | * If no stack-specific DNS resolution is provided, the hostname |
kadonotakashi | 0:8fdf9a60065b | 29 | * will be resolve using a UDP socket on the stack. |
kadonotakashi | 0:8fdf9a60065b | 30 | * |
kadonotakashi | 0:8fdf9a60065b | 31 | * @param host Hostname to resolve |
kadonotakashi | 0:8fdf9a60065b | 32 | * @param address Destination for the host SocketAddress |
kadonotakashi | 0:8fdf9a60065b | 33 | * @param version IP version of address to resolve, NSAPI_UNSPEC indicates |
kadonotakashi | 0:8fdf9a60065b | 34 | * version is chosen by the stack (defaults to NSAPI_UNSPEC) |
kadonotakashi | 0:8fdf9a60065b | 35 | * @return 0 on success, negative error code on failure |
kadonotakashi | 0:8fdf9a60065b | 36 | */ |
kadonotakashi | 0:8fdf9a60065b | 37 | virtual nsapi_error_t gethostbyname(const char *host, |
kadonotakashi | 0:8fdf9a60065b | 38 | SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC) = 0; |
kadonotakashi | 0:8fdf9a60065b | 39 | |
kadonotakashi | 0:8fdf9a60065b | 40 | /** Hostname translation callback (asynchronous) |
kadonotakashi | 0:8fdf9a60065b | 41 | * |
kadonotakashi | 0:8fdf9a60065b | 42 | * Callback will be called after DNS resolution completes or a failure occurs. |
kadonotakashi | 0:8fdf9a60065b | 43 | * |
kadonotakashi | 0:8fdf9a60065b | 44 | * Callback should not take more than 10ms to execute, otherwise it might |
kadonotakashi | 0:8fdf9a60065b | 45 | * prevent underlying thread processing. A portable user of the callback |
kadonotakashi | 0:8fdf9a60065b | 46 | * should not make calls to network operations due to stack size limitations. |
kadonotakashi | 0:8fdf9a60065b | 47 | * The callback should not perform expensive operations such as socket recv/send |
kadonotakashi | 0:8fdf9a60065b | 48 | * calls or blocking operations. |
kadonotakashi | 0:8fdf9a60065b | 49 | * |
kadonotakashi | 0:8fdf9a60065b | 50 | * @param status 0 on success, negative error code on failure |
kadonotakashi | 0:8fdf9a60065b | 51 | * @param address On success, destination for the host SocketAddress |
kadonotakashi | 0:8fdf9a60065b | 52 | */ |
kadonotakashi | 0:8fdf9a60065b | 53 | typedef mbed::Callback<void (nsapi_error_t result, SocketAddress *address)> hostbyname_cb_t; |
kadonotakashi | 0:8fdf9a60065b | 54 | |
kadonotakashi | 0:8fdf9a60065b | 55 | /** Translates a hostname to an IP address (asynchronous) |
kadonotakashi | 0:8fdf9a60065b | 56 | * |
kadonotakashi | 0:8fdf9a60065b | 57 | * The hostname may be either a domain name or an IP address. If the |
kadonotakashi | 0:8fdf9a60065b | 58 | * hostname is an IP address, no network transactions will be performed. |
kadonotakashi | 0:8fdf9a60065b | 59 | * |
kadonotakashi | 0:8fdf9a60065b | 60 | * If no stack-specific DNS resolution is provided, the hostname |
kadonotakashi | 0:8fdf9a60065b | 61 | * will be resolve using a UDP socket on the stack. |
kadonotakashi | 0:8fdf9a60065b | 62 | * |
kadonotakashi | 0:8fdf9a60065b | 63 | * Call is non-blocking. Result of the DNS operation is returned by the callback. |
kadonotakashi | 0:8fdf9a60065b | 64 | * If this function returns failure, callback will not be called. In case result |
kadonotakashi | 0:8fdf9a60065b | 65 | * is success (IP address was found from DNS cache), callback will be called |
kadonotakashi | 0:8fdf9a60065b | 66 | * before function returns. |
kadonotakashi | 0:8fdf9a60065b | 67 | * |
kadonotakashi | 0:8fdf9a60065b | 68 | * @param host Hostname to resolve |
kadonotakashi | 0:8fdf9a60065b | 69 | * @param callback Callback that is called for result |
kadonotakashi | 0:8fdf9a60065b | 70 | * @param version IP version of address to resolve, NSAPI_UNSPEC indicates |
kadonotakashi | 0:8fdf9a60065b | 71 | * version is chosen by the stack (defaults to NSAPI_UNSPEC) |
kadonotakashi | 0:8fdf9a60065b | 72 | * @return 0 on immediate success, |
kadonotakashi | 0:8fdf9a60065b | 73 | * negative error code on immediate failure or |
kadonotakashi | 0:8fdf9a60065b | 74 | * a positive unique id that represents the hostname translation operation |
kadonotakashi | 0:8fdf9a60065b | 75 | * and can be passed to cancel |
kadonotakashi | 0:8fdf9a60065b | 76 | */ |
kadonotakashi | 0:8fdf9a60065b | 77 | virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback, |
kadonotakashi | 0:8fdf9a60065b | 78 | nsapi_version_t version = NSAPI_UNSPEC) = 0; |
kadonotakashi | 0:8fdf9a60065b | 79 | |
kadonotakashi | 0:8fdf9a60065b | 80 | /** Cancels asynchronous hostname translation |
kadonotakashi | 0:8fdf9a60065b | 81 | * |
kadonotakashi | 0:8fdf9a60065b | 82 | * When translation is cancelled, callback will not be called. |
kadonotakashi | 0:8fdf9a60065b | 83 | * |
kadonotakashi | 0:8fdf9a60065b | 84 | * @param id Unique id of the hostname translation operation |
kadonotakashi | 0:8fdf9a60065b | 85 | * @return 0 on success, negative error code on failure |
kadonotakashi | 0:8fdf9a60065b | 86 | */ |
kadonotakashi | 0:8fdf9a60065b | 87 | virtual nsapi_error_t gethostbyname_async_cancel(int id) = 0; |
kadonotakashi | 0:8fdf9a60065b | 88 | |
kadonotakashi | 0:8fdf9a60065b | 89 | /** Add a domain name server to list of servers to query |
kadonotakashi | 0:8fdf9a60065b | 90 | * |
kadonotakashi | 0:8fdf9a60065b | 91 | * @param address Destination for the host address |
kadonotakashi | 0:8fdf9a60065b | 92 | * @return 0 on success, negative error code on failure |
kadonotakashi | 0:8fdf9a60065b | 93 | */ |
kadonotakashi | 0:8fdf9a60065b | 94 | virtual nsapi_error_t add_dns_server(const SocketAddress &address) = 0; |
kadonotakashi | 0:8fdf9a60065b | 95 | }; |
kadonotakashi | 0:8fdf9a60065b | 96 | |
kadonotakashi | 0:8fdf9a60065b | 97 | #endif |