Fork for fixes
DnsClient.h@9:a156d3de5647, 2019-08-27 (annotated)
- Committer:
- hudakz
- Date:
- Tue Aug 27 15:01:10 2019 +0000
- Revision:
- 9:a156d3de5647
- Child:
- 20:8d5738a6646e
Mbed OS 5 support added and API modified.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 9:a156d3de5647 | 1 | // Arduino DNS client for Enc28J60-based Ethernet shield |
hudakz | 9:a156d3de5647 | 2 | // (c) Copyright 2009-2010 MCQN Ltd. |
hudakz | 9:a156d3de5647 | 3 | // Released under Apache License, version 2.0 |
hudakz | 9:a156d3de5647 | 4 | #ifndef DNSClient_h |
hudakz | 9:a156d3de5647 | 5 | #define DNSClient_h |
hudakz | 9:a156d3de5647 | 6 | |
hudakz | 9:a156d3de5647 | 7 | #include "UdpSocket.h" |
hudakz | 9:a156d3de5647 | 8 | #include "IpAddress.h" |
hudakz | 9:a156d3de5647 | 9 | |
hudakz | 9:a156d3de5647 | 10 | class DnsClient |
hudakz | 9:a156d3de5647 | 11 | { |
hudakz | 9:a156d3de5647 | 12 | public: |
hudakz | 9:a156d3de5647 | 13 | // ctor |
hudakz | 9:a156d3de5647 | 14 | void begin(const IpAddress& aDNSServer); |
hudakz | 9:a156d3de5647 | 15 | |
hudakz | 9:a156d3de5647 | 16 | /** Convert a numeric IP address string into a four-byte IP address. |
hudakz | 9:a156d3de5647 | 17 | @param aIPAddrString IP address to convert |
hudakz | 9:a156d3de5647 | 18 | @param aResult IPAddress structure to store the returned IP address |
hudakz | 9:a156d3de5647 | 19 | @result 1 if aIPAddrString was successfully converted to an IP address, |
hudakz | 9:a156d3de5647 | 20 | else error code |
hudakz | 9:a156d3de5647 | 21 | */ |
hudakz | 9:a156d3de5647 | 22 | int inet_aton(const char* aIPAddrString, IpAddress& aResult); |
hudakz | 9:a156d3de5647 | 23 | |
hudakz | 9:a156d3de5647 | 24 | /** Resolve the given hostname to an IP address. |
hudakz | 9:a156d3de5647 | 25 | @param aHostname Name to be resolved |
hudakz | 9:a156d3de5647 | 26 | @param aResult IPAddress structure to store the returned IP address |
hudakz | 9:a156d3de5647 | 27 | @result 1 if aIPAddrString was successfully converted to an IP address, |
hudakz | 9:a156d3de5647 | 28 | else error code |
hudakz | 9:a156d3de5647 | 29 | */ |
hudakz | 9:a156d3de5647 | 30 | int getHostByName(const char* aHostname, IpAddress& aResult); |
hudakz | 9:a156d3de5647 | 31 | protected: |
hudakz | 9:a156d3de5647 | 32 | uint16_t buildRequest(const char* aName); |
hudakz | 9:a156d3de5647 | 33 | int16_t processResponse(uint16_t aTimeout, IpAddress& aAddress); |
hudakz | 9:a156d3de5647 | 34 | |
hudakz | 9:a156d3de5647 | 35 | IpAddress iDNSServer; |
hudakz | 9:a156d3de5647 | 36 | uint16_t iRequestId; |
hudakz | 9:a156d3de5647 | 37 | UdpSocket iUdp; |
hudakz | 9:a156d3de5647 | 38 | }; |
hudakz | 9:a156d3de5647 | 39 | #endif |