testexecmgmt/ucc/Source/Uccs.v2/ServiceStubs/MobileAgent/CMobileAgentServiceStub.cpp
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     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 * System Includes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include <assert.h>
       
    23 
       
    24 
       
    25 /*******************************************************************************
       
    26  *
       
    27  * Local Includes
       
    28  *
       
    29  ******************************************************************************/
       
    30 #include "strncpynt.h"
       
    31 #include "CMobileAgentServiceStub.h"
       
    32 #include "CCMncontroller.h"
       
    33 #include "../../Core/UCCS_ServiceValues.h"
       
    34 #include "../../Core/UCCS_ErrorCodes.h"
       
    35 
       
    36 
       
    37 /*******************************************************************************
       
    38  *
       
    39  * Definitions
       
    40  *
       
    41  ******************************************************************************/
       
    42 #define MAXBUFFERSIZE	2048
       
    43 
       
    44 
       
    45 /*******************************************************************************
       
    46  *
       
    47  * Macro Functions
       
    48  *
       
    49  ******************************************************************************/
       
    50 																		
       
    51 /*******************************************************************************
       
    52  *
       
    53  * Constructor / Destructor
       
    54  *
       
    55  ******************************************************************************/
       
    56 CMobileAgentServiceStub::CMobileAgentServiceStub()
       
    57 {
       
    58 	iClientMobileAgent = new CCMncontroller();
       
    59 	assert( iClientMobileAgent != NULL );
       
    60 }
       
    61 
       
    62 
       
    63 CMobileAgentServiceStub::~CMobileAgentServiceStub()
       
    64 {
       
    65 	delete iClientMobileAgent;
       
    66 }
       
    67 
       
    68 
       
    69 /*******************************************************************************
       
    70  *
       
    71  * Startup / Shutdown
       
    72  *
       
    73  ******************************************************************************/
       
    74 int CMobileAgentServiceStub::StartUccsService( char *aHostName, int *aErrorCode, int *aUnused )
       
    75 {
       
    76 	int client_stub_error;
       
    77 	
       
    78 	// check params
       
    79 	assert( aHostName != NULL );
       
    80 	assert( aErrorCode != NULL );
       
    81 	*aErrorCode = 0;
       
    82 	
       
    83 	//copy to class variable so that startRPCservice can use it later on
       
    84 	iHostName = aHostName;
       
    85 
       
    86 	// connect to the remote service
       
    87 	client_stub_error = iClientMobileAgent->Connect( iHostName );
       
    88 
       
    89 	// return the result
       
    90 	return client_stub_error;
       
    91 }
       
    92 
       
    93 
       
    94 int CMobileAgentServiceStub::StopUccsService( int *aErrorCode, int *aUnused )
       
    95 {
       
    96 	int client_stub_error;
       
    97 
       
    98 	// check params
       
    99 	assert( aErrorCode != NULL );
       
   100 	*aErrorCode = 0;
       
   101 
       
   102 	// shutdown the stub -- force it to close
       
   103 	client_stub_error = iClientMobileAgent->Disconnect();
       
   104 	
       
   105 	// done
       
   106 	return client_stub_error;
       
   107 }
       
   108 
       
   109 
       
   110 /*******************************************************************************
       
   111  *
       
   112  * IssueCommand
       
   113  *
       
   114  ******************************************************************************/
       
   115 CDataRecord* CMobileAgentServiceStub::IssueCommand( CDataRecord* aRequest )
       
   116 {
       
   117 	int i, err, client_stub_error, method_id = -1;
       
   118 	char *tmp_string;
       
   119 	CDataRecord *request_reply;
       
   120 
       
   121 	int rv_integer, sarg_integer;
       
   122 	TComponentList rv_component_list;
       
   123 	TOptionDesc sarg_option;
       
   124 	TResult rv_result;
       
   125 	TTunnelingModeDesc sarg_tunnel_mode;
       
   126 	TPolicyRequest sarg_policy_request;
       
   127 	TMobileNodeStatus rv_mnstatus;
       
   128 	TForeignAgentList rv_foreign_agent_list;
       
   129 	TForeignAgentInfo rv_foreign_agent_info, *tmp_foreign_agent_info;
       
   130 	TTimeoutRequest sarg_timeout;
       
   131 	TForeignAgentInfoRequest sarg_foreign_agent_info;
       
   132 	THomeAddressDesc sarg_home_address;
       
   133 
       
   134 	// check params
       
   135 	assert( aRequest != NULL );
       
   136 
       
   137 	// create a standard reply 
       
   138 	request_reply = CreateBaseReply( aRequest );
       
   139 	assert( request_reply != NULL );
       
   140 
       
   141 	// get and check the method_id
       
   142 	err = request_reply->GetFieldAsInt( "METHODID", &method_id );
       
   143 	if( method_id == -1 ) {
       
   144 		UpdateCompletionCode( request_reply, ERR_INVALID_METHOD );
       
   145 		return request_reply;
       
   146 	}
       
   147 
       
   148 	// now dispatch and call the appropriate method
       
   149 	switch( method_id ) {
       
   150 
       
   151 	// ss_startuprpcservice
       
   152 	case 1:
       
   153 
       
   154 		// make the call and update the return value
       
   155 		client_stub_error = iClientMobileAgent->ss_startuprpcservice( &rv_integer );
       
   156 		UpdateCompletionCode( request_reply, client_stub_error );		
       
   157 		if( client_stub_error != ERR_NONE ) {
       
   158 			break;
       
   159 		}
       
   160 
       
   161 		// set any return information
       
   162 		request_reply->NewField( "RESULT", rv_integer );
       
   163 		break;
       
   164 
       
   165 	// sc_shutdownrpcservice
       
   166 	case 2:
       
   167 			
       
   168 		// extract the parameters
       
   169 		GETINTEGERARGUMENT( "FORCE", &sarg_integer, 1, 1, aRequest, request_reply );
       
   170 		
       
   171 		// make the call and update the return value
       
   172 		client_stub_error = iClientMobileAgent->sc_shutdownrpcservice( sarg_integer, &rv_integer );
       
   173 		UpdateCompletionCode( request_reply, client_stub_error );
       
   174 		if( client_stub_error != ERR_NONE ) {
       
   175 			break;
       
   176 		}
       
   177 
       
   178 		// set the return values
       
   179 		request_reply->NewField( "RESULT", rv_integer );
       
   180 		break;
       
   181 
       
   182 	// list_devices
       
   183 	case 30:
       
   184 
       
   185 		// make the call and update the return value
       
   186 		client_stub_error = iClientMobileAgent->list_devices( &rv_component_list );
       
   187 		UpdateCompletionCode( request_reply, client_stub_error );
       
   188 		if( client_stub_error != ERR_NONE ) {
       
   189 			break;
       
   190 		}
       
   191 
       
   192 		// set the return values
       
   193 		request_reply->NewField( "AGENTCOUNT", rv_component_list.TComponentList_len );
       
   194 		for( i = 0; i < rv_component_list.TComponentList_len; i++ ) {
       
   195 			AddIteratedIntegerFieldName( "AGENTID", i, (rv_component_list.TComponentList_val)[i], request_reply );
       
   196 		}
       
   197 		break;		
       
   198 
       
   199 	// cstr_createagent
       
   200 	case 31:
       
   201 
       
   202 		//make the call and update the return value
       
   203 		client_stub_error = iClientMobileAgent->cstr_createagent( &rv_result ); 
       
   204 		UpdateCompletionCode( request_reply, client_stub_error );
       
   205 		if( client_stub_error != ERR_NONE ) {
       
   206 			break;
       
   207 		}
       
   208 
       
   209 		// set the return values
       
   210 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   211 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   212 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   213 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   214 		break;
       
   215 
       
   216 	// dstr_removeagent
       
   217 	case 32:
       
   218 
       
   219 		// extract the parameters
       
   220 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   221 
       
   222 		//make the call and update the return value
       
   223 		client_stub_error = iClientMobileAgent->dstr_removeagent( sarg_integer, &rv_integer ); 
       
   224 		UpdateCompletionCode( request_reply, client_stub_error );
       
   225 		if( client_stub_error != ERR_NONE ) {
       
   226 			break;
       
   227 		}
       
   228 
       
   229 		// set the return values
       
   230 		request_reply->NewField( "RESULT", rv_integer );
       
   231 		break;
       
   232 	
       
   233 	// startmobileagent
       
   234 	case 3:
       
   235 
       
   236 		// extract the parameters
       
   237 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   238 
       
   239 		//make the call and update the return value
       
   240 		client_stub_error = iClientMobileAgent->startmobileagent( sarg_integer, &rv_result ); 
       
   241 		UpdateCompletionCode( request_reply, client_stub_error );
       
   242 		if( client_stub_error != ERR_NONE ) {
       
   243 			break;
       
   244 		}
       
   245 
       
   246 		// set the return values
       
   247 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   248 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   249 		break;
       
   250 
       
   251 	// stopmobileagent
       
   252 	case 4: 
       
   253 
       
   254 		// extract the parameters
       
   255 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   256 
       
   257 		//make the call and update the return value
       
   258 		client_stub_error = iClientMobileAgent->stopmobileagent( sarg_integer, &rv_result ); 
       
   259 		UpdateCompletionCode( request_reply, client_stub_error );
       
   260 		if( client_stub_error != ERR_NONE ) {
       
   261 			break;
       
   262 		}
       
   263 
       
   264 		// set the return values
       
   265 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   266 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   267 		break;
       
   268 
       
   269 	// getmobileagentstatus
       
   270 	case 5:
       
   271 
       
   272 		// extract the parameters
       
   273 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   274 
       
   275 		// make the call and update the return value
       
   276 		client_stub_error = iClientMobileAgent->getmobileagentstatus( sarg_integer, &rv_result ); 
       
   277 		UpdateCompletionCode( request_reply, client_stub_error );
       
   278 		if( client_stub_error != ERR_NONE ) {
       
   279 			break;
       
   280 		}
       
   281 
       
   282 		// set the return values
       
   283 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   284 		request_reply->NewField( "MOBILE_NODE_AGENT_PROCESS_STATUS", rv_result.iData0 );
       
   285 		break;
       
   286 
       
   287 	// setsingleoption
       
   288 	case 6:
       
   289 
       
   290 		// extract the parameters
       
   291 		GETINTEGERARGUMENT( "AGENTID", &(sarg_option.iAgentID), 1, 0, aRequest, request_reply );
       
   292 		GETSTRINGARGUMENT( "TOKEN", &tmp_string, 2, 0, aRequest, request_reply );
       
   293 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionToken, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   294 		GETSTRINGARGUMENT( "VALUE", &tmp_string, 3, 0, aRequest, request_reply );
       
   295 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionValue, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   296 		sarg_option.iOptionBlockStart[0] = sarg_option.iOptionBlockEnd[0] = 0;
       
   297 
       
   298 		// make the call and update the return value
       
   299 		client_stub_error = iClientMobileAgent->setsingleoption( sarg_option, &rv_result ); 
       
   300 		UpdateCompletionCode( request_reply, client_stub_error );
       
   301 		if( client_stub_error != ERR_NONE ) {
       
   302 			break;
       
   303 		}
       
   304 
       
   305 		// set the return values
       
   306 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   307 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   308 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   309 		break;
       
   310 
       
   311 	// removesingleoption
       
   312 	case 33:
       
   313 
       
   314 		// extract the parameters
       
   315 		GETINTEGERARGUMENT( "AGENTID", &(sarg_option.iAgentID), 1, 0, aRequest, request_reply );
       
   316 		GETSTRINGARGUMENT( "TOKEN", &tmp_string, 2, 0, aRequest, request_reply );
       
   317 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionToken, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   318 		sarg_option.iOptionValue[0] = sarg_option.iOptionBlockStart[0] = sarg_option.iOptionBlockEnd[0] = 0;
       
   319 
       
   320 		// make the call and update the return value
       
   321 		client_stub_error = iClientMobileAgent->removesingleoption( sarg_option, &rv_result ); 
       
   322 		UpdateCompletionCode( request_reply, client_stub_error );
       
   323 		if( client_stub_error != ERR_NONE ) {
       
   324 			break;
       
   325 		}
       
   326 
       
   327 		// set the return values
       
   328 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   329 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   330 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   331 		break;
       
   332 
       
   333 	// addlistoption
       
   334 	case 7:
       
   335 
       
   336 		// extract the parameters
       
   337 		GETINTEGERARGUMENT( "AGENTID", &(sarg_option.iAgentID), 1, 0, aRequest, request_reply );
       
   338 		GETSTRINGARGUMENT( "VALUE", &tmp_string, 2, 0, aRequest, request_reply );
       
   339 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionValue, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   340 		GETSTRINGARGUMENT( "BLOCKSTART", &tmp_string, 2, 0, aRequest, request_reply );
       
   341 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionBlockStart, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   342 		GETSTRINGARGUMENT( "BLOCKEND", &tmp_string, 2, 0, aRequest, request_reply );
       
   343 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionBlockEnd, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   344 		sarg_option.iOptionToken[0] = 0;
       
   345 	
       
   346 		// make the call and update the return value
       
   347 		client_stub_error = iClientMobileAgent->addlistoption( sarg_option, &rv_result ); 
       
   348 		UpdateCompletionCode( request_reply, client_stub_error );
       
   349 		if( client_stub_error != ERR_NONE ) {
       
   350 			break;
       
   351 		}
       
   352 
       
   353 		// set the return values
       
   354 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   355 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   356 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   357 		break;
       
   358 
       
   359 	// removelistoption
       
   360 	case 8:
       
   361 
       
   362 		// extract the parameters
       
   363 		GETINTEGERARGUMENT( "AGENTID", &(sarg_option.iAgentID), 1, 0, aRequest, request_reply );
       
   364 		GETSTRINGARGUMENT( "TOKEN", &tmp_string, 2, 0, aRequest, request_reply );
       
   365 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionToken, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   366 		GETSTRINGARGUMENT( "BLOCKSTART", &tmp_string, 2, 0, aRequest, request_reply );
       
   367 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionBlockStart, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   368 		GETSTRINGARGUMENT( "BLOCKEND", &tmp_string, 2, 0, aRequest, request_reply );
       
   369 		STRNCPY_NULL_TERMINATE( sarg_option.iOptionBlockEnd, tmp_string, X_MAXOPTIONTOKENSIZE );
       
   370 		sarg_option.iOptionValue[0] = 0;
       
   371 	
       
   372 		// make the call and update the return value
       
   373 		client_stub_error = iClientMobileAgent->removelistoption( sarg_option, &rv_result ); 
       
   374 		UpdateCompletionCode( request_reply, client_stub_error );
       
   375 		if( client_stub_error != ERR_NONE ) {
       
   376 			break;
       
   377 		}
       
   378 
       
   379 		// set the return values
       
   380 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   381 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   382 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   383 		break;
       
   384 
       
   385 
       
   386 	// sethomeaddress
       
   387 	case 23:
       
   388 		// extract the parameters
       
   389 		GETINTEGERARGUMENT( "AGENTID", &(sarg_home_address.iAgentID), 1, 0, aRequest, request_reply );
       
   390 		GETSTRINGARGUMENT( "HOME_ADDRESS", &tmp_string, 2, 0, aRequest, request_reply );
       
   391 		sarg_home_address.iHomeAddress = inet_addr( tmp_string );
       
   392 		GETINTEGERARGUMENT( "HOME_ADDRESS_PREFIX", &(sarg_home_address.iHomeAddressPrefix), 3, 0, aRequest, request_reply );
       
   393 		GETSTRINGARGUMENT( "HOME_AGENT_ADDRESS", &tmp_string, 4, 0, aRequest, request_reply );
       
   394 		sarg_home_address.iHomeAgentAddress = inet_addr( tmp_string );
       
   395 		GETSTRINGARGUMENT( "INTERFACE", &tmp_string, 5, 0, aRequest, request_reply );
       
   396 		STRNCPY_NULL_TERMINATE( sarg_home_address.iInterfaceName, tmp_string, X_MAXINTERFACENAMELEN );
       
   397 
       
   398 		//make the call and update the return value
       
   399 		client_stub_error = iClientMobileAgent->sethomeaddress( sarg_home_address, &rv_result ); 
       
   400 		UpdateCompletionCode( request_reply, client_stub_error );
       
   401 		if( client_stub_error != ERR_NONE ) {
       
   402 			break;
       
   403 		}
       
   404 
       
   405 		// set the return values
       
   406 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   407 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   408 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   409 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   410 		break;
       
   411 
       
   412 	// getcareofaddress
       
   413 	case 9:
       
   414 
       
   415 		// extract the parameters
       
   416 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   417 
       
   418 		//make the call and update the return value
       
   419 		client_stub_error = iClientMobileAgent->getcareofaddress( sarg_integer, &rv_result ); 
       
   420 		UpdateCompletionCode( request_reply, client_stub_error );
       
   421 		if( client_stub_error != ERR_NONE ) {
       
   422 			break;
       
   423 		}
       
   424 
       
   425 		// set the return values
       
   426 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   427 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   428 		request_reply->NewField( "RESULT_DATA0", IntToAddress(rv_result.iData0) );
       
   429 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   430 		break;
       
   431 		
       
   432 	
       
   433 	// getstatus
       
   434 	case 11:
       
   435 
       
   436 		// extract the parameters
       
   437 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   438 
       
   439 		//make the call and update the return value
       
   440 		client_stub_error = iClientMobileAgent->getstatus( sarg_integer, &rv_mnstatus ); 
       
   441 		UpdateCompletionCode( request_reply, client_stub_error );
       
   442 		if( client_stub_error != ERR_NONE ) {
       
   443 			break;
       
   444 		}
       
   445 
       
   446 		// set the return values
       
   447 		request_reply->NewField( "RESULT", rv_mnstatus.iCallResult.iServiceResult );
       
   448 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_mnstatus.iCallResult.iSubComponentResult );
       
   449 		request_reply->NewField( "RESULT_DATA0", rv_mnstatus.iCallResult.iData0 );
       
   450 		request_reply->NewField( "RESULT_DATA1", rv_mnstatus.iCallResult.iData1 );
       
   451 		request_reply->NewField( "STATUS_CONNECTED", rv_mnstatus.iConnected );
       
   452 		request_reply->NewField( "STATUS_TUNNEL_UP", rv_mnstatus.iTunnelUp );
       
   453 		request_reply->NewField( "STATUS_LOCAL_ADDRESS", IntToAddress(rv_mnstatus.iLocalAddress) );
       
   454 		request_reply->NewField( "STATUS_COLOCATED_ADDRESS", IntToAddress(rv_mnstatus.iColocatedAddress) );
       
   455 		request_reply->NewField( "STATUS_FOREIGN_AGENT_ADDRESS", IntToAddress(rv_mnstatus.iForeignAgentAddress) );
       
   456 		request_reply->NewField( "STATUS_HOME_AGENT_ADDRESS", IntToAddress(rv_mnstatus.iHomeAgentAddress) );
       
   457 		request_reply->NewField( "STATUS_HOME_ADDRESS", IntToAddress(rv_mnstatus.iHomeAddress) );
       
   458 		request_reply->NewField( "STATUS_LIFETIME_REMAINING", rv_mnstatus.iLifetimeRemaining);
       
   459 		request_reply->NewField( "STATUS_LAST_REGISTRATION_REPLY_CODE", rv_mnstatus.iReplyCode );
       
   460 		request_reply->NewField( "STATUS_SECONDS_SINCE_LAST_REPLY", rv_mnstatus.iSecondsSinceLastReply );
       
   461 		request_reply->NewField( "STATUS_SECONDS_SINCE_LAST_REQUEST", rv_mnstatus.iSecondsSinceLastRequest );
       
   462 		request_reply->NewField( "STATUS_INFO_TEXT", rv_mnstatus.iInfoText );
       
   463 		request_reply->NewField( "STATUS_LAST_ERROR_STRING", rv_mnstatus.iLastErrorString );
       
   464 		break;
       
   465 
       
   466 
       
   467 	// connect
       
   468 	case 12:
       
   469 
       
   470 		// extract the parameters
       
   471 		GETINTEGERARGUMENT( "AGENTID", &(sarg_tunnel_mode.iAgentID), 1, 0, aRequest, request_reply );
       
   472 		GETINTEGERARGUMENT( "TUNNELMODE", (int*)&(sarg_tunnel_mode.iTunnelMode), 2, 0, aRequest, request_reply );
       
   473 
       
   474 		//make the call and update the return value
       
   475 		client_stub_error = iClientMobileAgent->connect( sarg_tunnel_mode, &rv_result ); 
       
   476 		UpdateCompletionCode( request_reply, client_stub_error );
       
   477 		if( client_stub_error != ERR_NONE ) {
       
   478 			break;
       
   479 		}
       
   480 
       
   481 		// set the return values
       
   482 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   483 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   484 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   485 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   486 		break;
       
   487 
       
   488 
       
   489 	// disconnect
       
   490 	case 13:
       
   491 
       
   492 		// extract the parameters
       
   493 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   494 
       
   495 		//make the call and update the return value
       
   496 		client_stub_error = iClientMobileAgent->disconnect( sarg_integer, &rv_result ); 
       
   497 		UpdateCompletionCode( request_reply, client_stub_error );
       
   498 		if( client_stub_error != ERR_NONE ) {
       
   499 			break;
       
   500 		}
       
   501 
       
   502 		// set the return values
       
   503 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   504 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   505 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   506 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   507 		break;
       
   508 
       
   509 
       
   510 	// confirm
       
   511 	case 16:
       
   512 
       
   513 		// extract the parameters
       
   514 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   515 
       
   516 		//make the call and update the return value
       
   517 		client_stub_error = iClientMobileAgent->confirm( sarg_integer, &rv_result ); 
       
   518 		UpdateCompletionCode( request_reply, client_stub_error );
       
   519 		if( client_stub_error != ERR_NONE ) {
       
   520 			break;
       
   521 		}
       
   522 
       
   523 		// set the return values
       
   524 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   525 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   526 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   527 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   528 		break;
       
   529 
       
   530 
       
   531 	// rescaninterfaces
       
   532 	case 17:
       
   533 
       
   534 		// extract the parameters
       
   535 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   536 
       
   537 		//make the call and update the return value
       
   538 		client_stub_error = iClientMobileAgent->rescaninterfaces( sarg_integer, &rv_result ); 
       
   539 		UpdateCompletionCode( request_reply, client_stub_error );
       
   540 		if( client_stub_error != ERR_NONE ) {
       
   541 			break;
       
   542 		}
       
   543 
       
   544 		// set the return values
       
   545 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   546 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   547 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   548 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   549 		break;
       
   550 
       
   551 	
       
   552 	// setfapolicy
       
   553 	case 18:
       
   554 
       
   555 		// extract the parameters
       
   556 		GETINTEGERARGUMENT( "AGENTID", &(sarg_policy_request.iAgentID), 1, 0, aRequest, request_reply );
       
   557 		GETINTEGERARGUMENT( "POLICY", &(sarg_policy_request.iPolicy), 2, 0, aRequest, request_reply );
       
   558 
       
   559 		//make the call and update the return value
       
   560 		client_stub_error = iClientMobileAgent->setfapolicy( sarg_policy_request, &rv_result ); 
       
   561 		UpdateCompletionCode( request_reply, client_stub_error );
       
   562 		if( client_stub_error != ERR_NONE ) {
       
   563 			break;
       
   564 		}
       
   565 
       
   566 		// set the return values
       
   567 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   568 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   569 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   570 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   571 		break;
       
   572 
       
   573 
       
   574 	// getfapolicy 
       
   575 	case 19:
       
   576 
       
   577 		// extract the parameters
       
   578 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   579 
       
   580 		//make the call and update the return value
       
   581 		client_stub_error = iClientMobileAgent->getfapolicy( sarg_integer, &rv_result ); 
       
   582 		UpdateCompletionCode( request_reply, client_stub_error );
       
   583 		if( client_stub_error != ERR_NONE ) {
       
   584 			break;
       
   585 		}
       
   586 
       
   587 		// set the return values
       
   588 		request_reply->NewField( "RESULT", rv_result.iServiceResult );
       
   589 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_result.iSubComponentResult );
       
   590 		request_reply->NewField( "RESULT_DATA0", rv_result.iData0 );
       
   591 		request_reply->NewField( "RESULT_DATA1", rv_result.iData1 );
       
   592 		break;
       
   593 
       
   594 
       
   595 	// listforeignagents
       
   596 	case 20:
       
   597 
       
   598 		// extract the parameters
       
   599 		GETINTEGERARGUMENT( "AGENTID", &sarg_integer, 1, 0, aRequest, request_reply );
       
   600 
       
   601 		//make the call and update the return value
       
   602 		client_stub_error = iClientMobileAgent->listforeignagents( sarg_integer, &rv_foreign_agent_list ); 
       
   603 		UpdateCompletionCode( request_reply, client_stub_error );
       
   604 		if( client_stub_error != ERR_NONE ) {
       
   605 			break;
       
   606 		}
       
   607 
       
   608 		// set the return values
       
   609 		request_reply->NewField( "FOREIGNAGENTCOUNT", rv_foreign_agent_list.TForeignAgentList_len );
       
   610 		for( i = 0; i < (signed)(rv_foreign_agent_list.TForeignAgentList_len); i++ ) {
       
   611 			tmp_foreign_agent_info = &((rv_foreign_agent_list.TForeignAgentList_val)[i]);
       
   612 			AddIteratedStringFieldName(	"FOREIGN_AGENT_ADDRESS", i, IntToAddress(tmp_foreign_agent_info->iForeignAgentAddress), request_reply );
       
   613 			AddIteratedStringFieldName(	"INTERFACE_NAME", i, tmp_foreign_agent_info->iInterfaceName, request_reply );
       
   614 			AddIteratedIntegerFieldName( "PRIORITY", i, tmp_foreign_agent_info->iPriority, request_reply );
       
   615 			AddIteratedStringFieldName(	"NAI", i, tmp_foreign_agent_info->iNAI, request_reply );
       
   616 			AddIteratedIntegerFieldName( "INUSE", i, tmp_foreign_agent_info->iInUse, request_reply );
       
   617 			AddIteratedIntegerFieldName( "INTERFACE_INDEX", i, tmp_foreign_agent_info->iInterfaceIndex, request_reply );
       
   618 			AddIteratedIntegerFieldName( "LAST_ADVERTISEMENT", i, tmp_foreign_agent_info->iLastAdvertisement, request_reply );
       
   619 			AddIteratedIntegerFieldName( "ADVERTISEMENT_EXPIRY", i, tmp_foreign_agent_info->iAdvertisementExpiry, request_reply );
       
   620 		}
       
   621 
       
   622 		// free the memory (if any was allocated)
       
   623 		if( rv_foreign_agent_list.TForeignAgentList_len > 0 ) {
       
   624 			XdrFree( (char**)&(rv_foreign_agent_list.TForeignAgentList_val), (int*)&(rv_foreign_agent_list.TForeignAgentList_len) );
       
   625 		}
       
   626 		break;
       
   627 
       
   628 
       
   629 	// getforeignagentinfo
       
   630 	case 21:
       
   631 
       
   632 		// extract the parameters
       
   633 		GETINTEGERARGUMENT( "AGENTID", &(sarg_foreign_agent_info.iAgentID), 1, 0, aRequest, request_reply );
       
   634 		GETSTRINGARGUMENT( "FOREIGN_AGENT_ADDRESS", &tmp_string, 2, 0, aRequest, request_reply );
       
   635 		sarg_foreign_agent_info.iForeignAgentID = AddressToInt( tmp_string );
       
   636 
       
   637 		//make the call and update the return value
       
   638 		client_stub_error = iClientMobileAgent->getforeignagentinfo( sarg_foreign_agent_info, &rv_foreign_agent_info ); 
       
   639 		UpdateCompletionCode( request_reply, client_stub_error );
       
   640 		if( client_stub_error != ERR_NONE ) {
       
   641 			break;
       
   642 		}
       
   643 
       
   644 		// set the return value
       
   645 		request_reply->NewField( "RESULT", rv_foreign_agent_info.iCallResult.iServiceResult );
       
   646 		request_reply->NewField( "RESULT_SUB_COMPONENT", rv_foreign_agent_info.iCallResult.iSubComponentResult );
       
   647 		request_reply->NewField( "RESULT_DATA0", rv_foreign_agent_info.iCallResult.iData0 );
       
   648 		request_reply->NewField( "RESULT_DATA1", rv_foreign_agent_info.iCallResult.iData1 );
       
   649 		request_reply->NewField( "FOREIGN_AGENT_ADDRESS", IntToAddress(rv_foreign_agent_info.iForeignAgentAddress) );
       
   650 		request_reply->NewField( "INTERFACE_NAME", rv_foreign_agent_info.iInterfaceName );
       
   651 		request_reply->NewField( "PRIORITY", rv_foreign_agent_info.iPriority );
       
   652 		request_reply->NewField( "NAI", rv_foreign_agent_info.iNAI );
       
   653 		request_reply->NewField( "INUSE", rv_foreign_agent_info.iInUse );
       
   654 		request_reply->NewField( "INTERFACE_INDEX",	rv_foreign_agent_info.iInterfaceIndex );
       
   655 		request_reply->NewField( "LAST_ADVERTISEMENT", rv_foreign_agent_info.iLastAdvertisement );
       
   656 		request_reply->NewField( "ADVERTISEMENT_EXPIRY", rv_foreign_agent_info.iAdvertisementExpiry );
       
   657 		break;
       
   658 
       
   659 
       
   660 	// settimeout
       
   661 	case 22:
       
   662 
       
   663 		// extract the parameters
       
   664 		GETINTEGERARGUMENT( "AGENTID", &(sarg_timeout.iAgentID), 1, 0, aRequest, request_reply );
       
   665 		GETINTEGERARGUMENT( "TIMEOUT", &(sarg_timeout.iTimeout), 2, 0, aRequest, request_reply );
       
   666 
       
   667 		//make the call and update the return value
       
   668 		client_stub_error = iClientMobileAgent->settimeout( sarg_timeout ); 
       
   669 		UpdateCompletionCode( request_reply, client_stub_error );
       
   670 		if( client_stub_error != ERR_NONE ) {
       
   671 			break;
       
   672 		}
       
   673 		break;
       
   674 
       
   675 	// any other method id will result in an RCC_INVALIDMETHODID result
       
   676 	default:
       
   677 		UpdateCompletionCode( request_reply, ERR_INVALID_METHOD );
       
   678 		break;
       
   679 	}
       
   680 
       
   681 	// everything should be handled above 
       
   682 	return request_reply;
       
   683 }
       
   684 
       
   685 
       
   686 /*******************************************************************************
       
   687  *
       
   688  * GetLastRPCError()
       
   689  *
       
   690  ******************************************************************************/
       
   691 char *CMobileAgentServiceStub::GetLastRPCError( int *aIntError )
       
   692 {
       
   693 	return iClientMobileAgent->GetLastRPCError( aIntError );
       
   694 }
       
   695 
       
   696 
       
   697 /*******************************************************************************
       
   698  *
       
   699  * GetStatus()
       
   700  *
       
   701  ******************************************************************************/
       
   702 int CMobileAgentServiceStub::GetStatus()
       
   703 {
       
   704 	assert( !"GetStatus() - is not implemented" );
       
   705 	return -1;
       
   706 }