backout 9856d1175cbb:642d6798feaa:27dd3e15308a

This commit is contained in:
Mathieu Lacage
2007-08-29 09:35:53 +02:00
parent 74f9163b24
commit e20b40ee61
30 changed files with 179 additions and 148 deletions

View File

@@ -73,26 +73,39 @@ DropTailQueue::DoEnqueue (const Packet& p)
return true;
}
Packet
DropTailQueue::DoDequeue ()
bool
DropTailQueue::DoDequeue (Packet& p)
{
NS_DEBUG("DropTailQueue::DoDequeue ( )");
NS_ASSERT(!IsEmpty());
Packet p = m_packets.front ();
NS_DEBUG("DropTailQueue::DoDequeue (" << &p << ")");
if (m_packets.empty())
{
NS_DEBUG("DropTailQueue::DoDequeue (): Queue empty");
return false;
}
p = m_packets.front ();
m_packets.pop ();
NS_DEBUG("DropTailQueue::DoDequeue (): Popped " << &p << " <= true");
return p;
return true;
}
Packet
DropTailQueue::DoPeek ()
bool
DropTailQueue::DoPeek (Packet& p)
{
NS_DEBUG("DropTailQueue::DoPeek ( )");
NS_ASSERT(!IsEmpty());
NS_DEBUG("DropTailQueue::DoPeek (" << &p << ")");
return m_packets.front ();
if (m_packets.empty())
{
NS_DEBUG("DropTailQueue::DoPeek (): Queue empty");
return false;
}
p = m_packets.front ();
return true;
}
}; // namespace ns3

View File

@@ -58,8 +58,8 @@ public:
private:
virtual bool DoEnqueue (const Packet& p);
virtual Packet DoDequeue ();
virtual Packet DoPeek ();
virtual bool DoDequeue (Packet &p);
virtual bool DoPeek (Packet &p);
private:
std::queue<Packet> m_packets;

View File

@@ -46,7 +46,7 @@ class Ipv4Header; // FIXME: ipv4-header.h needs to move from module
class Ipv4RoutingProtocol : public Object
{
public:
// void (*RouteReply) (bool found, Ipv4Route route, Packet& packet, Ipv4Header const &ipHeader);
// void (*RouteReply) (bool found, Ipv4Route route, Packet packet, Ipv4Header const &ipHeader);
/**
@@ -65,7 +65,7 @@ public:
* inserted and consequently the protocol type has to change).
*
*/
typedef Callback<void, bool, const Ipv4Route&, Packet&, const Ipv4Header&> RouteReplyCallback;
typedef Callback<void, bool, const Ipv4Route&, Packet, const Ipv4Header&> RouteReplyCallback;
/**
* \brief Asynchronously requests a route for a given packet and IP header
@@ -100,7 +100,7 @@ public:
* insert any extra header.
*/
virtual bool RequestRoute (const Ipv4Header &ipHeader,
Packet& packet,
Packet packet,
RouteReplyCallback routeReply) = 0;
};

View File

@@ -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)
{
@@ -197,7 +197,7 @@ NetDevice::GetChannel (void) const
// Receive packets from below
bool
NetDevice::ForwardUp(Packet& p, uint16_t param, const Address &from)
NetDevice::ForwardUp(const Packet& p, uint16_t param, const Address &from)
{
bool retval = false;

View File

@@ -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.
@@ -187,7 +187,7 @@ public:
* \returns true if the callback could handle the packet successfully, false
* otherwise.
*/
typedef Callback<bool,Ptr<NetDevice>,Packet &,uint16_t,const Address &> ReceiveCallback;
typedef Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t,const Address &> ReceiveCallback;
/**
* \param cb callback to invoke whenever a packet has been received and must
@@ -251,7 +251,7 @@ public:
* forwards it to the higher layers by calling this method
* which is responsible for passing it up to the Rx callback.
*/
bool ForwardUp (Packet& p, uint16_t param, const Address &address);
bool ForwardUp (const Packet& p, uint16_t param, const Address &address);
/**
@@ -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.

View File

@@ -213,7 +213,7 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler)
}
bool
Node::ReceiveFromDevice (Ptr<NetDevice> device, Packet &packet,
Node::ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet,
uint16_t protocol, const Address &from)
{
bool found = false;

View File

@@ -158,7 +158,7 @@ public:
/**
* A protocol handler
*/
typedef Callback<void,Ptr<NetDevice>, Packet &,uint16_t,const Address &> ProtocolHandler;
typedef Callback<void,Ptr<NetDevice>, const Packet &,uint16_t,const Address &> ProtocolHandler;
/**
* \param handler the handler to register
* \param protocolType the type of protocol this handler is
@@ -210,7 +210,7 @@ private:
*/
virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
bool ReceiveFromDevice (Ptr<NetDevice> device, Packet &packet,
bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet,
uint16_t protocol, const Address &from);
void Construct (void);
TraceResolver *CreateDevicesTraceResolver (const TraceContext &context);

View File

@@ -186,7 +186,7 @@ PacketSocket::Connect(const Address &ad)
}
int
PacketSocket::Send (Packet &p)
PacketSocket::Send (const Packet &p)
{
if (m_state == STATE_OPEN ||
m_state == STATE_BOUND)
@@ -198,7 +198,7 @@ PacketSocket::Send (Packet &p)
}
int
PacketSocket::SendTo(const Address &address, Packet &p)
PacketSocket::SendTo(const Address &address, const Packet &p)
{
PacketSocketAddress ad;
if (m_state == STATE_CLOSED)
@@ -262,7 +262,7 @@ PacketSocket::SendTo(const Address &address, Packet &p)
}
void
PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
PacketSocket::ForwardUp (Ptr<NetDevice> device, const Packet &packet,
uint16_t protocol, const Address &from)
{
if (m_shutdownRecv)
@@ -270,7 +270,7 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
return;
}
//Packet p = packet; ?
Packet p = packet;
PacketSocketAddress address;
address.SetPhysicalAddress (from);
@@ -279,7 +279,7 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
NS_DEBUG ("PacketSocket::ForwardUp: UID is " << packet.GetUid()
<< " PacketSocket " << this);
NotifyDataReceived (packet, address);
NotifyDataReceived (p, address);
}
}//namespace ns3

View File

@@ -82,15 +82,15 @@ public:
virtual int ShutdownSend (void);
virtual int ShutdownRecv (void);
virtual int Connect(const Address &address);
virtual int Send (Packet &p);
virtual int SendTo(const Address &address,Packet &p);
virtual int Send (const Packet &p);
virtual int SendTo(const Address &address,const Packet &p);
private:
private:
void Init (void);
void ForwardUp (Ptr<NetDevice> device, Packet &packet,
void ForwardUp (Ptr<NetDevice> device, const Packet &packet,
uint16_t protocol, const Address &from);
int DoBind (const PacketSocketAddress &address);
virtual void DoDispose (void);

View File

@@ -49,7 +49,7 @@ QueueTraceType::IsEnqueue (void) const
{
return m_type == ENQUEUE;
}
bool
bool
QueueTraceType::IsDequeue (void) const
{
return m_type == DEQUEUE;
@@ -122,25 +122,28 @@ Queue::Enqueue (const Packet& p)
return retval;
}
Packet
Queue::Dequeue ()
bool
Queue::Dequeue (Packet &p)
{
NS_ASSERT(!IsEmpty());
NS_DEBUG("Queue::Dequeue ( )");
NS_DEBUG("Queue::Dequeue (" << &p << ")");
Packet p = DoDequeue ();
bool retval = DoDequeue (p);
m_nBytes -= p.GetSize ();
m_nPackets--;
NS_ASSERT (m_nBytes >= 0);
NS_ASSERT (m_nPackets >= 0);
NS_DEBUG("Queue::Dequeue (): m_traceDequeue (p)");
if (retval)
{
m_nBytes -= p.GetSize ();
m_nPackets--;
m_traceDequeue (p);
NS_ASSERT (m_nBytes >= 0);
NS_ASSERT (m_nPackets >= 0);
return p;
NS_DEBUG("Queue::Dequeue (): m_traceDequeue (p)");
const Packet packet = p;
m_traceDequeue (packet);
}
return retval;
}
void
@@ -151,13 +154,12 @@ Queue::DequeueAll (void)
NS_ASSERT (!"Don't know what to do with dequeued packets!");
}
Packet
Queue::Peek ()
bool
Queue::Peek (Packet &p)
{
NS_ASSERT(!IsEmpty());
NS_DEBUG("Queue::Peek ( )");
NS_DEBUG("Queue::Peek (" << &p << ")");
return DoPeek ();
return DoPeek (p);
}

View File

@@ -83,16 +83,14 @@ public:
bool Enqueue (const Packet& p);
/**
* Remove a packet from the front of the Queue
* Must not be called on an empty queue.
* \return The packet removed from the queue
* \return True if the operation was successful; false otherwise
*/
Packet Dequeue ();
bool Dequeue (Packet &p);
/**
* Get a copy of the item at the front of the queue without removing it
* Must NOT be called on an empty queue
* \return The packet at the head of the queue.
* \return True if the operation was successful; false otherwise
*/
Packet Peek ();
bool Peek (Packet &p);
/**
* XXX Doesn't do anything right now, think its supposed to flush the queue
@@ -165,8 +163,8 @@ public:
private:
virtual bool DoEnqueue (const Packet& p) = 0;
virtual Packet DoDequeue () = 0;
virtual Packet DoPeek () = 0;
virtual bool DoDequeue (Packet &p) = 0;
virtual bool DoPeek (Packet &p) = 0;
protected:
// called by subclasses to notify parent of packet drops.

View File

@@ -173,7 +173,7 @@ public:
* \returns -1 in case of error or the number of bytes copied in the
* internal buffer and accepted for transmission.
*/
virtual int Send (Packet &p) = 0;
virtual int Send (const Packet &p) = 0;
/**
* \brief Send data to a specified peer.
@@ -182,7 +182,7 @@ public:
* \returns -1 in case of error or the number of bytes copied in the
* internal buffer and accepted for transmission.
*/
virtual int SendTo(const Address &address,Packet &p) = 0;
virtual int SendTo(const Address &address,const Packet &p) = 0;
protected:
void NotifyCloseCompleted (void);