GNU Radio's FOOT Package
multi_sniffer_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013 Christopher D. Kilgour
4  * Copyright 2008, 2009 Dominic Spill, Michael Ossmann
5  * Copyright 2007 Dominic Spill
6  * Copyright 2005, 2006 Free Software Foundation, Inc.
7  *
8  * This file is part of gr-bluetooth
9  *
10  * This is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2, or (at your option)
13  * any later version.
14  *
15  * This software is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this software; see the file COPYING. If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street,
23  * Boston, MA 02110-1301, USA.
24  */
25 
26 #ifndef INCLUDED_BLUETOOTH_GR_BLUETOOTH_MULTI_SNIFFER_IMPL_H
27 #define INCLUDED_BLUETOOTH_GR_BLUETOOTH_MULTI_SNIFFER_IMPL_H
28 
30 #include "gr_bluetooth/packet.h"
31 #include "gr_bluetooth/piconet.h"
32 #include "tun.h"
33 #include <map>
34 
35 namespace gr {
36  namespace bluetooth {
37 
38  class multi_sniffer_impl : virtual public multi_sniffer
39  {
40  private:
41  /* General Inquiry and Limited Inquiry Access Codes */
42  static const uint32_t GIAC = 0x9E8B33;
43  static const uint32_t LIAC = 0x9E8B00;
44 
45  /* Using tun for output */
46  bool d_tun;
47 
48  /* Tun stuff */
49  int d_tunfd;
50  char d_chan_name[20];
51  unsigned char d_ether_addr[ETH_ALEN];
52  static const unsigned short ETHER_TYPE = 0xFFF0;
53 
54  /* the piconets we are monitoring */
55  std::map<int, basic_rate_piconet::sptr> d_basic_rate_piconets;
56  std::map<uint32_t, low_energy_piconet::sptr> d_low_energy_piconets;
57 
58  /* handle AC */
59  void ac(char *symbols, int len, double freq, double snr);
60 
61  /* handle AA */
62  void aa(char *symbols, int len, double freq, double snr);
63 
64  /* handle ID packet (no header) */
65  void id(uint32_t lap);
66 
67  /* decode packets with headers */
69  bool first_run);
70  void decode(le_packet::sptr pkt, low_energy_piconet::sptr pn);
71 
72  /* work on UAP/CLK1-6 discovery */
73  void discover(classic_packet::sptr pkt, basic_rate_piconet::sptr pn);
74  void discover(le_packet::sptr pkt, low_energy_piconet::sptr pn);
75 
76  /* decode stored packets */
77  void recall(basic_rate_piconet::sptr pn);
78  void recall(low_energy_piconet::sptr pn);
79 
80  /* pull information out of FHS packet */
81  void fhs(classic_packet::sptr pkt);
82 
83  public:
84  multi_sniffer_impl(double sample_rate, double center_freq, double squelch_threshold, bool tun);
86 
87  // Where all the action really happens
88  int work(int noutput_items,
89  gr_vector_const_void_star& input_items,
90  gr_vector_void_star& output_items);
91  };
92 
93  } // namespace bluetooth
94 } // namespace gr
95 
96 #endif /* INCLUDED_BLUETOOTH_GR_BLUETOOTH_MULTI_SNIFFER_IMPL_H */
97 
<+description of block+>
Definition: multi_sniffer.h:41
boost::shared_ptr< classic_packet > sptr
Definition: packet.h:169
boost::shared_ptr< basic_rate_piconet > sptr
Definition: piconet.h:70
multi_sniffer_impl(double sample_rate, double center_freq, double squelch_threshold, bool tun)
boost::shared_ptr< low_energy_piconet > sptr
Definition: piconet.h:130
Definition: multi_block.h:33
Definition: multi_sniffer_impl.h:38
boost::shared_ptr< le_packet > sptr
Definition: packet.h:298
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)