diff --git a/src/devices/bridge/bridge-net-device.cc b/src/devices/bridge/bridge-net-device.cc index 03401e561..88709fd68 100644 --- a/src/devices/bridge/bridge-net-device.cc +++ b/src/devices/bridge/bridge-net-device.cc @@ -57,8 +57,8 @@ BridgeNetDevice::BridgeNetDevice () {} void -BridgeNetDevice::PromiscReceive (Ptr incomingPort, Ptr packet, uint16_t protocol, - Address const &src, Address const &dst, bool forMe) +BridgeNetDevice::ReceiveFromDevice (Ptr incomingPort, Ptr packet, uint16_t protocol, + Address const &src, Address const &dst, PacketType packetType) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_DEBUG ("UID is " << packet->GetUid ()); @@ -66,61 +66,25 @@ BridgeNetDevice::PromiscReceive (Ptr incomingPort, Ptr packet Mac48Address src48 = Mac48Address::ConvertFrom (src); Mac48Address dst48 = Mac48Address::ConvertFrom (dst); -// -// We never forward up packets that we sent. Real devices don't do this since -// their receivers are disabled during send, so we don't. Drop the packet -// silently (no tracing) since it would really never get here in a real device. -// - if (src48 == m_address) + + switch (packetType) { - NS_LOG_LOGIC ("Ignoring packet sourced by this device"); - return; - } + case PACKET_HOST: + if (dst48 == m_address) + { + m_rxCallback (this, packet, protocol, src, dst, packetType); + } + break; -// -// An IP host group address is mapped to an Ethernet multicast address -// by placing the low-order 23-bits of the IP address into the low-order -// 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex). -// -// We are going to receive all packets destined to any multicast address, -// which means clearing the low-order 23 bits the header destination -// - Mac48Address mcDest; - uint8_t mcBuf[6]; - - dst48.CopyTo (mcBuf); - mcBuf[3] &= 0x80; - mcBuf[4] = 0; - mcBuf[5] = 0; - mcDest.CopyFrom (mcBuf); - - Mac48Address multicast = Mac48Address::ConvertFrom (GetMulticast ()); - Mac48Address broadcast = Mac48Address::ConvertFrom (GetBroadcast ()); - - // decide whether this node should receive the packet for itself - - NS_LOG_DEBUG ("incomingPort: " << incomingPort->GetName () - << "; my address: " << m_address - << "; broadcast: " << broadcast - << "; dst48: " << dst48); - - if ((dst48 == broadcast) || - (mcDest == multicast) || - (dst48 == m_address)) - { - m_rxCallback (this, packet, protocol, src); - // m_rxTrace (originalPacket); - } - - // decide whether the packet should be forwarded - if ((dst48 == broadcast) || - (mcDest == multicast)) - { + case PACKET_BROADCAST: + case PACKET_MULTICAST: + m_rxCallback (this, packet, protocol, src, dst, packetType); ForwardBroadcast (incomingPort, packet, protocol, src48, dst48); - } - else if (dst48 != m_address) - { + break; + + case PACKET_OTHERHOST: ForwardUnicast (incomingPort, packet, protocol, src48, dst48); + break; } } @@ -221,8 +185,8 @@ BridgeNetDevice::AddBridgePort (Ptr bridgePort) m_address = Mac48Address::ConvertFrom (bridgePort->GetAddress ()); } - m_node->RegisterPromiscuousProtocolHandler (MakeCallback (&BridgeNetDevice::PromiscReceive, this), - 0, bridgePort); + m_node->RegisterProtocolHandler (MakeCallback (&BridgeNetDevice::ReceiveFromDevice, this), + 0, bridgePort); m_ports.push_back (bridgePort); } @@ -430,13 +394,6 @@ BridgeNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) } -void -BridgeNetDevice::SetPromiscuousReceiveCallback (NetDevice::PromiscuousReceiveCallback cb) -{ - m_promiscRxCallback = cb; -} - - void BridgeNetDevice::DoDispose (void) { diff --git a/src/devices/bridge/bridge-net-device.h b/src/devices/bridge/bridge-net-device.h index d316555e6..025624586 100644 --- a/src/devices/bridge/bridge-net-device.h +++ b/src/devices/bridge/bridge-net-device.h @@ -65,13 +65,12 @@ public: virtual void SetNode (Ptr node); virtual bool NeedsArp (void) const; virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb); protected: virtual void DoDispose (void); - void PromiscReceive (Ptr device, Ptr packet, uint16_t protocol, - Address const &source, Address const &destination, bool forMe); + void ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, + Address const &source, Address const &destination, PacketType packetType); void ForwardUnicast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst); void ForwardBroadcast (Ptr incomingPort, Ptr packet, @@ -81,7 +80,6 @@ protected: private: NetDevice::ReceiveCallback m_rxCallback; - NetDevice::PromiscuousReceiveCallback m_promiscRxCallback; Mac48Address m_address; Time m_expirationTime; // time it takes for learned MAC state to expire diff --git a/src/devices/csma/csma-net-device.cc b/src/devices/csma/csma-net-device.cc index 77cf52312..b1e8fd317 100644 --- a/src/devices/csma/csma-net-device.cc +++ b/src/devices/csma/csma-net-device.cc @@ -481,8 +481,7 @@ CsmaNetDevice::Receive (Ptr packet, Ptr senderDevice) if (m_encapMode == RAW) { m_rxTrace (packet); - m_promiscRxCallback (this, packet->Copy (), 0, GetAddress (), GetBroadcast (), true); - m_rxCallback (this, packet, 0, GetBroadcast ()); + m_rxCallback (this, packet, 0, GetBroadcast (), GetAddress (), PACKET_HOST); return; } @@ -554,19 +553,29 @@ CsmaNetDevice::Receive (Ptr packet, Ptr senderDevice) break; } - if ((header.GetDestination () != broadcast) && - (mcDest != multicast) && - (header.GetDestination () != destination)) + PacketType packetType; + + if (header.GetDestination () == broadcast) { - NS_LOG_LOGIC ("Not for me: promisc rx, then dropping pkt "); - m_promiscRxCallback (this, packet->Copy (), protocol, header.GetSource (), header.GetDestination (), false); - m_dropTrace (packet); - return; + packetType = PACKET_BROADCAST; + m_rxTrace (originalPacket); } - - m_promiscRxCallback (this, packet->Copy (), protocol, header.GetSource (), header.GetDestination (), true); - m_rxTrace (originalPacket); - m_rxCallback (this, packet, protocol, header.GetSource ()); + else if (mcDest == multicast) + { + packetType = PACKET_MULTICAST; + m_rxTrace (originalPacket); + } + else if (header.GetDestination () == destination) + { + packetType = PACKET_HOST; + m_rxTrace (originalPacket); + } + else + { + packetType = PACKET_OTHERHOST; + } + + m_rxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType); } } @@ -838,10 +847,4 @@ CsmaNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) m_rxCallback = cb; } -void -CsmaNetDevice::SetPromiscuousReceiveCallback (NetDevice::PromiscuousReceiveCallback cb) -{ - m_promiscRxCallback = cb; -} - } // namespace ns3 diff --git a/src/devices/csma/csma-net-device.h b/src/devices/csma/csma-net-device.h index bcfc70616..91e66517c 100644 --- a/src/devices/csma/csma-net-device.h +++ b/src/devices/csma/csma-net-device.h @@ -286,7 +286,6 @@ public: * \param cb The callback. */ virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb); protected: /** @@ -535,11 +534,6 @@ private: */ NetDevice::ReceiveCallback m_rxCallback; - /** - * The callback used to notify higher layers that a packet has been received in promiscuous mode. - */ - NetDevice::PromiscuousReceiveCallback m_promiscRxCallback; - /** * The interface index (really net evice index) that has been assigned to * this network device. diff --git a/src/devices/point-to-point/point-to-point-net-device.cc b/src/devices/point-to-point/point-to-point-net-device.cc index bdf424f3d..0ee8376de 100644 --- a/src/devices/point-to-point/point-to-point-net-device.cc +++ b/src/devices/point-to-point/point-to-point-net-device.cc @@ -241,7 +241,7 @@ PointToPointNetDevice::Receive (Ptr packet) // m_rxTrace (packet); ProcessHeader(packet, protocol); - m_rxCallback (this, packet, protocol, GetBroadcast ()); + m_rxCallback (this, packet, protocol, GetBroadcast (), m_address, PACKET_HOST); } } @@ -467,10 +467,4 @@ PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) m_rxCallback = cb; } -void -PointToPointNetDevice::SetPromiscuousReceiveCallback (NetDevice::PromiscuousReceiveCallback cb) -{ - // TODO -} - } // namespace ns3 diff --git a/src/devices/point-to-point/point-to-point-net-device.h b/src/devices/point-to-point/point-to-point-net-device.h index 604e7a625..352050ec4 100644 --- a/src/devices/point-to-point/point-to-point-net-device.h +++ b/src/devices/point-to-point/point-to-point-net-device.h @@ -176,7 +176,6 @@ public: virtual bool NeedsArp (void) const; virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb); private: diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index fd9c0fb09..79672729e 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -310,19 +310,15 @@ WifiNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) m_forwardUp = cb; } -void -WifiNetDevice::SetPromiscuousReceiveCallback (NetDevice::PromiscuousReceiveCallback cb) -{ - // TODO -} - void WifiNetDevice::ForwardUp (Ptr packet, const Mac48Address &from) { m_rxLogger (packet, from); LlcSnapHeader llc; packet->RemoveHeader (llc); - m_forwardUp (this, packet, llc.GetType (), from); + Mac48Address to = from; // FIXME + PacketType packetType = PACKET_HOST; // FIXME + m_forwardUp (this, packet, llc.GetType (), from, to, packetType); } void diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 903538df0..81d9046b3 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -101,7 +101,6 @@ public: virtual void SetNode (Ptr node); virtual bool NeedsArp (void) const; virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb); private: virtual void DoDispose (void); @@ -115,7 +114,7 @@ private: Ptr m_channel; Ptr m_mac; Ptr m_stationManager; - Callback ,Ptr,uint16_t,const Address &> m_forwardUp; + ReceiveCallback m_forwardUp; TracedCallback, Mac48Address> m_rxLogger; TracedCallback, Mac48Address> m_txLogger; uint32_t m_ifIndex; diff --git a/src/internet-stack/arp-l3-protocol.cc b/src/internet-stack/arp-l3-protocol.cc index bd27ce7c6..fa418deac 100644 --- a/src/internet-stack/arp-l3-protocol.cc +++ b/src/internet-stack/arp-l3-protocol.cc @@ -114,9 +114,16 @@ ArpL3Protocol::FindCache (Ptr device) } void -ArpL3Protocol::Receive(Ptr device, Ptr packet, uint16_t protocol, const Address &from) +ArpL3Protocol::Receive(Ptr device, Ptr packet, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION_NOARGS (); + + if (packetType == NetDevice::PACKET_OTHERHOST) + { + return; + } + Ptr cache = FindCache (device); ArpHeader arp; packet->RemoveHeader (arp); diff --git a/src/internet-stack/arp-l3-protocol.h b/src/internet-stack/arp-l3-protocol.h index 6815cdea0..0f131a71b 100644 --- a/src/internet-stack/arp-l3-protocol.h +++ b/src/internet-stack/arp-l3-protocol.h @@ -54,7 +54,8 @@ public: /** * \brief Recieve a packet */ - 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); /** * \brief Perform an ARP lookup * \param p diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index affe814bb..81b023b6e 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -449,10 +449,16 @@ Ipv4L3Protocol::FindInterfaceForDevice (Ptr device) } void -Ipv4L3Protocol::Receive( Ptr device, Ptr packet, uint16_t protocol, const Address &from) +Ipv4L3Protocol::Receive( Ptr device, Ptr packet, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION (this << &device << packet << protocol << from); + if (packetType == NetDevice::PACKET_OTHERHOST) + { + return; + } + NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); uint32_t index = 0; diff --git a/src/internet-stack/ipv4-l3-protocol.h b/src/internet-stack/ipv4-l3-protocol.h index 7b2879aaf..e009d2f43 100644 --- a/src/internet-stack/ipv4-l3-protocol.h +++ b/src/internet-stack/ipv4-l3-protocol.h @@ -25,6 +25,7 @@ #include #include "ns3/ipv4-address.h" #include "ns3/ptr.h" +#include "ns3/net-device.h" #include "ns3/ipv4.h" #include "ns3/traced-callback.h" #include "ns3/ipv4-header.h" @@ -82,7 +83,8 @@ 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); /** * \param packet packet to send diff --git a/src/internet-stack/ipv4-loopback-interface.cc b/src/internet-stack/ipv4-loopback-interface.cc index 088634f04..a87495009 100644 --- a/src/internet-stack/ipv4-loopback-interface.cc +++ b/src/internet-stack/ipv4-loopback-interface.cc @@ -73,7 +73,10 @@ Ipv4LoopbackInterface::SendTo (Ptr packet, Ipv4Address dest) m_node->GetObject (); ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER, - Mac48Address ("ff:ff:ff:ff:ff:ff")); + Mac48Address ("ff:ff:ff:ff:ff:ff"), + Mac48Address ("ff:ff:ff:ff:ff:ff"), + NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here + ); } }//namespace ns3 diff --git a/src/node/net-device.h b/src/node/net-device.h index 66b91de45..b90dd9ab4 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -254,17 +254,28 @@ public: */ virtual bool NeedsArp (void) const = 0; + + /** Packet types */ + enum PacketType + { + PACKET_HOST = 1, /* To us */ + PACKET_BROADCAST, /* To all */ + PACKET_MULTICAST, /* To group */ + PACKET_OTHERHOST, /* To someone else */ + }; + /** * \param device a pointer to the net device which is calling this callback * \param packet the packet received * \param protocol the 16 bit protocol number associated with this packet. * This protocol number is expected to be the same protocol number * given to the Send method by the user on the sender side. - * \param address the address of the sender + * \param sender the address of the sender + * \param receiver the address of the receiver * \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 &,const Address &, PacketType> ReceiveCallback; /** * \param cb callback to invoke whenever a packet has been received and must @@ -273,32 +284,6 @@ public: */ virtual void SetReceiveCallback (ReceiveCallback cb) = 0; - /** - * \param device a pointer to the net device which is calling this callback - * \param packet the packet received - * \param protocol the 16 bit protocol number associated with this packet. - * This protocol number is expected to be the same protocol number - * given to the Send method by the user on the sender side. - * \param sourceAddress source address - * \param destinationAddress destination address - * \param forMe true if the packet is normally picked up also for - * the non-promiscuous callback, false if it is received exclusively - * by the promiscuous callback. - * \returns true if the callback could handle the packet successfully, false - * otherwise. - */ - typedef Callback,Ptr,uint16_t, - const Address &, const Address &, bool> PromiscuousReceiveCallback; - - /** - * \param cb callback to invoke whenever a packet has been received - * in promiscuous mode. Note that PromiscuousReceiveCallback - * handles both packets for the device and packets not for - * it. In that sense, it receives a superset of packets - * received by the normal ReceivedCallback. - */ - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb) = 0; - }; } // namespace ns3 diff --git a/src/node/node.cc b/src/node/node.cc index 3646c8edb..91a996a74 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -96,7 +96,6 @@ Node::AddDevice (Ptr device) device->SetNode (this); device->SetIfIndex(index); device->SetReceiveCallback (MakeCallback (&Node::ReceiveFromDevice, this)); - device->SetPromiscuousReceiveCallback (MakeCallback (&Node::PromiscuousReceiveFromDevice, this)); NotifyDeviceAdded (device); return index; } @@ -182,35 +181,9 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler) } } -void -Node::RegisterPromiscuousProtocolHandler (PromiscuousProtocolHandler handler, - uint16_t protocolType, - Ptr device) -{ - struct Node::PromiscuousProtocolHandlerEntry entry; - entry.handler = handler; - entry.protocol = protocolType; - entry.device = device; - m_promiscuousHandlers.push_back (entry); -} - -void -Node::UnregisterPromiscuousProtocolHandler (PromiscuousProtocolHandler handler) -{ - for (PromiscuousProtocolHandlerList::iterator i = m_promiscuousHandlers.begin (); - i != m_promiscuousHandlers.end (); i++) - { - if (i->handler.IsEqual (handler)) - { - m_promiscuousHandlers.erase (i); - break; - } - } -} - bool -Node::ReceiveFromDevice (Ptr device, Ptr packet, - uint16_t protocol, const Address &from) +Node::ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, + const Address &from, const Address &to, NetDevice::PacketType packetType) { bool found = false; // if there are (potentially) multiple handlers, we need to copy the @@ -227,35 +200,7 @@ Node::ReceiveFromDevice (Ptr device, Ptr packet, if (i->protocol == 0 || i->protocol == protocol) { - i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from); - found = true; - } - } - } - return found; -} - - -bool -Node::PromiscuousReceiveFromDevice (Ptr device, Ptr packet, - uint16_t protocol, const Address &from, const Address &to, bool forMe) -{ - 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 (PromiscuousProtocolHandlerList::iterator i = m_promiscuousHandlers.begin (); - i != m_promiscuousHandlers.end (); i++) - { - if (i->device == 0 || - (i->device != 0 && i->device == device)) - { - if (i->protocol == 0 || - i->protocol == protocol) - { - i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, forMe); + i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType); found = true; } } diff --git a/src/node/node.h b/src/node/node.h index c5104a7b1..84f4c31f9 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -26,10 +26,10 @@ #include "ns3/object.h" #include "ns3/callback.h" #include "ns3/ptr.h" +#include "ns3/net-device.h" namespace ns3 { -class NetDevice; class Application; class Packet; class Address; @@ -130,7 +130,8 @@ public: /** * A protocol handler */ - typedef Callback, Ptr,uint16_t,const Address &> ProtocolHandler; + typedef Callback, Ptr,uint16_t,const Address &, + const Address &, NetDevice::PacketType> ProtocolHandler; /** * \param handler the handler to register * \param protocolType the type of protocol this handler is @@ -199,10 +200,8 @@ private: */ virtual void NotifyDeviceAdded (Ptr device); - bool ReceiveFromDevice (Ptr device, Ptr, - uint16_t protocol, const Address &from); - bool PromiscuousReceiveFromDevice (Ptr device, Ptr, - uint16_t protocol, const Address &from, const Address &to, bool forMe); + bool ReceiveFromDevice (Ptr device, Ptr, uint16_t protocol, + const Address &from, const Address &to, NetDevice::PacketType packetType); void Construct (void); struct ProtocolHandlerEntry { @@ -217,14 +216,6 @@ private: std::vector > m_applications; ProtocolHandlerList m_handlers; - // promiscuous protocol handlers - struct PromiscuousProtocolHandlerEntry { - PromiscuousProtocolHandler handler; - uint16_t protocol; - Ptr device; - }; - typedef std::vector PromiscuousProtocolHandlerList; - PromiscuousProtocolHandlerList m_promiscuousHandlers; }; } //namespace ns3 diff --git a/src/node/packet-socket.cc b/src/node/packet-socket.cc index 8d6e8272c..05b8b14d9 100644 --- a/src/node/packet-socket.cc +++ b/src/node/packet-socket.cc @@ -345,13 +345,19 @@ PacketSocket::SendTo (Ptr p, uint32_t flags, const Address &address) void PacketSocket::ForwardUp (Ptr device, Ptr packet, - uint16_t protocol, const Address &from) + uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION_NOARGS (); if (m_shutdownRecv) { return; } + if (packetType != NetDevice::PACKET_HOST) + { + return; + } + PacketSocketAddress address; address.SetPhysicalAddress (from); diff --git a/src/node/packet-socket.h b/src/node/packet-socket.h index 528ca740d..3bfc4ae3c 100644 --- a/src/node/packet-socket.h +++ b/src/node/packet-socket.h @@ -27,6 +27,7 @@ #include "ns3/traced-callback.h" #include "ns3/ptr.h" #include "ns3/socket.h" +#include "ns3/net-device.h" namespace ns3 { @@ -103,7 +104,8 @@ public: private: void ForwardUp (Ptr device, Ptr packet, - uint16_t protocol, const Address &from); + uint16_t protocol, const Address &from, const Address &to, + NetDevice::PacketType packetType); int DoBind (const PacketSocketAddress &address); uint32_t GetMinMtu (PacketSocketAddress ad) const; virtual void DoDispose (void); diff --git a/src/node/simple-net-device.cc b/src/node/simple-net-device.cc index b3fbf26f5..ba58688bb 100644 --- a/src/node/simple-net-device.cc +++ b/src/node/simple-net-device.cc @@ -46,10 +46,20 @@ void SimpleNetDevice::Receive (Ptr packet, uint16_t protocol, Mac48Address to, Mac48Address from) { - if (to == m_address || to == Mac48Address::GetBroadcast ()) + NetDevice::PacketType packetType; + if (to == m_address) { - m_rxCallback (this, packet, protocol, from); + packetType = NetDevice::PACKET_HOST; } + else if (to == Mac48Address::GetBroadcast ()) + { + packetType = NetDevice::PACKET_HOST; + } + else + { + NS_FATAL_ERROR ("Weird packet destination " << to); + } + m_rxCallback (this, packet, protocol, from, to, packetType); } void @@ -180,10 +190,6 @@ SimpleNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) { m_rxCallback = cb; } -void -SimpleNetDevice::SetPromiscuousReceiveCallback (NetDevice::PromiscuousReceiveCallback cb) -{ -} void SimpleNetDevice::DoDispose (void) diff --git a/src/node/simple-net-device.h b/src/node/simple-net-device.h index 455717871..ac77c5cc5 100644 --- a/src/node/simple-net-device.h +++ b/src/node/simple-net-device.h @@ -68,7 +68,6 @@ public: virtual void SetNode (Ptr node); virtual bool NeedsArp (void) const; virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); - virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb); protected: virtual void DoDispose (void);