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

(-)a/src/internet/helper/ipv4-routing-helper.h (-1 / +38 lines)
 Lines 23-28    Link Here 
23
#include "ns3/ptr.h"
23
#include "ns3/ptr.h"
24
#include "ns3/nstime.h"
24
#include "ns3/nstime.h"
25
#include "ns3/output-stream-wrapper.h"
25
#include "ns3/output-stream-wrapper.h"
26
#include "ns3/ipv4-list-routing.h"
26
27
27
namespace ns3 {
28
namespace ns3 {
28
29
 Lines 60-66   public: Link Here 
60
   * \returns a newly-created routing protocol
61
   * \returns a newly-created routing protocol
61
   */
62
   */
62
  virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const = 0;
63
  virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const = 0;
63
64
  
64
  /**
65
  /**
65
   * \brief prints the routing tables of all nodes at a particular time.
66
   * \brief prints the routing tables of all nodes at a particular time.
66
   * \param printTime the time at which the routing table is supposed to be printed.
67
   * \param printTime the time at which the routing table is supposed to be printed.
 Lines 107-117   public: Link Here 
107
   */
108
   */
108
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
109
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
109
110
111
  /**
112
   * @brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
113
   *
114
   * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
115
   * otherwise a simple DynamicCast will be performed
116
   *
117
   * @param protocol Smart pointer to Ipv4RoutingProtocol object
118
   */
119
  template<class T>
120
  static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol);
121
  
110
private:
122
private:
111
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
123
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
112
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
124
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
113
};
125
};
114
126
127
// This function does a recursive search for a requested routing protocol.
128
// Strictly speaking this recursion is not necessary, but why not?
129
template<class T>
130
Ptr<T> Ipv4RoutingHelper::GetRouting (Ptr<Ipv4RoutingProtocol> protocol)
131
{
132
  Ptr<T> ret = DynamicCast<T> (protocol);
133
  if (ret == 0)
134
    {
135
      // trying to check if protocol is a list routing
136
      Ptr<Ipv4ListRouting> lrp = DynamicCast<Ipv4ListRouting> (protocol);
137
      if (lrp != 0)
138
        {
139
          for (uint32_t i = 0; i < lrp->GetNRoutingProtocols ();  i++)
140
            {
141
              int16_t priority;
142
              ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
143
              if (ret != 0)
144
                break;
145
            }
146
        }
147
    }
148
149
  return ret;
150
}
151
115
} // namespace ns3
152
} // namespace ns3
116
153
117
154
(-)a/src/internet/helper/ipv6-routing-helper.h (-1 / +37 lines)
 Lines 24-29    Link Here 
24
#include "ns3/ptr.h"
24
#include "ns3/ptr.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/output-stream-wrapper.h"
26
#include "ns3/output-stream-wrapper.h"
27
#include "ns3/ipv6-list-routing.h"
27
28
28
namespace ns3 {
29
namespace ns3 {
29
30
 Lines 110-120   public: Link Here 
110
   */
111
   */
111
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
112
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
112
113
114
  /**
115
   * @brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
116
   *
117
   * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
118
   * otherwise a simple DynamicCast will be performed
119
   *
120
   * @param protocol Smart pointer to Ipv4RoutingProtocol object
121
   */
122
  template<class T>
123
  static Ptr<T> GetRouting (Ptr<Ipv6RoutingProtocol> protocol);
124
  
113
private:
125
private:
114
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
126
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
115
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
127
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
116
};
128
};
117
129
130
// This function does a recursive search for a requested routing protocol.
131
// Strictly speaking this recursion is not necessary, but why not?
132
template<class T>
133
Ptr<T> Ipv6RoutingHelper::GetRouting (Ptr<Ipv6RoutingProtocol> protocol)
134
{
135
  Ptr<T> ret = DynamicCast<T> (protocol);
136
  if (ret == 0)
137
    {
138
      // trying to check if protocol is a list routing
139
      Ptr<Ipv6ListRouting> lrp = DynamicCast<Ipv6ListRouting> (protocol);
140
      if (lrp != 0)
141
        {
142
          for (uint32_t i = 0; i < lrp->GetNRoutingProtocols ();  i++)
143
            {
144
              int16_t priority;
145
              ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
146
              if (ret != 0)
147
                break;
148
            }
149
        }
150
    }
151
152
  return ret;
153
}
154
118
} // namespace ns3
155
} // namespace ns3
119
156
120
157
121
- 

Return to bug 1296