From 1b62aa5a79d58cc2d1e528de20de7fdf77765d2e Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 1 Aug 2007 19:19:28 +0200 Subject: [PATCH] consitify the API a bit --- src/devices/csma-cd/csma-cd-net-device.cc | 3 ++- src/devices/csma-cd/csma-cd-net-device.h | 2 +- src/devices/point-to-point/point-to-point-net-device.cc | 3 ++- src/devices/point-to-point/point-to-point-net-device.h | 2 +- src/node/net-device.cc | 2 +- src/node/net-device.h | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/devices/csma-cd/csma-cd-net-device.cc b/src/devices/csma-cd/csma-cd-net-device.cc index 538625ee5..f522a7e16 100644 --- a/src/devices/csma-cd/csma-cd-net-device.cc +++ b/src/devices/csma-cd/csma-cd-net-device.cc @@ -250,8 +250,9 @@ CsmaCdNetDevice::DoNeedsArp (void) const } bool -CsmaCdNetDevice::SendTo (Packet& p, const Address& dest, uint16_t protocolNumber) +CsmaCdNetDevice::SendTo (const Packet& packet, const Address& dest, uint16_t protocolNumber) { + Packet p = packet; NS_DEBUG ("CsmaCdNetDevice::SendTo (" << &p << ")"); NS_DEBUG ("CsmaCdNetDevice::SendTo (): UID is " << p.GetUid () << ")"); diff --git a/src/devices/csma-cd/csma-cd-net-device.h b/src/devices/csma-cd/csma-cd-net-device.h index 05a327127..7bc5b79a5 100644 --- a/src/devices/csma-cd/csma-cd-net-device.h +++ b/src/devices/csma-cd/csma-cd-net-device.h @@ -249,7 +249,7 @@ private: * \param protocolNumber -- this parameter is not used here * \return true if success, false on failure */ - virtual bool SendTo (Packet& p, const Address& dest, uint16_t protocolNumber); + virtual bool SendTo (const Packet& p, const Address& dest, uint16_t protocolNumber); /** * Start Sending a Packet Down the Wire. 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 b450421f5..121f9e87e 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 @@ -102,9 +102,10 @@ void PointToPointNetDevice::SetInterframeGap(const Time& t) m_tInterframeGap = t; } -bool PointToPointNetDevice::SendTo (Packet& p, const Address& dest, +bool PointToPointNetDevice::SendTo (const Packet& packet, const Address& dest, uint16_t protocolNumber) { + Packet p = packet; NS_DEBUG ("PointToPointNetDevice::SendTo (" << &p << ", " << &dest << ")"); NS_DEBUG ("PointToPointNetDevice::SendTo (): UID is " << p.GetUid () << ")"); 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 77a55a8dc..06b472650 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 @@ -212,7 +212,7 @@ private: * @param protocolNumber Protocol Number used to find protocol touse * @returns true if success, false on failure */ - virtual bool SendTo (Packet& p, const Address& dest, + virtual bool SendTo (const Packet& p, const Address& dest, uint16_t protocolNumber); /** * Start Sending a Packet Down the Wire. diff --git a/src/node/net-device.cc b/src/node/net-device.cc index 4fa2e8d51..1ffe6d4b1 100644 --- a/src/node/net-device.cc +++ b/src/node/net-device.cc @@ -171,7 +171,7 @@ NetDevice::DisablePointToPoint (void) // Receive packet from above bool -NetDevice::Send(Packet& p, const Address& dest, uint16_t protocolNumber) +NetDevice::Send(const Packet& p, const Address& dest, uint16_t protocolNumber) { if (m_isUp) { diff --git a/src/node/net-device.h b/src/node/net-device.h index dd590f39c..315f16033 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -158,7 +158,7 @@ public: * * \return whether the Send operation succeeded */ - bool Send(Packet& p, const Address& dest, uint16_t protocolNumber); + bool Send(const Packet& p, const Address& dest, uint16_t protocolNumber); /** * \returns the node base class which contains this network * interface. @@ -274,7 +274,7 @@ public: * method. When the link is Up, this method is invoked to ask * subclasses to forward packets. Subclasses MUST override this method. */ - virtual bool SendTo (Packet& p, const Address &dest, uint16_t protocolNumber) = 0; + virtual bool SendTo (const Packet& p, const Address &dest, uint16_t protocolNumber) = 0; /** * \returns true if this NetDevice needs the higher-layers * to perform ARP over it, false otherwise.