Dependents: SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1
Diff: api/DnsRequest.h
- Revision:
- 0:3717b703f76d
- Child:
- 1:e52ec2a24c6a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api/DnsRequest.h Mon May 24 10:23:42 2010 +0000 @@ -0,0 +1,65 @@ +#ifndef DNSREQUEST_H +#define DNSREQUEST_H + +#include "if/net/net.h" +//Essentially it is a safe interface to NetDnsRequest + +enum DnsRequestErr +{ + __DNS_MIN = -0xFFFF, + DNS_SETUP, //NetDnsRequest not properly configured + DNS_IF, //If has problems, does not exist or is not initialized + DNS_MEM, //Not enough mem + DNS_INUSE, //If/Port is in use + DNS_PROCESSING, //Req has not completed +//... + DNS_OK = 0 +}; + +enum DnsReply +{ + DNS_PRTCL, + DNS_NOTFOUND, //Hostname is unknown + DNS_ERROR, //Problem with DNS Service + //... + DNS_FOUND, +}; + +class DnsRequest +{ +public: + DnsRequest(); + ~DnsRequest(); + + DnsRequestErr resolve(const char* hostname); + DnsRequestErr resolve(Host* pHost); + + class CDummy; + void setOnReply( void (*pMethod)(DnsReply) ); + template<class T> + //Linker bug : Must be defined here :( + void setOnReply( T* pItem, void (T::*pMethod)(DnsReply) ) + { + m_pCbItem = (CDummy*) pItem; + m_pCbMeth = (void (CDummy::*)(DnsReply)) pMethod; + } + + DnsRequestErr getResult(IpAddr* pIp); + + DnsRequestErr close(); + +protected: + void onNetDnsReply(NetDnsReply r); + DnsRequestErr checkInst(); + +private: + NetDnsRequest* m_pNetDnsRequest; + + CDummy* m_pCbItem; + void (CDummy::*m_pCbMeth)(DnsReply); + + void (*m_pCb)(DnsReply); + +}; + +#endif