ptrkrysik | 82bd117 | 2015-01-15 09:35:03 +0100 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
| 2 | /* @file |
| 3 | * @author Piotr Krysik <ptrkrysik@gmail.com> |
| 4 | * @section LICENSE |
| 5 | * |
| 6 | * Gr-gsm is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3, or (at your option) |
| 9 | * any later version. |
| 10 | * |
| 11 | * Gr-gsm is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with gr-gsm; see the file COPYING. If not, write to |
| 18 | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" |
| 25 | #endif |
| 26 | |
| 27 | #include <gnuradio/io_signature.h> |
| 28 | #include "tmsi_dumper_impl.h" |
ptrkrysik | 258bbb8 | 2015-01-15 11:31:47 +0100 | [diff] [blame] | 29 | #include "grgsm/gsmtap.h" |
| 30 | #include <stdio.h> |
ptrkrysik | 82bd117 | 2015-01-15 09:35:03 +0100 | [diff] [blame] | 31 | |
| 32 | namespace gr { |
| 33 | namespace gsm { |
ptrkrysik | 258bbb8 | 2015-01-15 11:31:47 +0100 | [diff] [blame] | 34 | |
| 35 | void tmsi_dumper_impl::dump_tmsi(pmt::pmt_t msg) |
| 36 | { |
| 37 | pmt::pmt_t message_plus_header_blob = pmt::cdr(msg); |
| 38 | uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob); |
| 39 | size_t message_plus_header_len=pmt::blob_length(message_plus_header_blob); |
| 40 | |
| 41 | gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header; |
| 42 | |
| 43 | for(int ii=sizeof(gsmtap_hdr); ii<message_plus_header_len; ii++) |
| 44 | { |
| 45 | printf(" %02x", message_plus_header[ii]); |
| 46 | } |
| 47 | std::cout << std::endl; |
| 48 | } |
| 49 | |
ptrkrysik | 82bd117 | 2015-01-15 09:35:03 +0100 | [diff] [blame] | 50 | tmsi_dumper::sptr |
| 51 | tmsi_dumper::make() |
| 52 | { |
| 53 | return gnuradio::get_initial_sptr |
| 54 | (new tmsi_dumper_impl()); |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * The private constructor |
| 59 | */ |
| 60 | tmsi_dumper_impl::tmsi_dumper_impl() |
| 61 | : gr::block("tmsi_dumper", |
ptrkrysik | 9162922 | 2015-01-15 10:28:14 +0100 | [diff] [blame] | 62 | gr::io_signature::make(0, 0, 0), |
| 63 | gr::io_signature::make(0, 0, 0)) |
ptrkrysik | 258bbb8 | 2015-01-15 11:31:47 +0100 | [diff] [blame] | 64 | { |
| 65 | message_port_register_in(pmt::mp("msgs")); |
| 66 | set_msg_handler(pmt::mp("msgs"), boost::bind(&tmsi_dumper_impl::dump_tmsi, this, _1)); |
| 67 | } |
ptrkrysik | 82bd117 | 2015-01-15 09:35:03 +0100 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * Our virtual destructor. |
| 71 | */ |
| 72 | tmsi_dumper_impl::~tmsi_dumper_impl() |
| 73 | { |
| 74 | } |
ptrkrysik | 82bd117 | 2015-01-15 09:35:03 +0100 | [diff] [blame] | 75 | } /* namespace gsm */ |
| 76 | } /* namespace gr */ |
| 77 | |