# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1268985228 -7200 # Node ID 0089b2f7ebd8a1cd3cd2602fdd1491c07253089b # Parent 28479eeba3fb363561c5811b1248298c176417e7 Revision: 201001 Kit: 201011 diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btexample/test/cit/ROMConfig/src/cteststepbtromconfigremcon002.cpp --- a/bluetooth/btexample/test/cit/ROMConfig/src/cteststepbtromconfigremcon002.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btexample/test/cit/ROMConfig/src/cteststepbtromconfigremcon002.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -66,7 +66,7 @@ if ( err!=expectedError ) { INFO_PRINTF4(\ - _L("Failed: Expected KErrNotFound (%d) and got %d when calling CRemConInterfaceSelector::OpenTargetL"),\ + _L("Failed: Expected %S(%d) and got %d when calling CRemConInterfaceSelector::OpenTargetL"),\ expectedErrorDesPtr, expectedError, err); SetTestStepResult(EFail); } diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btlogger/btsnoophcilogger/public/hciframelogger.h --- a/bluetooth/btlogger/btsnoophcilogger/public/hciframelogger.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btlogger/btsnoophcilogger/public/hciframelogger.h Fri Mar 19 09:53:48 2010 +0200 @@ -35,6 +35,9 @@ static const TUint KHCILoggerACLDataFrame = 0; // For future use if required static const TUint KHCILoggerSynchronousDataFrame = 0; // For future use if required +//KHCILoggerGenericDataFrame can be used instead of the above two flags as BTSnoop logger does not +//differencaite between the different types of data frames +static const TUint KHCILoggerGenericDataFrame = 0; static const TUint KHCILoggerCommandOrEvent = 0x00000002; static const TUint KHCILoggerFrameFragmented = 0x80000000; diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/avdtp/avdtpStreamStates.cpp --- a/bluetooth/btstack/avdtp/avdtpStreamStates.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/avdtp/avdtpStreamStates.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -909,13 +909,17 @@ // now we kick TCs into life if (aResult) { - // can return to Idle, user could try this operation again - // the way Open works means we have transport sessions interested in result of this - // they need to tell their sockets that their connects failed - - ChangeState(aStream, CAVStreamStateFactory::EStreamStateIdle); - - // no need to tell signalling session as Opening is not available to RGavdp + // late reply or connection problem, abort + + CSignallingChannel* sigch = aStream.iProtocol.FindSignallingChannel(aStream.iRemoteAddress.BTAddr()); + // should always have sigch here + __ASSERT_DEBUG(sigch, PanicInState(EAvdtpSignallingChannelShouldExist)); + if (sigch) + { + sigch->SendAbort(aStream, aStream.RemoteSEID()); + } + + // no need to tell signalling session as Opening is not available to RGavdp // Opening is performed when the necessary sockets are created and connected in a stream aStream.NotifyUserPlaneTransportSessionsError(NULL, aResult); } diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp --- a/bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -53,6 +53,26 @@ // Just send what we've got in Preferred. } +void TModeSpecificFecOptionHandlerBase::BuildRequestBasedOnUnacceptableParamsResponse( + TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const + { + LOG_FUNC + // In general the only negotiable parameter is channel mode - that's what we should + // take from the suggested response passed here in aPeer. The rest of the parameters are + // informative and we should use our own values, based on the mode - the remote can not + // reject informative parameters. + // Note on interop: + // Unfortunately <= 9.4 Symbian code _WILL_ reject if e.g. we send a MaxTransmit value + // which is greater than its own preference. To interoperate with those this method is + // overridden in the Legacy handler. + + aPreferred = TRetransmissionAndFlowControlOption(aPeer.LinkMode(), ETrue); + SetMaxTransmit(aPreferred, aFecNegotiator.MaxTransmit()); + ZeroUnspecifiedRequestFields(aPreferred); + } + void TModeSpecificFecOptionHandlerBase::SetMaxTransmit(TRetransmissionAndFlowControlOption& aFecOption, TUint8 /*aMaxTransmit*/) const { LOG_FUNC @@ -250,6 +270,47 @@ aMaxTransmit); } +void TLegacyFecHandler::BuildRequestBasedOnUnacceptableParamsResponse( + TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const + { + LOG_FUNC + // In general the only negotiable parameter is channel mode - that's what we should + // take from the suggested response passed here in aPeer. The rest of the parameters are + // informative and we should use our own values, based on the mode - the remote can not + // reject informative parameters. + // + // HOWEVER: + // + // Unfortunately <= 9.4 Symbian code _WILL_ reject if e.g. we send a MaxTransmit value + // which is greater than its own preference. To interoperate with those we take + // the whole FEC option suggested by the remote, including the informational parameters. + // <= 9.4 Symbian devices implement RTM and FC modes (and not ERTM and Streaming). + // Additionally, pretty much noone else in the market does - most people jumped from + // Basic straight to ERTM & Streaming. So it can be assumed that: + // Legacy (RTM & FC) ~= pre-ERTM Symbian. + + typedef TRetransmissionAndFlowControlOption TFec; // just 'coz I'm lazy + + // Use the remote's whole suggestion if all informational parameters look edible ... + if (aPeer.TxWindowSize() >= TFec::KMinValidTxWindowSize && + aPeer.MaxTransmit() >= TFec::KMinValidNumberTransmit && + aPeer.RetransmissionTimeout() >= TFec::KMinAcceptableRetransmissionTimeout && + aPeer.MonitorTimeout() >= TFec::KMinAcceptableMonitorTimeout && + aPeer.MaximumPDUSize() >= TFec::KMinValidMaximumPDUSize) + { + aPreferred = aPeer; + } + else // ... otherwise only use channel mode to prevent DoS attacks. + { + aPreferred = TRetransmissionAndFlowControlOption(aPeer.LinkMode(), ETrue); + SetMaxTransmit(aPreferred, aFecNegotiator.MaxTransmit()); + ZeroUnspecifiedRequestFields(aPreferred); + } + } + + // Basic mode TBool TBasicFecHandler::IsOptionValid(const TRetransmissionAndFlowControlOption& /*aFecOption*/) const @@ -476,9 +537,9 @@ if (aIsUnacceptableParameters) { iConfigStatus = EOptionConfigOutstanding; - // Only take the channel mode from peer's proposal and set informational - // (i.e. all other) parameters to our values. - BuildRequest(aFecOption.LinkMode(), iPreferred); + // Build a new request based on suggestion sent by the peer. + iFecNegotiator.ModeSpecificHandlers().BuildRequestBasedOnUnacceptableParamsResponse( + iPreferred, iPeer, iFecNegotiator); } else { diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/l2cap/L2CapFecNegotiator.h --- a/bluetooth/btstack/l2cap/L2CapFecNegotiator.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/l2cap/L2CapFecNegotiator.h Fri Mar 19 09:53:48 2010 +0200 @@ -46,6 +46,12 @@ const TRetransmissionAndFlowControlOption& aPeer) const; virtual void BuildNegativeResponse(TRetransmissionAndFlowControlOption& aPreferred, const TRetransmissionAndFlowControlOption& aPeer) const; + + virtual void BuildRequestBasedOnUnacceptableParamsResponse( + TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const; + // In general configuration procedure (spec chapter 7 General Procedures) if the remote accepts // an option from our ConfigReq, it doesn't have to include it in the response. So before // processing the options from a ConfigRsp we've received, we go through the preferred values @@ -104,6 +110,11 @@ virtual TBool IsOptionValid(const TRetransmissionAndFlowControlOption& aFecOption) const; virtual TBool IsPeerResponseAcceptable(const TRetransmissionAndFlowControlOption& aPreferred, const TRetransmissionAndFlowControlOption& aPeer) const; + virtual void BuildRequestBasedOnUnacceptableParamsResponse( + TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const; + virtual void SetMaxTransmit(TRetransmissionAndFlowControlOption& aFecOption, TUint8 aMaxTransmit) const; }; @@ -132,6 +143,9 @@ const TRetransmissionAndFlowControlOption& aPeer) const; inline void BuildNegativeResponse(TRetransmissionAndFlowControlOption& aPreferred, const TRetransmissionAndFlowControlOption& aPeer) const; + inline void BuildRequestBasedOnUnacceptableParamsResponse(TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const; inline void PrepareImplicitPeerResponse(TRetransmissionAndFlowControlOption& aImplicitResponse, const TRetransmissionAndFlowControlOption& aPreferred) const; inline void SetMaxTransmit(TRetransmissionAndFlowControlOption& aFecOption, TUint8 aMaxTransmit) const; diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/l2cap/L2CapFecNegotiator.inl --- a/bluetooth/btstack/l2cap/L2CapFecNegotiator.inl Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/l2cap/L2CapFecNegotiator.inl Fri Mar 19 09:53:48 2010 +0200 @@ -72,6 +72,19 @@ Handler(aPreferred).BuildNegativeResponse(aPreferred, aPeer); } +inline void +TFecOptionHandlerDelegator::BuildRequestBasedOnUnacceptableParamsResponse( + TRetransmissionAndFlowControlOption& aPreferred, + const TRetransmissionAndFlowControlOption& aPeer, + const TL2CapFecNegotiator& aFecNegotiator) const + { +#ifdef __FLOG_ACTIVE + LogCurrentValues(aPreferred, aPeer); +#endif + // Response has suggested mode, dispatch on that. + Handler(aPeer).BuildRequestBasedOnUnacceptableParamsResponse(aPreferred, aPeer, aFecNegotiator); + } + inline void TFecOptionHandlerDelegator::PrepareImplicitPeerResponse(TRetransmissionAndFlowControlOption& aImplicitResponse, const TRetransmissionAndFlowControlOption& aPreferred) const { diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/l2cap/l2sap.cpp --- a/bluetooth/btstack/l2cap/l2sap.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/l2cap/l2sap.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -141,6 +141,8 @@ clone->SetState(iState->iFactory.GetState(CL2CAPSAPStateFactory::EPassiveLinkPending)); clone->SetListeningSAP(*this); + clone->SetCodServiceBits(iCodServiceBits); + // Copy the details required for security. clone->iSecurity = iSecurity; clone->iRemoteDev = aAddr; diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/l2cap/l2sapstates.cpp --- a/bluetooth/btstack/l2cap/l2sapstates.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/l2cap/l2sapstates.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -880,9 +880,11 @@ } // State Transition Actions. -void TL2CAPSAPStateAccepting::Exit(CL2CAPConnectionSAP& /*aSAP*/) const +void TL2CAPSAPStateAccepting::Exit(CL2CAPConnectionSAP& aSAP) const { LOG_FUNC + + aSAP.RegisterCodService(); } /*************************************************************************/ diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/linkmgr/ACLSAP.cpp --- a/bluetooth/btstack/linkmgr/ACLSAP.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/linkmgr/ACLSAP.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -60,6 +60,7 @@ iStates[EOpen] =new (ELeave) TACLLinkStateOpen(*this); iStates[EOpenParked] =new (ELeave) TACLLinkStateOpenParked(*this); iStates[EClosing] =new (ELeave) TACLLinkStateClosing(*this); + iStates[EAcceptingClosing] =new (ELeave) TACLLinkStateAcceptingClosing(*this); } CACLLinkStateFactory::~CACLLinkStateFactory() @@ -432,7 +433,7 @@ { LOG_FUNC // we're not wanted - close - ChangeState(aContext, CACLLinkStateFactory::EClosing); + ChangeState(aContext, CACLLinkStateFactory::EAcceptingClosing); } //---------------------------------------------------------------------------------- @@ -497,7 +498,7 @@ { LOG_FUNC // just go - ChangeState(aContext, CACLLinkStateFactory::EClosing); + ChangeState(aContext, CACLLinkStateFactory::EAcceptingClosing); } //---------------------------------------------------------------------------------- @@ -869,6 +870,38 @@ //---------------------------------------------------------------------------------- +TACLLinkStateAcceptingClosing::TACLLinkStateAcceptingClosing(CACLLinkStateFactory& aFactory) +: TACLLinkState(aFactory) + { + LOG_FUNC + STATENAME("AcceptingClosing"); + } + +void TACLLinkStateAcceptingClosing::Shutdown(CACLLink& /*aContext*/, CServProviderBase::TCloseType /*aCloseType*/) const + { + LOG_FUNC + // we are! just ignore and continue + } + +void TACLLinkStateAcceptingClosing::Deletion(CACLLink& aContext) const + { + LOG_FUNC + aContext.ListeningSAP()->RemoveChild(&aContext); + } + +void TACLLinkStateAcceptingClosing::Error(CACLLink& aContext, TInt /*aError*/) const + { + LOG_FUNC + // This method is reached by receiving a Disconnection Complete Event with Status field != EOk, + // in this case we don't want to error the socket - so instead it is just closed + aContext.ListeningSAP()->RemoveChild(&aContext); + ChangeState(aContext, CACLLinkStateFactory::EClosed); + aContext.Socket()->CanClose(); + } + + +//---------------------------------------------------------------------------------- + TACLLinkStateClosed::TACLLinkStateClosed(CACLLinkStateFactory& aFactory) : TACLLinkState(aFactory) { diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/linkmgr/ACLSAP.h --- a/bluetooth/btstack/linkmgr/ACLSAP.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/linkmgr/ACLSAP.h Fri Mar 19 09:53:48 2010 +0200 @@ -57,6 +57,7 @@ EOpen, EOpenParked, EClosing, + EAcceptingClosing, // *** keep next one last *** EACLLinkMaxState, }; @@ -229,6 +230,18 @@ void Error(CACLLink& aContext, TInt aError) const; }; +NONSHARABLE_CLASS(TACLLinkStateAcceptingClosing) : public TACLLinkState + { +public: + TACLLinkStateAcceptingClosing(CACLLinkStateFactory& aFactory); + + void Shutdown(CACLLink& aContext, CServProviderBase::TCloseType aCloseType) const; + void Deletion(CACLLink& aContext) const; + + void Error(CACLLink& aContext, TInt aError) const; + }; + + NONSHARABLE_CLASS(TACLLinkStateClosed) : public TACLLinkState { public: diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/linkmgr/physicallinks.cpp --- a/bluetooth/btstack/linkmgr/physicallinks.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/linkmgr/physicallinks.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -1038,6 +1038,28 @@ NotifyStateChange(event); } + if (iACLLogicalLinks.Count() == 0) + { + // We don't already have an ACL logical link associated with this phy, + // so, in order to not miss ACL data from the remote, associate this + // phy with an ACL listener if there is one. + TLogicalLinkListener* listener = iLinksMan.FindListener(EACLLink); + + if (listener) + { + TBTConnect conn; + + conn.iBdaddr = iDevice.Address(); + conn.iCoD = iDevice.DeviceClass().DeviceClass(); + conn.iLinkType = EACLLink; + + // Ignore the return from ConnectRequest, if not accepted then we are in no + // worse situation than if we didn't try. + ASSERT_DEBUG(listener->iObserver); + (void)listener->iObserver->ConnectRequest(conn, *this); + } + } + // tell the logical links NotifyLogicalLinkUp(aConn); iLinksMan.ArbitrateAllPhysicalLinks(); @@ -1533,15 +1555,15 @@ if(pairingState == CBTPairingsCache::EDeferred) { // We're still waiting for the Pairing Caches paired device list to be filled. - // We'll respond when this is complete, so store details away for then. + // We'll respond when this is complete, so store details away for then. LOG(_L("CPhysicalLink: Waiting for physical link manager's paired device list from Registry!")) iPendingConnection = ETrue; - iLastPendingConnection.iConnH = aConn.iConnH; - iLastPendingConnection.iBdaddr = aConn.iBdaddr; - iLastPendingConnection.iCoD = aConn.iCoD; - iLastPendingConnection.iLinkType = aConn.iLinkType; - iLastPendingConnection.iEncryptMode = aConn.iEncryptMode; - // Return now as we are waiting and don't want to 'RejectConnection' + iLastPendingConnection.iConnH = aConn.iConnH; + iLastPendingConnection.iBdaddr = aConn.iBdaddr; + iLastPendingConnection.iCoD = aConn.iCoD; + iLastPendingConnection.iLinkType = aConn.iLinkType; + iLastPendingConnection.iEncryptMode = aConn.iEncryptMode; + // Return now as we are waiting and don't want to 'RejectConnection' return; } @@ -1699,7 +1721,7 @@ return KErrArgument; } aOption = TPtrC8(reinterpret_cast(&iSniffInterval), sizeof(TBasebandTime)); - return KErrNone; + return KErrNone; default: return KErrNotSupported; @@ -1720,26 +1742,26 @@ if ( aImmediately ) { iArbitrationDelay->Cancel(); - return DoArbitrate(aLocalPriority); + return DoArbitrate(aLocalPriority); } else if (iArbitrationDelay->IsActive()) { return KErrNone; } - else - { - iArbitrationDelay->Start(aLocalPriority); - return KErrNone; - } - } + else + { + iArbitrationDelay->Start(aLocalPriority); + return KErrNone; + } + } TInt CPhysicalLink::DoArbitrate(TBool aLocalPriority) - { - if (!IsConnected()) - { - return KErrDisconnected; - } - + { + if (!IsConnected()) + { + return KErrDisconnected; + } + //start arbitrate process with what our local controller supports TUint8 allowedModesMask = EHoldMode | EParkMode | ESniffMode; // local features sorted out later TBool roleSwitchAllowed = EFalse; @@ -2813,6 +2835,18 @@ SetAuthenticationPending(EPinRequestPending); // if not already set (because the remote initiated authentication). + __ASSERT_DEBUG(iSimplePairingMode != EPhySimplePairingEnabled, Panic(EBTSSPModeChangedDuringConnection)); + if (iSimplePairingMode == EPhySimplePairingUndefined) + { + iSimplePairingMode = EPhySimplePairingDisabled; + } + + if (!IsConnected()) + { + iPeerInSecurityMode3 = ETrue; + } + + if (iPinRequester) { return; @@ -3432,12 +3466,12 @@ } void CArbitrationDelayTimer::Start(TBool aLocalPriority) - { - LOG_FUNC - // Work out what the local priority will be now - TBool localPriority = iLocalPriority || aLocalPriority; - Cancel(); // cancel current timer (will also reset priority so ... - iLocalPriority = localPriority; // set the new priority) + { + LOG_FUNC + // Work out what the local priority will be now + TBool localPriority = iLocalPriority || aLocalPriority; + Cancel(); // cancel current timer (will also reset priority so ... + iLocalPriority = localPriority; // set the new priority) After(KBTArbitrationDelay); } @@ -3450,16 +3484,16 @@ LOG_FUNC if (iParent) { - iParent->DoArbitrate(iLocalPriority); + iParent->DoArbitrate(iLocalPriority); } } void CArbitrationDelayTimer::DoCancel() - { - LOG_FUNC - CTimer::DoCancel(); - iLocalPriority = EFalse; - } + { + LOG_FUNC + CTimer::DoCancel(); + iLocalPriority = EFalse; + } TInt CPhysicalLink::GetNumPendingHandles(TInt& aConnectionHandles, TLinkType aLinkType) const { diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/rfcomm/rfcommsap.cpp --- a/bluetooth/btstack/rfcomm/rfcommsap.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/rfcomm/rfcommsap.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -597,6 +597,8 @@ // Ensure the parent doesn't forget its clone iClonedChildren.Append(clone); + clone->SetCodServiceBits(iCodServiceBits); + return clone; } diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/rfcomm/rfcommstates.cpp --- a/bluetooth/btstack/rfcomm/rfcommstates.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/rfcomm/rfcommstates.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -1653,6 +1653,13 @@ ChangeState(aSAP,CRfcommStateFactory::ECloseOnStart); } + +void TRfcommStateWaitForStart::Exit(CRfcommSAP& aSAP) + { + aSAP.RegisterCodService(); + } + + /******************************************************************/ /* The Close On Start state. diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/rfcomm/rfcommstates.h --- a/bluetooth/btstack/rfcomm/rfcommstates.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/rfcomm/rfcommstates.h Fri Mar 19 09:53:48 2010 +0200 @@ -520,6 +520,7 @@ void DISC(CRfcommSAP& aSAP); void Error(CRfcommSAP& aSAP, TInt aErr, CRfcommSAP::TErrorTypes aType); + void Exit(CRfcommSAP& aSAP); }; /** diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/secman/btaccessrequester.cpp --- a/bluetooth/btstack/secman/btaccessrequester.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/secman/btaccessrequester.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -539,7 +539,7 @@ // If MITM protection is required by a service, or the device is in paired only connections mode // the require MITM protection. - if (iRequirements.MitmProtection() != EMitmNotRequired || iSecMan.ConnectionsManager().IsAcceptPairedOnlyMode()) + if (iRequirements.MitmProtection() != EMitmNotRequired) { if (iAccessType == EDedicatedBonding) { diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/secman/pairingserver.cpp --- a/bluetooth/btstack/secman/pairingserver.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/secman/pairingserver.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -775,11 +775,18 @@ iProxySap = CBTProxySAP::NewL(iPhysicalLinksManager, NULL); CleanupStack::Pop(this); // the start message cleaner - + + // Now we've entered the realm of not leaving with an error, since the connection + // process has started. Errors from now on must be via the Error() function call. iState = EInitialConnectionPending; iProxySap->SetNotify(this); iProxySap->SetRemName(addr); iProxySap->ActiveOpen(); + TRAPD(err, DoAccessRequestL()); + if(err != KErrNone) + { + Error(err); + } } void CDedicatedBondingSession::CleanupStartMessage(TAny* aPtr) @@ -815,6 +822,11 @@ addr.SetBTAddr(iProxySap->RemoteAddress()); iProxySap->SetRemName(addr); // triggers finding a link again. iProxySap->ActiveOpen(); + TRAPD(err, DoAccessRequestL()); + if(err != KErrNone) + { + Error(err); + } break; } // else not deferred so complete now.... @@ -830,6 +842,12 @@ err = KErrAccessDenied; } break; + case EInitialConnectionPending: + case EFinalConnectionPending: + // Access request shouldn't successfully complete if the connection is still pending + __ASSERT_DEBUG(aResult != EBTSecManAccessGranted, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedAccessCallback)); + // We should get the MSocketNotify::Error callback, so don't do anything else + break; default: LOG1(_L("Unexpected Access Request Complete in state %d"), iState); __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedAccessCallback)); @@ -856,23 +874,26 @@ __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); } -void CDedicatedBondingSession::ConnectCompleteL() +void CDedicatedBondingSession::ConnectComplete() { LOG_FUNC switch(iState) { case EInitialConnectionPending: iState = EInitialConnection; - DoAccessRequestL(); break; case EFinalConnectionPending: iState = EFinalConnection; - DoAccessRequestL(); break; case EInitialConnection: case EFinalConnection: // Apparently multiple connect completes are allowed by CSocket break; + case EShutdown: + // If an error occurred just after the connection request then we + // might receive a connection complete before the async shutdown request + // has been executed. + break; default: LOG1(_L("Unexpected Connect Complete in state %d"), iState); __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); @@ -880,16 +901,6 @@ } } -void CDedicatedBondingSession::ConnectComplete() - { - LOG_FUNC - TRAPD(err, ConnectCompleteL()); - if(err != KErrNone) - { - Error(err); - } - } - void CDedicatedBondingSession::ConnectComplete(const TDesC8& /*aConnectData*/) { LOG_FUNC diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/secman/pairingserver.h --- a/bluetooth/btstack/secman/pairingserver.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/secman/pairingserver.h Fri Mar 19 09:53:48 2010 +0200 @@ -214,7 +214,6 @@ void StartBondingL(const RMessage2& aMessage); void DoAccessRequestL(); - void ConnectCompleteL(); void Shutdown(); void Complete(TInt aError); diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetooth/btstack/secman/secman.cpp --- a/bluetooth/btstack/secman/secman.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btstack/secman/secman.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -453,34 +453,22 @@ oobPresence = EOOBDataPresent; } THCIAuthenticationRequirement authReq = link->AuthenticationRequirement(); - if(ConnectionsManager().IsAcceptPairedOnlyMode()) + switch(authReq) { - // in paired only mode, only MITM pairings are acceptable. - switch(authReq) - { case EMitmNotReqNoBonding: - case EMitmReqNoBonding: - authReq = EMitmReqNoBonding; - break; case EMitmNotReqDedicatedBonding: - case EMitmReqDedicatedBonding: - authReq = EMitmReqDedicatedBonding; - break; case EMitmNotReqGeneralBonding: - case EMitmReqGeneralBonding: - authReq = EMitmReqGeneralBonding; + link->SetLocalMITM(EFalse); break; - default: - PANIC(KBTSecPanic, EBTSecUnexpectedIoCapability); - break; - } - link->SetLocalMITM(ETrue); + case EMitmReqNoBonding: + case EMitmReqDedicatedBonding: + case EMitmReqGeneralBonding: + link->SetLocalMITM(ETrue); + break; + default: + PANIC(KBTSecPanic, EBTSecUnexpectedIoCapability); + break; } - else - { - link->SetLocalMITM(EFalse); - } - TRAP_IGNORE(iCommandController->IOCapabilityRequestReplyL(aAddr, EIOCapsDisplayYesNo, oobPresence, authReq)); } else diff -r 28479eeba3fb -r 0089b2f7ebd8 bluetoothmgmt/btcommon/bluetooth.txt --- a/bluetoothmgmt/btcommon/bluetooth.txt Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetoothmgmt/btcommon/bluetooth.txt Fri Mar 19 09:53:48 2010 +0200 @@ -1,7 +1,7 @@ # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/bthci2/CommandsEvents/BWINS/commandseventsU.def --- a/bthci/bthci2/CommandsEvents/BWINS/commandseventsU.def Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/bthci2/CommandsEvents/BWINS/commandseventsU.def Fri Mar 19 09:53:48 2010 +0200 @@ -1105,10 +1105,10 @@ ??0CVendorDebugCommand@@IAE@G@Z @ 1104 NONAME ; CVendorDebugCommand::CVendorDebugCommand(unsigned short) ?ConstructL@CVendorDebugCommand@@IAEXXZ @ 1105 NONAME ; void CVendorDebugCommand::ConstructL(void) ?Extension_@CVendorDebugCommand@@UAEHIAAPAXPAX@Z @ 1106 NONAME ; int CVendorDebugCommand::Extension_(unsigned int, void * &, void *) - ?SetCreditsConsumed@CVendorDebugCommand@@IAEXI@Z @ 1107 NONAME ; void CVendorDebugCommand::SetCreditsConsumed(unsigned int) - ?SetExpectsCommandCompleteEvent@CVendorDebugCommand@@IAEXH@Z @ 1108 NONAME ; void CVendorDebugCommand::SetExpectsCommandCompleteEvent(int) - ?SetExpectsCommandStatusEvent@CVendorDebugCommand@@IAEXH@Z @ 1109 NONAME ; void CVendorDebugCommand::SetExpectsCommandStatusEvent(int) - ?SetExpectsCompletingEvent@CVendorDebugCommand@@IAEHH@Z @ 1110 NONAME ; int CVendorDebugCommand::SetExpectsCompletingEvent(int) + ?SetCreditsConsumed@CVendorDebugCommand@@QAEXI@Z @ 1107 NONAME ; void CVendorDebugCommand::SetCreditsConsumed(unsigned int) + ?SetExpectsCommandCompleteEvent@CVendorDebugCommand@@QAEXH@Z @ 1108 NONAME ; void CVendorDebugCommand::SetExpectsCommandCompleteEvent(int) + ?SetExpectsCommandStatusEvent@CVendorDebugCommand@@QAEXH@Z @ 1109 NONAME ; void CVendorDebugCommand::SetExpectsCommandStatusEvent(int) + ?SetExpectsCompletingEvent@CVendorDebugCommand@@QAEHH@Z @ 1110 NONAME ; int CVendorDebugCommand::SetExpectsCompletingEvent(int) ?VendorDebugEvent@TVendorDebugCompleteEvent@@QBE?AVTPtrC8@@XZ @ 1111 NONAME ; class TPtrC8 TVendorDebugCompleteEvent::VendorDebugEvent(void) const ?AsNullTerminatedString@THCIEventBase@@IBE?AVTPtrC8@@H@Z @ 1112 NONAME ; class TPtrC8 THCIEventBase::AsNullTerminatedString(int) const ??0TNopCompleteEvent@@QAE@ABVTDesC8@@@Z @ 1113 NONAME ; TNopCompleteEvent::TNopCompleteEvent(class TDesC8 const &) diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/bthci2/CommandsEvents/generator/Commands.txt --- a/bthci/bthci2/CommandsEvents/generator/Commands.txt Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/bthci2/CommandsEvents/generator/Commands.txt Fri Mar 19 09:53:48 2010 +0200 @@ -1,7 +1,7 @@ # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/bthci2/CommandsEvents/generator/CompleteEvents.txt --- a/bthci/bthci2/CommandsEvents/generator/CompleteEvents.txt Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/bthci2/CommandsEvents/generator/CompleteEvents.txt Fri Mar 19 09:53:48 2010 +0200 @@ -1,7 +1,7 @@ # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/bthci2/CommandsEvents/generator/Events.txt --- a/bthci/bthci2/CommandsEvents/generator/Events.txt Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/bthci2/CommandsEvents/generator/Events.txt Fri Mar 19 09:53:48 2010 +0200 @@ -1,7 +1,7 @@ # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/bthci2/CommandsEvents/interface/VendorDebugCommand.h --- a/bthci/bthci2/CommandsEvents/interface/VendorDebugCommand.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/bthci2/CommandsEvents/interface/VendorDebugCommand.h Fri Mar 19 09:53:48 2010 +0200 @@ -77,14 +77,14 @@ IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& aInterface, TAny* aData); void Match(const THCIEventBase& aEvent, TBool& aMatchesCmd, TBool& aConcludesCmd, TBool& aContinueMatching) const; IMPORT_C void SetMatcher(MVendorDebugCommandMatcher* aMatcher); + IMPORT_C void SetCreditsConsumed(TUint aConsumedCredits); + IMPORT_C void SetExpectsCommandStatusEvent(TBool aExpectsCmdStatus); + IMPORT_C void SetExpectsCommandCompleteEvent(TBool aExpectsCmdComplete); + IMPORT_C TInt SetExpectsCompletingEvent(TBool aExpectsCompletingEvent); protected: IMPORT_C CVendorDebugCommand(const TUint16 opcode); IMPORT_C void ConstructL(); - IMPORT_C void SetCreditsConsumed(TUint aConsumedCredits); - IMPORT_C void SetExpectsCommandStatusEvent(TBool aExpectsCmdStatus); - IMPORT_C void SetExpectsCommandCompleteEvent(TBool aExpectsCmdComplete); - IMPORT_C TInt SetExpectsCompletingEvent(TBool aExpectsCompletingEvent); private: void Format(CHctlCommandFrame& aCommandFrame) const; diff -r 28479eeba3fb -r 0089b2f7ebd8 bthci/hci2implementations/hctls/bcsp/src/hctlbcspcontrollermanager.cpp --- a/bthci/hci2implementations/hctls/bcsp/src/hctlbcspcontrollermanager.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/hctls/bcsp/src/hctlbcspcontrollermanager.cpp Fri Mar 19 09:53:48 2010 +0200 @@ -190,11 +190,10 @@ switch(aState) { case EBTOff: - { - iHCTLBcsp.WriteBcCmd(iColdHaltCommand); //this should not produce a response + { iPowerDownCallback->CallBack(); //allows asynch callback to BTClient. iCurrentTask = EPowerDown; - iControllerManagerState = EWaiting; + iControllerManagerState = EResetHardware; iHCTLBcsp.Choke(); } break; diff -r 28479eeba3fb -r 0089b2f7ebd8 package_definition.xml --- a/package_definition.xml Tue Feb 02 01:12:20 2010 +0200 +++ b/package_definition.xml Fri Mar 19 09:53:48 2010 +0200 @@ -70,6 +70,11 @@ + + + + +