csma: (fixes #2556) Avoid modification of transmitted packets
Packets sent to channel may later be modified by calling device. Possible solutions are to copy before or after sending the packet to the channel. Adopted solution similar to YansWifiChannel; a Ptr<const Packet> is instead passed to the channel object, and channel object is responsible for copy.
This commit is contained in:
@@ -170,7 +170,7 @@ CsmaChannel::Detach (Ptr<CsmaNetDevice> device)
|
||||
}
|
||||
|
||||
bool
|
||||
CsmaChannel::TransmitStart (Ptr<Packet> p, uint32_t srcId)
|
||||
CsmaChannel::TransmitStart (Ptr<const Packet> p, uint32_t srcId)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << srcId);
|
||||
NS_LOG_INFO ("UID is " << p->GetUid () << ")");
|
||||
@@ -188,7 +188,7 @@ CsmaChannel::TransmitStart (Ptr<Packet> p, uint32_t srcId)
|
||||
}
|
||||
|
||||
NS_LOG_LOGIC ("switch to TRANSMITTING");
|
||||
m_currentPkt = p;
|
||||
m_currentPkt = p->Copy ();
|
||||
m_currentSrc = srcId;
|
||||
m_state = TRANSMITTING;
|
||||
return true;
|
||||
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
* \return True if the channel is not busy and the transmitting net
|
||||
* device is currently active.
|
||||
*/
|
||||
bool TransmitStart (Ptr<Packet> p, uint32_t srcId);
|
||||
bool TransmitStart (Ptr<const Packet> p, uint32_t srcId);
|
||||
|
||||
/**
|
||||
* \brief Indicates that the net device has finished transmitting
|
||||
|
||||
Reference in New Issue
Block a user