--- a/src/devices/point-to-point/point-to-point-topology.cc Wed Nov 14 20:40:05 2007 -0800
+++ b/src/devices/point-to-point/point-to-point-topology.cc Wed Nov 14 20:50:53 2007 -0800
@@ -62,6 +62,30 @@
return channel;
}
+Ptr<PointToPointNetDevice>
+PointToPointTopology::GetNetDevice (Ptr<Node> n, Ptr<PointToPointChannel> chan)
+{
+ Ptr<PointToPointNetDevice> found = 0;
+
+ // The PointToPoint channel is used to find the relevant NetDevice
+ NS_ASSERT (chan->GetNDevices () == 2);
+ Ptr<PointToPointNetDevice> nd1 = chan->GetDevice (0);
+ Ptr<PointToPointNetDevice> nd2 = chan->GetDevice (1);
+ if ( nd1->GetNode ()->GetId () == n->GetId () )
+ {
+ found = nd1;
+ }
+ else if ( nd2->GetNode ()->GetId () == n->GetId () )
+ {
+ found = nd2;
+ }
+ else
+ {
+ NS_ASSERT (found);
+ }
+ return found;
+}
+
void
PointToPointTopology::AddIpv4Addresses(
Ptr<const PointToPointChannel> chan,
--- a/src/devices/point-to-point/point-to-point-topology.h Wed Nov 14 20:40:05 2007 -0800
+++ b/src/devices/point-to-point/point-to-point-topology.h Wed Nov 14 20:50:53 2007 -0800
@@ -56,6 +56,17 @@
Ptr<Node> n1, Ptr<Node> n2, const DataRate& dataRate, const Time& delay);
/**
+ * \param n Node
+ * \param chan PointToPointChannel connected to node n
+ * \return Pointer to the corresponding PointToPointNetDevice
+ *
+ * Utility function to retrieve a PointToPointNetDevice pointer
+ * corresponding to the input parameters
+ */
+ static Ptr<PointToPointNetDevice> GetNetDevice(
+ Ptr<Node> n, Ptr<PointToPointChannel> chan);
+
+ /**
* \param chan PointToPointChannel to use
* \param n1 Node
* \param addr1 Ipv4 Address for n1