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 17 #pragma once 18 19 #include "fuzz/helpers.h" 20 #include "hal/hci_hal.h" 21 #include "hci/hci_packets.h" 22 23 namespace bluetooth { 24 namespace hal { 25 namespace fuzz { 26 27 class FuzzHciHal : public HciHal { 28 public: 29 void registerIncomingPacketCallback(HciHalCallbacks* callbacks) override; 30 void unregisterIncomingPacketCallback() override; 31 32 void sendHciCommand(HciPacket command) override; sendAclData(HciPacket packet)33 void sendAclData(HciPacket packet) override {} sendScoData(HciPacket packet)34 void sendScoData(HciPacket packet) override {} 35 36 void injectArbitrary(FuzzedDataProvider& fdp); 37 ToString()38 std::string ToString() const override { 39 return "HciHalFuzz"; 40 } 41 42 static const ModuleFactory Factory; 43 44 protected: ListDependencies(ModuleList * list)45 void ListDependencies(ModuleList* list) override {} Start()46 void Start() override {} Stop()47 void Stop() override {} 48 49 private: 50 void injectAclData(std::vector<uint8_t> data); 51 void injectHciEvent(std::vector<uint8_t> data); 52 void injectScoData(std::vector<uint8_t> data); 53 54 HciHalCallbacks* callbacks_; 55 hci::OpCode waiting_opcode_; 56 bool waiting_for_status_; 57 }; 58 59 } // namespace fuzz 60 } // namespace hal 61 } // namespace bluetooth 62