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 <vector> 22 23 #include "fuzz/helpers.h" 24 #include "l2cap/classic/internal/fixed_channel_impl.h" 25 #include "l2cap/internal/dynamic_channel_impl.h" 26 #include "l2cap/l2cap_packets.h" 27 #include "os/fuzz/fuzz_inject_queue.h" 28 #include "os/handler.h" 29 #include "packet/packet_view.h" 30 31 namespace bluetooth { 32 33 typedef os::IQueueEnqueue<packet::PacketView<packet::kLittleEndian>> EnqueueType; 34 typedef os::fuzz::FuzzInjectQueue<packet::PacketView<packet::kLittleEndian>> ChannelFuzzQueueType; 35 36 class ChannelFuzzController { 37 public: 38 ChannelFuzzController(os::Handler* l2cap_handler, std::shared_ptr<l2cap::internal::DynamicChannelImpl> chan); 39 40 ChannelFuzzController(os::Handler* l2cap_handler, std::shared_ptr<l2cap::classic::internal::FixedChannelImpl> chan); 41 42 void injectPacketData(std::vector<uint8_t> data); 43 44 void injectFrame(std::vector<uint8_t> data); 45 46 private: 47 std::shared_ptr<ChannelFuzzQueueType> channelInject_; 48 }; 49 } // namespace bluetooth 50