View | Details | Raw Unified | Return to bug 407
Collapse All | Expand All

(-)a/src/helper/olsr-helper.cc (+27 lines)
 Lines 33-38    Link Here 
33
OlsrHelper::OlsrHelper (const OlsrHelper &o)
33
OlsrHelper::OlsrHelper (const OlsrHelper &o)
34
  : m_agentFactory (o.m_agentFactory)
34
  : m_agentFactory (o.m_agentFactory)
35
{
35
{
36
  m_interfaceExclusions = o.m_interfaceExclusions;
36
}
37
}
37
38
38
OlsrHelper* 
39
OlsrHelper* 
 Lines 41-50    Link Here 
41
  return new OlsrHelper (*this); 
42
  return new OlsrHelper (*this); 
42
}
43
}
43
44
45
void
46
OlsrHelper::ExcludeInterface (Ptr<Node> node, uint32_t interface)
47
{
48
  std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
49
50
  if(it == m_interfaceExclusions.end ())
51
    {
52
      std::set<uint32_t> interfaces;
53
      interfaces.insert (interface);
54
    
55
      m_interfaceExclusions.insert (std::make_pair (node, std::set<uint32_t> (interfaces) ));
56
    }
57
  else
58
    {
59
      it->second.insert (interface);
60
    }
61
}
62
44
Ptr<Ipv4RoutingProtocol> 
63
Ptr<Ipv4RoutingProtocol> 
45
OlsrHelper::Create (Ptr<Node> node) const
64
OlsrHelper::Create (Ptr<Node> node) const
46
{
65
{
47
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
66
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
67
68
  std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
69
70
  if(it != m_interfaceExclusions.end ())
71
    {
72
      agent->SetInterfaceExclusions (it->second);
73
    }
74
48
  node->AggregateObject (agent);
75
  node->AggregateObject (agent);
49
  return agent;
76
  return agent;
50
}
77
}
(-)a/src/helper/olsr-helper.h (+13 lines)
 Lines 24-29    Link Here 
24
#include "ns3/node.h"
24
#include "ns3/node.h"
25
#include "node-container.h"
25
#include "node-container.h"
26
#include "ipv4-routing-helper.h"
26
#include "ipv4-routing-helper.h"
27
#include <map>
28
#include <set>
27
29
28
namespace ns3 {
30
namespace ns3 {
29
31
 Lines 57-62    Link Here 
57
   */
59
   */
58
  OlsrHelper* Copy (void) const;
60
  OlsrHelper* Copy (void) const;
59
61
62
 /**
63
   * \param node the node for which an exception is to be defined
64
   * \param interface an interface of node on which OLSR is not to be installed
65
   *
66
   * This method allows the user to specify an interface on which OLSR is not to be installed on
67
   */
68
  void ExcludeInterface (Ptr<Node> node, uint32_t interface);
69
60
  /**
70
  /**
61
   * \param node the node on which the routing protocol will run
71
   * \param node the node on which the routing protocol will run
62
   * \returns a newly-created routing protocol
72
   * \returns a newly-created routing protocol
 Lines 72-77    Link Here 
72
   * This method controls the attributes of ns3::olsr::RoutingProtocol
82
   * This method controls the attributes of ns3::olsr::RoutingProtocol
73
   */
83
   */
74
  void Set (std::string name, const AttributeValue &value);
84
  void Set (std::string name, const AttributeValue &value);
85
75
private:
86
private:
76
  /**
87
  /**
77
   * \internal
88
   * \internal
 Lines 80-85    Link Here 
80
   */
91
   */
81
  OlsrHelper &operator = (const OlsrHelper &o);
92
  OlsrHelper &operator = (const OlsrHelper &o);
82
  ObjectFactory m_agentFactory;
93
  ObjectFactory m_agentFactory;
94
95
  std::map< Ptr<Node>, std::set<uint32_t> > m_interfaceExclusions;
83
};
96
};
84
97
85
} // namespace ns3
98
} // namespace ns3
(-)a/src/routing/olsr/olsr-routing-protocol.cc (-4 / +18 lines)
 Lines 251-256    Link Here 
251
  NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress);
251
  NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress);
252
252
253
  Ipv4Address loopback ("127.0.0.1");
253
  Ipv4Address loopback ("127.0.0.1");
254
255
  bool canRunOlsr = false;
254
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
256
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
255
    {
257
    {
256
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
258
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
 Lines 269-274    Link Here 
269
          NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
271
          NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
270
        }
272
        }
271
273
274
      if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
275
        continue;
276
272
      // Create a socket to listen only on this interface
277
      // Create a socket to listen only on this interface
273
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
278
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
274
        UdpSocketFactory::GetTypeId()); 
279
        UdpSocketFactory::GetTypeId()); 
 Lines 279-291    Link Here 
279
        }
284
        }
280
      socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER));
285
      socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER));
281
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
286
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
287
288
      canRunOlsr = true;
282
    }
289
    }
283
290
284
  HelloTimerExpire ();
291
  if(canRunOlsr)
285
  TcTimerExpire ();
292
   {
286
  MidTimerExpire ();
293
      HelloTimerExpire ();
294
      TcTimerExpire ();
295
      MidTimerExpire ();
287
296
288
  NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
297
      NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
298
   }
289
}
299
}
290
300
291
void RoutingProtocol::SetMainInterface (uint32_t interface)
301
void RoutingProtocol::SetMainInterface (uint32_t interface)
 Lines 293-298    Link Here 
293
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
303
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
294
}
304
}
295
305
306
void RoutingProtocol::SetInterfaceExclusions (std::set<uint32_t> exceptions)
307
{
308
  m_interfaceExclusions = exceptions;
309
}
296
310
297
//
311
//
298
// \brief Processes an incoming %OLSR packet following RFC 3626 specification.
312
// \brief Processes an incoming %OLSR packet following RFC 3626 specification.
(-)a/src/routing/olsr/olsr-routing-protocol.h (+10 lines)
 Lines 105-110    Link Here 
105
   **/
105
   **/
106
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
106
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
107
107
108
private:
109
  std::set<uint32_t> m_interfaceExclusions;
110
111
public:
112
  std::set<uint32_t> GetInterfaceExclusions () const
113
    {
114
      return m_interfaceExclusions;
115
    }
116
  void SetInterfaceExclusions (std::set<uint32_t> exceptions);
117
108
protected:
118
protected:
109
  virtual void DoStart (void);
119
  virtual void DoStart (void);
110
private:
120
private:

Return to bug 407