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

(-)a/src/helper/olsr-helper.cc (+32 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
  std::map< Ptr<Node>, std::set<uint32_t> >::const_iterator i;
37
  
38
  for (i = o.m_interfaceExclusions.begin (); i != o.m_interfaceExclusions.end (); i++)
39
    {
40
      m_interfaceExclusions.insert (std::make_pair (i->first, std::set<uint32_t> (i->second) ));
41
    }
36
}
42
}
37
43
38
OlsrHelper* 
44
OlsrHelper* 
 Lines 41-50    Link Here 
41
  return new OlsrHelper (*this); 
47
  return new OlsrHelper (*this); 
42
}
48
}
43
49
50
void
51
OlsrHelper::ExcludeInterface (Ptr<Node> node, uint32_t interface)
52
{
53
  std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
54
55
  if(it == m_interfaceExclusions.end ())
56
    {
57
      std::set<uint32_t> interfaces;
58
      interfaces.insert (interface);
59
    
60
      m_interfaceExclusions.insert (std::make_pair (node, std::set<uint32_t> (interfaces) ));
61
    }
62
  else
63
    {
64
      it->second.insert (interface);
65
    }
66
}
67
44
Ptr<Ipv4RoutingProtocol> 
68
Ptr<Ipv4RoutingProtocol> 
45
OlsrHelper::Create (Ptr<Node> node) const
69
OlsrHelper::Create (Ptr<Node> node) const
46
{
70
{
47
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
71
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
72
73
  std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
74
75
  if(it != m_interfaceExclusions.end ())
76
    {
77
      agent->SetInterfaceExclusions (it->second);
78
    }
79
48
  node->AggregateObject (agent);
80
  node->AggregateObject (agent);
49
  return agent;
81
  return agent;
50
}
82
}
(-)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 / +20 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
      const std::set<uint32_t> ifaceExclusions = GetInterfaceExclusions();
275
276
      if(ifaceExclusions.find(i) != ifaceExclusions.end ())
277
        continue;
278
272
      // Create a socket to listen only on this interface
279
      // Create a socket to listen only on this interface
273
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
280
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
274
        UdpSocketFactory::GetTypeId()); 
281
        UdpSocketFactory::GetTypeId()); 
 Lines 279-291    Link Here 
279
        }
286
        }
280
      socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER));
287
      socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER));
281
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
288
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
289
290
      canRunOlsr = true;
282
    }
291
    }
283
292
284
  HelloTimerExpire ();
293
  if(canRunOlsr)
285
  TcTimerExpire ();
294
   {
286
  MidTimerExpire ();
295
      HelloTimerExpire ();
296
      TcTimerExpire ();
297
      MidTimerExpire ();
287
298
288
  NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
299
      NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
300
   }
289
}
301
}
290
302
291
void RoutingProtocol::SetMainInterface (uint32_t interface)
303
void RoutingProtocol::SetMainInterface (uint32_t interface)
 Lines 293-298    Link Here 
293
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
305
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
294
}
306
}
295
307
308
void RoutingProtocol::SetInterfaceExclusions (std::set<uint32_t> exceptions)
309
{
310
  m_interfaceExclusions = exceptions;
311
}
296
312
297
//
313
//
298
// \brief Processes an incoming %OLSR packet following RFC 3626 specification.
314
// \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 ()
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