• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "security/l2cap_security_module_interface.h"
17 #include "common/bind.h"
18 
19 namespace bluetooth {
20 namespace security {
21 
L2capSecurityModuleInterface(internal::SecurityManagerImpl * security_manager_impl,os::Handler * security_handler)22 L2capSecurityModuleInterface::L2capSecurityModuleInterface(internal::SecurityManagerImpl* security_manager_impl,
23                                                            os::Handler* security_handler)
24     : security_manager_impl_(security_manager_impl), security_handler_(security_handler) {}
25 
Enforce(hci::AddressWithType remote,l2cap::classic::SecurityPolicy policy,l2cap::classic::SecurityEnforcementInterface::ResultCallback result_callback)26 void L2capSecurityModuleInterface::Enforce(
27     hci::AddressWithType remote, l2cap::classic::SecurityPolicy policy,
28     l2cap::classic::SecurityEnforcementInterface::ResultCallback result_callback) {
29   this->security_handler_->Post(common::BindOnce(
30       &internal::SecurityManagerImpl::EnforceSecurityPolicy, common::Unretained(security_manager_impl_),
31       std::forward<hci::AddressWithType>(remote), std::forward<l2cap::classic::SecurityPolicy>(policy),
32       std::forward<l2cap::classic::SecurityEnforcementInterface::ResultCallback>(result_callback)));
33 }
34 
Enforce(hci::AddressWithType remote,l2cap::le::SecurityPolicy policy,l2cap::le::SecurityEnforcementInterface::ResultCallback result_callback)35 void L2capSecurityModuleInterface::Enforce(hci::AddressWithType remote, l2cap::le::SecurityPolicy policy,
36                                            l2cap::le::SecurityEnforcementInterface::ResultCallback result_callback) {
37   this->security_handler_->Post(common::BindOnce(
38       &internal::SecurityManagerImpl::EnforceLeSecurityPolicy, common::Unretained(security_manager_impl_),
39       std::forward<hci::AddressWithType>(remote), std::forward<l2cap::le::SecurityPolicy>(policy),
40       std::forward<l2cap::le::SecurityEnforcementInterface::ResultCallback>(result_callback)));
41 }
42 
43 }  // namespace security
44 }  // namespace bluetooth
45