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

(-)a/src/node/ipv4.cc (-45 / +3 lines)
 Lines 36-48   Ipv4::~Ipv4 () Link Here 
36
{}
36
{}
37
37
38
uint32_t 
38
uint32_t 
39
Ipv4::GetIfIndexByAddress (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask)
39
Ipv4::GetIfIndexByAddress (Ipv4Address addr, Ipv4Mask mask)
40
{
40
{
41
  Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
41
  for (uint32_t i = 0; i < GetNInterfaces (); i++)
42
  NS_ASSERT_MSG (ipv4, "Ipv4::GetIfIndexByAddress:  No Ipv4 interface");
43
  for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++)
44
    {
42
    {
45
      if (ipv4->GetAddress (i).CombineMask(amask) == a.CombineMask(amask) )
43
      if (GetAddress (i).CombineMask(mask) == addr.CombineMask(mask) )
46
        {
44
        {
47
          return i;
45
          return i;
48
        }
46
        }
 Lines 52-95   Ipv4::GetIfIndexByAddress (Ptr<Node> nod Link Here 
52
  return 0;
50
  return 0;
53
}
51
}
54
52
55
//
56
// XXX BUGBUG I don't think this is really the right approach here.  The call
57
// to GetRoute () filters down into Ipv4L3Protocol where it translates into
58
// a call into the Ipv4 static routing package.  This bypasses any other
59
// routing packages.  At a minimum, the name is misleading.
60
//
61
bool 
62
Ipv4::GetRouteToDestination (
63
  Ptr<Node> node, 
64
  Ipv4Route& route, 
65
  Ipv4Address a, 
66
  Ipv4Mask amask)
67
{
68
  Ipv4Route tempRoute;
69
  Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
70
  NS_ASSERT_MSG (ipv4, "Ipv4::GetRouteToDestination:  No Ipv4 interface");
71
  for (uint32_t i = 0; i < ipv4->GetNRoutes (); i++) 
72
    {
73
      tempRoute = ipv4->GetRoute (i);
74
      // Host route found
75
      if ( tempRoute.IsNetwork () == false && tempRoute.GetDest () == a ) 
76
        {
77
          route = tempRoute;
78
          return true;
79
        }
80
      else if ( tempRoute.IsNetwork () && 
81
                tempRoute.GetDestNetwork () == a.CombineMask(amask) )
82
        {
83
          route = tempRoute;
84
          return true;
85
        }
86
      else if ( tempRoute.IsDefault () )
87
        {
88
          route = tempRoute;
89
          return true;
90
        }
91
    }
92
  return false;
93
}
94
95
} // namespace ns3
53
} // namespace ns3
(-)a/src/node/ipv4.h (-10 / +10 lines)
 Lines 449-464   public: Link Here 
449
   */
449
   */
450
  virtual void SetDown (uint32_t i) = 0;
450
  virtual void SetDown (uint32_t i) = 0;
451
451
452
/**
452
  /**
453
 * Convenience functions (Doxygen still needed)
453
   * \brief Convenience function to return the ifIndex corresponding
454
 *
454
   * to the Ipv4Address provided
455
 * Return the ifIndex corresponding to the Ipv4Address provided.
455
   *
456
 */
456
   * \param addr Ipv4Address
457
  static uint32_t GetIfIndexByAddress (Ptr<Node> node, Ipv4Address a, 
457
   * \param mask corresponding Ipv4Mask
458
    Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
458
   * \returns ifIndex corresponding to a/amask
459
459
   */
460
  static bool GetRouteToDestination (Ptr<Node> node, Ipv4Route& route, 
460
  virtual uint32_t GetIfIndexByAddress (Ipv4Address addr, 
461
    Ipv4Address a, Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
461
    Ipv4Mask mask = Ipv4Mask("255.255.255.255"));
462
};
462
};
463
463
464
} // namespace ns3 
464
} // namespace ns3 
(-)a/src/routing/global-routing/global-route-manager-impl.cc (-1 / +1 lines)
 Lines 1172-1178   GlobalRouteManagerImpl::FindOutgoingInte Link Here 
1172
// we're looking for.  If we find one, return the corresponding interface
1172
// we're looking for.  If we find one, return the corresponding interface
1173
// index.
1173
// index.
1174
//
1174
//
1175
          return (Ipv4::GetIfIndexByAddress (node, a, amask) );
1175
          return (ipv4->GetIfIndexByAddress (a, amask) );
1176
        }
1176
        }
1177
    }
1177
    }
1178
//
1178
//

Return to bug 94