# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1276070102 -10800 # Node ID 1f10b9300be686a464dc6fea924342a9241e4bfd # Parent 32ba203390366442e45f2406d00c5c4736628cd1 Revision: 201018 Kit: 2010123 diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/eirman/eirmanserver.cpp --- a/bluetooth/btstack/eirman/eirmanserver.cpp Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/eirman/eirmanserver.cpp Wed Jun 09 10:55:02 2010 +0300 @@ -209,42 +209,46 @@ _LIT_SECURITY_POLICY_S0(KSDPSecurityPolicy, KSDPServerID); _LIT_SECURITY_POLICY_S0(KStackSecurityPolicy, KStackID); _LIT_SECURITY_POLICY_C1(KVendorSpecificDataSecurityPolicy, ECapabilityWriteDeviceData); - if(function == EEirManRegisterTag) + _LIT_SECURITY_POLICY_C1(KEirCommonSecurityPolicy, ECapabilityLocalServices); + + if(KEirCommonSecurityPolicy.CheckPolicy(aMsg)) { - tag = static_cast(aMsg.Int0()); - switch(tag) + if(function == EEirManRegisterTag) { - case EEirTagName: - case EEirTagTxPowerLevel: - /** These must have come from the stack **/ - if(KStackSecurityPolicy.CheckPolicy(aMsg)) - { - result = EPass; - } - break; - case EEirTagSdpUuid16: - case EEirTagSdpUuid32: - case EEirTagSdpUuid128: - /** These must have come from SDP server **/ - if(KSDPSecurityPolicy.CheckPolicy(aMsg)) - { - result = EPass; - } - break; - case EEirTagManufacturerSpecific: - /** To do this you must have write device data **/ - if(KVendorSpecificDataSecurityPolicy.CheckPolicy(aMsg)) - { - result = EPass; - } - break; - - case EEirTagFlags: - /** At present no implementation of Flags is supported. - So we are rejecting this until an implementation is provided. **/ - default: //unknown or reserved tag, reject - //no need to do anything - break; + tag = static_cast(aMsg.Int0()); + switch(tag) + { + case EEirTagName: + case EEirTagTxPowerLevel: + /** These must have come from the stack **/ + if(KStackSecurityPolicy.CheckPolicy(aMsg)) + { + result = EPass; + } + break; + case EEirTagSdpUuid16: + case EEirTagSdpUuid32: + case EEirTagSdpUuid128: + /** These must have come from SDP server **/ + if(KSDPSecurityPolicy.CheckPolicy(aMsg)) + { + result = EPass; + } + break; + case EEirTagManufacturerSpecific: + /** To do this you must have write device data **/ + if(KVendorSpecificDataSecurityPolicy.CheckPolicy(aMsg)) + { + result = EPass; + } + break; + case EEirTagFlags: + /** At present no implementation of Flags is supported. + So we are rejecting this until an implementation is provided. **/ + default: //unknown or reserved tag, reject + //no need to do anything + break; + } } } //Anything not covered by the above is invalid so do nothing and let it fail diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/eirman/eirmanserversecuritypolicy.h --- a/bluetooth/btstack/eirman/eirmanserversecuritypolicy.h Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/eirman/eirmanserversecuritypolicy.h Wed Jun 09 10:55:02 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 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" @@ -58,7 +58,7 @@ /** Main policy */ const CPolicyServer::TPolicy KEirManServerPolicy = { - CPolicyServer::EAlwaysPass , /** Specifies all connect attempts should pass */ + KPolicyCapabilityCheck , /** Connect attempts are only successful if the caller has ECapabilityLocalServices */ KEirManServerRangeCount, KEirManServerRanges, KEirManServerElementsIndex, diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/eirman/eirmansession.cpp --- a/bluetooth/btstack/eirman/eirmansession.cpp Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/eirman/eirmansession.cpp Wed Jun 09 10:55:02 2010 +0300 @@ -208,49 +208,47 @@ } delete iSession; } - +/* + * Each of the individual methods is responsible for completing the message. + * All 'leaves' are processed in CSession2::ServiceError() resulting in message completion + * with the appropriate error code. + * RegisterTagL() and RegisterSpaceAvailableListenerL() store aMessage parameter for the future use + * when the callbacks are called. + */ void CEirManExternalSession::ServiceL(const RMessage2& aMessage) { LOG_FUNC LOG1(_L("CEirManSession::ServiceL aMessage.Function() = %d"), aMessage.Function()); - TBool complete = ETrue; - TInt ret = KErrNone; switch (aMessage.Function()) { case EEirManRegisterTag: - complete = EFalse; // always async. - RegisterTag(aMessage); + RegisterTagL(aMessage); break; case EEirManSpaceAvailableNotification: - ret = RegisterSpaceAvailableListener(aMessage, complete); + RegisterSpaceAvailableListenerL(aMessage); break; case EEirManCancelSpaceAvailableNotification: - ret = CancelSpaceAvailableListener(); + CancelSpaceAvailableListenerL(aMessage); break; case EEirManSetData: - ret = SetData(aMessage); + SetDataL(aMessage); break; case EEirManNewData: - ret = NewData(aMessage); + NewDataL(aMessage); break; default: aMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidIPC); break; } - - if (complete) - { - aMessage.Complete(ret); - } } -void CEirManExternalSession::RegisterTag(const RMessage2& aMessage) +void CEirManExternalSession::RegisterTagL(const RMessage2& aMessage) { LOG_FUNC TEirTag tag = static_cast(aMessage.Int0()); @@ -259,84 +257,91 @@ iRegisterMessage = aMessage; iSession->RegisterTag(tag); - } void CEirManExternalSession::MesnRegisterComplete(TInt aResult) { if (aResult == KErrArgument) { - __ASSERT_ALWAYS(EFalse, iRegisterMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag)); + iRegisterMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag); } - iRegisterMessage.Complete(aResult); + else + { + iRegisterMessage.Complete(aResult); + } } -TInt CEirManExternalSession::RegisterSpaceAvailableListener(const RMessage2& aMessage, TBool& aComplete) +void CEirManExternalSession::RegisterSpaceAvailableListenerL(const RMessage2& aMessage) { LOG_FUNC if(iDataAvailableListenerMessage.Handle()) { LOG(_L("CEirManSession:::RegisterSpaceAvailableListener ERROR IN USE")); - return KErrInUse; + LEAVEL(KErrInUse); } iDataAvailableListenerMessage = aMessage; - aComplete = EFalse; - if(iLastSpaceOffered != 0) { LOG(_L("cached space present, completing immediately")); CompleteSpaceAvailableRequest(iLastSpaceOffered); iLastSpaceOffered = 0; - return KErrNone; + return; } LOG(_L("waiting for callback...")); - return KErrNone; } -TInt CEirManExternalSession::NewData(const RMessage2& aMessage) +void CEirManExternalSession::NewDataL(const RMessage2& aMessage) { LOG_FUNC - __ASSERT_ALWAYS(iSession->EirTag() != EEirTagRESERVED, aMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag)); + + if (iSession->EirTag() == EEirTagRESERVED) + { + aMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag); + return; + } + TInt requiredLength = static_cast(aMessage.Int0()); - return iSession->NewData(requiredLength); + LEAVEIFERRORL(iSession->NewData(requiredLength)); + aMessage.Complete(KErrNone); } -TInt CEirManExternalSession::CancelSpaceAvailableListener() +void CEirManExternalSession::CancelSpaceAvailableListenerL(const RMessage2& aMessage) { LOG_FUNC if(!iDataAvailableListenerMessage.Handle()) { - return KErrNotFound; + LEAVEL(KErrNotFound); } iDataAvailableListenerMessage.Complete(KErrCancel); - - return KErrNone; + aMessage.Complete(KErrNone); } -TInt CEirManExternalSession::SetData(const RMessage2& aMessage) +void CEirManExternalSession::SetDataL(const RMessage2& aMessage) { LOG_FUNC - __ASSERT_ALWAYS(iSession->EirTag() != EEirTagRESERVED, aMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag)); + if (iSession->EirTag() == EEirTagRESERVED) + { + aMessage.Panic(KEirManCliPncCat, EEirManPanicInvalidTag); + return; + } + TEirDataMode eirDataMode = static_cast(aMessage.Int1()); LOG1(_L("EirDataMode: %d"), eirDataMode); // No need to allocate memory with an expensive malloc() call (via HBuf8::NewL or whatever), // since the EIR contents fit in the stack, and the EIR Manager will cache the data anyway TBuf8 data; - TInt err = aMessage.Read(0, data); + LEAVEIFERRORL(aMessage.Read(0, data)); - if(err == KErrNone) - { - err = iSession->SetData(data, eirDataMode); - } - return err; + LEAVEIFERRORL(iSession->SetData(data, eirDataMode)); + aMessage.Complete(KErrNone); } void CEirManExternalSession::MesnSpaceAvailable(TUint aSpaceForTag) diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/eirman/eirmansession.h --- a/bluetooth/btstack/eirman/eirmansession.h Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/eirman/eirmansession.h Wed Jun 09 10:55:02 2010 +0300 @@ -85,11 +85,11 @@ private: void ConstructL(CEirManServer& aServer); CEirManExternalSession(); - void RegisterTag(const RMessage2& aMessage); - TInt RegisterSpaceAvailableListener(const RMessage2& aMessage, TBool& aComplete); - TInt CancelSpaceAvailableListener(); - TInt NewData(const RMessage2& aMessage); - TInt SetData(const RMessage2& aMessage); + void RegisterTagL(const RMessage2& aMessage); + void RegisterSpaceAvailableListenerL(const RMessage2& aMessage); + void CancelSpaceAvailableListenerL(const RMessage2& aMessage); + void NewDataL(const RMessage2& aMessage); + void SetDataL(const RMessage2& aMessage); private: void CompleteSpaceAvailableRequest(TUint aBytesAvailable); diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/linkmgr/ACLSAP.cpp --- a/bluetooth/btstack/linkmgr/ACLSAP.cpp Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/linkmgr/ACLSAP.cpp Wed Jun 09 10:55:02 2010 +0300 @@ -19,6 +19,7 @@ #include #include #include +#include #include "ACLSAP.h" #include "physicallinks.h" diff -r 32ba20339036 -r 1f10b9300be6 bluetooth/btstack/linkmgr/physicallinks.cpp --- a/bluetooth/btstack/linkmgr/physicallinks.cpp Tue May 25 13:54:55 2010 +0300 +++ b/bluetooth/btstack/linkmgr/physicallinks.cpp Wed Jun 09 10:55:02 2010 +0300 @@ -145,6 +145,7 @@ delete iPhysicalLinkMetrics; delete iPinRequester; delete iNumericComparator; + delete iUserConfirmer; delete iPasskeyEntry; delete iArbitrationDelay; delete iRoleSwitchCompleteCallBack;