Esempio n. 1
0
/*
 * Timers documentation:
 * http://www.x.org/releases/X11R7.7/doc/xorg-server/Xserver-spec.html#id2536042
 *
 * This function indirectly may call itself recursively using timer to guarantee correct
 * event delivery time. Ususally recursion ends after first recursive call.
 */
static CARD32 check_resolve_delayed(OsTimerPtr timer, CARD32 time, void *arg){
	LocalDevicePtr local = arg;
	struct MTouch *mt = local->private;
	mstime_t delta_millis;
	struct timeval delta;

	// If it was to early to trigger delayed button, next timer will be set,
	// but when called by timer such situation shouldn't take place.
	switch (mtouch_delayed(mt)){
	case 1:
		if(mt->is_timer_installed != 1){
			TimerCancel(mt->timer);
			mt->is_timer_installed = 1;
			timersub(&mt->gs.button_delayed_time, &mt->gs.time, &delta);
			delta_millis = timertoms(&delta);
			mt->timer = TimerSet(mt->timer, 0, delta_millis, check_resolve_delayed, local);
		}
		break;
	case 2:
		TimerCancel(mt->timer);
		mt->is_timer_installed = 0;
		handle_gestures(local, &mt->gs);
		break;
	case 3:
		TimerCancel(mt->timer);
		handle_gestures(local, &mt->gs);
		mt->is_timer_installed = 2;

		/* Install coasting timer */
		coasting_delayed(mt->timer, -1, arg);
		break;
	case 0: break;
	}
	return 0;
}
Esempio n. 2
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;
	};
Esempio n. 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;
	};
Esempio n. 4
0
void TimerFree(TimerPtr timer)
{
	if (!timer)
		return;
	TimerCancel(timer);
	free(timer);
}
Esempio n. 5
0
void CPppChap::SuccessL(RMBufPacket& aPacket)
/**
   Processes a CHAP Success packet and takes action to complete the
   authentication.
   @param aPacket [in] The CHAP Success packet to be processed.
   @internalComponent
*/
	{
	__ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
					KPppChapIdFieldSize + 
					KPppChapLengthFieldSize,
			User::Leave(KErrUnderflow));

// check the id
	if (!CheckIdentifier(aPacket))
		User::Leave(KErrGeneral);

	TimerCancel();
	DoSucceed();
	if (iPppLcp->CallbackEnabled() &&
		iPppLcp->CallbackRequestType() !=
			ECallbackIETFRequestTypeMSCBCP)
		{
		iPppLcp->CallbackGrantedAndAuthenticated();
		iPppLcp->TerminateLink(MNifIfNotify::ECallBack);
		}
	}
Esempio n. 6
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;
	};
Esempio n. 7
0
void CPppChap::LowerLayerDown(TInt /*aStatus*/)
/**
   @copydoc MPppRecvr::LowerLayerDown(TInt)
   @see MPppRecvr::LowerLayerDown(TInt)
   @internalComponent
*/
	{
	ASSERT(iPppLcp != 0);
	TimerCancel();
	}
Esempio n. 8
0
int parse_cmd(char *buf, size_t len, int fd)
{
	char *p, *q, *end;
	int ret = 0;

	p = buf;
	end = buf + len;
	while (p != end) {
		/* skip blank line */
		while (*p == '\r' || *p == '\n') p++;
		q = p;
		while ((*q != '\r') && (q != end)) q++;

		if (q != end) {
			/* get a line */
			*q = 0;
			if (strcmp(p, "LO") == 0) {
				write(fd, "LO\r\n", 4);
				TimerCancel(simpleTimer);
			} else if (strcmp(p, "LF") == 0) {
				write(fd, "LF\r\n", 4);
				TimerCancel(simpleTimer);
			} else if (strcmp(p, "DX") == 0) {
				simpleTimer = TimerSet(simpleTimer, 0, 50, GenerateSimpleData, (void *)fd);
			} else {
				write(fd, "E404\r\n", 6);
				TimerCancel(simpleTimer);
			}
			*q = '\r';
		} else {
			ret = q - q;
			break;
		}
		p = q;
	}
	return ret;
}
static void
SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
    NewClientInfoRec *pci = calldata;
    SecurityStateRec *state;
    SecurityAuthorizationPtr pAuth;
    int rc;

    state = dixLookupPrivate(&pci->client->devPrivates, stateKey);

    switch (pci->client->clientState) {
    case ClientStateInitial:
	state->trustLevel = XSecurityClientTrusted;
	state->authId = None;
	state->haveState = TRUE;
	break;

    case ClientStateRunning:
	state->authId = AuthorizationIDOfClient(pci->client);
	rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
			       SecurityAuthorizationResType, serverClient,
			       DixGetAttrAccess);
	if (rc == Success) {
	    /* it is a generated authorization */
	    pAuth->refcnt++;
	    if (pAuth->refcnt == 1 && pAuth->timer)
		TimerCancel(pAuth->timer);

	    state->trustLevel = pAuth->trustLevel;
	}
	break;

    case ClientStateGone:
    case ClientStateRetained:
	rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
			       SecurityAuthorizationResType, serverClient,
			       DixGetAttrAccess);
	if (rc == Success) {
	    /* it is a generated authorization */
	    pAuth->refcnt--;
	    if (pAuth->refcnt == 0)
		SecurityStartAuthorizationTimer(pAuth);
	}
	break;

    default:
	break;
    }
}
Esempio n. 10
0
void CPppChap::ChallengeL(RMBufPacket& aPacket)
/**
   Processes a CHAP Challenge packet and attempts to respond to the
   challenge.
   @param aPacket [in] The CHAP Challenge packet to be processed.
   @internalComponent
*/
	{
	TimerCancel();
	ProcessChallengePacketL(aPacket);

	if (IsAuthenticateRequestDone())
		{
		iResponseRetryCount = 0;
		RespondL();
		}
	}
Esempio n. 11
0
void CPppChap::FailureL(RMBufPacket& aPacket)
/**
   Processes a CHAP Failure packet and takes action to handle the
   authentication failure.
   @param aPacket [in] The CHAP Failure packet to be processed.
   @internalComponent
*/
	{
	__ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
					KPppChapIdFieldSize + 
					KPppChapLengthFieldSize,
			User::Leave(KErrUnderflow));

// check the id
	if (!CheckIdentifier(aPacket))
		User::Leave(KErrGeneral);

	TimerCancel();
	DoFail(KErrIfAuthenticationFailure);
	}
Esempio n. 12
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;
	};
Esempio n. 13
0
static CARD32 coasting_delayed(OsTimerPtr timer, CARD32 time, void *arg){
  LocalDevicePtr local = arg;
	struct MTouch *mt = local->private;

#if DEBUG_DRIVER
	xf86Msg(X_INFO, "coasting_delayed: speed_x=%f, speed_y=%f, dir=%i\n", mt->gs.scroll_speed_x, mt->gs.scroll_speed_y, mt->gs.move_dir);
#endif
	set_and_post_mask(mt, local->dev, mt->cfg.scroll_coast.tick_ms);

	if (mt->gs.scroll_coast_tick_no >= mt->cfg.scroll_coast.num_of_ticks){
		mt->gs.scroll_speed_x = mt->gs.scroll_speed_y = 0.0;
		mt->is_timer_installed = 0;
		TimerCancel(mt->timer);
		return 0;
	}

	++mt->gs.scroll_coast_tick_no;
	TimerSet(mt->timer, 0, mt->cfg.scroll_coast.tick_ms, coasting_delayed, local);
	mt->is_timer_installed = 2;

	return 0;
}
Esempio n. 14
0
void CPppMsChap2::SuccessL(RMBufPacket& aPacket)
/**
   @copydoc CPppChap::SuccessL(RMBufPacket&)
   @see CPppChap::SuccessL(RMBufPacket&)
   @internalComponent
*/
{
    __ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
                    KPppChapIdFieldSize +
                    KPppChapLengthFieldSize +
                    KPppMsChap2AuthenticatorResponseSize,
                    User::Leave(KErrUnderflow));

// check the id
    if (!CheckIdentifier(aPacket))
        User::Leave(KErrGeneral);

// no more retries
    TimerCancel();

    // Read the length of the MS-CHAP-V2 Failure packet and compute
    // the length of the CHAP Message field and go past the CHAP Code
    // field, the CHAP Identifier field and the CHAP Length field, in
    // order to read the CHAP Message field.

    TPtrC8 authResponse(aPacket.First()->Ptr() +
                        KPppChapCodeFieldSize +
                        KPppChapIdFieldSize +
                        KPppChapLengthFieldSize,
                        KPppMsChap2AuthenticatorResponseSize);

// 	TPtrC8 message(ptr + KPppChapCodeFieldSize + KPppChapIdFieldSize + KPppChapLengthFieldSize + KPppMsChap2AuthenticatorResponseSize + 3, BigEndian::Get16(ptr + KPppChapCodeFieldSize + KPppChapIdFieldSize) - KPppChapCodeFieldSize - KPppChapIdFieldSize - KPppChapLengthFieldSize - KPppMsChap2AuthenticatorResponseSize - 3);

    if (authResponse!=iAuthenticatorResponse)
        DoFail(KErrIfAuthenticationFailure);
    else
        DoSucceed();
}
Esempio n. 15
0
void CPppMsChap::FailureL(RMBufPacket& aPacket)
/**
   @copydoc CPppChap::FailureL(RMBufPacket&)
   @see CPppChap::FailureL(RMBufPacket&)
   @internalComponent
*/
	{
	__ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
					KPppChapIdFieldSize + 
					KPppChapLengthFieldSize ,
			User::Leave(KErrUnderflow));
	if (!CheckIdentifier(aPacket))
		User::Leave(KErrGeneral);

	TimerCancel();

	TPtrC8 failureMessage(aPacket.First()->Ptr() +
					KPppChapCodeFieldSize + 
					KPppChapIdFieldSize +
					KPppChapLengthFieldSize, 
				aPacket.Length() -
					KPppChapCodeFieldSize - 
					KPppChapIdFieldSize -
					KPppChapLengthFieldSize);

	if (failureMessage.Length()==0)
		{
		DoFail(KErrIfAuthenticationFailure);
		return;
		}

	TUint msChapError;
	TUint8 isRetryAllowed;
	TUint8 passwordProtoVersion;
	TBool hasNewChallenge;
	TInt sysError = KErrIfAuthenticationFailure;

	ProcessFailureMessageL(failureMessage, 
				msChapError,
				isRetryAllowed, 
				hasNewChallenge, 
				iChallengeRef,
				passwordProtoVersion);

	sysError = TranslateMsChapError(msChapError);

#ifndef __MS_CHAP_WITH_LAN_MANAGER__

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.

	DoFail(sysError);

#else // __MS_CHAP_WITH_LAN_MANAGER__

// The code only handles KPppMsChapAuthenticationFailure, and no other
// MS-CHAP specific errors.  In particular, this code does not handle
// KPppMsChapErrorPasswordExpired, since the password changing
// mechanisms have not been implemented in this release - this is in
// accordance with the project requirements.
	if (msChapError != KPppMsChapAuthenticationFailure)
		{
		DoFail(sysError);
		return;
		}

	if (!isRetryAllowed)
		{
		DoFail(sysError);
		return;
		}

	if (!hasNewChallenge)
		iChallengeRef[0] += 23; // magic constant from RFC 2433


	if(!iUseNTResponse)
		{
// Has already retried authentication using a LAN Manager compatible
// Challenge Response.  Have tried Microsoft Windows NT compatible
// Challenge Response and LAN Manager compatible Challenge Response,
// so fail now
		iUseNTResponse = ETrue;
		DoFail(sysError);
		return;
		}

// Retry authentication using a LAN Manager compatible Challenge
// Response.
	iUseNTResponse = EFalse;

	RetryPasswordL();

#endif //  __MS_CHAP_WITH_LAN_MANAGER__
	}
Esempio n. 16
0
void CPppMsChap2::FailureL(RMBufPacket& aPacket)
/**
   @copydoc CPppChap::FailureL(RMBufPacket&)
   @see CPppChap::FailureL(RMBufPacket&)
   @internalComponent
*/
{
    __ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
                    KPppChapIdFieldSize +
                    KPppChapLengthFieldSize +
                    KPppMsChap2AuthenticatorChallengeSize*2
                    + 2,
                    User::Leave(KErrUnderflow));

// check the id
    if (!CheckIdentifier(aPacket))
        User::Leave(KErrGeneral);

    TimerCancel();

#ifndef _DEBUG

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.

    DoFail(KErrIfAuthenticationFailure);

#else // _DEBUG

// Read the length of the MS-CHAP-V2 Failure packet and compute the
// length of the CHAP Message field and go past the CHAP Code field,
// the CHAP Identifier field and the CHAP Length field, in order to
// read the CHAP Message field
    TPtrC8 failureMessage(aPacket.First()->Ptr() +
                          KPppChapCodeFieldSize +
                          KPppChapIdFieldSize +
                          KPppChapLengthFieldSize,
                          aPacket.Length() -
                          KPppChapCodeFieldSize -
                          KPppChapIdFieldSize -
                          KPppChapLengthFieldSize);

    if (failureMessage.Length()==0)
    {
        DoFail(KErrIfAuthenticationFailure);
        return;
    }

    TUint msChapError;
    TUint8 isRetryAllowed;
    TUint8 passwordProtoVersion;
    TPtrC8 message;
    TInt sysError=KErrIfAuthenticationFailure;

    ProcessFailureMessageL(failureMessage,
                           msChapError,
                           isRetryAllowed,
                           iChallengeRef,
                           passwordProtoVersion,
                           message);

    sysError=TranslateMsChapError(msChapError);

// The code only handles KPppMsChapAuthenticationFailure, and no other
// MS-CHAP specific errors.  In particular, this code does not handle
// KPppMsChapErrorPasswordExpired, since the password changing
// mechanisms have not been implemented in this release - this is in
// accordance with the project requirements.
    if (msChapError != KPppMsChapAuthenticationFailure)
    {
        DoFail(sysError);
        return;
    }

    if (!isRetryAllowed)
    {
        DoFail(sysError);
        return;
    }

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.
    DoFail(sysError);

#endif // _DEBUG
}
Esempio n. 17
0
void CNifPDPContextTNif::DoCancel()
	{
	TimerCancel();
	};
Esempio n. 18
0
TInt CNifPDPContextTNif::HandleTFTModify(TDes8& aConfig)
	{
	// Get the Activation Duration.
	RPacketContext::TPacketFilterV2 iFilter;

	TInt tftmodify;
	const CTestConfigItem* item = CfgFile()->Item(KContextTFTModifyEntry);
	TInt err=CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, tftmodify);		// The 3rd parameter (3) represents the index of the variable on the config file line
	if (err!=KErrNone)
		tftmodify=KDefaultTFTModifyTime;

	// Start Timer to modfidy activation
	TimerCancel();
	TimerAfter(tftmodify*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 = opt;
	iParameter.iReasonCode = KErrNone;
	iParameter.iTFTOperationCode = opt.iTFTOperationCode;
	/**
	The individual operations will be performed according to the 
	operation code provided
	*/
	TTFTInfo aTFT,bTFT;
	if (iParameter.iTFTOperationCode == KAddFilters) 
		{
		iParameter.iContextConfig.GetTFTInfo(aTFT);

		opt.iContextConfig.GetTFTInfo(bTFT);
		bTFT.SetToFirst();
		bTFT.NextPacketFilter(iFilter);
		aTFT.AddPacketFilter(iFilter);
		iParameter.iContextConfig.SetTFTInfo(aTFT);	
		// update the Result
		opt.iReasonCode = KErrNone;
		iParameter.iReasonCode = KErrNone; 
		}
	else if (iParameter.iTFTOperationCode == KRemoveFilters) 
		{
		iParameter.iContextConfig.GetTFTInfo(aTFT);

		opt.iContextConfig.GetTFTInfo(bTFT);
		bTFT.SetToFirst();
		bTFT.NextPacketFilter(iFilter);
		aTFT.RemovePacketFilter(iFilter);
		iParameter.iContextConfig.SetTFTInfo(aTFT);	
		// update the Result
		opt.iReasonCode = KErrNone;
		iParameter.iReasonCode = KErrNone;
		}
	else if (iParameter.iTFTOperationCode == KAddSblpParameter)
		{
		
		iParameter.iContextConfig.GetTFTInfo(aTFT);

		opt.iContextConfig.GetTFTInfo(bTFT);
		bTFT.SetToFirst();
		bTFT.NextPacketFilter(iFilter);
		aTFT.AddPacketFilter(iFilter);
		/**
		These addition is for handling SBLP Parameters inside the TFT as per the 
		requirements of PREQ634.
		Currently only one SblpParameters ( consisting of one MAT and multiple associated
		Flow Identifires ). Later when R6 will be implemented this code needs to change to
		support the Multiple SBLP Parameter. However the infrastructure of Multiple SBLP is 
		already in place as iSblpParams uses RPointerArray
		*/
		RPacketContext::CTFTMediaAuthorizationV3 * aMAT = 	RPacketContext::CTFTMediaAuthorizationV3::NewL();
		/**
		Store it in RPointerArray to get it cleaned which destructing
		*/
		iSblpParams.AppendL(aMAT);
		/**
		Get the SBLP Parameters
		*/ 
		bTFT.GetSblpToken(*aMAT);
		/**
		Add SBLP Parameters to bTft; 		
		*/
		aTFT.AddSblpToken(iSblpParams[0]->iAuthorizationToken,iSblpParams[0]->iFlowIds);	
		iParameter.iContextConfig.SetTFTInfo(aTFT);	
		// update the Result
		opt.iReasonCode = KErrNone;
		iParameter.iReasonCode = KErrNone;
		
				
		//checking the values against PDPContext.txt and return result accordingly
		// Initialise the section in configuration file.
		TBuf8<KMaxName>		iSectionName1;   // SBLP section names
		
		TBool matFound = ETrue;
		TBool validToken = ETrue;
     	for (TInt sblpContextId = 0; matFound; sblpContextId++)
       	{
			
			iSectionName1.Format(KSBLPSectionNameFormat, sblpContextId);
			if(iNif->CfgFile()->Section(iSectionName1)==NULL)
			{
				matFound = EFalse;
				break;	
			}
			validToken = ETrue;
       		//comparing Authorisation token, if doesnt match exit
			TInt numberOfFlowIdsReceived = iSblpParams[0]->iFlowIds.Count();			
			
			const CTestConfigSection* sblpCfgSection = iNif->CfgFile()->Section(iSectionName1);
			const TDesC8& authorizationToken=sblpCfgSection->ItemValue(KAuthorizationToken,KDefaultAuthorizationToken);	
			if(authorizationToken.Compare(iSblpParams[0]->iAuthorizationToken) != 0)
				{
				LOG(_LIT(string1,"Media Authorisation does not match\n"));
				LOG(PdpLog::Printf(string1);)
				validToken = EFalse;
				}