Main Page   Modules   Class Hierarchy   Data Structures   File List   Data Fields   Globals   Related Pages  

oscl_dns_param.h

Go to the documentation of this file.
00001 
00002 #ifndef OSCL_DNS_PARAM_H_INCLUDED
00003 #define OSCL_DNS_PARAM_H_INCLUDED
00004 
00005 #include "oscl_socket_types.h"
00006 #include "oscl_dns_tuneables.h"
00007 #include "oscl_namestring.h"
00008 #include "oscl_dns.h"
00009 #include "oscl_mutex.h"
00010 #include "oscl_semaphore.h"
00011 
00012 class OsclDNSRequestAO;
00013 class OsclDNSRequest;
00014 
00015 #if(PV_DNS_IS_THREAD)
00016 /*
00017 ** Only the _OsclBasicAllocator is used in order to
00018 ** avoid the need to init memory manager in the DNS thread.
00019 */
00020 typedef _OsclBasicAllocator TDNSRequestParamAllocator;
00021 #else
00022 typedef OsclMemAllocator TDNSRequestParamAllocator;
00023 #endif
00024 
00025 /*
00026 ** Base class for all DNS method parameter sets
00027 ** A thread-safe, reference-counted parameter set.
00028 ** A reference count is used since the data may need
00029 ** to persist after the request is canceled while still
00030 ** waiting on some blocking OS-level operation to complete.
00031 */
00032 class DNSRequestParam
00033 {
00034     public:
00035 
00036         virtual ~DNSRequestParam()
00037         {
00038 #if(PV_DNS_IS_THREAD)
00039             iLock.Close();
00040             iStartup.Close();
00041 #endif
00042         }
00043 
00044         void RemoveRef();
00045 
00046 #if(PV_DNS_SERVER)
00047         void InThread();
00048 #endif
00049 
00050         virtual void Destroy() = 0;
00051 
00052         TPVDNSFxn iFxn;
00053         OsclDNSRequest *iDNSRequest;
00054 
00055 #if(PV_DNS_IS_THREAD)
00056         bool iThreadKillFlag;
00057         OsclMutex iLock;
00058         OsclSemaphore iStartup;
00059 #endif
00060 
00061 
00062     protected:
00063 
00064         DNSRequestParam(TPVDNSFxn aFxn);
00065 
00066         uint32 iRefCount;
00067 };
00068 
00069 
00070 /*
00071 ** Parameters for GetHostByName request
00072 */
00073 class GetHostByNameParam: public DNSRequestParam
00074 {
00075     public:
00076 
00077         //Use this routine to create, use DNSRequestParam::RemoveRef when finished.
00078         static GetHostByNameParam* Create(const char *name, OsclNetworkAddress* &addr, Oscl_Vector<OsclNetworkAddress, OsclMemAllocator>* aAddressList);
00079 
00080         //from DNSRequestParam
00081         void Destroy();
00082 
00083         ~GetHostByNameParam();
00084 
00085         void PersistHostAddress(const OsclNetworkAddress& addr)
00086         {
00087             if (iAddressList && (iAddressList->size() < iAddressList->capacity()))
00088             {
00089                 iAddressList->push_back(addr);
00090             }
00091 
00092             if (0 == oscl_strcmp(OSCL_STATIC_CAST(const char*, iAddr->ipAddr.Str()), ""))
00093                 iAddr->ipAddr.Set(addr.ipAddr.Str());
00094         }
00095 
00096         bool canPersistMoreHostAddresses()
00097         {
00098             return (iAddressList && (iAddressList->size() < iAddressList->capacity())) || (0 == oscl_strcmp(OSCL_STATIC_CAST(const char*, iAddr->ipAddr.Str()), ""));
00099         }
00100 
00101         //request params.
00102         char *iName;
00103         OsclNetworkAddress *iAddr;
00104         Oscl_Vector<OsclNetworkAddress, OsclMemAllocator> *iAddressList;
00105         enum
00106         {
00107             addressListCapacity = 10
00108         };
00109 
00110     private:
00111 
00112         GetHostByNameParam(const char *name, OsclNetworkAddress* &addr, Oscl_Vector<OsclNetworkAddress, OsclMemAllocator>* aAddressList);
00113 
00114 
00115 } ;
00116 
00117 
00118 #endif
00119 

OSCL API
Posting Version: CORE_8.000.1.1_RC4