Dependents: SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1
api/DnsRequest.h
- Committer:
- donatien
- Date:
- 2010-05-24
- Revision:
- 0:3717b703f76d
- Child:
- 1:e52ec2a24c6a
File content as of revision 0:3717b703f76d:
#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