Network Services

Dependents:   PwrCond_mbed5

Fork of W5500Interface_K22F by Andrew McCartney

Committer:
dgriffin65
Date:
Thu Jun 15 20:29:03 2017 +0000
Revision:
15:14382459c8b7
Converted to a single library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dgriffin65 15:14382459c8b7 1 // DNSClient.h 2013/4/5
dgriffin65 15:14382459c8b7 2 #pragma once
dgriffin65 15:14382459c8b7 3
dgriffin65 15:14382459c8b7 4 #include "UDPSocket.h"
dgriffin65 15:14382459c8b7 5
dgriffin65 15:14382459c8b7 6 //#define DBG_DNS 1
dgriffin65 15:14382459c8b7 7
dgriffin65 15:14382459c8b7 8 class DNSClient {
dgriffin65 15:14382459c8b7 9 public:
dgriffin65 15:14382459c8b7 10 DNSClient();
dgriffin65 15:14382459c8b7 11 DNSClient(NetworkStack *ns, const char* hostname = NULL);
dgriffin65 15:14382459c8b7 12 DNSClient(NetworkStack *ns, SocketAddress* pHost);
dgriffin65 15:14382459c8b7 13
dgriffin65 15:14382459c8b7 14 int setup(NetworkStack *ns);
dgriffin65 15:14382459c8b7 15
dgriffin65 15:14382459c8b7 16 virtual ~DNSClient();
dgriffin65 15:14382459c8b7 17 bool lookup(const char* hostname);
dgriffin65 15:14382459c8b7 18 bool set_server(const char* serverip, int port=53);
dgriffin65 15:14382459c8b7 19 uint32_t get_ip() {return m_ip;}
dgriffin65 15:14382459c8b7 20 const char* get_ip_address() {return m_ipaddr;}
dgriffin65 15:14382459c8b7 21
dgriffin65 15:14382459c8b7 22 protected:
dgriffin65 15:14382459c8b7 23 void poll();
dgriffin65 15:14382459c8b7 24 void callback();
dgriffin65 15:14382459c8b7 25 int response(uint8_t buf[], int size);
dgriffin65 15:14382459c8b7 26 int query(uint8_t buf[], int size, const char* hostname);
dgriffin65 15:14382459c8b7 27 void resolve(const char* hostname);
dgriffin65 15:14382459c8b7 28 uint8_t m_id[2];
dgriffin65 15:14382459c8b7 29 Timer m_interval;
dgriffin65 15:14382459c8b7 30 int m_retry;
dgriffin65 15:14382459c8b7 31 const char* m_hostname;
dgriffin65 15:14382459c8b7 32
dgriffin65 15:14382459c8b7 33 private:
dgriffin65 15:14382459c8b7 34 enum MyNetDnsState
dgriffin65 15:14382459c8b7 35 {
dgriffin65 15:14382459c8b7 36 MYNETDNS_START,
dgriffin65 15:14382459c8b7 37 MYNETDNS_PROCESSING, //Req has not completed
dgriffin65 15:14382459c8b7 38 MYNETDNS_NOTFOUND,
dgriffin65 15:14382459c8b7 39 MYNETDNS_ERROR,
dgriffin65 15:14382459c8b7 40 MYNETDNS_OK
dgriffin65 15:14382459c8b7 41 };
dgriffin65 15:14382459c8b7 42 MyNetDnsState m_state;
dgriffin65 15:14382459c8b7 43 UDPSocket *m_udp;
dgriffin65 15:14382459c8b7 44 NetworkStack *m_ns;
dgriffin65 15:14382459c8b7 45
dgriffin65 15:14382459c8b7 46 uint32_t m_ip;
dgriffin65 15:14382459c8b7 47 char m_ipaddr[24];
dgriffin65 15:14382459c8b7 48 };