Library to resolve text URLs to IP addresses (IPv4)
Dependents: NetworkSocketAPI NetworkSocketAPI Nucleo-AWS-IoT-mbed
DnsQuery.h@18:2cb1fffed50c, 2016-04-19 (annotated)
- Committer:
- Christopher Haster
- Date:
- Tue Apr 19 18:29:55 2016 -0500
- Revision:
- 18:2cb1fffed50c
- Parent:
- 10:0fe2c42a0261
Matched changes to NSAPI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Christopher Haster |
18:2cb1fffed50c | 1 | /* |
Christopher Haster |
18:2cb1fffed50c | 2 | * |
Christopher Haster |
18:2cb1fffed50c | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Christopher Haster |
18:2cb1fffed50c | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
Christopher Haster |
18:2cb1fffed50c | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
Christopher Haster |
18:2cb1fffed50c | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
Christopher Haster |
18:2cb1fffed50c | 7 | * furnished to do so, subject to the following conditions: |
Christopher Haster |
18:2cb1fffed50c | 8 | * |
Christopher Haster |
18:2cb1fffed50c | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Christopher Haster |
18:2cb1fffed50c | 10 | * substantial portions of the Software. |
Christopher Haster |
18:2cb1fffed50c | 11 | * |
Christopher Haster |
18:2cb1fffed50c | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Christopher Haster |
18:2cb1fffed50c | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Christopher Haster |
18:2cb1fffed50c | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Christopher Haster |
18:2cb1fffed50c | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Christopher Haster |
18:2cb1fffed50c | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Christopher Haster |
18:2cb1fffed50c | 17 | */ |
Christopher Haster |
18:2cb1fffed50c | 18 | #ifndef __DNSQUERY_H__ |
Christopher Haster |
18:2cb1fffed50c | 19 | #define __DNSQUERY_H__ |
Christopher Haster |
18:2cb1fffed50c | 20 | |
Christopher Haster |
18:2cb1fffed50c | 21 | #include "NetworkStack.h" |
Christopher Haster |
18:2cb1fffed50c | 22 | #include "UDPSocket.h" |
Christopher Haster |
18:2cb1fffed50c | 23 | |
Christopher Haster |
18:2cb1fffed50c | 24 | |
Christopher Haster |
18:2cb1fffed50c | 25 | /** Function dnsQuery implements the functionality to query a domain name |
Christopher Haster |
18:2cb1fffed50c | 26 | * server for an IP-Address of a given hostname. |
Christopher Haster |
18:2cb1fffed50c | 27 | * @param iface : Network interface to use for DNS resolution. |
Christopher Haster |
18:2cb1fffed50c | 28 | * @param sock : Previously opened socket to use for DNS resolution. |
Christopher Haster |
18:2cb1fffed50c | 29 | * @param hostname : The hostname of interest as a string. |
Christopher Haster |
18:2cb1fffed50c | 30 | * Format must be without http:// or www. IE google.com, mbed.org, etc. |
Christopher Haster |
18:2cb1fffed50c | 31 | * If a standard IP Address is passed, it will be copied into ip unmodified. |
Christopher Haster |
18:2cb1fffed50c | 32 | * @param ipaddress : A reference to a IPADDRESS_t object which will receive |
Christopher Haster |
18:2cb1fffed50c | 33 | * the resolved IP Address of the host in question. |
Christopher Haster |
18:2cb1fffed50c | 34 | * @returns 0 on succes, NS_DNS_FAILURE if host is not found, |
Christopher Haster |
18:2cb1fffed50c | 35 | * or a negative value for other errors. |
Christopher Haster |
18:2cb1fffed50c | 36 | */ |
Christopher Haster |
18:2cb1fffed50c | 37 | int32_t dnsQuery(NetworkStack *iface, const char *host, char *ip); |
Christopher Haster |
18:2cb1fffed50c | 38 | int32_t dnsQuery(UDPSocket *sock, const char *host, char *ip); |
Christopher Haster |
18:2cb1fffed50c | 39 | |
Christopher Haster |
18:2cb1fffed50c | 40 | |
Christopher Haster |
18:2cb1fffed50c | 41 | #endif // __DNSQUERY_H__ |