1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | /** @file ssl_socket.h
|
---|
5 | * @brief Implements socket creation for TLSIO adapters.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef AZURE_IOT_DNS_H
|
---|
9 | #define AZURE_IOT_DNS_H
|
---|
10 |
|
---|
11 | #ifdef __cplusplus
|
---|
12 | extern "C" {
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include "azure_macro_utils/macro_utils.h"
|
---|
16 | #include "umock_c/umock_c_prod.h"
|
---|
17 |
|
---|
18 | typedef void* DNSRESOLVER_HANDLE;
|
---|
19 |
|
---|
20 | // If options are added in future, DNSRESOLVER_OPTIONS will become a struct containing the options
|
---|
21 | typedef void DNSRESOLVER_OPTIONS;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @brief Begin the process of an asynchronous DNS lookup.
|
---|
25 | *
|
---|
26 | * @param hostname The url of the host to look up.
|
---|
27 | *
|
---|
28 | * @return @c The newly created DNSRESOLVER_HANDLE.
|
---|
29 | */
|
---|
30 | MOCKABLE_FUNCTION(, DNSRESOLVER_HANDLE, dns_resolver_create, const char*, hostname, int, port, const DNSRESOLVER_OPTIONS*, options);
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * @brief Continue the lookup process and report its completion state. Must be polled repeatedly for completion.
|
---|
34 | *
|
---|
35 | * @param dns The DNSRESOLVER_HANDLE.
|
---|
36 | *
|
---|
37 | * @return @c A bool to indicate completion.
|
---|
38 | */
|
---|
39 | MOCKABLE_FUNCTION(, bool, dns_resolver_is_lookup_complete, DNSRESOLVER_HANDLE, dns);
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * @brief Return the IPv4 of a completed lookup process. Call only after dns_resolver_is_lookup_complete indicates completion.
|
---|
43 | *
|
---|
44 | * @param dns The DNSRESOLVER_HANDLE.
|
---|
45 | *
|
---|
46 | * @return @c A uint32_t IPv4 address. 0 indicates failure or not finished.
|
---|
47 | */
|
---|
48 | MOCKABLE_FUNCTION(, uint32_t, dns_resolver_get_ipv4, DNSRESOLVER_HANDLE, dns);
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * @brief Return the addrInfo of a completed lookup process. Call only after dns_resolver_is_lookup_complete indicates completion.
|
---|
52 | *
|
---|
53 | * @param dns The DNSRESOLVER_HANDLE.
|
---|
54 | *
|
---|
55 | * @return @c A struct addrinfo. 0 indicates failure or not finished.
|
---|
56 | */
|
---|
57 | MOCKABLE_FUNCTION(, struct addrinfo*, dns_resolver_get_addrInfo, DNSRESOLVER_HANDLE, dns);
|
---|
58 |
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * @brief Destroy the module.
|
---|
62 | *
|
---|
63 | * @param dns The DNSRESOLVER_HANDLE.
|
---|
64 | */
|
---|
65 | MOCKABLE_FUNCTION(, void, dns_resolver_destroy, DNSRESOLVER_HANDLE, dns);
|
---|
66 |
|
---|
67 |
|
---|
68 | #ifdef __cplusplus
|
---|
69 | }
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | #endif /* AZURE_IOT_DNS_H */
|
---|