networkcontrol/ipnetworklayer/src/notify.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Support for TCP/IP stack calling NIFMAN via MNifIfNotify pointer in CNIfIfBase.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file notify.cpp
       
    20 */
       
    21 
       
    22 #include "notify.h"
       
    23 #include "panic.h"
       
    24 #include "idletimer.h"
       
    25 #include <comms-infras/ss_datamonitoringprovider.h>
       
    26 
       
    27 using namespace ESock;
       
    28 
       
    29 //
       
    30 // CIPShimNotify methods //
       
    31 //
       
    32 
       
    33 CIPShimNotify::CIPShimNotify(CIPShimIfBase* aIntf) : iIntf(aIntf)
       
    34 	{
       
    35 	}
       
    36 
       
    37 CIPShimNotify* CIPShimNotify::NewL(CIPShimIfBase* aIntf)
       
    38 	{
       
    39 	return new (ELeave) CIPShimNotify(aIntf);
       
    40 	}
       
    41 
       
    42 void CIPShimNotify::OpenRoute()
       
    43 	{ 
       
    44    	iIntf->ProtcolIntf()->OpenRoute();
       
    45 	}
       
    46 	
       
    47 void CIPShimNotify::CloseRoute()
       
    48 	{	       	
       
    49    	iIntf->ProtcolIntf()->CloseRoute();
       
    50 	}
       
    51 	
       
    52 TInt CIPShimNotify::PacketActivity(TDataTransferDirection aDirection, TUint aBytes, TBool aResetTimer)
       
    53 	{
       
    54 	ASSERT(iPacketActivity);
       
    55 	ASSERT(iConnectionVolumesPtr);
       
    56 	ASSERT(iSubConnectionVolumesPtr);
       
    57 			
       
    58 	*iPacketActivity = aResetTimer;
       
    59 
       
    60 	switch(aDirection)
       
    61 		{
       
    62 	case EIncoming:
       
    63 		/******************************
       
    64 		 * NOTE: shared memory write
       
    65 		 ******************************/
       
    66 		iConnectionVolumesPtr->iReceivedBytes += aBytes;
       
    67 		
       
    68 		if(iConnectionVolumesPtr->iReceivedBytes < aBytes)
       
    69 			{
       
    70 			iIntf->Flow().PostConnDataReceivedThresholdReached(KMaxTUint32);
       
    71 			}
       
    72 		else 
       
    73 			{
       
    74 			if(iConnectionThresholdsPtr->iReceivedThreshold && iConnectionVolumesPtr->iReceivedBytes >= iConnectionThresholdsPtr->iReceivedThreshold)
       
    75 				{
       
    76 				iConnectionThresholdsPtr->iReceivedThreshold = 0;
       
    77 				iIntf->Flow().PostConnDataReceivedThresholdReached(iConnectionVolumesPtr->iReceivedBytes);
       
    78 				}
       
    79 			}
       
    80 			
       
    81 		/******************************
       
    82 		 * NOTE: shared memory write
       
    83 		 ******************************/
       
    84 		iSubConnectionVolumesPtr->iReceivedBytes += aBytes;
       
    85 		
       
    86 		if(iSubConnectionVolumesPtr->iReceivedBytes < aBytes)
       
    87 			{
       
    88 			iIntf->Flow().PostSubConnDataReceivedThresholdReached(KMaxTUint32);
       
    89 			}
       
    90 		else
       
    91 			{
       
    92 			if(iSubConnectionThresholdsPtr->iReceivedThreshold && iSubConnectionVolumesPtr->iReceivedBytes >= iSubConnectionThresholdsPtr->iReceivedThreshold)
       
    93 				{
       
    94 				iSubConnectionThresholdsPtr->iReceivedThreshold = 0;
       
    95 				iIntf->Flow().PostSubConnDataReceivedThresholdReached(iSubConnectionVolumesPtr->iReceivedBytes);
       
    96 				}				
       
    97 			}			
       
    98 		break;
       
    99 		
       
   100 	case EOutgoing:
       
   101 		/******************************
       
   102 		 * NOTE: shared memory write
       
   103 		 ******************************/
       
   104 		iConnectionVolumesPtr->iSentBytes += aBytes;
       
   105 		
       
   106 		if(iConnectionVolumesPtr->iSentBytes < aBytes)
       
   107 			{
       
   108 			iIntf->Flow().PostConnDataSentThresholdReached(KMaxTUint32);
       
   109 			}
       
   110 		else 
       
   111 			{
       
   112 			if(iConnectionThresholdsPtr->iSentThreshold && iConnectionVolumesPtr->iSentBytes >= iConnectionThresholdsPtr->iSentThreshold)
       
   113 				{
       
   114 				iConnectionThresholdsPtr->iSentThreshold = 0;
       
   115 				iIntf->Flow().PostConnDataSentThresholdReached(iConnectionVolumesPtr->iSentBytes);
       
   116 				}
       
   117 			}
       
   118 			
       
   119 		/******************************
       
   120 		 * NOTE: shared memory write
       
   121 		 ******************************/
       
   122 		iSubConnectionVolumesPtr->iSentBytes += aBytes;
       
   123 		
       
   124 		if(iSubConnectionVolumesPtr->iSentBytes < aBytes)
       
   125 			{
       
   126 			iIntf->Flow().PostSubConnDataSentThresholdReached(KMaxTUint32);
       
   127 			}
       
   128 		else
       
   129 			{
       
   130 			if(iSubConnectionThresholdsPtr->iSentThreshold && iSubConnectionVolumesPtr->iSentBytes >= iSubConnectionThresholdsPtr->iSentThreshold)
       
   131 				{
       
   132 				iSubConnectionThresholdsPtr->iSentThreshold = 0;
       
   133 				iIntf->Flow().PostSubConnDataSentThresholdReached(iSubConnectionVolumesPtr->iSentBytes);
       
   134 				}				
       
   135 			}			
       
   136 		break;
       
   137 		
       
   138 	default:
       
   139 		break;
       
   140 		
       
   141 		} // switch(aDirection)
       
   142 
       
   143 	return KErrNone;
       
   144 	}
       
   145 
       
   146 void CIPShimNotify::SetPacketActivityFlag(volatile TBool* aPacketActivity)
       
   147 	{
       
   148 	ASSERT(aPacketActivity);
       
   149 	iPacketActivity = aPacketActivity;
       
   150 	}
       
   151 
       
   152 void CIPShimNotify::SetDataVolumePtrs(TDataVolumes* aConnectionVolumesPtr, TDataVolumes* aSubConnectionVolumesPtr)
       
   153 	{
       
   154 	ASSERT(aConnectionVolumesPtr);
       
   155 	ASSERT(aSubConnectionVolumesPtr);
       
   156 	
       
   157 	iConnectionVolumesPtr = aConnectionVolumesPtr;
       
   158 	iSubConnectionVolumesPtr = aSubConnectionVolumesPtr;
       
   159 	}
       
   160 	
       
   161 void CIPShimNotify::SetNotificationThresholdPtrs(TNotificationThresholds* aConnectionThresholdsPtr, TNotificationThresholds* aSubConnectionThresholdsPtr)
       
   162 	{
       
   163 	ASSERT(aConnectionThresholdsPtr);
       
   164 	ASSERT(aSubConnectionThresholdsPtr);
       
   165 	
       
   166 	iConnectionThresholdsPtr = aConnectionThresholdsPtr;
       
   167 	iSubConnectionThresholdsPtr = aSubConnectionThresholdsPtr;
       
   168 	}
       
   169 
       
   170 
       
   171 //
       
   172 // Methods stubbed out to panic
       
   173 //
       
   174 
       
   175 void CIPShimNotify::LinkLayerDown(TInt /*aReason*/, TAction /*aAction*/)
       
   176 	{
       
   177 	Panic(EBadNotifyCall);
       
   178 	}
       
   179 	
       
   180 void CIPShimNotify::LinkLayerUp()
       
   181 	{
       
   182 	Panic(EBadNotifyCall);
       
   183 	}
       
   184 	
       
   185 void CIPShimNotify::NegotiationFailed(CNifIfBase* /*aIf*/, TInt /*aReason*/)
       
   186 	{
       
   187 	Panic(EBadNotifyCall);
       
   188 	}
       
   189 	
       
   190 TInt CIPShimNotify::Authenticate(TDes& /*aUsername*/, TDes& /*aPassword*/)
       
   191 	{
       
   192 	Panic(EBadNotifyCall);
       
   193 	return KErrNotSupported;
       
   194 	}
       
   195 	
       
   196 void CIPShimNotify::CancelAuthenticate()
       
   197 	{
       
   198 	Panic(EBadNotifyCall);
       
   199 	}
       
   200 	
       
   201 TInt CIPShimNotify::GetExcessData(TDes8& /*aBuffer*/)
       
   202 	{
       
   203 	Panic(EBadNotifyCall);
       
   204 	return KErrNotSupported;
       
   205 	}
       
   206 	
       
   207 void CIPShimNotify::IfProgress(TInt /*aStage*/, TInt /*aError*/)
       
   208 	{
       
   209 	Panic(EBadNotifyCall);
       
   210 	}
       
   211 	
       
   212 void CIPShimNotify::IfProgress(TSubConnectionUniqueId /*aSubConnectionUniqueId*/, TInt /*aStage*/, TInt /*aError*/)
       
   213 	{
       
   214 	Panic(EBadNotifyCall);
       
   215 	}
       
   216 	
       
   217 TInt CIPShimNotify::Notification(TNifToAgentEventType /*aEvent*/, void * /*aInfo*/)
       
   218 	{
       
   219 	Panic(EBadNotifyCall);
       
   220 	return KErrNotSupported;
       
   221 	}
       
   222 	
       
   223 void CIPShimNotify::BinderLayerDown(CNifIfBase* /*aBinderIf*/, TInt /*aReason*/, TAction /*aAction*/)
       
   224 	{
       
   225 	Panic(EBadNotifyCall);
       
   226 	}
       
   227 		
       
   228 void CIPShimNotify::NotifyDataSent(TSubConnectionUniqueId /*aSubConnectionUniqueId*/, TUint /*aUplinkVolume*/)
       
   229 	{
       
   230 	Panic(EBadNotifyCall);
       
   231 	}
       
   232 	
       
   233 void CIPShimNotify::NotifyDataReceived(TSubConnectionUniqueId /*aSubConnectionUniqueId*/, TUint /*aDownlinkVolume*/)
       
   234 	{
       
   235 	Panic(EBadNotifyCall);
       
   236 	}
       
   237 	
       
   238 void CIPShimNotify::NifEvent(TNetworkAdaptorEventType /*aEventType*/, TUint /*aEvent*/, const TDesC8& /*aEventData*/, TAny* /*aSource*/)
       
   239 	{
       
   240 	Panic(EBadNotifyCall);
       
   241 	}
       
   242 	
       
   243 TInt CIPShimNotify::DoReadInt(const TDesC& /*aField*/, TUint32& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   244 	{
       
   245 	Panic(EBadNotifyCall);
       
   246 	return KErrNotSupported;
       
   247 	}
       
   248 	
       
   249 TInt CIPShimNotify::DoWriteInt(const TDesC& /*aField*/, TUint32 /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   250 	{
       
   251 	Panic(EBadNotifyCall);
       
   252 	return KErrNotSupported;
       
   253 	}
       
   254 	
       
   255 TInt CIPShimNotify::DoReadDes(const TDesC& /*aField*/, TDes8& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   256 	{
       
   257 	Panic(EBadNotifyCall);
       
   258 	return KErrNotSupported;
       
   259 	}
       
   260 	
       
   261 TInt CIPShimNotify::DoReadDes(const TDesC& /*aField*/, TDes16& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   262 	{
       
   263 	Panic(EBadNotifyCall);
       
   264 	return KErrNotSupported;
       
   265 	}
       
   266 	
       
   267 TInt CIPShimNotify::DoWriteDes(const TDesC& /*aField*/, const TDesC8& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   268 	{
       
   269 	Panic(EBadNotifyCall);
       
   270 	return KErrNotSupported;
       
   271 	}
       
   272 	
       
   273 TInt CIPShimNotify::DoWriteDes(const TDesC& /*aField*/, const TDesC16& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   274 	{
       
   275 	Panic(EBadNotifyCall);
       
   276 	return KErrNotSupported;
       
   277 	}
       
   278 	
       
   279 TInt CIPShimNotify::DoReadBool(const TDesC& /*aField*/, TBool& /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   280 	{
       
   281 	Panic(EBadNotifyCall);
       
   282 	return KErrNotSupported;
       
   283 	}
       
   284 	
       
   285 TInt CIPShimNotify::DoWriteBool(const TDesC& /*aField*/, TBool /*aValue*/, const RMessagePtr2* /*aMessage*/)
       
   286 	{
       
   287 	Panic(EBadNotifyCall);
       
   288 	return KErrNotSupported;
       
   289 	}
       
   290