BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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