diff -r dacc57c5d31f src/devices/bridge/bridge-net-device.cc --- a/src/devices/bridge/bridge-net-device.cc Thu Aug 07 10:13:54 2008 -0700 +++ b/src/devices/bridge/bridge-net-device.cc Thu Aug 07 10:47:53 2008 -0700 @@ -59,7 +59,7 @@ BridgeNetDevice::BridgeNetDevice () } void -BridgeNetDevice::ReceiveFromDevice (Ptr incomingPort, Ptr packet, uint16_t protocol, +BridgeNetDevice::ReceiveFromDevice (Ptr incomingPort, Ptr packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType) { NS_LOG_FUNCTION_NOARGS (); @@ -95,7 +95,7 @@ BridgeNetDevice::ReceiveFromDevice (Ptr< } void -BridgeNetDevice::ForwardUnicast (Ptr incomingPort, Ptr packet, +BridgeNetDevice::ForwardUnicast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst) { NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName () @@ -128,7 +128,7 @@ BridgeNetDevice::ForwardUnicast (Ptr incomingPort, Ptr packet, +BridgeNetDevice::ForwardBroadcast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst) { NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName () diff -r dacc57c5d31f src/devices/bridge/bridge-net-device.h --- a/src/devices/bridge/bridge-net-device.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/devices/bridge/bridge-net-device.h Thu Aug 07 10:47:53 2008 -0700 @@ -72,11 +72,11 @@ protected: protected: virtual void DoDispose (void); - void ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, + void ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType); - void ForwardUnicast (Ptr incomingPort, Ptr packet, + void ForwardUnicast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst); - void ForwardBroadcast (Ptr incomingPort, Ptr packet, + void ForwardBroadcast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst); void Learn (Mac48Address source, Ptr port); Ptr GetLearnedState (Mac48Address source); diff -r dacc57c5d31f src/internet-stack/arp-l3-protocol.cc --- a/src/internet-stack/arp-l3-protocol.cc Thu Aug 07 10:13:54 2008 -0700 +++ b/src/internet-stack/arp-l3-protocol.cc Thu Aug 07 10:47:53 2008 -0700 @@ -117,10 +117,12 @@ ArpL3Protocol::FindCache (Ptr } void -ArpL3Protocol::Receive(Ptr device, Ptr packet, uint16_t protocol, const Address &from, +ArpL3Protocol::Receive(Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION_NOARGS (); + + Ptr packet = p->Copy (); Ptr cache = FindCache (device); ArpHeader arp; diff -r dacc57c5d31f src/internet-stack/arp-l3-protocol.h --- a/src/internet-stack/arp-l3-protocol.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/internet-stack/arp-l3-protocol.h Thu Aug 07 10:47:53 2008 -0700 @@ -54,7 +54,7 @@ public: /** * \brief Receive a packet */ - void Receive(Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, + void Receive(Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); /** * \brief Perform an ARP lookup diff -r dacc57c5d31f src/internet-stack/ipv4-l3-protocol.cc --- a/src/internet-stack/ipv4-l3-protocol.cc Thu Aug 07 10:13:54 2008 -0700 +++ b/src/internet-stack/ipv4-l3-protocol.cc Thu Aug 07 10:47:53 2008 -0700 @@ -449,12 +449,14 @@ Ipv4L3Protocol::FindInterfaceForDevice ( } void -Ipv4L3Protocol::Receive( Ptr device, Ptr packet, uint16_t protocol, const Address &from, +Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { - NS_LOG_FUNCTION (this << &device << packet << protocol << from); + NS_LOG_FUNCTION (this << &device << p << protocol << from); NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); + + Ptr packet = p->Copy (); uint32_t index = 0; Ptr ipv4Interface; diff -r dacc57c5d31f src/internet-stack/ipv4-l3-protocol.h --- a/src/internet-stack/ipv4-l3-protocol.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/internet-stack/ipv4-l3-protocol.h Thu Aug 07 10:47:53 2008 -0700 @@ -83,7 +83,7 @@ public: * - implement a per-NetDevice ARP cache * - send back arp replies on the right device */ - void Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, + void Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); /** diff -r dacc57c5d31f src/node/net-device.h --- a/src/node/net-device.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/node/net-device.h Thu Aug 07 10:47:53 2008 -0700 @@ -274,7 +274,7 @@ public: * \returns true if the callback could handle the packet successfully, false * otherwise. */ - typedef Callback,Ptr,uint16_t,const Address &> ReceiveCallback; + typedef Callback,Ptr,uint16_t,const Address &> ReceiveCallback; /** * \param cb callback to invoke whenever a packet has been received and must @@ -296,7 +296,7 @@ public: * \returns true if the callback could handle the packet successfully, false * otherwise. */ - typedef Callback< bool, Ptr, Ptr, uint16_t, + typedef Callback< bool, Ptr, Ptr, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback; /** diff -r dacc57c5d31f src/node/node.cc --- a/src/node/node.cc Thu Aug 07 10:13:54 2008 -0700 +++ b/src/node/node.cc Thu Aug 07 10:47:53 2008 -0700 @@ -222,7 +222,7 @@ Node::UnregisterProtocolHandler (Protoco } bool -Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, +Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION(device->GetName ()); @@ -230,7 +230,7 @@ Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, +Node::NonPromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from) { NS_LOG_FUNCTION(device->GetName ()); @@ -238,15 +238,11 @@ Node::NonPromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, +Node::ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous) { NS_LOG_FUNCTION(device->GetName ()); 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++) @@ -259,7 +255,7 @@ Node::ReceiveFromDevice (Ptr { if (promiscuous == i->promiscuous) { - i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType); + i->handler (device, packet->Copy (), protocol, from, to, packetType); found = true; } } diff -r dacc57c5d31f src/node/node.h --- a/src/node/node.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/node/node.h Thu Aug 07 10:47:53 2008 -0700 @@ -145,7 +145,7 @@ public: * this value is only valid for promiscuous mode * protocol handlers. */ - typedef Callback, Ptr,uint16_t,const Address &, + typedef Callback, Ptr,uint16_t,const Address &, const Address &, NetDevice::PacketType> ProtocolHandler; /** * \param handler the handler to register @@ -189,10 +189,10 @@ private: */ virtual void NotifyDeviceAdded (Ptr device); - bool NonPromiscReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, const Address &from); - bool PromiscReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, + bool NonPromiscReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, const Address &from); + bool PromiscReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); - bool ReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, + bool ReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc); void Construct (void); diff -r dacc57c5d31f src/node/packet-socket.cc --- a/src/node/packet-socket.cc Thu Aug 07 10:13:54 2008 -0700 +++ b/src/node/packet-socket.cc Thu Aug 07 10:47:53 2008 -0700 @@ -344,7 +344,7 @@ PacketSocket::SendTo (Ptr p, uin } void -PacketSocket::ForwardUp (Ptr device, Ptr packet, +PacketSocket::ForwardUp (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { @@ -369,7 +369,7 @@ PacketSocket::ForwardUp (Ptr SocketAddressTag tag; tag.SetAddress (address); packet->AddTag (tag); - m_deliveryQueue.push (packet); + m_deliveryQueue.push (packet->Copy ()); m_rxAvailable += packet->GetSize (); NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this); NotifyDataRecv (); diff -r dacc57c5d31f src/node/packet-socket.h --- a/src/node/packet-socket.h Thu Aug 07 10:13:54 2008 -0700 +++ b/src/node/packet-socket.h Thu Aug 07 10:47:53 2008 -0700 @@ -103,7 +103,7 @@ public: Address &fromAddress); private: - void ForwardUp (Ptr device, Ptr packet, + void ForwardUp (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType); int DoBind (const PacketSocketAddress &address);