From af32684b4012f794b7e5108eac8c61c19c214181 Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Wed, 1 Apr 2009 16:14:05 +0400 Subject: [PATCH] Make routing protocol attribute of mesh point to be accessable by Config:: --- src/devices/mesh/mesh-point-device.cc | 14 +++++++++++++- src/devices/mesh/mesh-point-device.h | 8 +++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/devices/mesh/mesh-point-device.cc b/src/devices/mesh/mesh-point-device.cc index f2121ce27..fcf0b4039 100644 --- a/src/devices/mesh/mesh-point-device.cc +++ b/src/devices/mesh/mesh-point-device.cc @@ -23,6 +23,7 @@ #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/log.h" +#include "ns3/pointer.h" #include "ns3/mesh-point-device.h" NS_LOG_COMPONENT_DEFINE ("MeshPointDevice"); @@ -37,8 +38,12 @@ MeshPointDevice::GetTypeId () static TypeId tid = TypeId ("ns3::MeshPointDevice") .SetParent () .AddConstructor () + .AddAttribute ("RoutingProtocol", "The mesh routing protocol used by this mesh point.", + PointerValue (), + MakePointerAccessor (&MeshPointDevice::GetRoutingProtocol, + &MeshPointDevice::SetRoutingProtocol), + MakePointerChecker ()) ; - // TODO Add station-level attributes here return tid; } @@ -333,12 +338,19 @@ MeshPointDevice::SetRoutingProtocol (Ptr protocol) NS_ASSERT_MSG (PeekPointer(protocol->GetMeshPoint()) == this, "Routing protocol must be installed on mesh point to be usefull."); + m_routingProtocol = protocol; m_requestRoute = MakeCallback (&MeshL2RoutingProtocol::RequestRoute, protocol); m_myResponse = MakeCallback (&MeshPointDevice::DoSend, this); return; } +Ptr +MeshPointDevice::GetRoutingProtocol () const +{ + return m_routingProtocol; +} + void MeshPointDevice::DoSend (bool success, Ptr packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t outIface) { diff --git a/src/devices/mesh/mesh-point-device.h b/src/devices/mesh/mesh-point-device.h index 163aa181d..803bd034e 100644 --- a/src/devices/mesh/mesh-point-device.h +++ b/src/devices/mesh/mesh-point-device.h @@ -82,10 +82,10 @@ public: ///\name Protocols //\{ - /** - * \brief Register routing protocol to be used. Protocol must be alredy installed on this mesh point. - */ + /// Register routing protocol to be used. Protocol must be alredy installed on this mesh point. void SetRoutingProtocol (Ptr protocol); + /// Access current routing protocol + Ptr GetRoutingProtocol() const; //\} ///\name NetDevice interface for upper layers @@ -168,6 +168,8 @@ private: /// Routing response callback, this is supplied to mesh routing protocol MeshL2RoutingProtocol::RouteReplyCallback m_myResponse; + /// Current routing protocol, used mainly by GetRoutingProtocol + Ptr m_routingProtocol; }; } //namespace ns3 #endif