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 // Authors: corbin.souffrant@leviathansecurity.com 17 // dylan.katz@leviathansecurity.com 18 19 #pragma once 20 21 #include <gd/l2cap/classic/dynamic_channel_service.h> 22 #include <gd/l2cap/classic/internal/dynamic_channel_service_impl.h> 23 #include <gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.h> 24 #include <memory> 25 26 #include "hci/address.h" 27 #include "l2cap/classic/dynamic_channel_configuration_option.h" 28 #include "l2cap/classic/dynamic_channel_manager.h" 29 #include "l2cap/classic/security_policy.h" 30 #include "l2cap/psm.h" 31 #include "os/handler.h" 32 33 #include "fuzz_dynamic_channel_manager_impl.h" 34 35 namespace bluetooth { 36 namespace shim { 37 namespace { 38 class FuzzDynamicChannelManager : public l2cap::classic::DynamicChannelManager { 39 public: ConnectChannel(hci::Address device,l2cap::classic::DynamicChannelConfigurationOption configuration_option,l2cap::Psm psm,l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback,l2cap::classic::DynamicChannelManager::OnConnectionFailureCallback on_fail_callback)40 void ConnectChannel( 41 hci::Address device, 42 l2cap::classic::DynamicChannelConfigurationOption configuration_option, 43 l2cap::Psm psm, 44 l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback, 45 l2cap::classic::DynamicChannelManager::OnConnectionFailureCallback on_fail_callback) override { 46 impl_.ConnectChannel(device, configuration_option, psm, std::move(on_open_callback), std::move(on_fail_callback)); 47 } 48 RegisterService(l2cap::Psm psm,l2cap::classic::DynamicChannelConfigurationOption configuration_option,const l2cap::classic::SecurityPolicy & security_policy,l2cap::classic::DynamicChannelManager::OnRegistrationCompleteCallback on_registration_complete,l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback)49 void RegisterService( 50 l2cap::Psm psm, 51 l2cap::classic::DynamicChannelConfigurationOption configuration_option, 52 const l2cap::classic::SecurityPolicy& security_policy, 53 l2cap::classic::DynamicChannelManager::OnRegistrationCompleteCallback on_registration_complete, 54 l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback) override { 55 impl_.RegisterService( 56 psm, configuration_option, security_policy, std::move(on_registration_complete), std::move(on_open_callback)); 57 } FuzzDynamicChannelManager(FuzzDynamicChannelManagerImpl & impl)58 FuzzDynamicChannelManager(FuzzDynamicChannelManagerImpl& impl) : impl_(impl) {} 59 FuzzDynamicChannelManagerImpl& impl_; 60 }; 61 } // namespace 62 } // namespace shim 63 } // namespace bluetooth 64