Implemented message source block for unit testing
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt
index caf2660..d42bff8 100644
--- a/grc/CMakeLists.txt
+++ b/grc/CMakeLists.txt
@@ -23,6 +23,5 @@
 add_subdirectory(receiver)
 add_subdirectory(misc_utils)
 install(FILES
-    gsm_block_tree.xml
-    DESTINATION share/gnuradio/grc/blocks
+    gsm_block_tree.xml DESTINATION share/gnuradio/grc/blocks
 )
diff --git a/grc/gsm_block_tree.xml b/grc/gsm_block_tree.xml
index 2503710..5837ce2 100644
--- a/grc/gsm_block_tree.xml
+++ b/grc/gsm_block_tree.xml
@@ -51,6 +51,7 @@
       <block>gsm_message_printer</block>
       <block>gsm_clock_offset_corrector</block>
       <block>gsm_tmsi_dumper</block>
+      <block>gsm_message_source</block>
     </cat>
   </cat>
 </cat>
diff --git a/grc/misc_utils/CMakeLists.txt b/grc/misc_utils/CMakeLists.txt
index 5a3f874..403a321 100644
--- a/grc/misc_utils/CMakeLists.txt
+++ b/grc/misc_utils/CMakeLists.txt
@@ -29,5 +29,6 @@
     gsm_burst_sink.xml
     gsm_burst_source.xml
     gsm_burst_source_qa.xml
-    gsm_burst_sink_qa.xml DESTINATION share/gnuradio/grc/blocks
+    gsm_burst_sink_qa.xml 
+    gsm_message_source.xml DESTINATION share/gnuradio/grc/blocks
 )
diff --git a/grc/misc_utils/gsm_message_source.xml b/grc/misc_utils/gsm_message_source.xml
new file mode 100644
index 0000000..ab06f65
--- /dev/null
+++ b/grc/misc_utils/gsm_message_source.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<block>
+  <name>Message Source</name>
+  <key>gsm_message_source</key>
+  <import>import grgsm</import>
+  <make>grgsm.message_source($messages)</make>
+
+  <param>
+    <name>Messages</name>
+    <key>messages</key>
+    <value>["02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
+"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
+"02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00",
+"02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"]</value>
+    <type>raw</type>
+    <hide>true</hide>
+  </param>
+
+  <source>
+    <name>msgs</name>
+    <type>message</type>
+  </source>
+
+  <doc>
+This block is a basic message source for testing purposes.
+
+It takes a list of strings as input, where each string
+is a whitespace-separated list of hexadecimal values representing the data bytes of a message including the gsmtap header.
+
+Such strings can be obtained using the message printer with option "Print GSMTap header"
+  </doc>
+</block>
diff --git a/include/grgsm/misc_utils/CMakeLists.txt b/include/grgsm/misc_utils/CMakeLists.txt
index 8b74fc7..000b7ef 100644
--- a/include/grgsm/misc_utils/CMakeLists.txt
+++ b/include/grgsm/misc_utils/CMakeLists.txt
@@ -31,5 +31,6 @@
     controlled_rotator_cc.h
     controlled_const_source_f.h
     message_printer.h 
-    tmsi_dumper.h DESTINATION include/grgsm/misc_utils
+    tmsi_dumper.h 
+    message_source.h DESTINATION include/grgsm/misc_utils
 )
diff --git a/include/grgsm/misc_utils/message_source.h b/include/grgsm/misc_utils/message_source.h
new file mode 100644
index 0000000..5c3e8a1
--- /dev/null
+++ b/include/grgsm/misc_utils/message_source.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Roman Khassraf <rkhassraf@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gr-gsm; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#ifndef INCLUDED_GSM_MESSAGE_SOURCE_H
+#define INCLUDED_GSM_MESSAGE_SOURCE_H
+
+#include <grgsm/api.h>
+#include <gnuradio/block.h>
+
+namespace gr {
+  namespace gsm {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup gsm
+     *
+     */
+    class GSM_API message_source : virtual public gr::block
+    {
+     public:
+      typedef boost::shared_ptr<message_source> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of grgsm::message_source.
+       *
+       * To avoid accidental use of raw pointers, grgsm::message_source's
+       * constructor is in a private implementation
+       * class. grgsm::message_source::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make(const std::vector<std::string> &msg_data);
+
+      virtual void set_msg_data(const std::vector<std::string> &msg_data) = 0;
+    };
+
+  } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_MESSAGE_SOURCE_H */
+
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 61f0858..d66de3d 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -54,7 +54,8 @@
     misc_utils/burst_source_impl.cc
     misc_utils/burst_sink_qa_impl.cc
     misc_utils/burst_source_qa_impl.cc
-    decryption/decryption_impl.cc )
+    misc_utils/message_source_impl.cc 
+    decryption/decryption_impl.cc)
 
 add_library(gnuradio-grgsm SHARED ${grgsm_sources})
 target_link_libraries(gnuradio-grgsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES}
diff --git a/lib/misc_utils/message_source_impl.cc b/lib/misc_utils/message_source_impl.cc
new file mode 100644
index 0000000..de24968
--- /dev/null
+++ b/lib/misc_utils/message_source_impl.cc
@@ -0,0 +1,131 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Roman Khassraf <rkhassraf@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gr-gsm; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include "message_source_impl.h"
+#include "stdio.h"
+#include <grgsm/gsmtap.h>
+#include <grgsm/endian.h>
+#include <algorithm>
+
+#include <iostream>
+#include <string>
+#include <sstream>
+
+#define MSG_BYTE_LEN 39
+
+
+namespace gr {
+  namespace gsm {
+
+    message_source::sptr
+    message_source::make(const std::vector<std::string> &msg_data)
+    {
+      return gnuradio::get_initial_sptr
+        (new message_source_impl(msg_data));
+    }
+
+    /*
+     * The private constructor
+     */
+    message_source_impl::message_source_impl(const std::vector<std::string> &msg_data)
+      : gr::block("message_source",
+              gr::io_signature::make(0, 0, 0),
+              gr::io_signature::make(0, 0, 0)),
+              d_finished(false)
+    {
+        message_port_register_out(pmt::mp("msgs"));
+        set_msg_data(msg_data);
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    message_source_impl::~message_source_impl()
+    {
+        if (d_finished == false){
+            d_finished = true;
+        }
+    }
+
+    void message_source_impl::set_msg_data(const std::vector<std::string> &msg_data)
+    {
+        for (int i=0; i<msg_data.size(); i++)
+        {
+            std::istringstream iss(msg_data[i]);
+            std::vector<uint8_t> bytes;
+            unsigned int c;
+
+            while (iss >> std::hex >> c)
+            {
+                if (c < 256)
+                {
+                    bytes.push_back(c);
+                }
+            }
+
+            if (bytes.size() == MSG_BYTE_LEN)
+            {
+                d_msgs.push_back(bytes);
+            }
+        }
+    }
+
+    bool message_source_impl::start()
+    {
+        d_finished = false;
+        d_thread = boost::shared_ptr<gr::thread::thread>
+            (new gr::thread::thread(boost::bind(&message_source_impl::run, this)));
+        return block::start();
+    }
+
+    bool message_source_impl::stop()
+    {
+        d_finished = true;
+        d_thread->interrupt();
+        d_thread->join();
+        return block::stop();
+    }
+
+    bool message_source_impl::finished()
+    {
+        return d_finished;
+    }
+
+    void message_source_impl::run()
+    {
+        for (int i=0; i<d_msgs.size(); i++)
+        {
+            std::vector<uint8_t> current = d_msgs[i];
+            pmt::pmt_t blob_header_plus_burst = pmt::make_blob(&current[0], current.size());
+            pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob_header_plus_burst);
+            message_port_pub(pmt::mp("msgs"), msg);
+        }
+        post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1)));
+    }
+  } /* namespace gsm */
+} /* namespace gr */
+
diff --git a/lib/misc_utils/message_source_impl.h b/lib/misc_utils/message_source_impl.h
new file mode 100644
index 0000000..22a210e
--- /dev/null
+++ b/lib/misc_utils/message_source_impl.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Roman Khassraf <rkhassraf@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gr-gsm; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H
+#define INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H
+
+#include <grgsm/misc_utils/message_source.h>
+
+namespace gr {
+  namespace gsm {
+
+    class message_source_impl : public message_source
+    {
+     private:
+        boost::shared_ptr<gr::thread::thread> d_thread;
+        std::vector<std::vector<uint8_t> > d_msgs;
+        bool d_finished;
+        void run();
+     public:
+      message_source_impl(const std::vector<std::string> &msg_data);
+      ~message_source_impl();
+      virtual void set_msg_data(const std::vector<std::string> &msg_data);
+      bool start();
+      bool stop();
+      bool finished();
+    };
+
+  } // namespace grgsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_MESSAGE_SOURCE_IMPL_H */
+
diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i
index 5dc1bcd..6189fee 100644
--- a/swig/grgsm_swig.i
+++ b/swig/grgsm_swig.i
@@ -27,6 +27,7 @@
 #include "grgsm/misc_utils/burst_sink_qa.h"
 #include "grgsm/misc_utils/burst_source.h"
 #include "grgsm/misc_utils/burst_source_qa.h"
+#include "grgsm/misc_utils/message_source.h"
 %}
 
 
@@ -72,3 +73,5 @@
 GR_SWIG_BLOCK_MAGIC2(gsm, message_printer);
 %include "grgsm/misc_utils/tmsi_dumper.h"
 GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper);
+%include "grgsm/misc_utils/message_source.h"
+GR_SWIG_BLOCK_MAGIC2(gsm, message_source);