mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f782d9c66c49 1
dkato 0:f782d9c66c49 2 /** \addtogroup netsocket */
dkato 0:f782d9c66c49 3 /** @{*/
dkato 0:f782d9c66c49 4 /* nsapi_dns.h
dkato 0:f782d9c66c49 5 * Original work Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de)
dkato 0:f782d9c66c49 6 * Modified work Copyright (c) 2015 ARM Limited
dkato 0:f782d9c66c49 7 *
dkato 0:f782d9c66c49 8 * Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:f782d9c66c49 9 * you may not use this file except in compliance with the License.
dkato 0:f782d9c66c49 10 * You may obtain a copy of the License at
dkato 0:f782d9c66c49 11 *
dkato 0:f782d9c66c49 12 * http://www.apache.org/licenses/LICENSE-2.0
dkato 0:f782d9c66c49 13 *
dkato 0:f782d9c66c49 14 * Unless required by applicable law or agreed to in writing, software
dkato 0:f782d9c66c49 15 * distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:f782d9c66c49 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:f782d9c66c49 17 * See the License for the specific language governing permissions and
dkato 0:f782d9c66c49 18 * limitations under the License.
dkato 0:f782d9c66c49 19 */
dkato 0:f782d9c66c49 20 #ifndef NSAPI_DNS_H
dkato 0:f782d9c66c49 21 #define NSAPI_DNS_H
dkato 0:f782d9c66c49 22
dkato 0:f782d9c66c49 23 #include "nsapi_types.h"
dkato 0:f782d9c66c49 24 #ifdef __cplusplus
dkato 0:f782d9c66c49 25 #include "netsocket/NetworkStack.h"
dkato 0:f782d9c66c49 26 #endif
dkato 0:f782d9c66c49 27
dkato 0:f782d9c66c49 28 #ifndef __cplusplus
dkato 0:f782d9c66c49 29
dkato 0:f782d9c66c49 30
dkato 0:f782d9c66c49 31 /** Query a domain name server for an IP address of a given hostname
dkato 0:f782d9c66c49 32 *
dkato 0:f782d9c66c49 33 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 34 * @param host Hostname to resolve
dkato 0:f782d9c66c49 35 * @param addr Destination for the host address
dkato 0:f782d9c66c49 36 * @param version IP version to resolve
dkato 0:f782d9c66c49 37 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 38 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 39 */
dkato 0:f782d9c66c49 40 nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
dkato 0:f782d9c66c49 41 nsapi_addr_t *addr, nsapi_version_t version);
dkato 0:f782d9c66c49 42
dkato 0:f782d9c66c49 43 /** Query a domain name server for multiple IP address of a given hostname
dkato 0:f782d9c66c49 44 *
dkato 0:f782d9c66c49 45 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 46 * @param host Hostname to resolve
dkato 0:f782d9c66c49 47 * @param addr Array for the host addresses
dkato 0:f782d9c66c49 48 * @param addr_count Number of addresses allocated in the array
dkato 0:f782d9c66c49 49 * @param version IP version to resolve
dkato 0:f782d9c66c49 50 * @return Number of addresses found on success, negative error code on failure
dkato 0:f782d9c66c49 51 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 52 */
dkato 0:f782d9c66c49 53 nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
dkato 0:f782d9c66c49 54 nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version);
dkato 0:f782d9c66c49 55
dkato 0:f782d9c66c49 56 /** Add a domain name server to list of servers to query
dkato 0:f782d9c66c49 57 *
dkato 0:f782d9c66c49 58 * @param addr Destination for the host address
dkato 0:f782d9c66c49 59 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 60 */
dkato 0:f782d9c66c49 61 nsapi_error_t nsapi_dns_add_server(nsapi_addr_t addr);
dkato 0:f782d9c66c49 62
dkato 0:f782d9c66c49 63
dkato 0:f782d9c66c49 64 #else
dkato 0:f782d9c66c49 65
dkato 0:f782d9c66c49 66
dkato 0:f782d9c66c49 67 /** Query a domain name server for an IP address of a given hostname
dkato 0:f782d9c66c49 68 *
dkato 0:f782d9c66c49 69 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 70 * @param host Hostname to resolve
dkato 0:f782d9c66c49 71 * @param addr Destination for the host address
dkato 0:f782d9c66c49 72 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 73 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 74 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 75 */
dkato 0:f782d9c66c49 76 nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
dkato 0:f782d9c66c49 77 SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4);
dkato 0:f782d9c66c49 78
dkato 0:f782d9c66c49 79 /** Query a domain name server for an IP address of a given hostname
dkato 0:f782d9c66c49 80 *
dkato 0:f782d9c66c49 81 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 82 * @param host Hostname to resolve
dkato 0:f782d9c66c49 83 * @param addr Destination for the host address
dkato 0:f782d9c66c49 84 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 85 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 86 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 87 */
dkato 0:f782d9c66c49 88 extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
dkato 0:f782d9c66c49 89 nsapi_addr_t *addr, nsapi_version_t version = NSAPI_IPv4);
dkato 0:f782d9c66c49 90
dkato 0:f782d9c66c49 91 /** Query a domain name server for an IP address of a given hostname
dkato 0:f782d9c66c49 92 *
dkato 0:f782d9c66c49 93 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 94 * @param host Hostname to resolve
dkato 0:f782d9c66c49 95 * @param addr Destination for the host address
dkato 0:f782d9c66c49 96 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 97 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 98 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 99 */
dkato 0:f782d9c66c49 100 template <typename S>
dkato 0:f782d9c66c49 101 nsapi_error_t nsapi_dns_query(S *stack, const char *host,
dkato 0:f782d9c66c49 102 SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4)
dkato 0:f782d9c66c49 103 {
dkato 0:f782d9c66c49 104 return nsapi_dns_query(nsapi_create_stack(stack), host, addr, version);
dkato 0:f782d9c66c49 105 }
dkato 0:f782d9c66c49 106
dkato 0:f782d9c66c49 107 /** Query a domain name server for multiple IP address of a given hostname
dkato 0:f782d9c66c49 108 *
dkato 0:f782d9c66c49 109 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 110 * @param host Hostname to resolve
dkato 0:f782d9c66c49 111 * @param addr Array for the host addresses
dkato 0:f782d9c66c49 112 * @param addr_count Number of addresses allocated in the array
dkato 0:f782d9c66c49 113 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 114 * @return Number of addresses found on success, negative error code on failure
dkato 0:f782d9c66c49 115 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 116 */
dkato 0:f782d9c66c49 117 nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
dkato 0:f782d9c66c49 118 SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
dkato 0:f782d9c66c49 119
dkato 0:f782d9c66c49 120 /** Query a domain name server for multiple IP address of a given hostname
dkato 0:f782d9c66c49 121 *
dkato 0:f782d9c66c49 122 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 123 * @param host Hostname to resolve
dkato 0:f782d9c66c49 124 * @param addr Array for the host addresses
dkato 0:f782d9c66c49 125 * @param addr_count Number of addresses allocated in the array
dkato 0:f782d9c66c49 126 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 127 * @return Number of addresses found on success, negative error code on failure
dkato 0:f782d9c66c49 128 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 129 */
dkato 0:f782d9c66c49 130 extern "C" nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
dkato 0:f782d9c66c49 131 nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
dkato 0:f782d9c66c49 132
dkato 0:f782d9c66c49 133 /** Query a domain name server for multiple IP address of a given hostname
dkato 0:f782d9c66c49 134 *
dkato 0:f782d9c66c49 135 * @param stack Network stack as target for DNS query
dkato 0:f782d9c66c49 136 * @param host Hostname to resolve
dkato 0:f782d9c66c49 137 * @param addr Array for the host addresses
dkato 0:f782d9c66c49 138 * @param addr_count Number of addresses allocated in the array
dkato 0:f782d9c66c49 139 * @param version IP version to resolve (defaults to NSAPI_IPv4)
dkato 0:f782d9c66c49 140 * @return Number of addresses found on success, negative error code on failure
dkato 0:f782d9c66c49 141 * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
dkato 0:f782d9c66c49 142 */
dkato 0:f782d9c66c49 143 template <typename S>
dkato 0:f782d9c66c49 144 nsapi_size_or_error_t nsapi_dns_query_multiple(S *stack, const char *host,
dkato 0:f782d9c66c49 145 SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4)
dkato 0:f782d9c66c49 146 {
dkato 0:f782d9c66c49 147 return nsapi_dns_query_multiple(nsapi_create_stack(stack),
dkato 0:f782d9c66c49 148 host, addr, addr_count, version);
dkato 0:f782d9c66c49 149 }
dkato 0:f782d9c66c49 150
dkato 0:f782d9c66c49 151 /** Add a domain name server to list of servers to query
dkato 0:f782d9c66c49 152 *
dkato 0:f782d9c66c49 153 * @param addr Destination for the host address
dkato 0:f782d9c66c49 154 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 155 */
dkato 0:f782d9c66c49 156 extern "C" nsapi_error_t nsapi_dns_add_server(nsapi_addr_t addr);
dkato 0:f782d9c66c49 157
dkato 0:f782d9c66c49 158 /** Add a domain name server to list of servers to query
dkato 0:f782d9c66c49 159 *
dkato 0:f782d9c66c49 160 * @param addr Destination for the host address
dkato 0:f782d9c66c49 161 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 162 */
dkato 0:f782d9c66c49 163 static inline nsapi_error_t nsapi_dns_add_server(const SocketAddress &address)
dkato 0:f782d9c66c49 164 {
dkato 0:f782d9c66c49 165 return nsapi_dns_add_server(address.get_addr());
dkato 0:f782d9c66c49 166 }
dkato 0:f782d9c66c49 167
dkato 0:f782d9c66c49 168 /** Add a domain name server to list of servers to query
dkato 0:f782d9c66c49 169 *
dkato 0:f782d9c66c49 170 * @param addr Destination for the host address
dkato 0:f782d9c66c49 171 * @return 0 on success, negative error code on failure
dkato 0:f782d9c66c49 172 */
dkato 0:f782d9c66c49 173 static inline nsapi_error_t nsapi_dns_add_server(const char *address)
dkato 0:f782d9c66c49 174 {
dkato 0:f782d9c66c49 175 return nsapi_dns_add_server(SocketAddress(address));
dkato 0:f782d9c66c49 176 }
dkato 0:f782d9c66c49 177
dkato 0:f782d9c66c49 178
dkato 0:f782d9c66c49 179 #endif
dkato 0:f782d9c66c49 180
dkato 0:f782d9c66c49 181 #endif
dkato 0:f782d9c66c49 182
dkato 0:f782d9c66c49 183 /** @}*/