# HG changeset patch # User Tom Henderson # Date 1213160741 25200 # Node ID 67696960a256432a7dfba516913efab6d556eaa4 # Parent b0987a6a74c81e583b87bec0c8e39555aa5afc64 Ipv4 ifIndex renamed to interfaceIndex diff -r b0987a6a74c8 -r 67696960a256 src/helper/ipv4-address-helper.cc --- a/src/helper/ipv4-address-helper.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/helper/ipv4-address-helper.cc Tue Jun 10 22:05:41 2008 -0700 @@ -134,19 +134,19 @@ Ipv4AddressHelper::Assign (const NetDevi Ptr ipv4 = node->GetObject (); NS_ASSERT_MSG (ipv4, "Ipv4AddressHelper::Allocate(): Bad ipv4"); - int32_t ifIndex = ipv4->FindInterfaceForDevice (device); - if (ifIndex == -1) + int32_t interfaceIndex = ipv4->FindInterfaceForDevice (device); + if (interfaceIndex == -1) { - ifIndex = ipv4->AddInterface (device); + interfaceIndex = ipv4->AddInterface (device); } - NS_ASSERT_MSG (ifIndex >= 0, "Ipv4AddressHelper::Allocate(): " + NS_ASSERT_MSG (interfaceIndex >= 0, "Ipv4AddressHelper::Allocate(): " "Interface index not found"); - ipv4->SetAddress (ifIndex, NewAddress ()); - ipv4->SetNetworkMask (ifIndex, m_mask); - ipv4->SetMetric (ifIndex, 1); - ipv4->SetUp (ifIndex); - retval.Add (ipv4, ifIndex); + ipv4->SetAddress (interfaceIndex, NewAddress ()); + ipv4->SetNetworkMask (interfaceIndex, m_mask); + ipv4->SetMetric (interfaceIndex, 1); + ipv4->SetUp (interfaceIndex); + retval.Add (ipv4, interfaceIndex); } return retval; } diff -r b0987a6a74c8 -r 67696960a256 src/helper/static-multicast-route-helper.cc --- a/src/helper/static-multicast-route-helper.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/helper/static-multicast-route-helper.cc Tue Jun 10 22:05:41 2008 -0700 @@ -41,16 +41,17 @@ StaticMulticastRouteHelper::AddMulticast { Ptr ipv4 = n->GetObject (); - // We need to convert the NetDeviceContainer to an array of ifIndex + // We need to convert the NetDeviceContainer to an array of interfaceIndex std::vector outputInterfaces; - for (NetDeviceContainer::Iterator i = output.Begin (); i != output.End (); ++i) + for (NetDeviceContainer::Iterator i = output.Begin (); + i != output.End (); ++i) { Ptr nd = *i; - uint32_t oifIndex = ipv4->FindInterfaceForDevice (nd); - outputInterfaces.push_back(oifIndex); + uint32_t ointerfaceIndex = ipv4->FindInterfaceForDevice (nd); + outputInterfaces.push_back(ointerfaceIndex); } - uint32_t iifIndex = ipv4->FindInterfaceForDevice (input); - ipv4->AddMulticastRoute (source, group, iifIndex, outputInterfaces); + uint32_t iinterfaceIndex = ipv4->FindInterfaceForDevice (input); + ipv4->AddMulticastRoute (source, group, iinterfaceIndex, outputInterfaces); } void @@ -59,8 +60,8 @@ StaticMulticastRouteHelper::SetDefaultMu Ptr nd) { Ptr ipv4 = n->GetObject (); - uint32_t ifIndexSrc = ipv4->FindInterfaceForDevice (nd); - ipv4->SetDefaultMulticastRoute (ifIndexSrc); + uint32_t interfaceIndexSrc = ipv4->FindInterfaceForDevice (nd); + ipv4->SetDefaultMulticastRoute (interfaceIndexSrc); } void diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-impl.cc --- a/src/internet-stack/ipv4-impl.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-impl.cc Tue Jun 10 22:05:41 2008 -0700 @@ -224,21 +224,22 @@ Ipv4Impl::GetMetric (uint32_t i) const } bool -Ipv4Impl::GetIfIndexForDestination (Ipv4Address dest, uint32_t &ifIndex) const -{ - return m_ipv4->GetIfIndexForDestination (dest, ifIndex); +Ipv4Impl::GetIfIndexForDestination (Ipv4Address dest, + uint32_t &interfaceIndex) const +{ + return m_ipv4->GetIfIndexForDestination (dest, interfaceIndex); } Ipv4Address Ipv4Impl::GetSourceAddress (Ipv4Address destination) const { - uint32_t ifIndex = 0xffffffff; - - bool result = m_ipv4->GetIfIndexForDestination (destination, ifIndex); + uint32_t interfaceIndex = 0xffffffff; + + bool result = m_ipv4->GetIfIndexForDestination (destination, interfaceIndex); if (result) { - return m_ipv4->GetAddress (ifIndex); + return m_ipv4->GetAddress (interfaceIndex); } else { diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-impl.h --- a/src/internet-stack/ipv4-impl.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-impl.h Tue Jun 10 22:05:41 2008 -0700 @@ -95,7 +95,7 @@ public: virtual uint16_t GetMetric (uint32_t i) const; virtual Ipv4Address GetSourceAddress (Ipv4Address destination) const; virtual bool GetIfIndexForDestination (Ipv4Address dest, - uint32_t &ifIndex) const; + uint32_t &interfaceIndex) const; virtual uint16_t GetMtu (uint32_t i) const; virtual bool IsUp (uint32_t i) const; diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-interface.h --- a/src/internet-stack/ipv4-interface.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-interface.h Tue Jun 10 22:05:41 2008 -0700 @@ -35,9 +35,21 @@ class Packet; /** * \brief The IPv4 representation of a network interface * - * This class roughly corresponds to the struct in_device + * This class roughly corresponds to the struct if_addr * of Linux; the main purpose is to provide address-family * specific information (addresses) about an interface. + * Additionally, subclass provide an implementation of + * the Send() function, where functions such as ARP + * can be hooked into the outgoing packet processing. + * + * In Linux, multiple if_addrs may be associated to a single + * underlying net_device, and devices are typically known by string-based + * names such as "eth0" and "eth0:1". Presently, our Ipv4Interfaces + * are identified by integers, and only one Ipv4Interface can presently + * be associated with an underlying NetDevice. The ifIndex of + * an underlying NetDevice cannot be assumed to be the same as + * the interface index of this object, as indexed by the container + * of Ipv4Interface objects stored in the class Ipv4L3Protocol. * * This class defines two APIs: * - the public API which is expected to be used by both diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-l3-protocol.cc --- a/src/internet-stack/ipv4-l3-protocol.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-l3-protocol.cc Tue Jun 10 22:05:41 2008 -0700 @@ -193,12 +193,12 @@ Ipv4L3Protocol::Lookup ( void Ipv4L3Protocol::Lookup ( - uint32_t ifIndex, + uint32_t interfaceIndex, Ipv4Header const &ipHeader, Ptr packet, Ipv4RoutingProtocol::RouteReplyCallback routeReply) { - NS_LOG_FUNCTION (this << ifIndex << &ipHeader << packet << &routeReply); + NS_LOG_FUNCTION (this << interfaceIndex << &ipHeader << packet << &routeReply); for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin (); @@ -206,13 +206,13 @@ Ipv4L3Protocol::Lookup ( rprotoIter++) { NS_LOG_LOGIC ("Requesting route"); - if ((*rprotoIter).second->RequestRoute (ifIndex, ipHeader, packet, + if ((*rprotoIter).second->RequestRoute (interfaceIndex, ipHeader, packet, routeReply)) return; } if (ipHeader.GetDestination ().IsMulticast () && - ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY) + interfaceIndex == Ipv4RoutingProtocol::IF_INDEX_ANY) { NS_LOG_LOGIC ("Multicast destination with local source"); // @@ -378,14 +378,14 @@ Ipv4L3Protocol::FindInterfaceForAddr (Ip { NS_LOG_FUNCTION (this << addr); - uint32_t ifIndex = 0; + uint32_t interfaceIndex = 0; for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); - i++, ifIndex++) + i++, interfaceIndex++) { if ((*i)->GetAddress () == addr) { - return ifIndex; + return interfaceIndex; } } @@ -399,14 +399,14 @@ Ipv4L3Protocol::FindInterfaceForAddr (Ip { NS_LOG_FUNCTION (this << addr << mask); - uint32_t ifIndex = 0; + uint32_t interfaceIndex = 0; for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); - i++, ifIndex++) + i++, interfaceIndex++) { if ((*i)->GetAddress ().CombineMask (mask) == addr.CombineMask (mask)) { - return ifIndex; + return interfaceIndex; } } @@ -420,14 +420,14 @@ Ipv4L3Protocol::FindInterfaceIndexForDev { NS_LOG_FUNCTION (this << device); - uint32_t ifIndex = 0; + uint32_t interfaceIndex = 0; for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); - i++, ifIndex++) + i++, interfaceIndex++) { if ((*i)->GetDevice () == device) { - return ifIndex; + return interfaceIndex; } } @@ -609,12 +609,12 @@ Ipv4L3Protocol::SendRealOut (bool found, bool Ipv4L3Protocol::Forwarding ( - uint32_t ifIndex, + uint32_t interfaceIndex, Ptr packet, Ipv4Header &ipHeader, Ptr device) { - NS_LOG_FUNCTION (ifIndex << packet << &ipHeader<< device); + NS_LOG_FUNCTION (interfaceIndex << packet << &ipHeader<< device); NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ()); for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); @@ -678,13 +678,13 @@ Ipv4L3Protocol::Forwarding ( // We forward with a packet copy, since forwarding may change // the packet, affecting our local delivery NS_LOG_LOGIC ("Forwarding (multicast)."); - Lookup (ifIndex, ipHeader, packet->Copy (), + Lookup (interfaceIndex, ipHeader, packet->Copy (), MakeCallback (&Ipv4L3Protocol::SendRealOut, this)); return false; } } NS_LOG_LOGIC ("Not for me, forwarding."); - Lookup (ifIndex, ipHeader, packet, + Lookup (interfaceIndex, ipHeader, packet, MakeCallback (&Ipv4L3Protocol::SendRealOut, this)); return true; @@ -776,9 +776,9 @@ Ipv4L3Protocol::GetMetric (uint32_t i) c bool Ipv4L3Protocol::GetIfIndexForDestination ( - Ipv4Address destination, uint32_t& ifIndex) const -{ - NS_LOG_FUNCTION (this << destination << &ifIndex); + Ipv4Address destination, uint32_t& interfaceIndex) const +{ + NS_LOG_FUNCTION (this << destination << &interfaceIndex); // // The first thing we do in trying to determine a source address is to // consult the routing protocols. These will also check for a default route @@ -789,12 +789,12 @@ Ipv4L3Protocol::GetIfIndexForDestination i++) { NS_LOG_LOGIC ("Requesting Source Address"); - uint32_t ifIndexTmp; - - if ((*i).second->RequestIfIndex (destination, ifIndexTmp)) - { - NS_LOG_LOGIC ("Found ifIndex " << ifIndexTmp); - ifIndex = ifIndexTmp; + uint32_t interfaceIndexTmp; + + if ((*i).second->RequestIfIndex (destination, interfaceIndexTmp)) + { + NS_LOG_LOGIC ("Found interfaceIndex " << interfaceIndexTmp); + interfaceIndex = interfaceIndexTmp; return true; } } @@ -810,7 +810,7 @@ Ipv4L3Protocol::GetIfIndexForDestination if (GetNInterfaces () == 2) { NS_LOG_LOGIC ("One Interface. Using interface 1."); - ifIndex = 1; + interfaceIndex = 1; return true; } // @@ -838,9 +838,9 @@ Ipv4L3Protocol::GetIfIndexForDestination return false; } - ifIndex = route->GetInterface (); - - NS_LOG_LOGIC ("Default route specifies interface " << ifIndex); + interfaceIndex = route->GetInterface (); + + NS_LOG_LOGIC ("Default route specifies interface " << interfaceIndex); return true; } diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-l3-protocol.h --- a/src/internet-stack/ipv4-l3-protocol.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-l3-protocol.h Tue Jun 10 22:05:41 2008 -0700 @@ -152,7 +152,7 @@ public: void SetMetric (uint32_t i, uint16_t metric); uint16_t GetMetric (uint32_t i) const; bool GetIfIndexForDestination (Ipv4Address destination, - uint32_t& ifIndex) const; + uint32_t& interfaceIndex) const; uint16_t GetMtu (uint32_t i) const; bool IsUp (uint32_t i) const; void SetUp (uint32_t i); @@ -166,7 +166,7 @@ protected: virtual void DoDispose (void); private: - void Lookup (uint32_t ifIndex, + void Lookup (uint32_t interfaceIndex, Ipv4Header const &ipHeader, Ptr packet, Ipv4RoutingProtocol::RouteReplyCallback routeReply); @@ -175,7 +175,7 @@ private: Ipv4Route const &route, Ptr packet, Ipv4Header const &ipHeader); - bool Forwarding (uint32_t ifIndex, + bool Forwarding (uint32_t interfaceIndex, Ptr packet, Ipv4Header &ipHeader, Ptr device); diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-static-routing.cc --- a/src/internet-stack/ipv4-static-routing.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-static-routing.cc Tue Jun 10 22:05:41 2008 -0700 @@ -296,7 +296,7 @@ Ipv4StaticRouting::LookupStatic ( Ipv4StaticRouting::LookupStatic ( Ipv4Address origin, Ipv4Address group, - uint32_t ifIndex) + uint32_t interfaceIndex) { NS_LOG_FUNCTION_NOARGS (); // @@ -317,12 +317,12 @@ Ipv4StaticRouting::LookupStatic ( // // The first case is the restrictive case where the origin, group and index // matches. This picks up exact routes during forwarded and exact routes from -// the local node (in which case the ifIndex is a wildcard). +// the local node (in which case the interfaceIndex is a wildcard). // if (origin == route->GetOrigin () && group == route->GetGroup ()) { - if (ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY || - ifIndex == route->GetInputInterface ()) + if (interfaceIndex == Ipv4RoutingProtocol::IF_INDEX_ANY || + interfaceIndex == route->GetInputInterface ()) { return *i; } @@ -334,7 +334,7 @@ Ipv4StaticRouting::LookupStatic ( // just happily forward packets we don't really know what to do with. // Multicast storms are not generally considered a good thing. // - if (ifIndex != Ipv4RoutingProtocol::IF_INDEX_ANY) + if (interfaceIndex != Ipv4RoutingProtocol::IF_INDEX_ANY) { return 0; } @@ -515,12 +515,13 @@ Ipv4StaticRouting::RemoveRoute (uint32_t bool Ipv4StaticRouting::RequestRoute ( - uint32_t ifIndex, + uint32_t interfaceIndex, Ipv4Header const &ipHeader, Ptr packet, RouteReplyCallback routeReply) { - NS_LOG_FUNCTION (this << ifIndex << &ipHeader << packet << &routeReply); + NS_LOG_FUNCTION (this << interfaceIndex << &ipHeader << packet + << &routeReply); NS_LOG_LOGIC ("source = " << ipHeader.GetSource ()); @@ -531,7 +532,7 @@ Ipv4StaticRouting::RequestRoute ( NS_LOG_LOGIC ("Multicast destination"); Ipv4MulticastRoute *mRoute = LookupStatic(ipHeader.GetSource (), - ipHeader.GetDestination (), ifIndex); + ipHeader.GetDestination (), interfaceIndex); if (mRoute) { @@ -570,9 +571,10 @@ Ipv4StaticRouting::RequestRoute ( } bool -Ipv4StaticRouting::RequestIfIndex (Ipv4Address destination, uint32_t& ifIndex) -{ - NS_LOG_FUNCTION (this << destination << &ifIndex); +Ipv4StaticRouting::RequestIfIndex (Ipv4Address destination, + uint32_t& interfaceIndex) +{ + NS_LOG_FUNCTION (this << destination << &interfaceIndex); // // First, see if this is a multicast packet we have a route for. If we // have a route, then send the packet down each of the specified interfaces. @@ -594,8 +596,8 @@ Ipv4StaticRouting::RequestIfIndex (Ipv4A return false; } - ifIndex = mRoute->GetOutputInterface(0); - NS_LOG_LOGIC ("Found ifIndex " << ifIndex); + interfaceIndex = mRoute->GetOutputInterface(0); + NS_LOG_LOGIC ("Found interfaceIndex " << interfaceIndex); return true; } return false; // Let other routing protocols try to handle this @@ -607,7 +609,7 @@ Ipv4StaticRouting::RequestIfIndex (Ipv4A Ipv4Route *route = LookupStatic (destination); if (route) { - ifIndex = route->GetInterface (); + interfaceIndex = route->GetInterface (); return true; } else diff -r b0987a6a74c8 -r 67696960a256 src/internet-stack/ipv4-static-routing.h --- a/src/internet-stack/ipv4-static-routing.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/internet-stack/ipv4-static-routing.h Tue Jun 10 22:05:41 2008 -0700 @@ -102,8 +102,8 @@ public: * * If the destination address is a multicast, then the exact processing steps * depend on whether or not the packet has been sourced locally. This is - * determined by the parameter ifIndex. This is the interface index over which - * this packet was received. If the packet has not been received over a + * determined by the parameter interfaceIndex. This is the interface over + * which this packet was received. If the packet has not been received over a * network interface, this index will be set to * Ipv4RoutingProtocol::IF_INDEX_ANY (a very large number). In that case, * we want to avoid the requirement that an explicit route out of each node @@ -118,9 +118,9 @@ public: * packet out of as many interfaces as required using the provided callback * (think of it as a pre-packaged send call). * - * @param ifIndex The network interface index over which the packed was - * received. If the packet is from a local source, ifIndex will be set to - * Ipv4RoutingProtocol::IF_INDEX_ANY. + * @param interfaceIndex The IP interface index over which the packed was + * received. If the packet is from a local source, interfaceIndex will be + * set to Ipv4RoutingProtocol::IF_INDEX_ANY. * @param ipHeader the Ipv4Header containing the source and destination IP * addresses for the packet. * @param packet The packet to be sent if a route is found. @@ -134,7 +134,7 @@ public: * @see Ipv4StaticRouting * @see Ipv4RoutingProtocol */ - virtual bool RequestRoute (uint32_t ifIndex, + virtual bool RequestRoute (uint32_t interfaceIndex, Ipv4Header const &ipHeader, Ptr packet, RouteReplyCallback routeReply); @@ -162,7 +162,7 @@ public: * * @param destination The Ipv4Address if the destination of a hypothetical * packet. This may be a multicast group address. - * @param ifIndex A reference to the interface index over which a packet + * @param interfaceIndex A reference to the interface index over which a packet * sent to this destination would be sent. * @return Returns true if a route is found to the destination that involves * a single output interface index, otherwise returns false indicating that @@ -173,7 +173,7 @@ public: * @see Ipv4RoutingProtocol * @see Ipv4L3Protocol */ - virtual bool RequestIfIndex (Ipv4Address destination, uint32_t& ifIndex); + virtual bool RequestIfIndex (Ipv4Address destination, uint32_t& interfaceIndex); /** * @brief Add a host route to the static routing table. @@ -492,7 +492,7 @@ private: Ipv4Route *LookupStatic (Ipv4Address dest); Ipv4MulticastRoute *LookupStatic (Ipv4Address origin, Ipv4Address group, - uint32_t ifIndex); + uint32_t interfaceIndex); HostRoutes m_hostRoutes; NetworkRoutes m_networkRoutes; diff -r b0987a6a74c8 -r 67696960a256 src/node/ipv4.h --- a/src/node/ipv4.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/node/ipv4.h Tue Jun 10 22:05:41 2008 -0700 @@ -76,7 +76,7 @@ public: /** * \brief Request that a packet be routed. * - * \param ifIndex The interface index on which the packet was received. + * \param interfaceIndex The Ipv4 interface on which the packet was received. * \param ipHeader IP header of the packet * \param packet packet that is being sent or forwarded * \param routeReply callback that will receive the route reply @@ -111,7 +111,7 @@ public: * destination will be serviced by cloning the packet and calling the * route reply callback once for each outgoing interface in the route. */ - virtual bool RequestRoute (uint32_t ifIndex, + virtual bool RequestRoute (uint32_t interfaceIndex, const Ipv4Header &ipHeader, Ptr packet, RouteReplyCallback routeReply) = 0; @@ -129,7 +129,8 @@ public: * routing protocols for what they would do if presented with a packet of the * given destination. * - * Note that the a single interface index is returned. This means that if + * Note that the a single interface index is returned, corresponding to an + * Ipv4Interface index. This means that if * the destination address is a multicast, and an explicit route is present * that includeds multiple output interfaces, that route cannot be used. * @@ -139,7 +140,7 @@ public: * * \param destination The Ipv4Address if the destination of a hypothetical * packet. This may be a multicast group address. - * \param ifIndex A reference to the interface index over which a packet + * \param interfaceIndex A reference to the interface index over which a packet * sent to this destination would be sent. * \return Returns true if a route is found to the destination that involves * a single output interface index, otherwise false. @@ -149,19 +150,22 @@ public: * \see Ipv4L3Protocol */ virtual bool RequestIfIndex (Ipv4Address destination, - uint32_t& ifIndex) = 0; + uint32_t& interfaceIndex) = 0; static const uint32_t IF_INDEX_ANY = 0xffffffff; }; /** - * \brief Access to the Ipv4 forwarding table and to the ipv4 interfaces - * - * This class allows you to create ipv4 interfaces based on a NetDevice. - * Multiple interfaces can be created for a single NetDevice, hence - * achieving multihoming. - * - * This class also allows you to control the content of the ipv4 + * \brief Access to the Ipv4 forwarding table and to the Ipv4 interfaces + * + * This class allows you to create Ipv4 interfaces based on a NetDevice. + * An Ipv4Interface holds an Ipv4 address for the NetDevice (which + * does not know about IP). The interface indices at this layer + * may be different from the NetDevice ifIndex values, to allow for the + * possibility of having more than one Ipv4Interface map to a NetDevice, + * although presently only one Ipv4Interface may map to a NetDevice. + * + * This class also allows you to control the content of the Ipv4 * forwarding table. */ class Ipv4 : public Object @@ -187,28 +191,28 @@ public: /** * \param dest destination address * \param nextHop address of next hop. - * \param interface interface of next hop. + * \param interfaceIndex interface of next hop. * * Add route to host dest through host nextHop * on interface. */ virtual void AddHostRouteTo (Ipv4Address dest, Ipv4Address nextHop, - uint32_t interface) = 0; + uint32_t interfaceIndex) = 0; /** * \param dest destination address - * \param interface of next hop + * \param interfaceIndex interface of next hop * * add route to host dest on interface. */ virtual void AddHostRouteTo (Ipv4Address dest, - uint32_t interface) = 0; + uint32_t interfaceIndex) = 0; /** * \param network destination network * \param networkMask netmask of destination network * \param nextHop address of next hop - * \param interface interface of next hop + * \param interfaceIndex interface of next hop * * add route to network dest with netmask * through host nextHop on interface @@ -216,28 +220,28 @@ public: virtual void AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, - uint32_t interface) = 0; + uint32_t interfaceIndex) = 0; /** * \param network destination network * \param networkMask netmask of destination network - * \param interface interface of next hop + * \param interfaceIndex interface of next hop * * add route to network dest with netmask * on interface */ virtual void AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, - uint32_t interface) = 0; + uint32_t interfaceIndex) = 0; /** * \param nextHop address of default next hop - * \param interface interface of default next hop. + * \param interfaceIndex interface of default next hop. * * set the default route to host nextHop on * interface. */ virtual void SetDefaultRoute (Ipv4Address nextHop, - uint32_t interface) = 0; + uint32_t interfaceIndex) = 0; /** * \returns the number of entries in the routing table. @@ -306,9 +310,9 @@ public: virtual void RemoveMulticastRoute (uint32_t i) = 0; /** - * \param device device to add to the list of ipv4 interfaces + * \param device device to add to the list of Ipv4 interfaces * which can be used as output interfaces during packet forwarding. - * \returns the index of the ipv4 interface added. + * \returns the index of the Ipv4 interface added. * * Once a device has been added, it can never be removed: if you want * to disable it, you can invoke Ipv4::SetDown which will @@ -322,10 +326,10 @@ public: virtual uint32_t GetNInterfaces (void) = 0; /** - * \brief Find and return the interface ID of the interface that has been + * \brief Find and return the interface index of the interface that has been * assigned the specified IP address. * \param addr The IP address assigned to the interface of interest. - * \returns The index of the ipv4 interface with the given address. + * \returns The index of the Ipv4 interface with the given address. * * Each IP interface has an IP address associated with it. It is often * useful to search the list of interfaces for one that corresponds to @@ -336,7 +340,7 @@ public: virtual uint32_t FindInterfaceForAddr (Ipv4Address addr) const = 0; /** - * \brief Find and return the interface ID of the interface that has been + * \brief Find and return the interface index of the interface that has been * assigned the specified (masked) IP address. * \param addr The IP address assigned to the interface of interest. * \param mask The address mask to be used in address matching. @@ -352,7 +356,7 @@ public: Ipv4Mask mask) const = 0; /** - * \brief Find and return the interface ID of the interface that has been + * \brief Find and return the interface index of the interface that has been * associated with the specified (masked) NetDevice * \param nd The net device of the interface of interest. * \returns The index of the ipv4 interface associated with the given net @@ -367,8 +371,8 @@ public: virtual int32_t FindInterfaceForDevice(Ptr nd) const = 0; /** - * \param i index of ipv4 interface - * \returns the NetDevice associated with the ipv4 interface index + * \param i index of Ipv4 interface + * \returns the NetDevice associated with the Ipv4 interface index */ virtual Ptr GetNetDevice (uint32_t i) = 0; @@ -437,12 +441,12 @@ public: /** * \param dest The IP address of a hypothetical destination. - * \param ifIndex filled in with the interface index that will be used to + * \param interfaceIndex filled in with the interface index that will be used to * send a packet to the hypothetical destination. * \returns true if a single interface can be identified, false otherwise. */ virtual bool GetIfIndexForDestination (Ipv4Address dest, - uint32_t &ifIndex) const = 0; + uint32_t &interfaceIndex) const = 0; /** * \param i index of ipv4 interface @@ -475,12 +479,12 @@ public: virtual void SetDown (uint32_t i) = 0; /** - * \brief Convenience function to return the ifIndex corresponding + * \brief Convenience function to return the interfaceIndex corresponding * to the Ipv4Address provided * * \param addr Ipv4Address * \param mask corresponding Ipv4Mask - * \returns ifIndex corresponding to a/amask + * \returns interfaceIndex corresponding to a/amask */ virtual uint32_t GetIfIndexByAddress (Ipv4Address addr, Ipv4Mask mask = Ipv4Mask("255.255.255.255")); diff -r b0987a6a74c8 -r 67696960a256 src/routing/global-routing/global-router-interface.cc --- a/src/routing/global-routing/global-router-interface.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/routing/global-routing/global-router-interface.cc Tue Jun 10 22:05:41 2008 -0700 @@ -560,13 +560,18 @@ GlobalRouter::DiscoverLSAs (void) // Now, we have to find the Ipv4 interface whose netdevice is the one we // just found. This is still the IP on the local side of the channel. There // is a function to do this used down in the guts of the stack, but it's not -// exported so we had to whip up an equivalent. -// - uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal); - Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal); - Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal); +// exported so we had to whip up an equivalent. This code relies on +// a one-to-one mapping between Ipv4Interface and NetDevice, so if that +// relationship ever changes, all of the calls to FindIfIndexForDevice +// in this file may need to change. +// + uint32_t interfaceIndexLocal = FindIfIndexForDevice(node, ndLocal); + Ipv4Address addrLocal = + ipv4Local->GetAddress(interfaceIndexLocal); + Ipv4Mask maskLocal = + ipv4Local->GetNetworkMask(interfaceIndexLocal); NS_LOG_LOGIC ("Working with local address " << addrLocal); - uint16_t metricLocal = ipv4Local->GetMetric (ifIndexLocal); + uint16_t metricLocal = ipv4Local->GetMetric (interfaceIndexLocal); // // Now, we're going to walk over to the remote net device on the other end of // the point-to-point channel we now know we have. This is where our adjacent @@ -623,15 +628,16 @@ GlobalRouter::DiscoverLSAs (void) // is a function to do this used down in the guts of the stack, but it's not // exported so we had to whip up an equivalent. // - uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal); + uint32_t interfaceIndexLocal = FindIfIndexForDevice(node, ndLocal); // // Now that we have the Ipv4 interface index, we can get the address and mask // we need. // - Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal); - Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal); + Ipv4Address addrLocal = + ipv4Local->GetAddress(interfaceIndexLocal); + Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(interfaceIndexLocal); NS_LOG_LOGIC ("Working with local address " << addrLocal); - uint16_t metricLocal = ipv4Local->GetMetric (ifIndexLocal); + uint16_t metricLocal = ipv4Local->GetMetric (interfaceIndexLocal); // // Now, we're going to walk over to the remote net device on the other end of // the point-to-point channel we now know we have. This is where our adjacent @@ -665,13 +671,15 @@ GlobalRouter::DiscoverLSAs (void) // Now, just like we did above, we need to get the IP interface index for the // net device on the other end of the point-to-point channel. // - uint32_t ifIndexRemote = FindIfIndexForDevice(nodeRemote, ndRemote); + uint32_t interfaceIndexRemote = FindIfIndexForDevice(nodeRemote, ndRemote); // // Now that we have the Ipv4 interface, we can get the (remote) address and // mask we need. // - Ipv4Address addrRemote = ipv4Remote->GetAddress(ifIndexRemote); - Ipv4Mask maskRemote = ipv4Remote->GetNetworkMask(ifIndexRemote); + Ipv4Address addrRemote = + ipv4Remote->GetAddress(interfaceIndexRemote); + Ipv4Mask maskRemote = + ipv4Remote->GetNetworkMask(interfaceIndexRemote); NS_LOG_LOGIC ("Working with remote address " << addrRemote); // // Now we can fill out the link records for this link. There are always two @@ -714,9 +722,9 @@ GlobalRouter::DiscoverLSAs (void) { // Build one NetworkLSA for each interface that is a DR Ptr ndLocal = *i; - uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal); - Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal); - Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal); + uint32_t interfaceIndexLocal = FindIfIndexForDevice(node, ndLocal); + Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceIndexLocal); + Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(interfaceIndexLocal); GlobalRoutingLSA *pLSA = new GlobalRoutingLSA; pLSA->SetLSType (GlobalRoutingLSA::NetworkLSA); @@ -751,11 +759,11 @@ GlobalRouter::FindDesignatedRouterForLin GlobalRouter::FindDesignatedRouterForLink (Ptr node, Ptr ndLocal) const { - uint32_t ifIndexLocal = FindIfIndexForDevice(node, ndLocal); + uint32_t interfaceIndexLocal = FindIfIndexForDevice(node, ndLocal); Ptr ipv4Local = GetObject (); NS_ASSERT (ipv4Local); - Ipv4Address addrLocal = ipv4Local->GetAddress(ifIndexLocal); - Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(ifIndexLocal); + Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceIndexLocal); + Ipv4Mask maskLocal = ipv4Local->GetNetworkMask(interfaceIndexLocal); Ptr ch = ndLocal->GetChannel(); uint32_t nDevices = ch->GetNDevices(); diff -r b0987a6a74c8 -r 67696960a256 src/routing/olsr/routing-table.cc --- a/src/routing/olsr/routing-table.cc Tue Jun 10 06:08:16 2008 -0700 +++ b/src/routing/olsr/routing-table.cc Tue Jun 10 22:05:41 2008 -0700 @@ -105,7 +105,7 @@ RoutingTable::FindSendEntry (RoutingTabl bool -RoutingTable::RequestRoute (uint32_t ifIndex, +RoutingTable::RequestRoute (uint32_t interfaceIndex, const Ipv4Header &ipHeader, Ptr packet, RouteReplyCallback routeReply) @@ -149,7 +149,7 @@ RoutingTable::RequestRoute (uint32_t ifI bool RoutingTable::RequestIfIndex (Ipv4Address destination, - uint32_t& ifIndex) + uint32_t& interfaceIndex) { RoutingTableEntry entry1, entry2; if (Lookup (destination, entry1)) @@ -157,7 +157,7 @@ RoutingTable::RequestIfIndex (Ipv4Addres bool foundSendEntry = FindSendEntry (entry1, entry2); if (!foundSendEntry) NS_FATAL_ERROR ("FindSendEntry failure"); - ifIndex = entry2.interface; + interfaceIndex = entry2.interface; return true; } else diff -r b0987a6a74c8 -r 67696960a256 src/routing/olsr/routing-table.h --- a/src/routing/olsr/routing-table.h Tue Jun 10 06:08:16 2008 -0700 +++ b/src/routing/olsr/routing-table.h Tue Jun 10 22:05:41 2008 -0700 @@ -97,12 +97,12 @@ public: RoutingTableEntry &outEntry) const; // From Ipv4RoutingProtocol - virtual bool RequestRoute (uint32_t ifIndex, + virtual bool RequestRoute (uint32_t interfaceIndex, const Ipv4Header &ipHeader, Ptr packet, RouteReplyCallback routeReply); virtual bool RequestIfIndex (Ipv4Address destination, - uint32_t& ifIndex); + uint32_t& interfaceIndex); };