made nicer static variables of packet dump mode and location
[pingcheck] / src / tools / feed_packet_data.cpp
index d11ab10..5a0733d 100644 (file)
@@ -67,8 +67,7 @@ void increase_verbosity()
  * @returns positive error code or negated number of packets created
  */
 int read_packets( std::istream &input_stream, const bool is_icmp,
-                                              const bool is_v4,
-                                              const int dump_mode )
+                                              const bool is_v4)
 {
     // peek at start of stream to see if there is a pcap header
     bool is_pcap = check_for_pcap_header(input_stream);
@@ -126,14 +125,14 @@ int read_packets( std::istream &input_stream, const bool is_icmp,
                 GlobalLogger.info() << "Trying to read ICMP v4 packet"
                                     << std::endl;
                 packet = IcmpPacketFactory::create_icmp_packet(
-                        boost::asio::ip::icmp::v4(), input_stream, dump_mode);
+                                     boost::asio::ip::icmp::v4(), input_stream);
             }
             else  // v6
             {
                 GlobalLogger.info() << "Trying to read ICMP v6 packet"
                                     << std::endl;
                 packet = IcmpPacketFactory::create_icmp_packet(
-                        boost::asio::ip::icmp::v6(), input_stream, dump_mode);
+                                     boost::asio::ip::icmp::v6(), input_stream);
             }
 
             if (packet)
@@ -235,7 +234,7 @@ int main(int argc, char *argv[])
     int current_return, return_val = 0;
     int packet_count_good = 0;
     int packet_count_bad = 0;
-    int dump_mode = 0;  // never dump
+    DumpMode dump_mode = DUMP_NEVER;
 
     if (argc == 1)
     {
@@ -246,6 +245,8 @@ int main(int argc, char *argv[])
         return 1;
     }
 
+    IcmpPacketFactory::PacketDumpMode = dump_mode;
+
     // convert arguments to vector of strings and loop over them
     std::vector<std::string> args(argv+1, argv + argc);
     BOOST_FOREACH (const std::string &arg, args)
@@ -267,7 +268,7 @@ int main(int argc, char *argv[])
         else if (arg == "--")   // read input from stdin
         {
             GlobalLogger.info() << "Trying to read from stdin" << std::endl;
-            current_return = read_packets(std::cin, is_icmp, is_v4, dump_mode);
+            current_return = read_packets(std::cin, is_icmp, is_v4);
         }
         else   // assume is file name
         {
@@ -283,8 +284,7 @@ int main(int argc, char *argv[])
             }
             else
             {
-                current_return = read_packets( file_stream, is_icmp, is_v4,
-                                               dump_mode);
+                current_return = read_packets( file_stream, is_icmp, is_v4);
                 file_stream.close();
             }
         }