in case of unknown ICMP reply type, consume data instead of returning failure in...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 18 Mar 2015 10:45:07 +0000 (11:45 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 18 Mar 2015 10:45:07 +0000 (11:45 +0100)
src/icmp/icmpdata.h
src/icmp/icmppacket.cpp

index 7e92f64..f53f160 100644 (file)
@@ -42,6 +42,8 @@ class IcmpData
 public:
     IcmpData();
 
+    IcmpData(const std::size_t size_arg);
+
     virtual ~IcmpData() {};
 
     virtual bool match_echo_reply(const uint16_t identifier,
@@ -75,9 +77,6 @@ public:
 
 protected:
 
-    // called by subclasses
-    IcmpData(const std::size_t size_arg);
-
     std::size_t size;
     MessagePayload raw_data;
 };
index 95bb8a4..b90f481 100644 (file)
@@ -213,7 +213,12 @@ IcmpPacket::ReadReturnCode IcmpPacket::read( std::istream &is )
             icmp_data_ptr.reset( new IcmpDestinationUnreachableData(
                                        static_cast<std::size_t>(data_length)) );
         else
-            return ReadReturnCode_UNKNOWN_ICMP_TYPE;
+        {   // unspecified icmp data type, will consume right amount of data
+            //   from stream but return false for match_echo_request and
+            //   match_destination_unreachable 
+            icmp_data_ptr.reset( new IcmpData(
+                                       static_cast<std::size_t>(data_length)) );
+        }
         icmp_data_ptr->read( is );
     }