src/node/node.cc
changeset 4685 ae536d9e0d6d
parent 4578 88434ff8f0a5
     1.1 --- a/src/node/node.cc	Tue Jun 23 22:12:35 2009 -0700
     1.2 +++ b/src/node/node.cc	Wed Jul 15 18:46:14 2009 +0200
     1.3 @@ -31,6 +31,8 @@
     1.4  #include "ns3/global-value.h"
     1.5  #include "ns3/boolean.h"
     1.6  
     1.7 +#include "nsc-glue.h"
     1.8 +
     1.9  NS_LOG_COMPONENT_DEFINE ("Node");
    1.10  
    1.11  namespace ns3{
    1.12 @@ -67,7 +69,8 @@
    1.13  
    1.14  Node::Node()
    1.15    : m_id(0), 
    1.16 -    m_sid(0)
    1.17 +    m_sid(0),
    1.18 +    m_useNsc(false)
    1.19  {
    1.20    Construct ();
    1.21  }
    1.22 @@ -251,6 +254,11 @@
    1.23                 << ") Packet UID " << packet->GetUid ());
    1.24    bool found = false;
    1.25  
    1.26 +  if (m_useNsc && m_nscGlue->IsNscProtocol (protocol)) {
    1.27 +      m_nscGlue->PassPacketToNsc (packet, 0); // 0: NSC interface ID. XXX: Map &device <-> nscindex
    1.28 +      return true;
    1.29 +  }
    1.30 +
    1.31    for (ProtocolHandlerList::iterator i = m_handlers.begin ();
    1.32         i != m_handlers.end (); i++)
    1.33      {
    1.34 @@ -271,4 +279,36 @@
    1.35    return found;
    1.36  }
    1.37  
    1.38 +#ifdef NETWORK_SIMULATION_CRADLE
    1.39 +void
    1.40 +Node::SetNscLibrary(const std::string &soname)
    1.41 +{
    1.42 +  m_nscGlue = CreateObject <NscGlue> ();
    1.43 +  m_nscGlue->SetNode (this);
    1.44 +  m_nscGlue->SetNscLibrary (soname);
    1.45 +
    1.46 +  m_useNsc = true;
    1.47 +}
    1.48 +
    1.49 +std::string
    1.50 +Node::GetNscLibrary(void) const
    1.51 +{
    1.52 +  return m_nscGlue->GetNscLibrary ();
    1.53 +}
    1.54 +
    1.55 +
    1.56 +
    1.57 +INetStack *
    1.58 +Node::GetNscInetStack(void)
    1.59 +{
    1.60 +  NS_ASSERT_MSG(m_useNsc, "GetNscInetStack called, but nsc disabled on this node");
    1.61 +  return m_nscGlue->m_nscStack;
    1.62 +}
    1.63 +
    1.64 +void Node::RegisterNscWakeupCallback(Callback<void> cb)
    1.65 +{
    1.66 +  NS_ASSERT (m_nscGlue);
    1.67 +  m_nscGlue->RegisterWakeupCallback (cb);
    1.68 +}
    1.69 +#endif
    1.70  }//namespace ns3