src/node/node.cc
changeset 3016 f77acbb9f7b4
parent 2965 4b28e9740e3b
child 3380 38b8549b1ad3
child 3435 1d704c128f1f
--- a/src/node/node.cc	Tue May 13 01:04:42 2008 +0100
+++ b/src/node/node.cc	Wed May 14 18:15:26 2008 +0100
@@ -186,6 +186,11 @@
                          uint16_t protocol, const Address &from)
 {
   bool found = false;
+  // if there are (potentially) multiple handlers, we need to copy the
+  // packet before passing it to each handler, because handlers may
+  // modify it.
+  bool copyNeeded = (m_handlers.size () > 1);
+
   for (ProtocolHandlerList::iterator i = m_handlers.begin ();
        i != m_handlers.end (); i++)
     {
@@ -195,7 +200,7 @@
           if (i->protocol == 0 || 
               i->protocol == protocol)
             {
-              i->handler (device, packet, protocol, from);
+              i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from);
               found = true;
             }
         }