TInt DISIRouter::Send(
        TDes8& aMessage,
        const TUint8 aObjId
        )
    {
    C_TRACE( ( _T( "DISIRouter::Send 0x%x 0x%x>" ), &aMessage, aObjId ) );

    if( ( ( aObjId == EIscNokiaUsbPhonetLink ) && ( GET_SENDER_DEV( aMessage.Ptr() ) == PN_DEV_PC ) ) ||
        ( aObjId == PN_OBJ_ROUTING_REQ ) || 
        ( aObjId == PN_OBJ_EVENT_MULTICAST ) ||
        ( aObjId == ROUTER_OBJECT_IDENTIFIER ) ||
        ( aObjId == PIPEHANDLER_OBJECT_IDENTIFIER ) ) 
        {
        // No need to update sender dev and obj id
        C_TRACE( ( _T( "DISIRouter::Send message tx address not needed to updata 0x%x 0x%x>" ), aObjId, GET_SENDER_DEV( aMessage.Ptr() ) ) );
        }
    else
        {
        TUint8* messageBlockPtr( const_cast<TUint8*>( aMessage.Ptr() ) );        
        SET_SENDER_DEV( messageBlockPtr, PN_DEV_OWN );
        SET_SENDER_OBJ( messageBlockPtr, aObjId );
        }
    TInt error = iShCLTransceiver->RouteISIMessage( aMessage );
    C_TRACE( ( _T( "DISIRouter::Send 0x%x 0x%x<" ), &aMessage, aObjId ) );
    return error;
    }
コード例 #2
0
// -----------------------------------------------------------------------------
// CG711PayloadFormatRead::DecodePayload
// Decodes all audio frames from the received RTP payload buffer. Decoded
// audio frames are saved to the internal array so that audio frames can be
// requested one at a time with GetNextFrame() -method.
// No assumption about frame count in RTP packet is done.
// -----------------------------------------------------------------------------
//
TInt CG711PayloadFormatRead::DecodePayload( TDes8& aSourceBuffer )
{
    DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload SourceBufSize: %d",
                   aSourceBuffer.Size() );
    DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload SourceBufLength: %d",
                   aSourceBuffer.Length() );

    iFrameIndex = 0;

    const TUint8* framePtr = aSourceBuffer.Ptr();
    const TUint8* endPtr = aSourceBuffer.Ptr() + aSourceBuffer.Size();

    TInt frames = aSourceBuffer.Size() / TInt( iCInfo.iFrameSize );

    DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload FrameSize: %d",
                   iCInfo.iFrameSize );
    DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload Frames: %d",
                   frames );

    // Construct pointers to frames in payload if not in CN mode
    if ( !iCnFrame )
    {
        while ( frames-- )
        {
            const TPtr8 bufPtr( const_cast<TUint8*>( framePtr ),
                                iCInfo.iFrameSize, iCInfo.iFrameSize );
            iFrameArray.Append( bufPtr );

            framePtr += iCInfo.iFrameSize;
            if ( framePtr >= endPtr )
            {
                frames = 0;
            }
        }
    }
    else if ( aSourceBuffer.Size() && iCnFrame )
    {
        // If it is a CN frame, then we must do special handling. This is
        // because e.g Cisco kit sends 1 byte CN frames, thus we need to
        // expand the source buffer with zeroes.
        TInt targetLen = iCInfo.iFrameSize;
        targetLen = targetLen - aSourceBuffer.Size();

        DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload CN frame size adjust: %d",
                       targetLen );

        const TChar zero( '0' );
        aSourceBuffer.AppendFill( zero, targetLen );

        const TPtr8 bufPtr( const_cast<TUint8*>( framePtr ),
                            iCInfo.iFrameSize, iCInfo.iFrameSize );

        iFrameArray.Append( bufPtr );
    }


    return iFrameArray.Count();
}
コード例 #3
0
TInt CNifPDPContextTNif::HandlePDPCreate(TDes8& aConfig)
	{
	RPacketContext::TProtocolType pdpType;
	iNif->FirstExistingPDPContext()->ContextPDPType(pdpType);

	// Context creation is synchronous call.
	const TDesC8& contextName=CfgFile()->ItemValue(KContextName, KDefaultName);
	iContextName.Copy(contextName);

	RPacketContext::TGSNAddress name;
	iNif->FirstExistingPDPContext()->ContextAPNName(name);

	// Update the return data.
	TContextParameters& opt = *(TContextParameters*)aConfig.Ptr();
	opt.iContextConfig.SetPdpType(pdpType);
	opt.iContextType=ESecondaryContext;
	opt.iContextConfig.SetAccessPointName(name);
	opt.iReasonCode = KErrNone;				// we need to set this to success IDO

	// Update the local data copy.	
	iParameter.iContextConfig.SetPdpType(pdpType);
	iParameter.iContextType=ESecondaryContext;
	iParameter.iContextConfig.SetAccessPointName(name);

	//TODO: We need to start a timer as well to simulate the creation
	// if telephony decides the creation is Asyn call.

	// Start Timer to new PDP .
	TimerCancel();
	TimerAfter(2000*1000);

	return KErrNone;
	};
コード例 #4
0
TInt CNifPDPContextTNif::HandleContextActivate(TDes8& aConfig)
	{
	TContextParameters& opt = *(TContextParameters*)aConfig.Ptr();
	if (iParameter.iContextInfo.iStatus ==  RPacketContext::EStatusActivating)
	{
		opt.iReasonCode = KErrInUse;				// we need to set this to success 
		return KErrGeneral;
	}
	else if(iParameter.iContextInfo.iStatus ==  RPacketContext::EStatusActive)
	{
		opt.iReasonCode = KErrInUse;
		return KErrGeneral;
	}
	
	// Get the Activation Duration.
	TInt activateDuration;
	const CTestConfigItem* item = CfgFile()->Item(KContextActivateEntry);
	TInt err=CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, activateDuration);		// The 3rd parameter (3) represents the index of the variable on the config file line
	if (err!=KErrNone)
		activateDuration=KDefaultActivationTime;

	// Start Timer to activate the PDP context.
	TimerCancel();
	TimerAfter(activateDuration*1000);

	// Update the return data.
	opt.iReasonCode = KErrNone;				// we need to set this to success IDO
	opt.iContextInfo.iStatus = RPacketContext::EStatusActivating;
	// Update the local data copy.	
	iParameter.iReasonCode = KErrNone;
	
	return KErrNone;
	};
コード例 #5
0
TInt CNifPDPContextTNif::HandleQosSet(TDes8& aConfig)
	{
	// Update local record.
	TContextParameters& opt = *(TContextParameters*)aConfig.Ptr();
	CopyQosReqParameter(opt);

	// Get the Qos Profile Name.
	const TDesC8& name=CfgFile()->ItemValue(KQosProfileName, KDefaultName);
	iQosProfileName.Copy(name);

	// Get the Qos Setting Duration.
	TInt qosDuration;
	const CTestConfigItem* item = CfgFile()->Item(KContextQosSetEntry);
	TInt err=CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, qosDuration);		// The 3rd parameter (3) represents the index of the variable on the config file line
	if (err!=KErrNone)
		qosDuration=KDefaultQosSettingTime;

	// Start Timer to set Qos.
	TimerCancel();
	TimerAfter(qosDuration*1000);	

	// Update the return data.
	opt.iReasonCode = KErrNone; 				// we need to set this to success 
	// Update the local data copy.	
	iParameter.iReasonCode = KErrNone;
	return KErrNone;
	};
コード例 #6
0
ファイル: t_modem1.cpp プロジェクト: kuailexs/symbiandump-os1
LOCAL_C TInt TranslateCrLf(TDes8 &aDes)
//
// Search for CR/LF characters in a string and replace them with
// '\r' '\n' format. Also replaces unprintable characters with "?"
//
{

    TText8 buf[KBlockSize];
    TText8 *pS=(TText8*)aDes.Ptr();
    TText8 *pSE=pS+aDes.Size();
    TText8 *pT=&buf[0];
    TText8 *pTMax=pT+(KBlockSize-1);
    for (; pS<pSE; pS++,pT++)
    {
        if (pT>=pTMax)
            return(KErrTooBig);
        if (*pS=='\xD'||*pS=='\xA')
        {
            *pT++='\\';
            *pT=(*pS=='\xD')?'r':'n';
        }
        else if (((TChar)*pS).IsPrint())
            *pT=*pS;
        else
            *pT='\?';
    }
    *pT=0;
    if ((pT-&buf[0])>aDes.MaxLength())
        return(KErrTooBig);
    aDes.Copy(&buf[0]);
    return(KErrNone);
}
TBool DISIRouter::Receive( TDes8& aMessage, const TUint8 aObjId )
    {
    C_TRACE( ( _T( "DISIRouter::Receive 0x%x 0x%x>" ), &aMessage, aObjId ) );
    TBool error( EFalse );
    TUint8* messageBlockPtr( const_cast<TUint8*>( aMessage.Ptr() ) ); 

    NKern::FMWait( iClientTableFastMutex );
    if( iClientTable[ aObjId ] )
        {
        NKern::FMSignal( iClientTableFastMutex );
        ( iClientTable[ aObjId ]->iChannel )->Receive( aMessage ); //may not be safe, consider receive/delete sync
        C_TRACE( ( _T( "DISIRouter::Receive ok 0x%x 0x%x" ), &aMessage, aObjId ) );
        error = ETrue;
        }
    else
        {
        NKern::FMSignal( iClientTableFastMutex );
        C_TRACE( ( _T( "DISIRouter::Receive failed 0x%x 0x%x" ), &aMessage, aObjId ) );
        error = EFalse;
        }

    C_TRACE( ( _T( "DISIRouter::Receive 0x%x 0x%x %d<" ), &aMessage, aObjId, error ) );
    return error;

    }
コード例 #8
0
TInt CIPv6Binder::DeleteContext(TDes8& aContextParameters)
/**
 * Deletes a context. As the NIF is responsible for one primary context,
 * this is equivalent to closing down the NIF.
 *
 * @param aContextParameters Parameters of the context to delete
 * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone
 */
	{
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_DELETECONTEXT_1, "CIPv6Binder::DeleteContext");

	if (aContextParameters.Length() != sizeof(TContextParameters))
		{
		return KErrArgument;
		}

	TUint8* ptr = CONST_CAST(TUint8*, aContextParameters.Ptr());
	TContextParameters* params = REINTERPRET_CAST(TContextParameters*, ptr);

	if (params->iContextInfo.iContextId != 
		STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi()))
		{
		params->iReasonCode = KErrBadName;
		}
	else
		{
		params->iReasonCode = KErrNone; 
		GetFlow().Stop(KErrNone, MNifIfNotify::EDisconnect);
		}

	return KErrNone;
	}
コード例 #9
0
EXPORT_C int Tbuf8ToWchar(TDes8& aSrc, wchar_t* aDes, int& n_size)
{	
    int retval = ESuccess;	
    unsigned int ilen = aSrc.Length();
    int minusone = -1;
    
    if(0 == ilen)
    {
    	return EDescriptorNoData;
    }
    else if(!aDes)
    {
    	return EInvalidPointer;
    }
    else if(n_size < ilen+1)
    {	
        n_size = ilen+1; 
    	return EInvalidSize;
    }	
	
	if(minusone != mbstowcs(aDes, (const char*)aSrc.Ptr(), ilen))
	{
	    *(aDes + ilen) = L'\0';	
	}
	else 
	{
		retval = EInvalidMBSSequence;
	}
	
	return retval;			
}		
// KErrBadDescriptor, if message length too small
// KErrUnderFlow, if message length too big.
// KErrCouldNotConnect, if receiver object is out of scope.
TInt DISICLTransceiver::ValidateISIMessage(
        TDes8& aMessage
        )
    {

    C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage 0x%x>" ), &aMessage ) );
    const TUint16 descLength( aMessage.Length() );
    TInt msgOk( KErrNone );
    msgOk = ( ISI_HEADER_OFFSET_MESSAGEID >= descLength ) ? KErrBadDescriptor : msgOk;
    TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
    // Get ISI message length after known that the descriptor is big enough.
    const TUint8* msgPtr( aMessage.Ptr() );
    const TUint16 isiMsgLength( GET_LENGTH( msgPtr ) + PN_HEADER_SIZE );
    // If the descriptor length is less than ISI message length.
    msgOk = ( ( msgOk == KErrNone && isiMsgLength > descLength ) ? KErrUnderflow : msgOk );
    TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
    // If the ISI message length is bigger that the largest supported.
    msgOk = ( ( msgOk == KErrNone && isiMsgLength > KMaxISIMsgSize ) ? KErrUnderflow : msgOk );
    TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
    // If the ISI message length with PN_HEADER_SIZE is less or equal than ISI_HEADER_OFFSET_MESSAGEID.
    msgOk = ( ( msgOk == KErrNone && isiMsgLength <= ISI_HEADER_OFFSET_MESSAGEID ) ? KErrUnderflow : msgOk );
    TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
    TRACE_ASSERT_INFO( msgOk == KErrNone, isiMsgLength );
    TRACE_ASSERT_INFO( msgOk == KErrNone, descLength );
    C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage %d<" ), msgOk ) );
    return msgOk;
    }
コード例 #11
0
ファイル: FINGER.CPP プロジェクト: cdaffara/symbiandump-os1
TInt RecvLine(RTest &aTest, TDes8 &aBuf, RSocket &aSock)
	{
	TInt offset=0;
	TText ch=0;

	do
		{
		TPtr8 ptr(NULL, 0);
		TSockXfrLength len;
		TRequestStatus stat;

		ptr.Set((TUint8 *)aBuf.Ptr()+offset, aBuf.Length()-offset, aBuf.Length()-offset);
		aSock.RecvOneOrMore(ptr,0,stat,len);
		User::WaitForRequest(stat);
		aTest(stat==KErrNone);
		TInt length=len();
		TInt n=0;
		while (length--)
			{
			ch = *(ptr.Ptr()+n);
			if (ch=='\r' || ch=='\n')
				break;
			++offset;
			++n;
			}
		}
	while (ch!='\r' && ch!='\n' );

	aBuf.SetLength(offset);
	return offset;
	}
コード例 #12
0
EXPORT_C void CRtpHandlerBase::SaveReadStatus(TDes8& aClientBuf)
	{	
	__RTP_LOG1(_L("CRtpHandlerBase [0x%x]::SaveClientStatus"), this);
	__RTP_LOG2(_L("\taClientBuffer at 0x%x, of Length %d"), aClientBuf.Ptr(), aClientBuf.Length());
	ASSERT(iDataObserver); //With out DataObserver the app shouldnot attempt a read
	iClientDataPtr = &aClientBuf;
	}
コード例 #13
0
TInt	CWsGceCscBase::DebugInfo(TWsDebugInfoFunc aFunction, 
		                                 TInt aParam, 
		                                 TDes8& aHostBuffer,
		                                 const void*&aReturnedObject,
		                                 TInt aObjectSize)const
	{
	TInt reqSize=iSession.DebugInfo(aFunction,aHostBuffer,aParam);
	aReturnedObject=NULL;
	if (reqSize<0)
		{
		if ((reqSize%aObjectSize)!=0)
			{
			return KErrCorrupt;
			}
		else
			{
			return reqSize;
			}
		}
	if (reqSize>aHostBuffer.MaxLength())
		{
		return reqSize/aObjectSize;
		}
	if (reqSize==0)
		{
		reqSize=aHostBuffer.MaxLength();
		}
	if ((reqSize%aObjectSize)!=0)
		{
		return KErrCorrupt;
		}
	aReturnedObject=(const void*)aHostBuffer.Ptr();
	reqSize/=aObjectSize;
	return reqSize;
	}
コード例 #14
0
ファイル: US_BUF.CPP プロジェクト: cdaffara/symbiandump-os2
/** Reads data from the stream buffer into the specified descriptor.

This function is called by ReadL(TDes8&,TInt,TRequestStatus&).

This implementation deals with the request synchronously, and completes the 
request with KErrNone. Other implementations may choose to deal with this 
in a true asynchronous manner.

In addition, the read operation itself uses the DoReadL(TAny*,TInt) variant.

@param aDes The target descriptor for the data read from the stream buffer. 
On return, the length of the descriptor is set to the number of bytes read 
from the stream buffer.
@param aMaxLength The maximum number of bytes to be read. This value must not 
be greater than the maximum length of the descriptor, otherwise the function 
raises a STORE-Stream 2 panic.
@param aStatus The request status that indicates the completion status of this 
asynchronous request.
@return The maximum number of bytes to be read, as used in this request. This 
implementation uses, and returns, the value supplied in aMaxLength. Other 
implementations may choose to use a different value.
@see MStreamBuf::ReadL() */
EXPORT_C TInt MStreamBuf::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
	{
	__ASSERT_DEBUG(aMaxLength<=aDes.MaxLength(),Panic(EStreamReadBeyondEnd));
	aDes.SetLength(DoReadL((TUint8*)aDes.Ptr(),aMaxLength));
	TRequestStatus* stat=&aStatus;
	User::RequestComplete(stat,KErrNone);
	return aMaxLength;
	}
TInt DISICLTransceiver::SendCommIsaEntityNotReachableResp(
        TDes8& aNotDeliveredMessage
        )
    {
    C_TRACE( ( _T( "DISICLTransceiver::SendCommIsaEntityNotReachableResp 0x%x>" ), &aNotDeliveredMessage ) );
    const TUint8* notDeliveredMsgPtr( aNotDeliveredMessage.Ptr() );
    TInt error = KErrAlreadyExists;
    // Avoid COMM_ISA_ENTITY_NOT_REACHABLE_RESP loop.
    if( ( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MESSAGEID ] == COMMON_MESSAGE ) &&
        ( ( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] == COMM_ISA_ENTITY_NOT_REACHABLE_RESP ) || 
          ( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] == COMM_SERVICE_NOT_IDENTIFIED_RESP ) ) )
        {
        C_TRACE( ( _T( "DISICLTransceiver Not sending another CommIsaEntityNotReachableResp 0x%x 0x%x" ), &aNotDeliveredMessage, notDeliveredMsgPtr[ ISI_HEADER_OFFSET_SUBMESSAGEID ] ) );
        }
    else
        {
        // Follows COMM specification: 000.031
        TUint8 length( ISI_HEADER_SIZE + SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP );
        TDes8& respMsg = MemApi::AllocBlock( length );
        ASSERT_RESET_ALWAYS( length > ISI_HEADER_OFFSET_MESSAGEID, ( EISICLTransceiverOverTheLimits | EDISICLTransceiverTraceId << KClassIdentifierShift ) );
        TUint8* respMsgPtr = const_cast<TUint8*>( respMsg.Ptr() );
        // We start to append from transaction id.
        respMsg.SetLength( ISI_HEADER_OFFSET_TRANSID );
        // Get the header until messageid from prev. message.
        // Just turn receiver and sender device and object vice versa.
        respMsgPtr[ ISI_HEADER_OFFSET_MEDIA ] = notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MEDIA ];
        SET_RECEIVER_DEV( respMsgPtr, GET_SENDER_DEV( aNotDeliveredMessage ) );
        SET_SENDER_DEV  ( respMsgPtr, GET_RECEIVER_DEV( aNotDeliveredMessage ) );
        respMsgPtr[ ISI_HEADER_OFFSET_RESOURCEID ] = notDeliveredMsgPtr[ ISI_HEADER_OFFSET_RESOURCEID ];
        SET_LENGTH( respMsgPtr, ( length - PN_HEADER_SIZE ) );
        SET_RECEIVER_OBJ( respMsgPtr, GET_SENDER_OBJ( aNotDeliveredMessage ) );
        SET_SENDER_OBJ( respMsgPtr, GET_RECEIVER_OBJ( aNotDeliveredMessage ) );
        // Set from undelivered message
        respMsg.Append( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_TRANSID ] );
        // Message Identifier
        respMsg.Append( COMMON_MESSAGE );
        // Sub message Identifier.
        respMsg.Append( COMM_ISA_ENTITY_NOT_REACHABLE_RESP );
        // Not Delivered Message from original message.
        respMsg.Append( notDeliveredMsgPtr[ ISI_HEADER_OFFSET_MESSAGEID ] );
        // Status
        respMsg.Append( COMM_ISA_ENTITY_NOT_AVAILABLE );//  different status in a case of device not existing
        // Filler
        const TUint8 KFiller( 0x00 );
        respMsg.Append( KFiller );
        // Filler
        respMsg.Append( KFiller );
        // Filler
        respMsg.Append( KFiller );
        error = RouteISIMessage( respMsg, EFalse );
        // Programming error in this function if below assert is raised
        ASSERT_RESET_ALWAYS( KErrNone == error, ( EISICLTransceiverCommIsaEntityNotReachableResp | EDISICLTransceiverTraceId << KClassIdentifierShift ) );        
        }
    MemApi::DeallocBlock( aNotDeliveredMessage );
    C_TRACE( ( _T( "DISICLTransceiver::SendCommIsaEntityNotReachableResp 0x%x<" ), &aNotDeliveredMessage ) );
    return error;

    }
コード例 #16
0
ファイル: MSCHAP.CPP プロジェクト: cdaffara/symbiandump-os2
// NB The use of the LAN Manager compatible challenge response has
// been deprecated according to RFC 2433.
inline void CPppMsChap::LmPasswordHashL(const TDesC8& aPassword,
					TDes8& aPasswordHash)
/**
   Computes the hash of the LAN Manager password using DES.
   @param aPassword [in] The LAN Manager password (0 to 14 OEM char).
   @param aPasswordHash [out] The DES hash of the LAN Manager password
   (16 octets).
   @note This function implements the LmPasswordHash routine specified
   in RFC 2433.
   @note The use of the LAN Manager compatible Challenge Response has
   been deprecated according to RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aPassword.Length() <=
		KPppMsChapMaxLANManagerPasswordLength);
	ASSERT(aPasswordHash.Length() == KPppMsChapHashSize);

	HBufC8* ucasePasswordBuf =
	       HBufC8::NewLC(KPppMsChapMaxLANManagerPasswordLength);
	TPtr8 ucasePassword(ucasePasswordBuf->Des());
	ucasePassword.Copy(aPassword);
	ucasePassword.UpperCase();
	ucasePassword.AppendFill(0,
		KPppMsChapMaxLANManagerPasswordLength -
			ucasePassword.Length());

// The first 8 octets of aResponse
	TPtr8 responseChunk(const_cast<TUint8*>(aPasswordHash.Ptr()),
				KPppDESKeySize, KPppDESKeySize);
	DesHashL(ucasePassword.Left(KPppMsChapDESKeySize), 
		responseChunk);

	responseChunk.Set(const_cast<TUint8*>(aPasswordHash.Ptr()) +
				KPppDESKeySize, 
			KPppDESKeySize,
			KPppDESKeySize);
	DesHashL(ucasePassword.Mid(KPppMsChapDESKeySize,
			KPppMsChapDESKeySize), 
		responseChunk);

	CleanupStack::PopAndDestroy(ucasePasswordBuf);
	ASSERT(aPasswordHash.Length() == KPppMsChapHashSize);
	}
コード例 #17
0
// -----------------------------------------------------------------------------
// CDirectoryDesc::Read : Reading from a Directory
// -----------------------------------------------------------------------------
void CDirectoryDesc::Read(TDes8& aDesc, TRequestStatus& aStatus)
{
    TInt errorNum = KErrNone;
    const TInt16 KDirentSize = 8;
    TInt readLen = aDesc.MaxLength();
    TUint8* bufPtr = const_cast<TUint8*>(aDesc.Ptr());
    TInt copiedInfo = 0;
    TEntryArray entries;
    errorNum = iDir.Read( entries );
    TDirent direntEntry;

    if (errorNum == KErrNone || errorNum == KErrEof)
    {
        errorNum = KErrNone;
        TEntry entry;
        TInt len = 0;
        TInt count = entries.Count();
        TBuf8<KMaxFileName> fileName;
        TInt index = 0;
        TInt copyLen = 0;
        //Loop through each entry and get all the informations
        for (; index<count && copiedInfo<readLen; index++, copiedInfo += copyLen)
        {
            entry = entries[index];
            //Copy File's UID
            TUid fileUID = entry.iType.MostDerived();
            direntEntry.iEntryNum = fileUID.iUid;
            HBufC8 *name;
            if(ConvertUnicodeToUtf8(entry.iName,name,errorNum) == -1)
            {
                break;
            }
            //Copy entry type and record Length
            fileName.Copy( name->Des() );
            delete name;
            len = fileName.Length();
            direntEntry.iRecLen = KDirentSize + len + 1;
            //Maintaing a four byte boundary.
            direntEntry.iRecLen = Align4(direntEntry.iRecLen);
            direntEntry.iEntryType = 0;
            direntEntry.iNameLen = len;
            //Copy entry name
            Mem::Copy( direntEntry.iEntryName, fileName.PtrZ(), len+1);

            //Copy structure on to the buffer
            copyLen = Min(direntEntry.iRecLen, (readLen - copiedInfo));
            Mem::Copy( bufPtr, &direntEntry, copyLen );
            bufPtr += copyLen;
        }
    }

    //Set the Length
    aDesc.SetLength( copiedInfo );
    TRequestStatus* status = &aStatus;
    User::RequestComplete(status, errorNum);
}
コード例 #18
0
void CDatabase::HexToStrL(TDes8& aSource)
/**
	Convert a string containing hexadecimal representation to another string containing binary representation
	@param aSource Source data containing a string
 */
	{
	TUint8 *pSource = (TUint8 *)aSource.Ptr();
	TUint8 *pDest	= (TUint8 *)aSource.Ptr();
	
	TInt len = aSource.Length();
	TInt idxSource;
	TInt idxDest;
	
	for(idxSource=0, idxDest=0; idxSource<len; ++idxDest,idxSource+=2)
		{
		pDest[idxDest] = HexToIntL(pSource+idxSource);
		}
	
	aSource.SetLength(idxDest);
	}
コード例 #19
0
ファイル: IPC_PRVD.CPP プロジェクト: cdaffara/symbiandump-os1
void CIpcStreamProvd::GetData(TDes8 &aDesc,TUint /*options*/,TSockAddr* /*anAddr*/)
	{
	__ASSERT_DEBUG(iConnection,Panic(EBadWriteCall));
	__ASSERT_DEBUG(iSocket,Panic(EBadWriteCall));

	CCirBuffer& buf=((CIpcStreamProvd *)iConnection)->iBuffer;

	__ASSERT_DEBUG(aDesc.Length()<=buf.Count(),Panic(EReadGetTooMuch));

	buf.Remove((TUint8 *)aDesc.Ptr(),aDesc.Length());
	iConnection->CanSend();
	}
コード例 #20
0
static void GetWhirlPoolHash(TDes8& aWhirlPoolHash, TDes8& aImei)
{
#ifdef WHIRLPOOL_SYMBIAN 
    struct NESSIEstruct w;
    u8 digest[DIGESTBYTES];
    NESSIEinit(&w);
    NESSIEadd(aImei.Ptr(), 8*aImei.Length(), &w);
    NESSIEfinalize(&w, digest);    
    for(int  i = 0; i < DIGESTBYTES; i++)
        aWhirlPoolHash.AppendNumFixedWidth(digest[i],EHex, 2);
#endif    
}
コード例 #21
0
ファイル: kdes8.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Copies the content of the source descriptor to the destination descriptor.

If the current thread is a user thread, i.e. the mode in spsr_svc is 'User',
then data is read using user mode privileges .

@param aDest The destination descriptor.
@param aSrc  The source descriptor.

@panic KERN-COMMON 19, if aDest is not a valid descriptor type.
@panic KERN-COMMON 23, if aSrc is longer that the maximum length of aDest.
@panic KERN-EXEC   33, if aSrc is not a valid descriptor type.

@pre Do not call from User thread if in a critical section.
@pre Interrupts must be enabled.
@pre Kernel must be unlocked.
@pre No fast mutex can be held.
@pre Call in a thread context.
@pre Can be used in a device driver.

@post The length of the destination descriptor is equal to the length of the source descriptor.
*/
EXPORT_C void Kern::KUDesGet(TDes8& aDest, const TDesC8& aSrc)
	{
	CHECK_PRECONDITIONS(MASK_NO_CRITICAL_IF_USER|MASK_THREAD_STANDARD,"Kern::KUDesGet");	
//ETDes8BadDescriptorType = 19
//ETDes8Overflow = 23
//EKUDesInfoInvalidType= 33
	TInt ulen, umax;
	TUint8* kptr=(TUint8*)aDest.Ptr();
	const TUint8* uptr=Kern::KUDesInfo(aSrc, ulen, umax);
	aDest.SetLength(ulen);
	kumemget(kptr,uptr,ulen);
	}
コード例 #22
0
ファイル: ymodem.cpp プロジェクト: kuailexs/symbiandump-os1
TInt YModem::ReadPacket(TDes8& aDest)
	{
	TUint8* pD = (TUint8*)aDest.Ptr();
	TInt r;
	TPtr8 d(pD, 0, 1);
	r = ReadBlock(d);
	if (r != KErrNone)
		return r;
	if (d.Length()==0)
		return KErrZeroLengthPacket;
	TUint8 b0 = *pD;
	if (b0==CAN)
		return KErrAbort;
	if (b0==EOT)
		return KErrEof;
	if (b0==SOH)
		iBlockSize=128;
	else if (b0==STX)
		iBlockSize=1024;
	else
		return KErrBadPacketType;
	iTimeout=5000000;
	iPacketSize = iBlockSize+5;
	d.Set(pD+1, 0, iPacketSize-1);
	r = ReadBlock(d);
	if (r!=KErrNone && r!=KErrTimedOut)
		return r;
	if (d.Length() < iPacketSize-1)
		return KErrPacketTooShort;
	TUint8 seq = pD[1];
	TUint8 seqbar = pD[2];
	seqbar^=seq;
	if (seqbar != 0xff)
		return KErrCorruptSequenceNumber;
	if (seq==iSeqNum)
		return KErrAlreadyExists;
	else
		{
		TUint8 nextseq=(TUint8)(iSeqNum+1);
		if (seq!=nextseq)
			return KErrWrongSequenceNumber;
		}
	iCrc=0;
	UpdateCrc(pD+3, iBlockSize);
	aDest.SetLength(iPacketSize);
	TUint16 rx_crc = (TUint16)((pD[iPacketSize-2]<<8) | pD[iPacketSize-1]);
	if (rx_crc != iCrc)
		return KErrBadCrc;
	++iSeqNum;
	return KErrNone;
	}
コード例 #23
0
EXPORT_C void CStreamCipher::Process(const TDesC8& aInput, TDes8& aOutput)
	{
	TInt outputIndex = aOutput.Size();

	// aOutput may already have outputIndex bytes of data in it
	// check there will still be enough space to process the result
	__ASSERT_DEBUG(aOutput.MaxLength() - outputIndex >= MaxOutputLength(aInput.Length()), User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow));

	aOutput.Append(aInput);

	TPtr8 transformBuf((TUint8*)(aOutput.Ptr()) + outputIndex, aInput.Size(),
		aInput.Size());
	DoProcess(transformBuf);
	}
コード例 #24
0
/**
 Private Setter, used by the constructor and the assignment operator
 @param aDes Data buffer to create extended inquiry response from
 */
EXPORT_C void TExtendedInquiryResponseDataCodec::Set(TDes8& aDes)
	{
	LOG_FUNC
	// Check length consistency
	TUint16 length = ComputeSignificantLength(aDes);
	if(length > KNameRecord8BitMaxLength)
		{
		// Reset the EIR and discard any data it may contain, since it was malformed anyway
		iEir.Set(NULL, 0, 0);
		}
	else
		{
		iEir.Set(const_cast<TUint8*>(aDes.Ptr()), length, aDes.MaxLength());
		}
	}
コード例 #25
0
TBool TDebugFunctionality::GetStopModeFunctionality(TDes8& aDFBlock)
{
    TUint32 size = GetStopModeFunctionalityBufSize();
    if (aDFBlock.MaxLength() < size)
    {
        // Insufficient space to contain the debug functionality block
        return EFalse;
    }

    TUint8* ptr = (TUint8*)&size;
    aDFBlock.SetLength(0);
    aDFBlock.Append(ptr, 4);
    TVersion version = TVersion(KStopModeMajorVersionNumber, KStopModeMinorVersionNumber, KStopModePatchVersionNumber);
    ptr = (TUint8*)&version;
    aDFBlock.Append(ptr, sizeof(TVersion));

    AppendBlock((const TSubBlock&)StopModeFunctionalityCore,aDFBlock);
    AppendBlock((const TSubBlock&)StopModeFunctionalityFunctions,aDFBlock);
    AppendBlock((const TSubBlock&)StopModeFunctionalityList,aDFBlock);

    const TTagHeader& header = StopModeFunctionalityBuffers->iHeader;
    aDFBlock.Append((TUint8*)&header, sizeof(TTagHeader));

    for(TInt i=0; i<EBuffersLast; i++)
    {
        TTag tag;
        TheDBufferManager.GetBufferDetails((TBufferType)i, tag);
        aDFBlock.Append((TUint8*)&tag, sizeof(TTag));
    }

    if(aDFBlock.Length() != size - 4)
    {
        return EFalse;
    }

    TUint32* ptr32 = (TUint32*)aDFBlock.Ptr();
    TUint32 checksum = 0;
    for(TInt i=0; i<aDFBlock.Length(); i+=4)
    {
        checksum^=*ptr32;
        ptr32++;
    }

    ptr = (TUint8*)&checksum;
    aDFBlock.Append(ptr, 4);

    return ETrue;
}
コード例 #26
0
ファイル: UM_BUF.CPP プロジェクト: cdaffara/symbiandump-os2
EXPORT_C void TDesBuf::Set(TDes8& aDes,TInt aMode)
/** Sets up the stream to use the specified descriptor.

@param aDes The descriptor that hosts the stream and that also acts as the 
intermediate buffer.
@param aMode The mode in which the buffer is to be used. It can be used in 
either or both read and write modes, represented by ERead and EWrite.
@see TDes8
@see MStreamBuf::TRead
@see MStreamBuf::TWrite */
	{
	iDes=&aDes;
	TUint8* ptr=(TUint8*)aDes.Ptr();
	SetBuf(ERead,(aMode&ERead)?ptr:NULL,ptr+aDes.Length());
	SetBuf(EWrite,(aMode&EWrite)?ptr:NULL,ptr+aDes.MaxLength());
	}
コード例 #27
0
TInt DArmPlatThread::Context(TDes8& aDes)
	{
	TArmRegSet& s=*(TArmRegSet*)aDes.Ptr();
	aDes.SetLength(sizeof(s));
	TInt r=KErrNone;
	if (iThreadType!=EThreadUser || this==TheCurrentThread)
		r=KErrAccessDenied;
	else if (iExiting)
		r=KErrDied;
	else
		{
		TUint32 unused;
		NKern::ThreadGetUserContext(&iNThread,&s,unused);
		}
	return r;
	}
コード例 #28
0
void CMemSpyMemStreamReader::ReadL( TDes8& aDes )
    {
    const TInt length = ReadInt32L();

    // Need to check the remaining text is actually present...
    IsAvailableL( length );

    // Now read into client descriptor
    aDes.SetLength( length );
    if  ( length > 0 ) 
        {
        TUint8* dest = const_cast< TUint8* >( aDes.Ptr() );
        Mem::Copy( dest, iCurrent, length );
        }
    //
    IncrementPos( length );
    }
コード例 #29
0
TInt CNifPDPContextTNif::HandlePDPDelete(TDes8& aConfig)
	{
	// Get the Activation Duration.
	TInt deleteDuration;

	const CTestConfigItem* item = CfgFile()->Item(KContextDeleteEntry);
	TInt err=CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, deleteDuration);		// The 3rd parameter (3) represents the index of the variable on the config file line
	if (err!=KErrNone)
		deleteDuration=KDefaultDeletionTime;
//leteDuration=KDefaultDeletionTime;
	// Start Timer to delete the PDP context.
	TimerCancel();
	TimerAfter(deleteDuration*1000);
	// Update the return data.
	TContextParameters& opt = *(TContextParameters*)aConfig.Ptr();
	opt.iReasonCode = KErrNone;				// we need to set this to success IDO
	// Update the local data copy.	
	iParameter.iReasonCode = KErrNone;
	return KErrNone;
	};
コード例 #30
0
ファイル: MSCHAP.CPP プロジェクト: cdaffara/symbiandump-os2
inline void CPppMsChap::MakeDesKey(const TDesC8& aMsChapKey, 
				TDes8& aDesKey)
/**
   Creates a DES key by inserting the parity bits.  The DES algorithm
   takes as input a 64-bit stream where the 8th, 16th, 24th, etc. bits
   are parity bits ignored by the encrypting algorithm.
   @param aMsChapKey [in] A key used by MS-CHAP for DES encryption. (7
   octets).
   @param aDesKey [out] A DES key (8 octets).
   @internalComponent
*/
	{
	ASSERT(aMsChapKey.Length() == KPppMsChapDESKeySize);
	ASSERT(aDesKey.Length() == KPppDESKeySize);

// RFC 2433, RFC 2759: "Use the DES encryption algorithm [4] in ECB
// mode [10] to encrypt Clear into Cypher such that Cypher can only be
// decrypted back to Clear by providing Key.  Note that the DES
// algorithm takes as input a 64-bit stream where the 8th, 16th, 24th,
// etc.  bits are parity bits ignored by the encrypting algorithm.
// Unless you write your own DES to accept 56-bit input without
// parity, you will need to insert the parity bits yourself."

	TUint8* pdk = const_cast<TUint8*>(aDesKey.Ptr());
	const TUint8* pmk = aMsChapKey.Ptr();
	TUint16 high, low;
	TUint8 i = 0;
    do
		{
		high = *(pmk + i/8);
		low = *(pmk + i/8 + 1);
		*(pdk + i/7) = static_cast<TUint8>(
			((high << 8 | low) >> (8 - i%8)) & 0xfe);
		i += 7;
		}
	while (i < 49);

	*(pdk + 7) = static_cast<TUint8>(*(pmk + 6) << 1 & 0xfe);

	ASSERT(aDesKey.Length() == KPppDESKeySize);
	}