コード例 #1
0
enum TVerdict CTS_CEsockSendAndRecvData::doTestStepL( void )
	{
	TRequestStatus stat, stat2;
	TBuf8<50> Data;

	// Qos Channel(s)
	for (TInt i = 0;i < iQoSSuite->iQoSChannel.Count();i++)
		{
		// Socket(s)
		for (TInt i2 = 0;i2 < iQoSSuite->iQoSChannel[i]->GetSocketListCount() ;i2++)
			{
			// set up data buffers
			HBufC8 * writebuf = HBufC8::NewMaxLC( iQoSSuite->iQoSChannel[i]->iPacketSize[i2] );
			HBufC8 * readbuf  = HBufC8::NewMaxLC( iQoSSuite->iQoSChannel[i]->iPacketSize[i2] );
			TPtr8 ptrWritebuf = writebuf->Des();
			TPtr8 ptrReadbuf = readbuf->Des();

			TInt recvCount = 0;

			Log( _L("QoS Channel <%d>, Socket <%d>"), i+1, i2+1);

			// Send / Recv TCP
			if (iQoSSuite->iQoSChannel[i]->iProtocol[i2] == KProtocolInetTcp)
				{
				Log( _L("Sending TCP data, %d packets of %d bytes = %d"), 
				iQoSSuite->iQoSChannel[i]->iPackets[i2], iQoSSuite->iQoSChannel[i]->iPacketSize[i2], iQoSSuite->iQoSChannel[i]->iPackets[i2] * iQoSSuite->iQoSChannel[i]->iPacketSize[i2]);
				
				// Number of Packets to Send / Recv
				for (TInt i4 = 0; i4 < iQoSSuite->iQoSChannel[i]->iPackets[i2]; i4++)
					{
					// initialise data
					Data.Format(_L8("TCP-packet:%d helloworld"),i4);
					ptrWritebuf.Repeat( Data );

					// write data
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->Write(ptrWritebuf, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					// read data
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->Read(ptrReadbuf, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					// compare the data
					TESTL( ptrWritebuf.Compare( ptrReadbuf ) == 0);
					recvCount+=ptrReadbuf.Length();
					}
				//	writebuf and readbuf
				CleanupStack::PopAndDestroy(2);	
				} 

			// Send / Recv UDP
			if (iQoSSuite->iQoSChannel[i]->iProtocol[i2] == KProtocolInetUdp)
				{
				Log( _L("Send Udp Data, %d packets of %d bytes = %d"), 
				iQoSSuite->iQoSChannel[i]->iPackets[i2], iQoSSuite->iQoSChannel[i]->iPacketSize[i2], iQoSSuite->iQoSChannel[i]->iPackets[i2] * iQoSSuite->iQoSChannel[i]->iPacketSize[i2]);

				// Number of Packets to Send / Recv
				for (TInt i4 = 0; i4 < iQoSSuite->iQoSChannel[i]->iPackets[i2]; i4++)
					{
					// initialise data
					Data.Format(_L8("UDP-packet:%d helloworld"),i4);
					ptrWritebuf.Repeat( Data );

					// write data 
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->SendTo(ptrWritebuf, iQoSSuite->iQoSChannel[i]->iDestAddr[i2], 0, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->RecvFrom(ptrReadbuf, iQoSSuite->iQoSChannel[i]->iDestAddr[i2], 0, stat2);
					User::WaitForRequest(stat2);
					TESTL(stat==KErrNone);

					// compare the data
				  	TESTL( ptrWritebuf.Compare( ptrReadbuf ) == 0 );
					recvCount += ptrReadbuf.Length();
					}
				//	writebuf and readbuf
				CleanupStack::PopAndDestroy(2);
				}

			// check the total received (95 per cent is allowable for us)
			TESTL(recvCount*iQoSSuite->iQoSChannel[i]->iPacketSize[i2] > (0.95*(iQoSSuite->iQoSChannel[i]->iPackets[i2]*iQoSSuite->iQoSChannel[i]->iPacketSize[i2])) );	
			}		
		}

	return EPass;
	}
コード例 #2
0
TVerdict CBigSendRecvRtp::doTestStepL()
/**
 * @return - TVerdict code
 */
	{
	SetTestStepResult(EFail);
	if(KErrNone == InitSocketsL())
		{
		iIpAddrDest1.SetPort(9000);
		RBuf8 sendBuf;
		sendBuf.CreateMax(KBufferSize1);
		sendBuf.CleanupClosePushL();
		RBuf8 recvBuf;
		recvBuf.CreateMax(KBufferSize1);
		recvBuf.CleanupClosePushL();
		
		/* Fill the buffer with given character upto its length */
		sendBuf.Fill('Q');
		TRequestStatus status;
		/* do a Send of the data */
		iRtpSocket.SendTo(sendBuf, iIpAddrDest1, NULL, status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		/* Now do a Receive */
		recvBuf.FillZ();
		iRtpSocket.RecvFrom(recvBuf,iIpAddrDest1,NULL,status);
		User::WaitForRequest(status);
		User::LeaveIfError(status.Int());
		
		/* Obtain a TPtr of the data excluding the RTP header */
		TPtr8 sendBufPtr = sendBuf.MidTPtr(KRtpHeaderSize);
		TPtr8 recvBufPtr = recvBuf.MidTPtr(KRtpHeaderSize);
		/* Check if the data received is the same as the data sent */
		TInt ret = sendBufPtr.Compare(recvBufPtr);
		if(ret == 0)
			{
			/* Increase the buffer size and fill it up with given data */
			sendBuf.ReAlloc(KBufferSize2);
			recvBuf.ReAlloc(KBufferSize2);
			sendBuf.Fill('Q', KBufferSize2);
			
			/* Send the larger data */
			iRtpSocket.SendTo(sendBuf, iIpAddrDest1, NULL, status);
			User::WaitForRequest(status);
			User::LeaveIfError(status.Int());
			/* Now do a Receive */
			recvBuf.FillZ(KBufferSize2);
			iRtpSocket.RecvFrom(recvBuf,iIpAddrDest1,NULL,status);
			User::WaitForRequest(status);
			User::LeaveIfError(status.Int());
			/* Get pointer to data and compare both of them */
			TPtr8 sendBufPtr = sendBuf.MidTPtr(KRtpHeaderSize);
			TPtr8 recvBufPtr = recvBuf.MidTPtr(KRtpHeaderSize);
			TInt ret = sendBufPtr.Compare(recvBufPtr);
			if(ret == 0)
				{
				SetTestStepResult(EPass);
				}
			}
		CleanupStack::PopAndDestroy(2);
		}
	return TestStepResult();
	}
TVerdict CSymmetricMacIncrementalWithReplicateStep::doTestStepL()
	{
	//Assume faliure, unless all is successful
	SetTestStepResult(EFail);
		
	INFO_PRINTF1(_L("*** Symmetric Mac - Incremental with Replicate ***"));
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
		
	TPtrC keyPath;
	TPtrC sourcePath;
	TVariantPtrC algorithm;

	if(	!GetStringFromConfig(ConfigSection(),KConfigEncryptKeyPath, keyPath) ||
		!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid, algorithm) ||
		!GetStringFromConfig(ConfigSection(),KConfigSourcePath, sourcePath))
		{
		User::Leave(KErrNotFound);
		}
	
	// Create key 
	TKeyProperty keyProperty;
	CCryptoParams* keyParams = CCryptoParams::NewLC(); 
	
	HBufC8* convertKey = ReadInHexPlainTextL(keyPath);
	CleanupStack::PushL(convertKey);
	
	keyParams->AddL(*convertKey, KSymmetricKeyParameterUid);
	
	CKey* key=CKey::NewL(keyProperty, *keyParams);
	CleanupStack::PushL(key);
	
	//Create a pointer for the Hmac Implementation Object
	CMac* macImpl= NULL;
	
	//Retrieve a Mac Factory Object			
	TRAPD(err,CMacFactory::CreateMacL(macImpl,
										algorithm,
										*key,
										NULL));
				
	if (err != KErrNone)
		{
		CleanupStack::PopAndDestroy(3, keyParams); // keyParams, convertKey, key
		delete macImpl;
		ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Mac Object - %d ***"), err);
		return EFail;
		}
	
	INFO_PRINTF1(_L("Plugin loaded."));
	
	//Push the Mac Implementation Object onto the Cleanup Stack
	CleanupStack::PushL(macImpl);

	RFs fsSession;
	
	User::LeaveIfError(fsSession.Connect());
	CleanupClosePushL(fsSession);

	RFile sourceFile;
	CleanupClosePushL(sourceFile);
	
	//Open the specified source file
	User::LeaveIfError(sourceFile.Open(fsSession,sourcePath, EFileRead));

	TInt sourceLength = 0;
	TInt readPosition = 0;
	TInt readIncrement = 0;
	TBool macComplete = EFalse;
	TBool macReplicated = EFalse;
	TPtrC8 macStr;
	
	CMac* macReplicateImpl = NULL;
	
	User::LeaveIfError(sourceFile.Size(sourceLength));
	
	//Divide the total size of the source file up into individual equal sized blocks to read
	//over several increments
	readIncrement = sourceLength/KDataReadBlocks;
	
	if (readIncrement == 0)
		{
		ERR_PRINTF2(_L("*** Error: Source File must be larger than %d bytes ***"), KDataReadBlocks);
		User::LeaveIfError(KErrNotSupported);
		}

	do 
		{							
		//Create a heap based descriptor to store the data
		HBufC8* sourceData = HBufC8::NewL(readIncrement);
		CleanupStack::PushL(sourceData);
		TPtr8 sourcePtr = sourceData->Des();
		
		//Read in a block of data from the source file from the current position
		err = sourceFile.Read(readPosition,sourcePtr,readIncrement);
		
		HBufC8* convertSrc = ConvertFromHexFormatToRawL(*sourceData);
		CleanupStack::PopAndDestroy(sourceData);
		CleanupStack::PushL(convertSrc);
		
		//Update the read position by adding the number of bytes read
		readPosition += readIncrement;
		
		if(readPosition == readIncrement)
			{
			//Read in the first block from the data file into the Mac implementation object
			if(macReplicated == EFalse)
				{
				macImpl->MacL(*convertSrc);
				INFO_PRINTF2(_L("Intial Mac - Bytes Read: %d"), readPosition);
				}
			else
				{
				macReplicateImpl->MacL(*convertSrc);
				INFO_PRINTF2(_L("Intial Mac (Replicate) - Bytes Read: %d"), readPosition);	
				}
			CleanupStack::PopAndDestroy(convertSrc);
			}
		else if(readPosition >= sourceLength)
			{
			//Reading in the final block, constructs the complete hash value and returns it within a TPtrC8
			macStr.Set(macReplicateImpl->FinalL(*convertSrc));
			
			CleanupStack::PopAndDestroy(convertSrc);
			
			//Sets the Complete Flag to ETrue in order to drop out of the loop
			macComplete = ETrue;
			
			TInt totalRead = (readPosition - readIncrement) + (*sourceData).Length();
			INFO_PRINTF2(_L("Final Mac - Bytes Read: %d"),totalRead);
			}
		//If the read position is half the source length and the implementation
		//object hasn't already been replicated
		else if((readPosition >= sourceLength/2) && (macReplicated == EFalse))
			{
			INFO_PRINTF1(_L("Replicating Mac Object..."));
			macImpl->UpdateL(*convertSrc);
			
			CleanupStack::PopAndDestroy(convertSrc);
			
			//Create a Copy of the existing Mac Object with NO internal message state
			macReplicateImpl = macImpl->ReplicateL();
			
			macReplicated = ETrue;
			
			//Sets the read position back to 0 inorder to restart the file read from the beginning
			readPosition =0;
			CleanupStack::PushL(macReplicateImpl);
			INFO_PRINTF2(_L("*** Mac REPLICATE - Bytes Read: %d ***"), readPosition);
			}
		else
			{
			//Update the message data within the Mac object with the new block
			if(macReplicated == EFalse)
				{
				macImpl->UpdateL(*convertSrc);
				INFO_PRINTF2(_L("Mac Update - Bytes Read: %d"), readPosition);		
				}
			else
				{
				macReplicateImpl->UpdateL(*convertSrc);
				INFO_PRINTF2(_L("Mac Update (Replicate) - Bytes Read: %d"), readPosition);		
				}
			CleanupStack::PopAndDestroy(convertSrc);
			}					
		}while(macComplete == EFalse);

	//Create a NULL TCharacteristics pointer
	const TCharacteristics* charsPtr(NULL);
	
	//Retrieve the characteristics for the mac implementation object
	TRAP_LOG(err, macImpl->GetCharacteristicsL(charsPtr));
	
	//Static cast the characteristics to type TMacCharacteristics
	const TMacCharacteristics* macCharsPtr = static_cast<const TMacCharacteristics*>(charsPtr);
	
	//The mac output size is returned in Bits, divide by 8 to get the Byte size
	TInt macSize = macCharsPtr->iCipherAlgorithmChar->iBlockSize/8;
	HBufC8* macData = HBufC8::NewLC(macSize);
	TPtr8 macPtr = macData->Des();

	macPtr.Copy(macStr);

	//Check that expected data equals the encrypted data
	HBufC8* encryptedFileData = ReadInHexCiphertextL();
	CleanupStack::PushL(encryptedFileData);
			
	if(	!macPtr.Compare(TPtrC8(*encryptedFileData)))
		{
		INFO_PRINTF1(_L("*** Mac - Incremental with Replicate : PASS ***"));
		SetTestStepResult(EPass);	
		}
	else
		{
		ERR_PRINTF2(_L("*** FAIL: Mac Mismatch  ***"), err);
		}						

	CleanupStack::PopAndDestroy(9, keyParams);	// keyParams, convertKey, key, macImpl, &fsSession, &sourceFile, macReplicateImpl, macData, encryptedFileData
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
	return TestStepResult();  
	}
コード例 #4
0
/*
* Wave file structure: Riff header + Wave format chunk + Wave data chunk
* 
* Riff header:
* ==================================================
* Offset Size Description      Value
* 0x00      4 Chunk ID         "RIFF"
* 0x04      4 Chunk Data Size  ( file size ) - 8
* 0x08      4 RIFF Type        "WAVE"
* 0x0c      *  Wave chunks *
*
* Wave Format Chunk:
* ==================================================
* Offset Size Description      Value
* 0x00      4 Chunk ID         "fmt "
* 0x04      4 Chunk Data Size  16 + extra format bytes ( 0 for normal wav files)
* 0x08      2 Compression code 1...65535               ( 1 for PCM uncompressed)
* 0x0a      2 Nbr of channels  1...65535
* 0x0c      4 Sample rate      1...0xFFFFFFFF
* 0x10      4 Average bytes per sec
* 0x14      2 block align
* 0x16      2 siginificant bits per sample
* 0x18      2 extra format bytes 0...65535
* 0x1a        * extra format bytes, if any *
*
* Wave Data Chunk:
* ==================================================
* Offset Size Description      Value
* 0x00      4 Chunk ID         "data"
* 0x04      4 Chunk data size  
* 0x08        * sample data *
*
*/
void CTactileAudioPlayer::ReadSampleL( RFile& aFile, 
                                       HBufC8*& aDes, 
                                       TUint& aChannels, 
                                       TUint& aSampleRate )
    {
    TRACE("CTactileAudioPlayer::ReadSampleL - Start");
    const TInt fmtOffset  = 0x0c;
    const TInt dataOffset = fmtOffset + 0x18;
    
    TBuf8<KRiffHeaderSize> header;
    TInt err = aFile.Read( header, KRiffHeaderSize );
    if ( err )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL: reading from file failed, aborting");
        User::Leave( err );
        }

    TPtr8 p = header.LeftTPtr( 4 );
    
    if ( p.Compare( KRiff ) )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL: no RIFF header found, aborting" );
        User::Leave( KErrCorrupt );
        }

    p = header.MidTPtr( 0x08, 4 );
    if ( p.Compare( KWave ) )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL:  not a WAVE file, aborting" );
        User::Leave( KErrCorrupt );
        }

    p = header.MidTPtr( fmtOffset + 0x00, 4 );
    if ( p.Compare( KFmt ) )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL:  no 'fmt ' chunk found, aborting" );
        User::Leave( KErrCorrupt );
        }

    p = header.MidTPtr( dataOffset, 4 );
    if ( p.Compare( KData ) )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL:  no 'data' chunk found, aborting" );
        User::Leave( KErrCorrupt );
        }

    TUint8 lo = header[ fmtOffset + 0x08 ];
    TUint8 hi = header[ fmtOffset + 0x08 + 1 ];
    if ( !( lo == 1 && hi == 0) )
        {
        TRACE("CTactileAudioPlayer::ReadSampleL: non PCM wav not supported, aborting" );
        User::Leave( KErrNotSupported );
        }

    lo = header[ fmtOffset + 0x0a ];
    hi = header[ fmtOffset + 0x0a + 1 ];
    aChannels = lo;
    if ( !(aChannels == 1 || aChannels == 2 && hi == 0) )
        {
        TRACE2("CTactileAudioPlayer::ReadSampleL: unsupported number of channels ( %d ), aborting", aChannels );
        User::Leave( KErrNotSupported );
        }

    aSampleRate = 0;
    for ( TInt i = 0; i < 4; i++ )
        {
        lo = header[ fmtOffset + 0x0c + i ];
        TUint32 tmp = lo;
        tmp = tmp << i * 8;

        aSampleRate = aSampleRate | tmp;
        }

    lo = header[ fmtOffset + 0x16 ];
    hi = header[ fmtOffset + 0x16 + 1 ];
    TUint16 bitsPerSample = hi;
    bitsPerSample = bitsPerSample << 8;
    bitsPerSample = bitsPerSample | lo;

    if ( bitsPerSample != 16 )
        {
        TRACE2("CTactileAudioPlayer::ReadSampleL:  %d bits per sample not supported", bitsPerSample );
        User::Leave( KErrNotSupported );
        }

    TUint32 bytesPerSample = bitsPerSample / 8;
    
    // how many bytes for 6 ms
    TUint bytesNeeded = ( aSampleRate * aChannels * bytesPerSample * 6 ) / 1000;

    TInt fsize( 0 );
    if ( aFile.Size( fsize ) == KErrNone && fsize >= bytesNeeded + KRiffHeaderSize )
        {
        aDes = HBufC8::NewL( bytesNeeded );
        TPtr8 des = aDes->Des();
        aFile.Read( des, bytesNeeded );
        }
    else
        {
        TRACE("CTactileAudioPlayer::ReadSampleL: Less than 6ms content in file, aborting" );
        User::Leave( KErrNotSupported );
        }

    TRACE3("CTactileAudioPlayer::ReadSampleL %dHz %dchannel sample read successfully - End", 
        iSampleRate, iChannels);
    }
コード例 #5
0
// -----------------------------------------------------------------------------
// CBSBrandHandler::ReadStreamL()
// -----------------------------------------------------------------------------
//
MBSElement* CBSBrandHandler::ReadStreamL( const TDesC8& aId, RFileReadStream& aStream,
										  TBool aAllowEmptyId /* = EFalse */ )
	{
	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL BEGIN"));
	TBSElementType type = (TBSElementType)aStream.ReadInt16L();
	MBSElement* returnValue = NULL;
	
	TInt idSize = aStream.ReadInt16L();
	
	HBufC8* elementId = HBufC8::NewLC( idSize );
	TPtr8 elementIdPtr = elementId->Des();

	if( idSize == 0 && aAllowEmptyId )
		{
		// we don't read empty ID
		}
	else
		{
		aStream.ReadL( elementIdPtr, idSize );
        elementIdPtr.SetLength( idSize );// Set length
		}
	

	TBool match = EFalse;
	if( aAllowEmptyId || ( 0 == elementIdPtr.Compare( aId ) ) )
		{
		match = ETrue;
		}
		
    TPtrC8 idPtrC( *elementId );// idPtrC creation moved here so it will be updated correctly.
	if( elementId->Length() == 0 )
		{
		CleanupStack::PopAndDestroy( elementId );
		elementId = NULL;
		idPtrC.Set( KNullDesC8 );
		}

	switch( type )
		{
		case EBSInt:
			{
			TInt intData = aStream.ReadInt16L();
			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type INT"));
			if( match )
				{
                // Codescanner warning: neglected to put variable on cleanup stack (id:35)
                // This method cannot leave after this line
				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
																  EBSInt,
																  intData ); 
				}
			break;
			}		
		case EBSText:
		case EBSFile: // flow through
			{
			TInt textSize = aStream.ReadInt16L();
			HBufC* textData = HBufC::NewLC( textSize );

			TPtr textPtr = textData->Des();
			aStream.ReadL( textPtr, textSize );

			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type TEXT/ FILE"));
			if( match )
				{
                // Codescanner warning: neglected to put variable on cleanup stack (id:35)
                // This method cannot leave after this line
				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
																  type,
																  *textData ); 
				}

			CleanupStack::PopAndDestroy( textData );
			break;
			}
		case EBSList:
			{
			RBSObjOwningPtrArray<MBSElement> listData;
			CleanupClosePushL( listData );
			TInt count = aStream.ReadInt16L();
			
			for( TInt i = 0; i < count; i++ )
				{
				MBSElement* subElement = ReadStreamL( KNullDesC8, aStream, ETrue );
				CleanupDeletePushL( subElement );
				listData.AppendL( subElement );
				CleanupStack::Pop(); // subElement
				}
				
			if( match )
				{
                // Codescanner warning: neglected to put variable on cleanup stack (id:35)
                // This method cannot leave after this line
				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
																  EBSList,
																  listData ); 
				}
			CleanupStack::Pop(); // listData
			break;
			}
		case EBSBuffer:
			{
			TInt bufferSize = aStream.ReadInt16L();
			HBufC8* buffeData = HBufC8::NewLC( bufferSize );

			TPtr8 bufferPtr = buffeData->Des();
			aStream.ReadL( bufferPtr, bufferSize );

			if( match )
				{
                // Codescanner warning: neglected to put variable on cleanup stack (id:35)
                // This method cannot leave after this line				
				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
																  EBSBuffer,
																  *buffeData ); 
				}

			CleanupStack::PopAndDestroy( buffeData );
			break;
			}
		case EBSBitmap:
			{
			TInt length = aStream.ReadInt16L();
			HBufC8* fileId = HBufC8::NewLC( length );
			
			TPtr8 fileIdPtr = fileId->Des();
			aStream.ReadL( fileIdPtr, length );
			
			TInt bitmapId = aStream.ReadInt16L();
			TInt maskId = aStream.ReadInt16L();
			TInt skinId = aStream.ReadInt16L();
			TInt skinMaskId = aStream.ReadInt16L();

			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type BITMAP .. bitmap ID is [%d]"), bitmapId);
			if( match )
				{
				CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId,
													  maskId,
													  skinId,
													  skinMaskId,
													  fileIdPtr );

                // Codescanner warning: neglected to put variable on cleanup stack (id:35)
                // This method cannot leave after this line
				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
																  EBSBitmap,
																  bitmap ); 
				CleanupStack::Pop( bitmap ); 
				}
		    CleanupStack::PopAndDestroy( fileId ); 

			break;
			}
		default:
			{
			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type DEFAULT : corrupt"));
			User::Leave( KErrCorrupt );
			break;
			}
		}

	if( elementId )
		{
		CleanupStack::PopAndDestroy( elementId );
		}

	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL END"));
	return returnValue;
	}
コード例 #6
0
void CMultipleArray::SendAndRecvL(TInt aExtraSocksToJoin)
	{
	TRequestStatus stat;
	TBuf8<50> Data;

	// set up data buffers
	HBufC8 * writebuf = HBufC8::NewMaxLC( iPacketSize[aExtraSocksToJoin] );
	HBufC8 * readbuf  = HBufC8::NewMaxLC( iPacketSize[aExtraSocksToJoin] );
	TPtr8 ptrWritebuf = writebuf->Des();
	TPtr8 ptrReadbuf = readbuf->Des();

	TInt recvCount = 0;

	// Send / Recv TCP
	if (iProtocol[aExtraSocksToJoin] == KProtocolInetTcp)
		{
		for (TInt i = 0; i < iPackets[aExtraSocksToJoin]; i++)
			{
			iQoSStep->iQoSSuite->Log( _L("Sending TCP data, %d packets of %d bytes = %d"), 
			iPackets[aExtraSocksToJoin], iPacketSize[aExtraSocksToJoin], iPackets[aExtraSocksToJoin] * iPacketSize[aExtraSocksToJoin]);

			// initialise data
			Data.Format(_L8("TCP-packet:%d helloworld"),i);
			ptrWritebuf.Repeat( Data );

			// write data
			GetSocketHandle(aExtraSocksToJoin)->Write(ptrWritebuf, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to write tcp data to destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// read data
			GetSocketHandle(aExtraSocksToJoin)->Read(ptrReadbuf, stat);
			User::WaitForRequest(stat); //, TimerStatus);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to read tcp data from destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// compare the data
			if (ptrWritebuf.Compare( ptrReadbuf ) != 0)
				{
				iQoSStep->iQoSSuite->Log(_L("Data written to and read from destination address do not match in size"));
//				return Fail;
				}

			recvCount+=ptrReadbuf.Length();
			}

		CleanupStack::PopAndDestroy(2);	//	writebuf and readbuf
		} 

	// Send / Recv UDP 
	if (iProtocol[aExtraSocksToJoin] == KProtocolInetUdp)
		{
		iQoSStep->iQoSSuite->Log( _L("Send Udp Data, %d packets of %d bytes = %d"), 
		iPackets[aExtraSocksToJoin], iPacketSize[aExtraSocksToJoin], iPackets[aExtraSocksToJoin] * iPacketSize[aExtraSocksToJoin]);
	
		for (TInt i = 0; i < iPackets[aExtraSocksToJoin]; i++)
			{
			// initialise data
			Data.Format(_L8("UDP-packet:%d helloworld"),i);
			ptrWritebuf.Repeat( Data );	

			// write data
			GetSocketHandle(aExtraSocksToJoin)->Send(ptrWritebuf, 0, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to write udp data to destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			GetSocketHandle(aExtraSocksToJoin)->Recv(ptrReadbuf, 0, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to read udp data from destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// compare the data
			if (ptrWritebuf.Compare( ptrReadbuf ) != 0 )
				{
				iQoSStep->iQoSSuite->Log(_L("Data written to and read from destination address do not match in sizevalue"));
//				return Fail;
				}
			recvCount += ptrReadbuf.Length();
			}

		// get rid of the old buffers 
		CleanupStack::PopAndDestroy(2);	//	writebuf and readbuf
		}


	// check the total received (95 per cent is allowable for us)
	if (recvCount*iPacketSize[aExtraSocksToJoin] < (0.95*(iPackets[aExtraSocksToJoin]*iPacketSize[aExtraSocksToJoin])))
		{
		iQoSStep->iQoSSuite->Log(_L("The total packets received is less than 95 per cent of the overall packets sent"));
//		return Fail;
		}
	}