1 // Copyright 2024 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 17 #include <cstdint> 18 19 #include "pw_containers/intrusive_forward_list.h" 20 21 namespace pw::bluetooth::proxy { 22 23 // Direction a packet is traveling in the proxy host. 24 enum class Direction { 25 kFromController, 26 kFromHost, 27 }; 28 29 struct L2capChannelConnectionInfo { 30 Direction direction; 31 uint16_t psm; 32 uint16_t connection_handle; 33 // Otherwise known as source_cid 34 uint16_t remote_cid; 35 // Otherwise known as destination_cid 36 uint16_t local_cid; 37 }; 38 39 class L2capStatusDelegate 40 : public IntrusiveForwardList<L2capStatusDelegate>::Item { 41 public: 42 virtual ~L2capStatusDelegate() = default; 43 44 /// Should return true if the implementor is interested in l2cap channel 45 /// connections for this psm. 46 virtual bool ShouldTrackPsm(uint16_t psm) = 0; 47 48 /// Called when a l2cap channel connection successfully made. Note: this 49 /// doesn't currently handle credit based l2cap channels. 50 virtual void HandleConnectionComplete( 51 const L2capChannelConnectionInfo& info) = 0; 52 53 /// Called when a l2cap channel connection is disconnected. 54 /// 55 /// Note you cannot Register or Unregister a delegate in this method. 56 virtual void HandleDisconnectionComplete( 57 const L2capChannelConnectionInfo& info) = 0; 58 }; 59 60 } // namespace pw::bluetooth::proxy 61