diff --git a/src/node/net-device.h b/src/node/net-device.h index f0fe4de36..065b1c2c8 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -267,19 +267,21 @@ public: * 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 &> PromiscuousReceiveCallback; + 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 and must be forwarded to the higher - * layers, i.e. for all packets whose destination address - * does NOT match the NetDevice address. Note that - * ReceiveCallback and PromiscuousReceiveCallback handle - * mutually exclusive sets of packets, and you need to use - * both callbacks in order to receive ALL packets. + * 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; diff --git a/src/node/node.cc b/src/node/node.cc index d7e032174..3646c8edb 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -238,7 +238,7 @@ Node::ReceiveFromDevice (Ptr device, Ptr packet, bool Node::PromiscuousReceiveFromDevice (Ptr device, Ptr packet, - uint16_t protocol, const Address &from, const Address &to) + 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 @@ -255,7 +255,7 @@ Node::PromiscuousReceiveFromDevice (Ptr device, Ptr packet, if (i->protocol == 0 || i->protocol == protocol) { - i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to); + i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, forMe); found = true; } } diff --git a/src/node/node.h b/src/node/node.h index 3588ffc19..c5104a7b1 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -158,7 +158,7 @@ public: * A promiscuous protocol handler */ typedef Callback, Ptr,uint16_t, - const Address &, const Address &> PromiscuousProtocolHandler; + const Address &, const Address &, bool> PromiscuousProtocolHandler; /** * \param handler the handler to register * \param protocolType the type of protocol this handler is @@ -202,7 +202,7 @@ private: 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); + uint16_t protocol, const Address &from, const Address &to, bool forMe); void Construct (void); struct ProtocolHandlerEntry {