tcpiputils/dhcp/src/DHCPControl.cpp
branchRCL_3
changeset 75 c1029e558ef5
parent 63 425d8f4f7fa5
equal deleted inserted replaced
67:bb2423252ea3 75:c1029e558ef5
    92 	name().iIndex=1;
    92 	name().iIndex=1;
    93 	//this is somethig unheard of in OO environment that we cannot get hold of a simple object relations
    93 	//this is somethig unheard of in OO environment that we cannot get hold of a simple object relations
    94 	//forced to do this horrible stuff
    94 	//forced to do this horrible stuff
    95 	RSocket socket;
    95 	RSocket socket;
    96 	User::LeaveIfError(socket.Open(iEsock, KAfInet, KSockDatagram, KProtocolInetUdp,iConnection));
    96 	User::LeaveIfError(socket.Open(iEsock, KAfInet, KSockDatagram, KProtocolInetUdp,iConnection));
    97 	CleanupClosePushL( socket );
       
    98 	// make socket invisible for interface counting
    97 	// make socket invisible for interface counting
    99 	User::LeaveIfError(socket.SetOpt(KSoKeepInterfaceUp, KSolInetIp, 0));
    98 	User::LeaveIfError(socket.SetOpt(KSoKeepInterfaceUp, KSolInetIp, 0));
   100 	
    99 	
       
   100 	CleanupClosePushL( socket );
   101 	TPckgBuf<TSoInet6InterfaceInfo> info;
   101 	TPckgBuf<TSoInet6InterfaceInfo> info;
   102 	while ( err == KErrNotFound && iConnection.Control(KCOLProvider, KConnGetInterfaceName, name) == KErrNone )
   102 	while ( err == KErrNotFound && iConnection.Control(KCOLProvider, KConnGetInterfaceName, name) == KErrNone )
   103 		{
   103 		{
   104 		TSoInet6InterfaceInfo& q = info();
   104 		TSoInet6InterfaceInfo& q = info();
   105 		User::LeaveIfError(socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl, 0));
   105 		User::LeaveIfError(socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl, 0));
   162 /** 
   162 /** 
   163   * If necessary then complete client.
   163   * If necessary then complete client.
   164   *   If complete is performed, true is returned
   164   *   If complete is performed, true is returned
   165   */
   165   */
   166 	{
   166 	{
       
   167 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::CompleteClientMessage  Error %d. FunctionCancel %d"),this,aError,aFunctionToCancel));
       
   168 
   167 	if (iMessage &&
   169 	if (iMessage &&
   168 		 !iMessage->IsNull() &&
   170 		 !iMessage->IsNull() &&
   169 		  ( aFunctionToCancel == -1 || aFunctionToCancel == iMessage->Function() || EConfigDaemonDeregister == iMessage->Function() ) )
   171 		  ( aFunctionToCancel == -1 || aFunctionToCancel == iMessage->Function() || EConfigDaemonDeregister == iMessage->Function() ) )
   170 		{
   172 		{
       
   173 		__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::CompleteClientMessage iMessage->Complete with Function %d"),this,iMessage->Function()));
   171 		iMessage->Complete(aError);
   174 		iMessage->Complete(aError);
   172 		iMessage = NULL;
   175 		iMessage = NULL;
   173 		return ETrue;
   176 		return ETrue;
   174 		}
   177 		}
   175 	return EFalse;
   178 	return EFalse;
   178 
   181 
   179 
   182 
   180 void CDHCPControl::BindingFinishedL()
   183 void CDHCPControl::BindingFinishedL()
   181    {
   184    {
   182    //cancel any pending timer
   185    //cancel any pending timer
   183 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl::BindingFinishedL")));
   186 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::BindingFinishedL"),this));
   184 	iTimer->Cancel();
   187 	iTimer->Cancel();
   185 	UpdateDns(iDhcpStateMachine->iHostName, iDhcpStateMachine->iDomainName);
   188 	UpdateDns(iDhcpStateMachine->iHostName, iDhcpStateMachine->iDomainName);
   186 	iDhcpStateMachine->iStartedAquisitionAt.HomeTime(); //remember acquisition time
   189 	iDhcpStateMachine->iStartedAquisitionAt.HomeTime(); //remember acquisition time
   187 	
   190 	
   188 	/** A compromise til we have implemented the "lifetime" option (#42) for
   191 	/** A compromise til we have implemented the "lifetime" option (#42) for
   203 	}
   206 	}
   204  
   207  
   205  
   208  
   206 void CDHCPControl::ServiceAnyOutstandingIoctlL()
   209 void CDHCPControl::ServiceAnyOutstandingIoctlL()
   207 	{
   210 	{
       
   211     __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::ServiceAnyOutstandingIoctlL "),this));
   208 	if(iMessage && !iMessage->IsNull() && (iMessage->Function() == EConfigDaemonIoctl || iMessage->Function() == EConfigDaemonDeregister))
   212 	if(iMessage && !iMessage->IsNull() && (iMessage->Function() == EConfigDaemonIoctl || iMessage->Function() == EConfigDaemonDeregister))
   209 		{
   213 		{
   210 		TInt err = KErrNone;
   214 		TInt err = KErrNone;
   211 		
   215 	    __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::ServiceAnyOutstandingIoctlL, iMessage complete %d, iState =%d"),this,iMessage->Function(), iState ));
   212 		// Run the request again, this time service it (because iMessage is set).  We need
   216 		// Run the request again, this time service it (because iMessage is set).  We need
   213 		// to check to make sure the IOCTL is not a renew which has caused a reinitialisation
   217 		// to check to make sure the IOCTL is not a renew which has caused a reinitialisation
   214 		// - we don't want to restart the IOCTL!.
   218 		// - we don't want to restart the IOCTL!.
   215 		if( ( ( iState != EInitInProgress ) && ( iState != EInformInProgress ) ) || !iInitStartedByRenew )
   219 		if( ( ( iState != EInitInProgress ) && ( iState != EInformInProgress ) ) || !iInitStartedByRenew )
   216 			{
   220 			{
       
   221             __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::ServiceAnyOutstandingIoctlL, iMessage.function = %d, iState= %d"), this, iMessage->Function(), iState));
   217 			TRAP(err,HandleClientRequestL(*iMessage));
   222 			TRAP(err,HandleClientRequestL(*iMessage));
   218 			}
   223 			}
   219 		iInitStartedByRenew = EFalse;
   224 		iInitStartedByRenew = EFalse;
   220 		
   225 		
   221 		CompleteClientIoctlMessage(err);
   226 		CompleteClientIoctlMessage(err);
   225 #ifdef SYMBIAN_NETWORKING_DHCPSERVER	
   230 #ifdef SYMBIAN_NETWORKING_DHCPSERVER	
   226 void CDHCPControl::ServiceAnyOutstandingServerIoctlL()
   231 void CDHCPControl::ServiceAnyOutstandingServerIoctlL()
   227 	{
   232 	{
   228 	if(iMessage && !iMessage->IsNull() && iMessage->Function() == EConfigDaemonIoctl)
   233 	if(iMessage && !iMessage->IsNull() && iMessage->Function() == EConfigDaemonIoctl)
   229 		{
   234 		{
       
   235         __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::ServiceAnyOutstandingServerIoctlL, iMessage.function = %d"), this, iMessage->Function()));
   230 		// run the request again, this time service it (because iMessage is set)
   236 		// run the request again, this time service it (because iMessage is set)
   231 		TRAPD(err,HandleClientRequestL(*iMessage));
   237 		TRAPD(err,HandleClientRequestL(*iMessage));
   232 		CompleteServerIoctlMessage(err);
   238 		CompleteServerIoctlMessage(err);
   233 		}
   239 		}
   234 	}
   240 	}
   352   *  This is done by setting iMessage to the message.
   358   *  This is done by setting iMessage to the message.
   353   *
   359   *
   354   * @internalTechnology
   360   * @internalTechnology
   355   */
   361   */
   356 	{
   362 	{
       
   363     __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPControl[%08x]::HandleClientRequestL,  aMessage.Handle %08x, aMessage.Function %d"), this, aMessage.Handle(), aMessage.Function()));
   357 	if (aMessage.Function() == EConfigDaemonDeregister)
   364 	if (aMessage.Function() == EConfigDaemonDeregister)
   358 		{
   365 		{
   359 		iDhcpDaemonDeregister = ETrue;
   366 		iDhcpDaemonDeregister = ETrue;
   360 		SaveAndHandleClientRequestL(aMessage,KConnAddrRelease);	
   367 		SaveAndHandleClientRequestL(aMessage,KConnAddrRelease);	
   361 		return;	
   368 		return;	
   721   */
   728   */
   722 	{
   729 	{
   723 	// cancel possibly working message sender & socket activity and delete current states
   730 	// cancel possibly working message sender & socket activity and delete current states
   724 	iDhcpStateMachine->Cancel();
   731 	iDhcpStateMachine->Cancel();
   725 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
   732 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
   726 		         _L8("CDHCPControl::TaskCompleteL (%d) with error = %d") ,
   733 		         _L8("CDHCPControl[%08x]::TaskCompleteL (%d) with error = %d") ,this,
   727 		         iState, aError));
   734 		         iState, aError));
   728 	if ( aError == KErrServerTerminated )
   735 	if ( aError == KErrServerTerminated )
   729 		{
   736 		{
   730 		__CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
   737 		__CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
   731 		         _L8("CDHCPControl::TaskCompleteL server terminated => complete client request & going to idle")));
   738 		         _L8("CDHCPControl::TaskCompleteL server terminated => complete client request & going to idle")));
   737 	switch (iState)
   744 	switch (iState)
   738 		{
   745 		{
   739 		case EInitInProgress:
   746 		case EInitInProgress:
   740 			if (KErrTimedOut == aError)
   747 			if (KErrTimedOut == aError)
   741 				{
   748 				{
       
   749 			 __CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
       
   750 			                 _L8("CDHCPControl[%08x]::TaskCompleteL EInitInProgress"), this));
   742 				// Listen for Link Local address.
   751 				// Listen for Link Local address.
   743 				// DHCP server is timed out so we unblock our client.
   752 				// DHCP server is timed out so we unblock our client.
   744 				if (iDhcpConfigListener && iDhcpConfigListener->HaveLinkLocal())
   753 				if (iDhcpConfigListener && iDhcpConfigListener->HaveLinkLocal())
   745 					{
   754 					{
   746 					CompleteClientConfigureMessage(KErrNone);
   755 					CompleteClientConfigureMessage(KErrNone);
   839 			iDhcpStateMachine->StartInitL(this,CDHCPStateMachine::ESubsequentCalls);
   848 			iDhcpStateMachine->StartInitL(this,CDHCPStateMachine::ESubsequentCalls);
   840 			iState = EInitInProgress;
   849 			iState = EInitInProgress;
   841 			break;
   850 			break;
   842 
   851 
   843 		case EReleaseInProgress:
   852 		case EReleaseInProgress:
       
   853 	           __CFLOG_VAR((KLogSubSysDHCP, KLogCode, 
       
   854 	                             _L8("CDHCPControl[%08x]::TaskCompleteL  EReleaseInProgress"), this));
   844 			if (! iDhcpDaemonDeregister)  
   855 			if (! iDhcpDaemonDeregister)  
   845 				{
   856 				{
   846 				iDhcpStateMachine->RemoveConfiguredAddress();
   857 				iDhcpStateMachine->RemoveConfiguredAddress();
   847 				iDhcpDaemonDeregister = EFalse;
   858 				iDhcpDaemonDeregister = EFalse;
   848 				}
   859 				}