Network Services
Fork of W5500Interface_K22F by
DNSClient/DNSClient.h@0:e11e8793c3ce, 2014-08-20 (annotated)
- Committer:
- Bongjun
- Date:
- Wed Aug 20 00:28:37 2014 +0000
- Revision:
- 0:e11e8793c3ce
first release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bongjun | 0:e11e8793c3ce | 1 | // DNSClient.h 2013/4/5 |
Bongjun | 0:e11e8793c3ce | 2 | #pragma once |
Bongjun | 0:e11e8793c3ce | 3 | |
Bongjun | 0:e11e8793c3ce | 4 | #include "UDPSocket.h" |
Bongjun | 0:e11e8793c3ce | 5 | |
Bongjun | 0:e11e8793c3ce | 6 | class DNSClient { |
Bongjun | 0:e11e8793c3ce | 7 | public: |
Bongjun | 0:e11e8793c3ce | 8 | DNSClient(const char* hostname = NULL); |
Bongjun | 0:e11e8793c3ce | 9 | DNSClient(Endpoint* pHost); |
Bongjun | 0:e11e8793c3ce | 10 | virtual ~DNSClient(); |
Bongjun | 0:e11e8793c3ce | 11 | bool lookup(const char* hostname = NULL); |
Bongjun | 0:e11e8793c3ce | 12 | uint32_t ip; |
Bongjun | 0:e11e8793c3ce | 13 | protected: |
Bongjun | 0:e11e8793c3ce | 14 | void poll(); |
Bongjun | 0:e11e8793c3ce | 15 | void callback(); |
Bongjun | 0:e11e8793c3ce | 16 | int response(uint8_t buf[], int size); |
Bongjun | 0:e11e8793c3ce | 17 | int query(uint8_t buf[], int size, const char* hostname); |
Bongjun | 0:e11e8793c3ce | 18 | void resolve(const char* hostname); |
Bongjun | 0:e11e8793c3ce | 19 | uint8_t m_id[2]; |
Bongjun | 0:e11e8793c3ce | 20 | Timer m_interval; |
Bongjun | 0:e11e8793c3ce | 21 | int m_retry; |
Bongjun | 0:e11e8793c3ce | 22 | const char* m_hostname; |
Bongjun | 0:e11e8793c3ce | 23 | private: |
Bongjun | 0:e11e8793c3ce | 24 | enum MyNetDnsState |
Bongjun | 0:e11e8793c3ce | 25 | { |
Bongjun | 0:e11e8793c3ce | 26 | MYNETDNS_START, |
Bongjun | 0:e11e8793c3ce | 27 | MYNETDNS_PROCESSING, //Req has not completed |
Bongjun | 0:e11e8793c3ce | 28 | MYNETDNS_NOTFOUND, |
Bongjun | 0:e11e8793c3ce | 29 | MYNETDNS_ERROR, |
Bongjun | 0:e11e8793c3ce | 30 | MYNETDNS_OK |
Bongjun | 0:e11e8793c3ce | 31 | }; |
Bongjun | 0:e11e8793c3ce | 32 | MyNetDnsState m_state; |
Bongjun | 0:e11e8793c3ce | 33 | UDPSocket *m_udp; |
Bongjun | 0:e11e8793c3ce | 34 | }; |