diff --git a/src/devices/p2p/p2p-net-device.cc b/src/devices/p2p/p2p-net-device.cc index 00afd9752..e5f1f8d58 100644 --- a/src/devices/p2p/p2p-net-device.cc +++ b/src/devices/p2p/p2p-net-device.cc @@ -350,8 +350,8 @@ PointToPointNetDevice::GetQueue(void) const return m_queue; } -PointToPointChannel* -PointToPointNetDevice::GetChannel(void) const +Channel* +PointToPointNetDevice::DoGetChannel(void) const { return m_channel; } diff --git a/src/devices/p2p/p2p-net-device.h b/src/devices/p2p/p2p-net-device.h index c276dbf6f..b5330dbfe 100644 --- a/src/devices/p2p/p2p-net-device.h +++ b/src/devices/p2p/p2p-net-device.h @@ -33,8 +33,8 @@ namespace ns3 { -class PointToPointChannel; class Queue; +class PointToPointChannel; class PointToPointNetDevice : public NetDevice { public: @@ -60,7 +60,6 @@ public: protected: Queue* GetQueue(void) const; - PointToPointChannel* GetChannel(void) const; private: virtual bool SendTo (Packet& p, const MacAddress& dest); @@ -70,6 +69,8 @@ private: void TransmitReadyEvent (void); virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context); + virtual Channel *DoGetChannel(void) const; + enum TxMachineState { diff --git a/src/node/ipv4-loopback-interface.cc b/src/node/ipv4-loopback-interface.cc index 5db423d37..3700e6178 100644 --- a/src/node/ipv4-loopback-interface.cc +++ b/src/node/ipv4-loopback-interface.cc @@ -27,40 +27,8 @@ namespace ns3 { -class Ipv4DummyNetDevice : public NetDevice -{ -public: - Ipv4DummyNetDevice (Node *node); - Node *PeekNode (void) const; -private: - virtual bool SendTo (Packet& p, const MacAddress& dest); - virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context); -}; - -Ipv4DummyNetDevice::Ipv4DummyNetDevice (Node *node) - : NetDevice (node, MacAddress ()) -{ - SetMtu (10000); -} -Node * -Ipv4DummyNetDevice::PeekNode (void) const -{ - return GetNode (); -} -bool -Ipv4DummyNetDevice::SendTo (Packet& p, const MacAddress& dest) -{ - return false; -} -TraceResolver * -Ipv4DummyNetDevice::DoCreateTraceResolver (TraceContext const &context) -{ - return new EmptyTraceResolver (context); -} - - Ipv4LoopbackInterface::Ipv4LoopbackInterface (Node *node) - : Ipv4Interface (new Ipv4DummyNetDevice (node)), + : Ipv4Interface (0), m_node (node) { } diff --git a/src/node/net-device.cc b/src/node/net-device.cc index 3f8e076d0..00ffece6c 100644 --- a/src/node/net-device.cc +++ b/src/node/net-device.cc @@ -169,6 +169,12 @@ NetDevice::CreateTraceResolver (TraceContext const &context) return DoCreateTraceResolver (context); } +Channel * +NetDevice::GetChannel (void) const +{ + return DoGetChannel (); +} + // Receive packet from below bool NetDevice::ForwardUp (Packet& packet) diff --git a/src/node/net-device.h b/src/node/net-device.h index 3552775a7..e5076d66e 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -29,10 +29,10 @@ namespace ns3 { -class Ipv4L4Demux; class Node; class TraceResolver; class TraceContext; +class Channel; /** * \brief Network layer to device interface @@ -71,6 +71,13 @@ class NetDevice { */ TraceResolver *CreateTraceResolver (TraceContext const &context); + /** + * \return the channel this NetDevice is connected to. The value + * returned can be zero if the NetDevice is not yet connected + * to any channel. + */ + Channel *GetChannel (void) const; + /** * \return the current MacAddress of this interface. */ @@ -218,6 +225,7 @@ class NetDevice { virtual bool SendTo (Packet& p, const MacAddress& dest) = 0; virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context) = 0; + virtual Channel *DoGetChannel (void) const = 0; Node* m_node; std::string m_name; uint16_t m_ifIndex;