LOG_INFO("UNIMPLEMENTED key_flag:%s", hci::KeyFlagText(key_flag).c_str());
}
void Link::OnRoleChange(hci::Role new_role) {
- LOG_INFO("UNIMPLEMENTED role:%s", hci::RoleText(new_role).c_str());
+ role_ = new_role;
}
void Link::OnDisconnection(hci::ErrorCode reason) {
OnAclDisconnected(reason);
void LinkManager::ConnectDynamicChannelServices(
hci::Address device, Link::PendingDynamicChannelConnection pending_dynamic_channel_connection, Psm psm) {
+ if (!IsPsmValid(psm)) {
+ return;
+ }
auto* link = GetLink(device);
if (link == nullptr) {
acl_manager_->CreateConnection(device);
*/
virtual SecurityInterface* GetSecurityInterface(os::Handler* handler, LinkSecurityInterfaceListener* listener);
+ friend security::SecurityModule;
+
protected:
void ListDependencies(ModuleList* list) override;
struct impl;
std::unique_ptr<impl> pimpl_;
- friend security::SecurityModule;
-
DISALLOW_COPY_AND_ASSIGN(L2capClassicModule);
};
namespace internal {
std::shared_ptr<DynamicChannelImpl> DynamicChannelAllocator::AllocateChannel(Psm psm, Cid remote_cid) {
- ASSERT_LOG(IsPsmValid(psm), "Psm 0x%x is invalid", psm);
-
if (used_remote_cid_.find(remote_cid) != used_remote_cid_.end()) {
LOG_INFO("Remote cid 0x%x is used", remote_cid);
return nullptr;
std::shared_ptr<DynamicChannelImpl> DynamicChannelAllocator::AllocateReservedChannel(Cid reserved_cid, Psm psm,
Cid remote_cid) {
- ASSERT_LOG(IsPsmValid(psm), "Psm 0x%x is invalid", psm);
-
if (used_remote_cid_.find(remote_cid) != used_remote_cid_.end()) {
LOG_INFO("Remote cid 0x%x is used", remote_cid);
return nullptr;
os::Handler* l2cap_handler)
: psm_(psm), cid_(cid), remote_cid_(remote_cid), link_(link), l2cap_handler_(l2cap_handler),
device_(link->GetDevice()) {
- ASSERT(IsPsmValid(psm_));
ASSERT(cid_ > 0);
ASSERT(remote_cid_ > 0);
ASSERT(link_ != nullptr);
protected:
DynamicChannelService(Psm psm, internal::DynamicChannelServiceManagerImpl* manager, os::Handler* handler)
: psm_(psm), manager_(manager), l2cap_layer_handler_(handler) {
- ASSERT(IsPsmValid(psm));
ASSERT(manager_ != nullptr);
ASSERT(l2cap_layer_handler_ != nullptr);
}
void DynamicChannelServiceManagerImpl::Register(Psm psm,
DynamicChannelServiceImpl::PendingRegistration pending_registration) {
- if (!IsPsmValid(psm)) {
- std::unique_ptr<DynamicChannelService> invalid_service(new DynamicChannelService());
- pending_registration.user_handler_->Post(
- common::BindOnce(std::move(pending_registration.on_registration_complete_callback_),
- DynamicChannelManager::RegistrationResult::FAIL_INVALID_SERVICE, std::move(invalid_service)));
- } else if (IsServiceRegistered(psm)) {
+ if (IsServiceRegistered(psm)) {
std::unique_ptr<DynamicChannelService> invalid_service(new DynamicChannelService());
pending_registration.user_handler_->Post(common::BindOnce(
std::move(pending_registration.on_registration_complete_callback_),
.security_policy_ = SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK,
.on_registration_complete_callback_ =
common::BindOnce(&L2capLeDynamicServiceManagerTest::OnServiceRegistered, common::Unretained(this), true)};
- Cid cid = kSmpBrCid;
- EXPECT_FALSE(manager_->IsServiceRegistered(cid));
- manager_->Register(cid, std::move(pending_registration));
- EXPECT_TRUE(manager_->IsServiceRegistered(cid));
+ Psm psm = 0x41;
+ EXPECT_FALSE(manager_->IsServiceRegistered(psm));
+ manager_->Register(psm, std::move(pending_registration));
+ EXPECT_TRUE(manager_->IsServiceRegistered(psm));
sync_user_handler();
EXPECT_TRUE(service_registered_);
- manager_->Unregister(cid, common::BindOnce([] {}), user_handler_);
- EXPECT_FALSE(manager_->IsServiceRegistered(cid));
+ manager_->Unregister(psm, common::BindOnce([] {}), user_handler_);
+ EXPECT_FALSE(manager_->IsServiceRegistered(psm));
}
-TEST_F(L2capLeDynamicServiceManagerTest, register_le_dynamic_channel_bad_cid) {
+TEST_F(L2capLeDynamicServiceManagerTest, register_le_dynamic_channel_even_number_psm) {
DynamicChannelServiceImpl::PendingRegistration pending_registration{
.user_handler_ = user_handler_,
.security_policy_ = SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK,
.on_registration_complete_callback_ =
- common::BindOnce(&L2capLeDynamicServiceManagerTest::OnServiceRegistered, common::Unretained(this), false)};
- Cid cid = 0x1000;
- EXPECT_FALSE(manager_->IsServiceRegistered(cid));
- manager_->Register(cid, std::move(pending_registration));
- EXPECT_FALSE(manager_->IsServiceRegistered(cid));
+ common::BindOnce(&L2capLeDynamicServiceManagerTest::OnServiceRegistered, common::Unretained(this), true)};
+ Psm psm = 0x0100;
+ EXPECT_FALSE(manager_->IsServiceRegistered(psm));
+ manager_->Register(psm, std::move(pending_registration));
+ EXPECT_TRUE(manager_->IsServiceRegistered(psm));
sync_user_handler();
- EXPECT_FALSE(service_registered_);
+ EXPECT_TRUE(service_registered_);
}
} // namespace internal
void LeSignallingManager::OnConnectionRequest(SignalId signal_id, Psm psm, Cid remote_cid, Mtu mtu, uint16_t mps,
uint16_t initial_credits) {
- if (!IsPsmValid(psm)) {
- LOG_WARN("Invalid psm received from remote psm:%d remote_cid:%d", psm, remote_cid);
- send_connection_response(signal_id, kInvalidCid, 0, 0, 0,
- LeCreditBasedConnectionResponseResult::LE_PSM_NOT_SUPPORTED);
- return;
- }
-
if (remote_cid == kInvalidCid) {
LOG_WARN("Invalid remote cid received from remote psm:%d remote_cid:%d", psm, remote_cid);
send_connection_response(signal_id, kInvalidCid, 0, 0, 0,