0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This file was autogenerated by rpcgen, but should be modified by the developer.
|
|
16 |
* Make sure you don't use the -component_mod flag in future or this file will be overwritten.
|
|
17 |
* Mon Oct 13 13:43:15 2003
|
|
18 |
* System Includes
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
#include <stdio.h>
|
|
26 |
#include <math.h>
|
|
27 |
|
|
28 |
|
|
29 |
/****************************************************************************************
|
|
30 |
*
|
|
31 |
* Local Includes
|
|
32 |
*
|
|
33 |
***************************************************************************************/
|
|
34 |
#include "CSvcHacontroller.h"
|
|
35 |
#include "hacontroller.h"
|
|
36 |
#include "standard_service_manager.h"
|
|
37 |
|
|
38 |
|
|
39 |
/****************************************************************************************
|
|
40 |
*
|
|
41 |
* Macro Functions
|
|
42 |
*
|
|
43 |
***************************************************************************************/
|
|
44 |
|
|
45 |
|
|
46 |
/****************************************************************************************
|
|
47 |
*
|
|
48 |
* File-scope variables
|
|
49 |
*
|
|
50 |
***************************************************************************************/
|
|
51 |
static TStartupInfo iStartupInfo;
|
|
52 |
static CIntegerAllocator *iAliasHostAddressAllocator;
|
|
53 |
static CNetworkPartitionManager *iNetworkPartitionManager;
|
|
54 |
static CComponentManager<CSHacontroller> *iComponentManager;
|
|
55 |
|
|
56 |
/****************************************************************************************
|
|
57 |
*
|
|
58 |
* Implementation
|
|
59 |
*
|
|
60 |
***************************************************************************************/
|
|
61 |
|
|
62 |
|
|
63 |
/****************************************************************************************
|
|
64 |
*
|
|
65 |
* PUBLIC: GetInstanceKeyFromArgs
|
|
66 |
*
|
|
67 |
***************************************************************************************/
|
|
68 |
int CSvcHacontroller::GetInstanceKeyFromArgs( int aMethod, void *aArgs )
|
|
69 |
{
|
|
70 |
int rv;
|
|
71 |
int *ik_integer;
|
|
72 |
TOptionDesc *ik_option;
|
|
73 |
THaTunnelID *ik_tunnel_id;
|
|
74 |
TTimeoutRequest *ik_timeout;
|
|
75 |
TGetTunnelRequest *ik_tunnel_info;
|
|
76 |
|
|
77 |
switch( aMethod ) {
|
|
78 |
|
|
79 |
// Methods with an integer arg that is the key
|
|
80 |
case DSTR_REMOVEAGENT:
|
|
81 |
case STARTMOBILEAGENT:
|
|
82 |
case STOPMOBILEAGENT:
|
|
83 |
case GETMOBILEAGENTSTATUS:
|
|
84 |
case GETSTATUS:
|
|
85 |
case LISTTUNNELS:
|
|
86 |
ik_integer = (int*)aArgs;
|
|
87 |
rv = *ik_integer;
|
|
88 |
break;
|
|
89 |
|
|
90 |
// TOptionDesc
|
|
91 |
case SETSINGLEOPTION:
|
|
92 |
case REMOVESINGLEOPTION:
|
|
93 |
case ADDLISTOPTION:
|
|
94 |
case REMOVELISTOPTION:
|
|
95 |
ik_option = (TOptionDesc*)aArgs;
|
|
96 |
rv = ik_option->iAgentID;
|
|
97 |
break;
|
|
98 |
|
|
99 |
// THaTunnelID
|
|
100 |
case DESTROYTUNNELID:
|
|
101 |
ik_tunnel_id = (THaTunnelID*)aArgs;
|
|
102 |
rv = ik_tunnel_id->iAgentID;
|
|
103 |
break;
|
|
104 |
|
|
105 |
// Timeout
|
|
106 |
case SETTIMEOUT:
|
|
107 |
ik_timeout = (TTimeoutRequest*)aArgs;
|
|
108 |
rv = ik_timeout->iAgentID;
|
|
109 |
break;
|
|
110 |
|
|
111 |
// TGetTunnelRequest
|
|
112 |
case GETTUNNELINFO:
|
|
113 |
ik_tunnel_info = (TGetTunnelRequest*)aArgs;
|
|
114 |
rv = ik_tunnel_info->iAgentID;
|
|
115 |
break;
|
|
116 |
|
|
117 |
// Invalid
|
|
118 |
default:
|
|
119 |
rv = ERR_INVALID_METHOD;
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
return rv;
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
/****************************************************************************************
|
|
127 |
*
|
|
128 |
* PUBLIC: SetError
|
|
129 |
*
|
|
130 |
***************************************************************************************/
|
|
131 |
int CSvcHacontroller::SetError( int aMethod, void *aArgs, int aError )
|
|
132 |
{
|
|
133 |
int rv = ERR_NONE;
|
|
134 |
TResult *rv_result;
|
|
135 |
TComponentList *rv_cl;
|
|
136 |
THaStatus *rv_status;
|
|
137 |
THaTunnelList *rv_tunnellist;
|
|
138 |
THaTunnelInfo *rv_tunnel_info;
|
|
139 |
|
|
140 |
switch( aMethod ) {
|
|
141 |
|
|
142 |
// TComponentList
|
|
143 |
case LIST_DEVICES:
|
|
144 |
SET_LIST_ERROR_CODE( TComponentList, rv_cl );
|
|
145 |
break;
|
|
146 |
|
|
147 |
// TResult
|
|
148 |
case CSTR_CREATEAGENT:
|
|
149 |
case DSTR_REMOVEAGENT:
|
|
150 |
case STARTMOBILEAGENT:
|
|
151 |
case STOPMOBILEAGENT:
|
|
152 |
case SETSINGLEOPTION:
|
|
153 |
case REMOVESINGLEOPTION:
|
|
154 |
case ADDLISTOPTION:
|
|
155 |
case REMOVELISTOPTION:
|
|
156 |
case DESTROYTUNNELID:
|
|
157 |
SET_ERROR_CODE( TResult, iServiceResult, rv_result );
|
|
158 |
break;
|
|
159 |
|
|
160 |
// THaStatus
|
|
161 |
case GETSTATUS:
|
|
162 |
SET_ERROR_CODE( THaStatus, iCallResult.iServiceResult, rv_status );
|
|
163 |
break;
|
|
164 |
|
|
165 |
// THaTunnelList
|
|
166 |
case LISTTUNNELS:
|
|
167 |
SET_LIST_ERROR_CODE( THaTunnelList, rv_tunnellist );
|
|
168 |
break;
|
|
169 |
|
|
170 |
// THaTunnelInfo
|
|
171 |
case GETTUNNELINFO:
|
|
172 |
SET_ERROR_CODE( THaTunnelInfo, iCallResult.iServiceResult, rv_tunnel_info );
|
|
173 |
break;
|
|
174 |
|
|
175 |
// Invalid
|
|
176 |
default:
|
|
177 |
rv = ERR_INVALID_METHOD;
|
|
178 |
break;
|
|
179 |
}
|
|
180 |
return rv;
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
/****************************************************************************************
|
|
185 |
*
|
|
186 |
* PUBLIC: GetError
|
|
187 |
*
|
|
188 |
***************************************************************************************/
|
|
189 |
int CSvcHacontroller::GetError( int aMethod, void *aArgs )
|
|
190 |
{
|
|
191 |
TResult *result;
|
|
192 |
|
|
193 |
// check assumption
|
|
194 |
assert( (aMethod == CSTR_CREATEAGENT) || (aMethod == DSTR_REMOVEAGENT) );
|
|
195 |
|
|
196 |
// return error code
|
|
197 |
result = (TResult*)aArgs;
|
|
198 |
return result->iServiceResult;
|
|
199 |
}
|
|
200 |
|
|
201 |
|
|
202 |
/****************************************************************************************
|
|
203 |
*
|
|
204 |
* PUBLIC: StartRPCService
|
|
205 |
*
|
|
206 |
***************************************************************************************/
|
|
207 |
int CSvcHacontroller::StartRPCService( CComponentManager<CSHacontroller> *aComponentManager, TStartupInfo *aArg )
|
|
208 |
{
|
|
209 |
int err;
|
|
210 |
|
|
211 |
// save the startup info
|
|
212 |
iStartupInfo = *((TStartupInfo*)aArg);
|
|
213 |
|
|
214 |
// store the component manager
|
|
215 |
assert( iComponentManager == NULL );
|
|
216 |
iComponentManager = aComponentManager;
|
|
217 |
|
|
218 |
// setup the home address integer allocator
|
|
219 |
iAliasHostAddressAllocator = new CIntegerAllocator();
|
|
220 |
assert( iAliasHostAddressAllocator != NULL );
|
|
221 |
err = iAliasHostAddressAllocator->AddToIntegerPool( iStartupInfo.iBaseInterfaceStartHostAddressRange,
|
|
222 |
iStartupInfo.iBaseInterfaceStopHostAddressRange );
|
|
223 |
if( err == -1 ) {
|
|
224 |
delete iAliasHostAddressAllocator;
|
|
225 |
iAliasHostAddressAllocator = NULL;
|
|
226 |
return ERR_INTEGER_ALLOCATOR_SETUP_ERROR;
|
|
227 |
}
|
|
228 |
|
|
229 |
// setup the network partition manager
|
|
230 |
iNetworkPartitionManager = new CNetworkPartitionManager();
|
|
231 |
assert( iNetworkPartitionManager != NULL );
|
|
232 |
err = iNetworkPartitionManager->SetConfiguration( iStartupInfo.iVirtualNetworkPrefix,
|
|
233 |
iStartupInfo.iVirtualNetworkPrefixMask,
|
|
234 |
iStartupInfo.iVirtualNetworkAllocSize );
|
|
235 |
if( err == -1 ) {
|
|
236 |
delete iAliasHostAddressAllocator;
|
|
237 |
iAliasHostAddressAllocator = NULL;
|
|
238 |
delete iNetworkPartitionManager;
|
|
239 |
iNetworkPartitionManager = NULL;
|
|
240 |
return ERR_VIRTUAL_NETWORK_CONFIGURATION_ERROR;
|
|
241 |
}
|
|
242 |
|
|
243 |
|
|
244 |
// done - success
|
|
245 |
return ERR_NONE;
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
/****************************************************************************************
|
|
250 |
*
|
|
251 |
* PUBLIC: StopRPCService
|
|
252 |
*
|
|
253 |
***************************************************************************************/
|
|
254 |
int CSvcHacontroller::StopRPCService()
|
|
255 |
{
|
|
256 |
// delete the host address allocator
|
|
257 |
delete iAliasHostAddressAllocator;
|
|
258 |
iAliasHostAddressAllocator = NULL;
|
|
259 |
|
|
260 |
// delete the subnet address allocator
|
|
261 |
delete iNetworkPartitionManager;
|
|
262 |
iNetworkPartitionManager = NULL;
|
|
263 |
|
|
264 |
// cleanup the component manager (stubs do the deletion)
|
|
265 |
iComponentManager = NULL;
|
|
266 |
return ERR_NONE;
|
|
267 |
}
|
|
268 |
|
|
269 |
|
|
270 |
/****************************************************************************************
|
|
271 |
*
|
|
272 |
* PUBLIC: GetStartupInfo
|
|
273 |
*
|
|
274 |
***************************************************************************************/
|
|
275 |
TStartupInfo CSvcHacontroller::GetStartupInfo()
|
|
276 |
{
|
|
277 |
return iStartupInfo;
|
|
278 |
}
|
|
279 |
|
|
280 |
|
|
281 |
/****************************************************************************************
|
|
282 |
*
|
|
283 |
* PUBLIC: GetAliasHostAddressAllocator
|
|
284 |
*
|
|
285 |
***************************************************************************************/
|
|
286 |
CIntegerAllocator *CSvcHacontroller::GetAliasHostAddressAllocator()
|
|
287 |
{
|
|
288 |
return iAliasHostAddressAllocator;
|
|
289 |
}
|
|
290 |
|
|
291 |
|
|
292 |
/****************************************************************************************
|
|
293 |
*
|
|
294 |
* PUBLIC: GetAliasHostAddressAllocator
|
|
295 |
*
|
|
296 |
***************************************************************************************/
|
|
297 |
CNetworkPartitionManager *CSvcHacontroller::GetNetworkPartitionManager()
|
|
298 |
{
|
|
299 |
return iNetworkPartitionManager;
|
|
300 |
}
|
|
301 |
|