1 /* 2 * Copyright 2019 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 #pragma once 17 18 #include <memory> 19 20 #include "l2cap/classic/dynamic_channel_manager.h" 21 #include "l2cap/classic/fixed_channel_manager.h" 22 #include "l2cap/classic/link_security_interface.h" 23 #include "l2cap/classic/security_enforcement_interface.h" 24 #include "module.h" 25 26 namespace bluetooth { 27 28 namespace security { 29 class SecurityModule; 30 } 31 32 namespace l2cap { 33 namespace classic { 34 35 class L2capClassicModule : public bluetooth::Module { 36 public: 37 L2capClassicModule(); 38 virtual ~L2capClassicModule(); 39 40 /** 41 * Get the api to the classic fixed channel l2cap module 42 */ 43 virtual std::unique_ptr<FixedChannelManager> GetFixedChannelManager(); 44 45 /** 46 * Get the api to the classic dynamic channel l2cap module 47 */ 48 virtual std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager(); 49 50 static const ModuleFactory Factory; 51 52 protected: 53 void ListDependencies(ModuleList* list) override; 54 55 void Start() override; 56 57 void Stop() override; 58 59 std::string ToString() const override; 60 61 private: 62 struct impl; 63 std::unique_ptr<impl> pimpl_; 64 65 friend security::SecurityModule; 66 /** 67 * Only for the classic security module to inject functionality to enforce security level for a connection. When 68 * classic security module is stopping, inject nullptr. Note: We expect this only to be called during stack startup. 69 * This is not synchronized. 70 */ 71 virtual void InjectSecurityEnforcementInterface(SecurityEnforcementInterface* security_enforcement_interface); 72 73 /** 74 * Get the interface for Security Module to access link function. 75 * Security Module needs to register the callback for ACL link connected and disconnected. When connected, either by 76 * incoming or by outgoing connection request, Security Module receives a LinkSecurityInterface proxy, which can be 77 * used to access some link functionlities. 78 */ 79 virtual SecurityInterface* GetSecurityInterface(os::Handler* handler, LinkSecurityInterfaceListener* listener); 80 81 DISALLOW_COPY_AND_ASSIGN(L2capClassicModule); 82 }; 83 84 } // namespace classic 85 } // namespace l2cap 86 } // namespace bluetooth 87