summaryrefslogtreecommitdiff
path: root/system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager.h
blob: 22b529185d0f5e08f7539cc1b864278b55c2d651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Authors: corbin.souffrant@leviathansecurity.com
//          dylan.katz@leviathansecurity.com

#pragma once

#include <gd/l2cap/classic/dynamic_channel_service.h>
#include <gd/l2cap/classic/internal/dynamic_channel_service_impl.h>
#include <gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.h>
#include <memory>

#include "hci/address.h"
#include "l2cap/classic/dynamic_channel_configuration_option.h"
#include "l2cap/classic/dynamic_channel_manager.h"
#include "l2cap/classic/security_policy.h"
#include "l2cap/psm.h"
#include "os/handler.h"

#include "fuzz_dynamic_channel_manager_impl.h"

namespace bluetooth {
namespace shim {
namespace {
class FuzzDynamicChannelManager : public l2cap::classic::DynamicChannelManager {
 public:
  void ConnectChannel(
      hci::Address device,
      l2cap::classic::DynamicChannelConfigurationOption configuration_option,
      l2cap::Psm psm,
      l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback,
      l2cap::classic::DynamicChannelManager::OnConnectionFailureCallback on_fail_callback) override {
    impl_.ConnectChannel(device, configuration_option, psm, std::move(on_open_callback), std::move(on_fail_callback));
  }

  void RegisterService(
      l2cap::Psm psm,
      l2cap::classic::DynamicChannelConfigurationOption configuration_option,
      const l2cap::classic::SecurityPolicy& security_policy,
      l2cap::classic::DynamicChannelManager::OnRegistrationCompleteCallback on_registration_complete,
      l2cap::classic::DynamicChannelManager::OnConnectionOpenCallback on_open_callback) override {
    impl_.RegisterService(
        psm, configuration_option, security_policy, std::move(on_registration_complete), std::move(on_open_callback));
  }
  FuzzDynamicChannelManager(FuzzDynamicChannelManagerImpl& impl) : impl_(impl) {}
  FuzzDynamicChannelManagerImpl& impl_;
};
}  // namespace
}  // namespace shim
}  // namespace bluetooth