• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 <cstdint>
20 #include <fstream>
21 
22 #include "device.h"
23 
24 namespace rootcanal {
25 
26 namespace bredr_bb {
27 namespace {
28 class BaseBandPacketBuilder;
29 }
30 }  // namespace bredr_bb
31 
32 using ::bluetooth::hci::Address;
33 
34 class BaseBandSniffer : public Device {
35  public:
36   BaseBandSniffer(const std::string& filename);
37   ~BaseBandSniffer() = default;
38 
Create(const std::string & filename)39   static std::shared_ptr<BaseBandSniffer> Create(const std::string& filename) {
40     return std::make_shared<BaseBandSniffer>(filename);
41   }
42 
43   // Return a string representation of the type of device.
GetTypeString()44   virtual std::string GetTypeString() const override {
45     return "baseband_sniffer";
46   }
47 
48   virtual void ReceiveLinkLayerPacket(
49       model::packets::LinkLayerPacketView packet, Phy::Type type,
50       int8_t rssi) override;
51 
52  private:
53   void AppendRecord(std::unique_ptr<bredr_bb::BaseBandPacketBuilder> packet);
54   std::ofstream output_;
55 };
56 
57 }  // namespace rootcanal
58