123
DnsClient.h@19:543c2d21e510, 2022-06-06 (annotated)
- Committer:
- advxolltm
- Date:
- Mon Jun 06 16:36:52 2022 +0000
- Revision:
- 19:543c2d21e510
- Parent:
- 18:8d5738a6646e
123
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 | 18:8d5738a6646e | 33 | int16_t processResponse(time_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 |