18
18
#define NSAPI_DNS_H
19
19
20
20
#include " nsapi_types.h"
21
+ #ifdef __cplusplus
21
22
#include " network-socket/NetworkStack.h"
23
+ #endif
24
+
25
+ #ifndef __cplusplus
22
26
23
27
24
28
/* * Query a domain name server for an IP address of a given hostname
25
29
*
26
30
* @param stack Network stack as target for DNS query
27
31
* @param addr Destination for the host address
28
32
* @param host Hostname to resolve
29
- * @param version IP version to resolve (defaults to NSAPI_IPv4)
33
+ * @param version IP version to resolve
30
34
* @return 0 on success, negative error code on failure
31
35
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
32
36
*/
33
- NSAPI_C_LINKAGE
34
37
int nsapi_dns_query (nsapi_stack_t *stack, nsapi_addr_t *addr,
35
38
const char *host, nsapi_version_t version);
36
39
37
- #ifdef __cplusplus
38
- int nsapi_dns_query (nsapi_stack_t *stack, nsapi_addr_t *addr,
39
- const char *host);
40
+ /* * Query a domain name server for multiple IP address of a given hostname
41
+ *
42
+ * @param stack Network stack as target for DNS query
43
+ * @param addr Array for the host addresses
44
+ * @param addr_count Number of addresses allocated in the array
45
+ * @param host Hostname to resolve
46
+ * @param version IP version to resolve
47
+ * @return Number of addresses found on success, negative error code on failure
48
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
49
+ */
50
+ int nsapi_dns_query_multiple (nsapi_stack_t *stack,
51
+ nsapi_addr_t *addr, unsigned addr_count,
52
+ const char *host, nsapi_version_t version);
53
+
54
+ /* * Add a domain name server to list of servers to query
55
+ *
56
+ * @param addr Destination for the host address
57
+ * @return 0 on success, negative error code on failure
58
+ */
59
+ int nsapi_dns_add_server (nsapi_addr_t addr);
60
+
61
+
62
+ #else
63
+
64
+
65
+ /* * Query a domain name server for an IP address of a given hostname
66
+ *
67
+ * @param stack Network stack as target for DNS query
68
+ * @param addr Destination for the host address
69
+ * @param host Hostname to resolve
70
+ * @param version IP version to resolve (defaults to NSAPI_IPv4)
71
+ * @return 0 on success, negative error code on failure
72
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
73
+ */
40
74
int nsapi_dns_query (NetworkStack *stack, SocketAddress *addr,
41
75
const char *host, nsapi_version_t version = NSAPI_IPv4);
42
76
77
+ /* * Query a domain name server for an IP address of a given hostname
78
+ *
79
+ * @param stack Network stack as target for DNS query
80
+ * @param addr Destination for the host address
81
+ * @param host Hostname to resolve
82
+ * @param version IP version to resolve (defaults to NSAPI_IPv4)
83
+ * @return 0 on success, negative error code on failure
84
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
85
+ */
86
+ extern " C" int nsapi_dns_query (nsapi_stack_t *stack, nsapi_addr_t *addr,
87
+ const char *host, nsapi_version_t version = NSAPI_IPv4);
88
+
89
+ /* * Query a domain name server for an IP address of a given hostname
90
+ *
91
+ * @param stack Network stack as target for DNS query
92
+ * @param addr Destination for the host address
93
+ * @param host Hostname to resolve
94
+ * @param version IP version to resolve (defaults to NSAPI_IPv4)
95
+ * @return 0 on success, negative error code on failure
96
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
97
+ */
43
98
template <typename S>
44
99
int nsapi_dns_query (S *stack, SocketAddress *addr,
45
100
const char *host, nsapi_version_t version = NSAPI_IPv4)
46
101
{
47
102
return nsapi_dns_query (nsapi_create_stack (stack), addr, host, version);
48
103
}
49
- #endif
50
-
51
104
52
105
/* * Query a domain name server for multiple IP address of a given hostname
53
106
*
@@ -59,19 +112,34 @@ int nsapi_dns_query(S *stack, SocketAddress *addr,
59
112
* @return Number of addresses found on success, negative error code on failure
60
113
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
61
114
*/
62
- NSAPI_C_LINKAGE
63
- int nsapi_dns_query_multiple (nsapi_stack_t *stack,
64
- nsapi_addr_t *addr, unsigned addr_count,
65
- const char *host, nsapi_version_t version);
66
-
67
- #ifdef __cplusplus
68
- int nsapi_dns_query_multiple (nsapi_stack_t *stack,
69
- nsapi_addr_t *addr, unsigned addr_count,
70
- const char *host);
71
115
int nsapi_dns_query_multiple (NetworkStack *stack,
72
116
SocketAddress *addr, unsigned addr_count,
73
117
const char *host, nsapi_version_t version = NSAPI_IPv4);
74
118
119
+ /* * Query a domain name server for multiple IP address of a given hostname
120
+ *
121
+ * @param stack Network stack as target for DNS query
122
+ * @param addr Array for the host addresses
123
+ * @param addr_count Number of addresses allocated in the array
124
+ * @param host Hostname to resolve
125
+ * @param version IP version to resolve (defaults to NSAPI_IPv4)
126
+ * @return Number of addresses found on success, negative error code on failure
127
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
128
+ */
129
+ extern " C" int nsapi_dns_query_multiple (nsapi_stack_t *stack,
130
+ nsapi_addr_t *addr, unsigned addr_count,
131
+ const char *host, nsapi_version_t version = NSAPI_IPv4);
132
+
133
+ /* * Query a domain name server for multiple IP address of a given hostname
134
+ *
135
+ * @param stack Network stack as target for DNS query
136
+ * @param addr Array for the host addresses
137
+ * @param addr_count Number of addresses allocated in the array
138
+ * @param host Hostname to resolve
139
+ * @param version IP version to resolve (defaults to NSAPI_IPv4)
140
+ * @return Number of addresses found on success, negative error code on failure
141
+ * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
142
+ */
75
143
template <typename S>
76
144
int nsapi_dns_query_multiple (S *stack,
77
145
SocketAddress *addr, unsigned addr_count,
@@ -80,24 +148,35 @@ int nsapi_dns_query_multiple(S *stack,
80
148
return nsapi_dns_query_multiple (nsapi_create_stack (stack),
81
149
addr, addr_count, host, version);
82
150
}
83
- #endif
84
151
152
+ /* * Add a domain name server to list of servers to query
153
+ *
154
+ * @param addr Destination for the host address
155
+ * @return 0 on success, negative error code on failure
156
+ */
157
+ extern " C" int nsapi_dns_add_server (nsapi_addr_t addr);
85
158
86
159
/* * Add a domain name server to list of servers to query
87
160
*
88
- * @param stack Network stack as target for DNS query
89
161
* @param addr Destination for the host address
90
- * @param host Hostname to resolve
91
162
* @return 0 on success, negative error code on failure
92
- * NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
93
163
*/
94
- NSAPI_C_LINKAGE
95
- int nsapi_dns_add_server (nsapi_addr_t addr);
164
+ static inline int nsapi_dns_add_server (const SocketAddress &address)
165
+ {
166
+ return nsapi_dns_add_server (address.get_addr ());
167
+ }
168
+
169
+ /* * Add a domain name server to list of servers to query
170
+ *
171
+ * @param addr Destination for the host address
172
+ * @return 0 on success, negative error code on failure
173
+ */
174
+ static inline int nsapi_dns_add_server (const char *address)
175
+ {
176
+ return nsapi_dns_add_server (SocketAddress (address));
177
+ }
96
178
97
- #ifdef __cplusplus
98
- int nsapi_dns_add_server (const SocketAddress &address);
99
- int nsapi_dns_add_server (const char *address);
100
- #endif
101
179
180
+ #endif
102
181
103
182
#endif
0 commit comments