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