Hansong Zhang | b096076 | 2019-11-14 17:57:10 -0800 | [diff] [blame^] | 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 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <memory> |
| 20 | #include <unordered_map> |
| 21 | #include <utility> |
| 22 | |
| 23 | #include "common/bidi_queue.h" |
| 24 | #include "l2cap/cid.h" |
| 25 | #include "l2cap/internal/channel_impl.h" |
| 26 | #include "l2cap/internal/data_controller.h" |
| 27 | #include "l2cap/internal/scheduler.h" |
| 28 | #include "l2cap/l2cap_packets.h" |
| 29 | #include "l2cap/mtu.h" |
| 30 | #include "os/handler.h" |
| 31 | #include "os/queue.h" |
| 32 | #include "packet/base_packet_builder.h" |
| 33 | #include "packet/packet_view.h" |
| 34 | |
| 35 | namespace bluetooth { |
| 36 | namespace l2cap { |
| 37 | namespace internal { |
| 38 | |
| 39 | class ErtmController : public DataController { |
| 40 | public: |
| 41 | using UpperEnqueue = packet::PacketView<packet::kLittleEndian>; |
| 42 | using UpperDequeue = packet::BasePacketBuilder; |
| 43 | using UpperQueueDownEnd = common::BidiQueueEnd<UpperEnqueue, UpperDequeue>; |
| 44 | ErtmController(Cid cid, Cid remote_cid, UpperQueueDownEnd* channel_queue_end, os::Handler* handler, |
| 45 | Scheduler* scheduler); |
| 46 | void OnSdu(std::unique_ptr<packet::BasePacketBuilder> sdu) override; |
| 47 | void OnPdu(BasicFrameView pdu) override; |
| 48 | std::unique_ptr<BasicFrameBuilder> GetNextPacket() override; |
| 49 | |
| 50 | private: |
| 51 | [[maybe_unused]] Cid cid_; |
| 52 | [[maybe_unused]] os::EnqueueBuffer<UpperEnqueue> enqueue_buffer_; |
| 53 | [[maybe_unused]] os::Handler* handler_; |
| 54 | std::queue<std::unique_ptr<BasicFrameBuilder>> pdu_queue_; |
| 55 | [[maybe_unused]] Scheduler* scheduler_; |
| 56 | }; |
| 57 | |
| 58 | } // namespace internal |
| 59 | } // namespace l2cap |
| 60 | } // namespace bluetooth |