• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #include "l2cap/l2cap_packets.h"
22 #include "packet/base_packet_builder.h"
23 #include "packet/packet_view.h"
24 
25 namespace bluetooth {
26 namespace l2cap {
27 namespace internal {
28 
29 class DataController {
30  public:
31   virtual ~DataController() = default;
32 
33   // SDU -> PDUs and notify Scheduler
34   virtual void OnSdu(std::unique_ptr<packet::BasePacketBuilder> sdu) = 0;
35 
36   // PDUs -> SDU and enqueue to channel queue end
37   virtual void OnPdu(packet::PacketView<true> pdu) = 0;
38 
39   // Used by Scheduler to get next PDU
40   virtual std::unique_ptr<packet::BasePacketBuilder> GetNextPacket() = 0;
41 
42   // Set FCS mode. This only applies to some modes (ERTM).
43   virtual void EnableFcs(bool enabled) = 0;
44 
45   // Set retransmission and flow control. Ignore the mode option because each DataController only handles one mode.
46   // This only applies to some modes (ERTM).
47   virtual void SetRetransmissionAndFlowControlOptions(
48       const RetransmissionAndFlowControlConfigurationOption& option) = 0;
49 };
50 
51 }  // namespace internal
52 }  // namespace l2cap
53 }  // namespace bluetooth
54