• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 
19 #ifndef OSCL_DNS_PARAM_H_INCLUDED
20 #define OSCL_DNS_PARAM_H_INCLUDED
21 
22 #include "oscl_socket_types.h"
23 #include "oscl_dns_tuneables.h"
24 #include "oscl_namestring.h"
25 #include "oscl_dns.h"
26 #include "oscl_mutex.h"
27 #include "oscl_semaphore.h"
28 
29 class OsclDNSRequestAO;
30 class OsclDNSRequest;
31 
32 #if(PV_DNS_IS_THREAD)
33 /*
34 ** Only the _OsclBasicAllocator is used in order to
35 ** avoid the need to init memory manager in the DNS thread.
36 */
37 typedef _OsclBasicAllocator TDNSRequestParamAllocator;
38 #else
39 typedef OsclMemAllocator TDNSRequestParamAllocator;
40 #endif
41 
42 /*
43 ** Base class for all DNS method parameter sets
44 ** A thread-safe, reference-counted parameter set.
45 ** A reference count is used since the data may need
46 ** to persist after the request is canceled while still
47 ** waiting on some blocking OS-level operation to complete.
48 */
49 class DNSRequestParam
50 {
51     public:
52 
~DNSRequestParam()53         virtual ~DNSRequestParam()
54         {
55 #if(PV_DNS_IS_THREAD)
56             iLock.Close();
57             iStartup.Close();
58 #endif
59         }
60 
61         void RemoveRef();
62 
63 #if(PV_DNS_SERVER)
64         void InThread();
65 #endif
66 
67         virtual void Destroy() = 0;
68 
69         TPVDNSFxn iFxn;
70         OsclDNSRequest *iDNSRequest;
71 
72 #if(PV_DNS_IS_THREAD)
73         bool iThreadKillFlag;
74         OsclMutex iLock;
75         OsclSemaphore iStartup;
76 #endif
77 
78 
79     protected:
80 
81         DNSRequestParam(TPVDNSFxn aFxn);
82 
83         uint32 iRefCount;
84 };
85 
86 
87 /*
88 ** Parameters for GetHostByName request
89 */
90 class GetHostByNameParam: public DNSRequestParam
91 {
92     public:
93 
94         //Use this routine to create, use DNSRequestParam::RemoveRef when finished.
95         static GetHostByNameParam* Create(const char *name, OsclNetworkAddress* &addr);
96 
97         //from DNSRequestParam
98         void Destroy();
99 
100         ~GetHostByNameParam();
101 
102         //request params.
103         char *iName;
104         OsclNetworkAddress *iAddr;
105 
106     private:
107 
108         GetHostByNameParam(const char *name, OsclNetworkAddress* &addr);
109 
110 
111 } ;
112 
113 
114 #endif
115 
116