datacommsserver/esockserver/ssock/SS_SOCK.CPP
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 //#include "ss_std.h"
       
    17 
       
    18 #define SYMBIAN_NETWORKING_UPS
       
    19 
       
    20 #include <es_prot.h>
       
    21 #include <comms-infras/ss_roles.h>
       
    22 #include <comms-infras/ss_log.h>
       
    23 #include "es_mbufif.h"
       
    24 #include <ss_glob.h>
       
    25 #include <ss_protprov.h>
       
    26 #include <comms-infras/ss_sapshim.h>
       
    27 #include "ss_sock.h"
       
    28 #include <in_sock.h>
       
    29 #include "ss_sapfactshim.h"
       
    30 #include <comms-infras/ss_nodemessages_dataclient.h>
       
    31 
       
    32 #include <comms-infras/ss_msgintercept.h>
       
    33 
       
    34 #ifdef SYMBIAN_NETWORKING_UPS
       
    35 #include <comms-infras/ss_platsec_apiext.h>		// MPlatSecApiExt
       
    36 #endif //SYMBIAN_NETWORKING_UPS
       
    37 
       
    38 #ifdef _DEBUG
       
    39 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    40 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    41 _LIT(KSpecAssert_ESockSSockS_SOCK, "ESockSSockS_SOCK");
       
    42 #endif
       
    43 
       
    44 
       
    45 using namespace ESock;
       
    46 using namespace Messages;
       
    47 using namespace Factories;
       
    48 using namespace Den;
       
    49 
       
    50 //
       
    51 #define MSG_PRM(prmIndex)		(prmIndex)
       
    52 
       
    53 CSocket::CSocket(CSockSession *aSession, CPlayer* aPlayer, const Den::TSubSessionUniqueId aSubSessionUniqueId, TInt aSocketType)
       
    54 	: CSockSubSession(aSession, aPlayer, aSubSessionUniqueId), ASocket(aSocketType)
       
    55 /**
       
    56 Constructor - set up default options.
       
    57 */
       
    58 	{
       
    59 	LOG_NODE_CREATE(KESockFlowTag, CSocket)
       
    60 	}
       
    61 
       
    62 TInt CSocket::SecurityCheck()
       
    63     {
       
    64 	return iSSP->SecurityCheck(Session());
       
    65     }
       
    66 
       
    67 void CSocket::DontCompleteCurrentRequest()
       
    68     {
       
    69     CSockSubSession::DontCompleteCurrentRequest();
       
    70     }
       
    71 
       
    72 void CSocket::SetClosing()
       
    73     {
       
    74     CSockSubSession::SetClosing();
       
    75     }
       
    76 
       
    77 TBool CSocket::IsClosing()
       
    78     {
       
    79     return CSockSubSession::IsClosing();
       
    80     }
       
    81 
       
    82 void CSocket::GetOwnerInfo(TProcessId& aProcId, TSoOwnerInfo& aInfo, TThreadId& aThreadId)
       
    83     {
       
    84     CSockSubSession::GetOwnerInfo(aProcId, aInfo.iUid, aThreadId);
       
    85     }
       
    86 
       
    87 const RNodeInterface* CSocket::ServiceProvider() const
       
    88     {
       
    89     return ASocket::ServiceProvider();
       
    90     }
       
    91 
       
    92 
       
    93 void CSocket::SetReturn(TInt aReturnValue) const
       
    94     {
       
    95     CSockSubSession::SetReturn(aReturnValue);
       
    96     }
       
    97 
       
    98 ASocket* CSocket::GetAcceptingSocket()
       
    99     {
       
   100     CSocket* newCon=Session()->CSocketFromHandle(GetUserMessage(ESocketConnectMessage)->ReadInt(1));
       
   101     return newCon;
       
   102     }
       
   103 
       
   104 
       
   105 CSocket* CSocket::NewLC(TServerProtocolDesc *aServiceInfo, CSockSession *aSession, CPlayer* aPlayer, CProtocolBase* aProt, const Den::TSubSessionUniqueId aSubSessionUniqueId, TInt aSocketType)
       
   106 /**
       
   107 Common static cocreator to create all sockets.
       
   108 
       
   109 */
       
   110 	{
       
   111 	CSocket *s = new(ELeave) CSocket(aSession, aPlayer, aSubSessionUniqueId, aSocketType);
       
   112 	CleanupStack::PushL(s);
       
   113 	s->ConstructL(aProt);
       
   114 	s->Create(aServiceInfo);
       
   115 	ESOCK_DEBUG_REGISTER_GENERAL_NODE(ESockDebug::KSocketNodeUid, s);
       
   116 	return s;
       
   117 	}
       
   118 
       
   119 
       
   120 CSocket::~CSocket()
       
   121 /**
       
   122 Socket destructor. Will ensure that the SSP (and any accept queue) is shutdown before destroying it.
       
   123 Automatically completes all outstanding requests.
       
   124 
       
   125 */
       
   126 	{
       
   127 	// Toast anything we've got hanging around....
       
   128 	FinalCompleteAllBlockedMessages(KErrAbort);
       
   129 	LOG_NODE_DESTROY(KESockFlowTag, CSocket)
       
   130 	}
       
   131 
       
   132 void CSocket::ConstructL (CProtocolBase* aProtocol)
       
   133 	{
       
   134 	InitUserMessageL (ESocketCurrentMessage);
       
   135 	InitUserMessageL (ESocketReadMessage);
       
   136 	InitUserMessageL (ESocketWriteMessage);
       
   137 	InitUserMessageL (ESocketCloseMessage);
       
   138 	InitUserMessageL (ESocketIoCtlMessage);				
       
   139 	InitUserMessageL (ESocketConnectMessage);	
       
   140 	InitUserMessageL (ESocketSetLocalNameMessage);		
       
   141 	CSockSubSession::ConstructL(aProtocol);		
       
   142 	}
       
   143 
       
   144 void CSocket::InitiateDestruction()
       
   145     {
       
   146 	// Remove the subsession from the session's subsession list.
       
   147     if(iSession)
       
   148 		{
       
   149 		iSession->SubSessions().Lock();
       
   150 
       
   151 		CSubSessionIx::TSubSessionHandle handle;
       
   152 		if(iSession->SubSessions().Find(this, handle) == KErrNone)
       
   153 			{
       
   154 			iSession->PitBoss().RemoveSubSession(handle, iSession);
       
   155 			}
       
   156 		
       
   157 		iSession->SubSessions().Unlock();
       
   158 		}
       
   159 
       
   160     ASocket::InitiateDestruction();
       
   161 	
       
   162 	if (!FlowRequestPending())
       
   163 		{
       
   164 		delete this;
       
   165 		}
       
   166     }
       
   167 
       
   168 void CSocket::InitUserMessageL ( TSocketMessage aMessage )
       
   169 	{
       
   170 	CSocketMessage* msg = new (ELeave)CSocketMessage;
       
   171 	SetUserMessage ( aMessage, msg );
       
   172 	}
       
   173 
       
   174 
       
   175 void CSocket::FinalCompleteAllBlockedMessages(TInt aResult)
       
   176 	{
       
   177 	CompleteConnect(aResult);
       
   178 	CompleteClose(aResult);
       
   179 	CompleteRead(aResult);
       
   180 	CompleteWrite(aResult);
       
   181 	CompleteIoctl(aResult);
       
   182 	CompleteSetLocalName(aResult);
       
   183 	}
       
   184 
       
   185 void CSocket::ShutdownL()
       
   186 /**
       
   187 Terminate the protocol
       
   188 */
       
   189 	{
       
   190     ASocket::ShutdownL(RSocket::TShutdown(Message().Int0())/*type*/, Message().Ptr1() != NULL);
       
   191 	}
       
   192 
       
   193 TBool CSocket::CloseSocket()
       
   194 /**
       
   195 A Client has closed our RSocket - or we're being closed by the session because our client has exited
       
   196 */
       
   197 	{
       
   198 	TBool immediate = ASocket::CloseSocket();
       
   199 	if (immediate)
       
   200 		{
       
   201 		static_cast<CPlayer&>(Player()).DeleteSocket(*this);
       
   202 		}
       
   203 	return immediate;
       
   204 	}
       
   205 
       
   206 void CSocket::ConnectL()
       
   207 /**
       
   208 Active open the socket - from a client request.
       
   209 */
       
   210 	{
       
   211 	ASocket::ConnectL(Message().Ptr1() != NULL);
       
   212 	}
       
   213 
       
   214 //indexes of the data elements in RMessage for Get/SetOpt
       
   215 #define  OPT_NAME_INDEX		    0
       
   216 #define  OPT_OPTION_INDEX		1 //for the option value
       
   217 #define  OPT_OPT_LENGTH_INDEX	2
       
   218 #define  OPT_OPT_LEVEL_INDEX	3
       
   219 
       
   220 /**
       
   221     Set a socket option from a client request
       
   222 */
       
   223 void CSocket::SetSockOptionL()
       
   224 	{
       
   225 	TInt optionName=Message().Int0();
       
   226 	TInt optionLength=Message().GetDesLengthL(1);
       
   227 	TInt optionLevel=Message().Int2();
       
   228 
       
   229     ASocket::SetSockOptionL(optionName, optionLength, optionLevel);
       
   230 	}
       
   231 
       
   232 void CSocket::GetSockOptionL()
       
   233 /**
       
   234 Read a socket option from us (or attempt the protocol if we don't support the option)
       
   235 
       
   236 */
       
   237 	{
       
   238 	TInt optionName=Message().Int0();
       
   239 	TInt optionLength=SafeMessage().GetDesMaxLengthL(1);
       
   240 	TInt optionLevel=Message().Int2();
       
   241     ASocket::GetSockOptionL(optionName, optionLength, optionLevel, Message().Ptr1() != NULL);
       
   242 	}
       
   243 
       
   244 void CSocket::IoctlL()
       
   245 /**
       
   246 Perform an Ioctl from a user request
       
   247 */
       
   248 	{
       
   249 	TInt optionName = Message().Int0();
       
   250 	TInt optionLength = (Message().Ptr1() != NULL) ? SafeMessage().GetDesMaxLengthL(1) : 0;
       
   251 	TInt optionLevel =Message().Int2();
       
   252     ASocket::IoctlL(optionName, optionLength, optionLevel, Message().Ptr1() != NULL);
       
   253 	}
       
   254 
       
   255 
       
   256 void CSocket::ListenL()
       
   257 /**
       
   258 Listen request service
       
   259 Listen is a dead and, clients can't do anything with the socket other than Accept after a listen.
       
   260 */
       
   261 	{
       
   262    	TInt qlen = Message().Int0()>0 ? Message().Int0() : 1;
       
   263     ASocket::ListenL(qlen, Message().Ptr1() != NULL);
       
   264 	}
       
   265 
       
   266 ASocket* CSocket::InitiateAcceptingSocket()
       
   267     {
       
   268     // Create the accepting socket - we have to do this outside the subsessions lock
       
   269     // because the lock does not support recursion.
       
   270 	CSocket* acceptingSocket = NULL;
       
   271 	TInt acceptingHandle = 0;
       
   272 	TRAPD(ret, acceptingSocket = static_cast<CPlayer&>(Player()).NewSocketL(EFalse, acceptingHandle));
       
   273 	if(ret != KErrNone)
       
   274 		{
       
   275 		SetReturn(ret);
       
   276 		return NULL;
       
   277 		}
       
   278 	
       
   279 	CSocket* nullSocket = NULL;	
       
   280 	TBool found = EFalse;
       
   281 
       
   282 	// Now that we have the new socket created on the Player we replace the null one with it.
       
   283 		{
       
   284 		CSubSessionIx& subSessions = iSession->SubSessions();
       
   285 		subSessions.Lock();
       
   286 
       
   287 		// Find the null socket - we do this inside the subsessions lock to ensure it cannot
       
   288 		// be orphaned until we are finished.
       
   289 		const TInt nullSocketHandle = Message().Int1();
       
   290 		nullSocket = static_cast<CSocket*>(subSessions.At(nullSocketHandle, TCFSubSessInfo::ESocket));
       
   291 		if(nullSocket)
       
   292 			{
       
   293 			if (nullSocket->State()!=ESStateNull)
       
   294 				{
       
   295 				PanicSocketClient(EAcceptTwice);
       
   296 		
       
   297 				subSessions.Unlock();
       
   298 
       
   299 				return NULL;
       
   300 				}
       
   301 			
       
   302 			found = subSessions.At(acceptingHandle, TCFSubSessInfo::ESocket) != NULL;
       
   303 			if(found)
       
   304 				{
       
   305 				LOG(ESockLog::Printf(KESockSessDetailTag, _L8("CSocket::InitiateAcceptingSocket() replacing null socket %08x with accepting socket %08x"), nullSocket, acceptingSocket) );
       
   306 				subSessions.Remove(acceptingHandle);
       
   307 				subSessions.Replace(nullSocketHandle, acceptingSocket);
       
   308 				//We need to ensure that the socket does not get accepted onto twice
       
   309 				acceptingSocket->SetState(ESStateAccepting);
       
   310 				}
       
   311 			else
       
   312 				{
       
   313 				LOG(ESockLog::Printf(KESockSessDetailTag, _L8("CSocket::InitiateAcceptingSocket() accepting socket %08x not found - the session is probably being destroyed"), acceptingSocket, nullSocket) );
       
   314 				}
       
   315 			}
       
   316 		else
       
   317 			{
       
   318 			PanicSocketClient(ESockBadHandle);
       
   319 		
       
   320 			subSessions.Unlock();
       
   321 
       
   322 			return NULL;
       
   323 			}
       
   324 		
       
   325 		subSessions.Unlock();
       
   326 		}
       
   327 	
       
   328 	// Destroy the null socket if the replacement was successful.
       
   329 	if(found)
       
   330 		{
       
   331 		RAllocator* prevAllocator = Player().PitBoss().MaybeSwitchHeap(nullSocket->Player().WorkerId());
       
   332 		LOG(ESockLog::Printf(KESockSessDetailTag, _L8("CSocket::InitiateAcceptingSocket() destroying null socket %08x"), nullSocket) );
       
   333 		nullSocket->InitiateDestruction();
       
   334 		if(prevAllocator)
       
   335 			{
       
   336 			User::SwitchAllocator(prevAllocator);
       
   337 			}
       
   338 		}
       
   339 	else
       
   340 		{
       
   341 		// Accepting socket will be deleted by session cleanup.
       
   342 		acceptingSocket = NULL;
       
   343 		SetReturn(KErrCancel);
       
   344 		}
       
   345 		
       
   346 	return acceptingSocket;
       
   347     }
       
   348     
       
   349 void CSocket::PanicSocketClient(TESockPanic aPanic)
       
   350 	{
       
   351 	CWorkerSubSession::PanicClient(KESockClientPanic, (TInt) aPanic);
       
   352 	}
       
   353 
       
   354 
       
   355 /** Provides a sizeable buffer for strictly temporary use, eg within current stack frame: there's only one buffer
       
   356  * and no protocol for returning so shared use can't be detected: the intended use is for transferring data to/from 
       
   357  * a client. 
       
   358  * @return pointer to a buffer of at least the requested size, or NULL if this proves impossible
       
   359  */ 
       
   360 TDes8* CSocket::BorrowTemporaryBuffer(TInt aSize)
       
   361     {
       
   362     return static_cast<CPlayer&>(Player()).BorrowTemporaryBuffer(aSize);
       
   363     }
       
   364 
       
   365 /** Provides a sizeable buffer for strictly temporary use, eg within current stack frame: there's only one buffer
       
   366  * and no protocol for returning so shared use can't be detected: the intended use is for transferring data to/from 
       
   367  * a client. 
       
   368  * @return Pointer to a buffer of at least the requested size
       
   369  * @leave KErrNoMemory if the request cannot be satisfied
       
   370  */ 
       
   371 TDes8* CSocket::BorrowTemporaryBufferL(TInt aSize)
       
   372     {
       
   373     return static_cast<TDes8*>(User::LeaveIfNull(static_cast<CPlayer&>(Player()).BorrowTemporaryBuffer(aSize)));
       
   374     }
       
   375 
       
   376 void CSocket::ReferenceL()
       
   377 /**
       
   378 Get a global reference to this socket.
       
   379 */
       
   380 	{
       
   381 	TName name;
       
   382 	ComposeSubSessionName(this, name);
       
   383 	Message().WriteL(MSG_PRM(0), name);
       
   384 	SetReturn(KErrNone);
       
   385 	}
       
   386 
       
   387 void CSocket::ProcessMessageL()
       
   388 	{
       
   389 	RSafeMessage& msg = const_cast<RSafeMessage&>(SafeMessage());
       
   390 	static_cast<CSocketMessage*>(iCurrentMsg)->SetMessage(msg);
       
   391 	// local flag to indicate processed messages
       
   392 	// cleared in the case of ESoClose - socket deletion
       
   393 	TBool processed =ETrue;
       
   394 	switch(msg.Function())
       
   395 		{
       
   396 		case ESoShutdown:
       
   397 			ShutdownL();
       
   398 			break;
       
   399 
       
   400 		case ESoClose:
       
   401             CloseSocket();
       
   402             processed = EFalse; // no need to reset iMessage handle
       
   403 			break;
       
   404 
       
   405 		case ESoSendToNoLength:		// flags,addr,buf
       
   406 			{
       
   407 		    TInt sendByteCount = msg.GetDesLengthL(2);
       
   408 		    TInt sendFlags = msg.Int0();   
       
   409 		    ASocket::SendL(ASocket::KNoXferLen, MSG_PRM(1), sendByteCount, sendFlags, EFalse);
       
   410 			break;
       
   411 			}
       
   412 		case ESoSendNoLength:		// flags,buflen,buf
       
   413 			{
       
   414 		    TInt sendByteCount = msg.Int1();	// sanity-checked by SendL() 
       
   415 		    TInt sendFlags = msg.Int0();   
       
   416 		    ASocket::SendL(ASocket::KNoXferLen, ASocket::KNoAddrArg, sendByteCount, sendFlags, EFalse);
       
   417 			break;
       
   418 			}
       
   419 		case ESoSendTo:				//xferlen(flags),addr,buf
       
   420 			{
       
   421 		    TInt sendByteCount = msg.GetDesLengthL(2);
       
   422 			ReadParamL(ESocketCurrentMessage,MSG_PRM(0),iXferLength);
       
   423 			TInt sendFlags = iXferLength();
       
   424 		    ASocket::SendL(MSG_PRM(0), MSG_PRM(1), sendByteCount, sendFlags, EFalse);
       
   425 			break;
       
   426 			}
       
   427 		case ESoSend:				//flags,xferlen,buf
       
   428 			{
       
   429 		    TInt sendByteCount = msg.GetDesLengthL(2);
       
   430 		    TInt sendFlags = msg.Int0();   
       
   431 		    ASocket::SendL(MSG_PRM(1), ASocket::KNoAddrArg, sendByteCount, sendFlags, EFalse);
       
   432 			break;
       
   433 			}
       
   434 		case ESoWrite:				//0,buflen,buf
       
   435 			{
       
   436 		    TInt sendByteCount = msg.Int1();	// sanity-checked by SendL() 
       
   437 		    TInt sendFlags = 0;   
       
   438 		    ASocket::SendL(ASocket::KNoXferLen, ASocket::KWriteNoAddrArg, sendByteCount, sendFlags, EFalse);
       
   439 			break;
       
   440 			}
       
   441 		case ESoRecvFromNoLength:	//flags,addr,buf
       
   442 			{
       
   443 		    TInt readByteCount = msg.GetDesMaxLengthL(2);
       
   444 		    TInt readFlags = msg.Int0();
       
   445 		    ASocket::RecvL(KNoXferLen, MSG_PRM(1), readByteCount, readFlags, EFalse, EFalse);
       
   446 			break;
       
   447 			}
       
   448 		case ESoRecvNoLength:		//flags,bufmaxlen,buf
       
   449 			{
       
   450 		    TInt readByteCount = Message().Int1();
       
   451 		    TInt readFlags = Message().Int0();
       
   452 		    ASocket::RecvL(KNoXferLen, KNoAddrArg, readByteCount, readFlags, EFalse, EFalse);
       
   453 			}
       
   454 			break;
       
   455 		case ESoRecvOneOrMoreNoLength:	//flags,bufmaxlen,buf
       
   456 			{
       
   457 		    TInt readByteCount = Message().Int1();
       
   458 		    TInt readFlags = Message().Int0();
       
   459 		    ASocket::RecvL(KNoXferLen, KNoAddrArg, readByteCount, readFlags, EFalse, ETrue);
       
   460 			}
       
   461 			break;
       
   462 		case ESoRecvOneOrMore:		//flags,xferlen,buf
       
   463 			{
       
   464 		    TInt readByteCount = msg.GetDesMaxLengthL(2);
       
   465 		    TInt readFlags = Message().Int0();
       
   466 		    ASocket::RecvL(MSG_PRM(1), KNoAddrArg, readByteCount, readFlags, EFalse, ETrue);
       
   467 			}
       
   468 			break;
       
   469 		case ESoRecvFrom:			//xferlen(flags),addr,buf
       
   470 			{
       
   471 		    TInt readByteCount = msg.GetDesMaxLengthL(2);
       
   472 			ReadParamL(ESocketCurrentMessage,MSG_PRM(0),iXferLength);
       
   473 			TInt readFlags = iXferLength();
       
   474 		    ASocket::RecvL(MSG_PRM(0), MSG_PRM(1), readByteCount, readFlags, EFalse, EFalse);
       
   475 			}
       
   476 			break;
       
   477 		case ESoRecv:				//flags,xferlen,buf
       
   478 			{
       
   479 		    TInt readByteCount = msg.GetDesMaxLengthL(2);
       
   480 		    TInt readFlags = Message().Int0();
       
   481 		    ASocket::RecvL(MSG_PRM(1), KNoAddrArg, readByteCount, readFlags, EFalse, EFalse);
       
   482 			}
       
   483 			break;
       
   484 		case ESoRead:				//0,bufmaxlen,buf
       
   485 			{
       
   486 		    TInt readByteCount = Message().Int1();
       
   487 		    ASocket::RecvL(KNoXferLen, KNoAddrArg, readByteCount, 0, EFalse, EFalse);
       
   488 			}
       
   489 			break;
       
   490 
       
   491 		case ESoConnect:
       
   492 			ConnectL();
       
   493 			break;
       
   494 
       
   495 		case ESoBind:
       
   496 			BindL();
       
   497 			break;
       
   498 
       
   499 		case ESoAccept:
       
   500 			Accept();
       
   501 			break;
       
   502 
       
   503 		case ESoListen:
       
   504 			ListenL();
       
   505 			break;
       
   506 
       
   507 		case ESoSetOpt:
       
   508 			SetSockOptionL();
       
   509 			break;
       
   510 
       
   511 		case ESoGetOpt:
       
   512 			GetSockOptionL();
       
   513 			break;
       
   514 
       
   515 		case ESoIoctl:
       
   516 			IoctlL();
       
   517 			break;
       
   518 
       
   519 		case ESoGetDiscData:
       
   520 			GetDisconnectDataL();
       
   521 			break;
       
   522 
       
   523 		case ESoGetLocalName:
       
   524 			LocalNameL();
       
   525 			break;
       
   526 
       
   527 		case ESoGetRemoteName:
       
   528 			RemoteNameL();
       
   529 			break;
       
   530 
       
   531 		case ESoCancelRecv:
       
   532 			CancelRecv();
       
   533 			break;
       
   534 
       
   535 		case ESoCancelSend:
       
   536 			CancelSend();
       
   537 			break;
       
   538 
       
   539 		case ESoCancelIoctl:
       
   540 			CancelIoctl();
       
   541 			break;
       
   542 
       
   543 		case ESoCancelConnect:
       
   544 			CancelConnect();
       
   545 			break;
       
   546 
       
   547 		case ESoCancelAccept:
       
   548 			CancelAccept();
       
   549 			break;
       
   550 
       
   551 		case ESoCancelAll:
       
   552 			CancelAll();
       
   553 			break;
       
   554 
       
   555 		case ESoSocketInfo:
       
   556 		   GetInfoL();
       
   557 			break;
       
   558 
       
   559 		case ESoReference:
       
   560 			ReferenceL();
       
   561 			break;
       
   562 
       
   563 		default:
       
   564 			SetReturn(KErrNotSupported);
       
   565 		}
       
   566 	// message for this CSocket has been processed - can reset iMessage handle
       
   567 	if (processed)
       
   568 	    {
       
   569 	    static_cast<CSocketMessage*>(iCurrentMsg)->ProcessedMessage();
       
   570 	    }
       
   571 	}
       
   572 
       
   573 void CSocket::CompleteFlowRequestMessage(TInt err)
       
   574 	{
       
   575 	LOG(ESockLog::Printf(KESockSessDetailTag, _L8("CSocket::CompleteFlowRequestMessage() socket (%08X) completing flow request message (%08X) with %d"), this, iFlowRequestMessage.Handle(), err) );
       
   576 	iFlowRequestMessage.Complete(err);
       
   577 	}
       
   578 
       
   579 // ------------------------------------------------
       
   580 TInt CSocketMessage::ReadDes(TInt aSrcParamIndex,TDes8 &aDes,TInt anOffset)
       
   581 	{
       
   582 	return iMessage.Read(aSrcParamIndex, aDes, anOffset);
       
   583 	}
       
   584 
       
   585 TInt CSocketMessage::ReadInt(TInt aSrcParamIndex)
       
   586 	{
       
   587 	TInt param = 0;
       
   588 	switch (aSrcParamIndex)
       
   589 		{
       
   590 	case 0:
       
   591 		param = iMessage.Int0();
       
   592 		break;
       
   593 		
       
   594 	case 1:
       
   595 		param = iMessage.Int1();
       
   596 		break;
       
   597 		
       
   598 	case 2:
       
   599 		param = iMessage.Int2();
       
   600 		break;
       
   601 	
       
   602 	case 3:
       
   603 		param = iMessage.Int3();
       
   604 		break;
       
   605 		
       
   606 	default:
       
   607 		__ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSockS_SOCK, 1));
       
   608 		}
       
   609 	return param;
       
   610 	}
       
   611 
       
   612 TInt CSocketMessage::ReadMBuf(TInt /* aSrcParamIndex */, RMBufChain& /* aBufChain */)
       
   613 	{
       
   614 	// Currently we don't support writing into RMBufChains
       
   615 	User::Invariant();
       
   616 	return KErrNotSupported;
       
   617 	}
       
   618 
       
   619 TInt CSocketMessage::WriteDes(TInt aDstParamIndex,const TDesC8& aDes,TInt anOffset)
       
   620 	{
       
   621 	return iMessage.Write(aDstParamIndex, aDes, anOffset);
       
   622 	}
       
   623 
       
   624 TInt CSocketMessage::WriteMBuf(TInt /* aDstParamIndex */,RMBufChain& /* aBufChain */)
       
   625 	{
       
   626 	// Currently we don't support writing into RMBufChains
       
   627 	User::Invariant();
       
   628 	return KErrNotSupported;
       
   629 	}
       
   630 	
       
   631 void CSocketMessage::InitMBuf(TInt /* aParamIndex */)
       
   632 	{
       
   633 	// Currently we don't support RMBufChains
       
   634 	User::Invariant();		
       
   635 	}
       
   636 
       
   637 void CSocketMessage::CompleteMessage(TInt anError)
       
   638 	{
       
   639 	iMessage.Complete(anError);
       
   640 	}
       
   641 
       
   642 void CSocketMessage::AcquireMessage(AMessage* aMessage)
       
   643 	{
       
   644 	CSocketMessage* msg = (static_cast<CSocketMessage*>(this));
       
   645 	CSocketMessage* msg2 = (static_cast<CSocketMessage*>(aMessage));	
       
   646 	msg->SetMessage(msg2->Message());
       
   647 	}
       
   648 
       
   649 TBool CSocketMessage::IsNull (TInt aParamIndex)
       
   650 	{
       
   651 	switch (aParamIndex)	
       
   652 		{
       
   653 		case 0:
       
   654 		return (iMessage.Ptr0() == NULL);
       
   655 
       
   656 		case 1:
       
   657 		return (iMessage.Ptr1() == NULL);		
       
   658 		
       
   659 		case 2:
       
   660 		return (iMessage.Ptr2() == NULL);				
       
   661 		
       
   662 		case 3:
       
   663 		return (iMessage.Ptr3() == NULL);						
       
   664 		
       
   665 		default:
       
   666 		__ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSockS_SOCK, 2));
       
   667 		}
       
   668 	return EFalse;
       
   669 	}
       
   670 
       
   671 // --------------------------------------------------------------
       
   672 
       
   673 #ifdef SYMBIAN_NETWORKING_UPS
       
   674 TInt CSocketMessage::GetProcessAndThreadId(TProcessId& aProcessId, TThreadId& aThreadId) const
       
   675 	{
       
   676 	return ASockSubSessionPlatsecApiExt::GetProcessAndThreadIdFromRMessage(Message(), aProcessId, aThreadId);
       
   677 	}
       
   678 #endif