Indent correctly IPv6 code.

This commit is contained in:
Sebastien Vincent
2009-12-30 14:22:25 +01:00
parent 6cb7afc694
commit 0752fbef6f
57 changed files with 8527 additions and 8528 deletions

View File

@@ -42,7 +42,7 @@ Ipv6ListRouting::GetTypeId (void)
Ipv6ListRouting::Ipv6ListRouting ()
: m_ipv6 (0)
: m_ipv6 (0)
{
NS_LOG_FUNCTION_NOARGS ();
}
@@ -116,16 +116,16 @@ Ipv6ListRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<
#ifdef NOTYET
if (m_ipv6->MulticastCheckGroup (iif, dst))
#endif
if (true)
{
NS_LOG_LOGIC ("Multicast packet for me-- local deliver");
Ptr<Packet> packetCopy = p->Copy ();
// Here may want to disable lcb callback in recursive RouteInput
// call below
lcb (packetCopy, header, iif);
// Fall through-- we may also need to forward this
retVal = true;
}
if (true)
{
NS_LOG_LOGIC ("Multicast packet for me-- local deliver");
Ptr<Packet> packetCopy = p->Copy ();
// Here may want to disable lcb callback in recursive RouteInput
// call below
lcb (packetCopy, header, iif);
// Fall through-- we may also need to forward this
retVal = true;
}
/* do not forward link-local multicast address */
if (dst == Ipv6Address::GetAllNodesMulticast () || dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ())
@@ -134,7 +134,7 @@ Ipv6ListRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<
}
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end ();
m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
NS_LOG_LOGIC ("Multicast packet for me-- trying to forward");
@@ -146,12 +146,12 @@ Ipv6ListRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<
return retVal;
}
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
for (uint32_t j = 0; j < m_ipv6->GetNInterfaces (); j++)
{
for (uint32_t i = 0; i < m_ipv6->GetNAddresses (j); i++)
@@ -183,7 +183,7 @@ Ipv6ListRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<
}
// Next, try to find a route
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -201,7 +201,7 @@ Ipv6ListRouting::NotifyInterfaceUp (uint32_t interface)
{
NS_LOG_FUNCTION (this << interface);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -213,7 +213,7 @@ Ipv6ListRouting::NotifyInterfaceDown (uint32_t interface)
{
NS_LOG_FUNCTION (this << interface);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -225,7 +225,7 @@ Ipv6ListRouting::NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress addr
{
NS_LOG_FUNCTION (this << interface << address);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -237,7 +237,7 @@ Ipv6ListRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress a
{
NS_LOG_FUNCTION (this << interface << address);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -249,7 +249,7 @@ void Ipv6ListRouting::NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Addr
{
NS_LOG_FUNCTION (this << dst << mask << nextHop << interface);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -261,7 +261,7 @@ void Ipv6ListRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6A
{
NS_LOG_FUNCTION (this << dst << mask << nextHop << interface);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -275,7 +275,7 @@ Ipv6ListRouting::SetIpv6 (Ptr<Ipv6> ipv6)
NS_LOG_FUNCTION (this << ipv6);
NS_ASSERT (m_ipv6 == 0);
for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end ();
rprotoIter++)
{
@@ -340,113 +340,113 @@ Ipv6ListRouting::Compare (const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingPr
namespace ns3 {
class Ipv6ARouting : public Ipv6RoutingProtocol {
public:
Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) { return 0;}
bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
void NotifyInterfaceUp (uint32_t interface) {}
void NotifyInterfaceDown (uint32_t interface) {}
void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
};
class Ipv6ARouting : public Ipv6RoutingProtocol {
public:
Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) { return 0;}
bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
void NotifyInterfaceUp (uint32_t interface) {}
void NotifyInterfaceDown (uint32_t interface) {}
void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
};
class Ipv6BRouting : public Ipv6RoutingProtocol {
public:
Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) { return 0;}
bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
void NotifyInterfaceUp (uint32_t interface) {}
void NotifyInterfaceDown (uint32_t interface) {}
void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
};
class Ipv6BRouting : public Ipv6RoutingProtocol {
public:
Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) { return 0;}
bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb) {return false;}
void NotifyInterfaceUp (uint32_t interface) {}
void NotifyInterfaceDown (uint32_t interface) {}
void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) {}
void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
};
class Ipv6ListRoutingNegativeTestCase : public TestCase
{
public:
Ipv6ListRoutingNegativeTestCase();
virtual bool DoRun (void);
};
class Ipv6ListRoutingNegativeTestCase : public TestCase
{
public:
Ipv6ListRoutingNegativeTestCase();
virtual bool DoRun (void);
};
Ipv6ListRoutingNegativeTestCase::Ipv6ListRoutingNegativeTestCase()
: TestCase("Check negative priorities")
{}
bool
Ipv6ListRoutingNegativeTestCase::DoRun (void)
{
Ptr<Ipv6ListRouting> lr = CreateObject<Ipv6ListRouting> ();
Ptr<Ipv6RoutingProtocol> aRouting = CreateObject<Ipv6ARouting> ();
Ptr<Ipv6RoutingProtocol> bRouting = CreateObject<Ipv6BRouting> ();
// The Ipv6BRouting should be added with higher priority (larger integer value)
lr->AddRoutingProtocol (aRouting, -10);
lr->AddRoutingProtocol (bRouting, -5);
int16_t first = 3;
uint32_t num = lr->GetNRoutingProtocols ();
NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX");
Ptr<Ipv6RoutingProtocol> firstRp = lr->GetRoutingProtocol (0, first);
NS_TEST_ASSERT_MSG_EQ (-5, first, "XXX");
NS_TEST_ASSERT_MSG_EQ (firstRp, bRouting, "XXX");
Ipv6ListRoutingNegativeTestCase::Ipv6ListRoutingNegativeTestCase()
: TestCase("Check negative priorities")
{}
bool
Ipv6ListRoutingNegativeTestCase::DoRun (void)
{
Ptr<Ipv6ListRouting> lr = CreateObject<Ipv6ListRouting> ();
Ptr<Ipv6RoutingProtocol> aRouting = CreateObject<Ipv6ARouting> ();
Ptr<Ipv6RoutingProtocol> bRouting = CreateObject<Ipv6BRouting> ();
// The Ipv6BRouting should be added with higher priority (larger integer value)
lr->AddRoutingProtocol (aRouting, -10);
lr->AddRoutingProtocol (bRouting, -5);
int16_t first = 3;
uint32_t num = lr->GetNRoutingProtocols ();
NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX");
Ptr<Ipv6RoutingProtocol> firstRp = lr->GetRoutingProtocol (0, first);
NS_TEST_ASSERT_MSG_EQ (-5, first, "XXX");
NS_TEST_ASSERT_MSG_EQ (firstRp, bRouting, "XXX");
// XXX
return false;
}
// XXX
return false;
}
class Ipv6ListRoutingPositiveTestCase : public TestCase
{
public:
Ipv6ListRoutingPositiveTestCase();
virtual bool DoRun (void);
};
class Ipv6ListRoutingPositiveTestCase : public TestCase
{
public:
Ipv6ListRoutingPositiveTestCase();
virtual bool DoRun (void);
};
Ipv6ListRoutingPositiveTestCase::Ipv6ListRoutingPositiveTestCase()
: TestCase("Check positive priorities")
{}
bool
Ipv6ListRoutingPositiveTestCase::DoRun (void)
{
Ptr<Ipv6ListRouting> lr = CreateObject<Ipv6ListRouting> ();
Ptr<Ipv6RoutingProtocol> aRouting = CreateObject<Ipv6ARouting> ();
Ptr<Ipv6RoutingProtocol> bRouting = CreateObject<Ipv6BRouting> ();
// The Ipv6ARouting should be added with higher priority (larger integer
// value) and will be fetched first below
lr->AddRoutingProtocol (aRouting, 10);
lr->AddRoutingProtocol (bRouting, 5);
int16_t first = 3;
int16_t second = 3;
uint32_t num = lr->GetNRoutingProtocols ();
NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX");
Ptr<Ipv6RoutingProtocol> firstRp = lr->GetRoutingProtocol (0, first);
NS_TEST_ASSERT_MSG_EQ (10, first, "XXX");
NS_TEST_ASSERT_MSG_EQ (firstRp, aRouting, "XXX");
Ptr<Ipv6RoutingProtocol> secondRp = lr->GetRoutingProtocol (1, second);
NS_TEST_ASSERT_MSG_EQ (5, second, "XXX");
NS_TEST_ASSERT_MSG_EQ (secondRp, bRouting, "XXX");
// XXX
return false;
}
Ipv6ListRoutingPositiveTestCase::Ipv6ListRoutingPositiveTestCase()
: TestCase("Check positive priorities")
{}
bool
Ipv6ListRoutingPositiveTestCase::DoRun (void)
{
Ptr<Ipv6ListRouting> lr = CreateObject<Ipv6ListRouting> ();
Ptr<Ipv6RoutingProtocol> aRouting = CreateObject<Ipv6ARouting> ();
Ptr<Ipv6RoutingProtocol> bRouting = CreateObject<Ipv6BRouting> ();
// The Ipv6ARouting should be added with higher priority (larger integer
// value) and will be fetched first below
lr->AddRoutingProtocol (aRouting, 10);
lr->AddRoutingProtocol (bRouting, 5);
int16_t first = 3;
int16_t second = 3;
uint32_t num = lr->GetNRoutingProtocols ();
NS_TEST_ASSERT_MSG_EQ (num, 2, "XXX");
Ptr<Ipv6RoutingProtocol> firstRp = lr->GetRoutingProtocol (0, first);
NS_TEST_ASSERT_MSG_EQ (10, first, "XXX");
NS_TEST_ASSERT_MSG_EQ (firstRp, aRouting, "XXX");
Ptr<Ipv6RoutingProtocol> secondRp = lr->GetRoutingProtocol (1, second);
NS_TEST_ASSERT_MSG_EQ (5, second, "XXX");
NS_TEST_ASSERT_MSG_EQ (secondRp, bRouting, "XXX");
static class Ipv6ListRoutingTestSuite : public TestSuite
{
public:
Ipv6ListRoutingTestSuite()
: TestSuite("ipv6-list-routing", UNIT)
{
AddTestCase(new Ipv6ListRoutingPositiveTestCase());
AddTestCase(new Ipv6ListRoutingNegativeTestCase());
}
// XXX
return false;
}
} g_ipv6ListRoutingTestSuite;
static class Ipv6ListRoutingTestSuite : public TestSuite
{
public:
Ipv6ListRoutingTestSuite()
: TestSuite("ipv6-list-routing", UNIT)
{
AddTestCase(new Ipv6ListRoutingPositiveTestCase());
AddTestCase(new Ipv6ListRoutingNegativeTestCase());
}
} g_ipv6ListRoutingTestSuite;
} // namespace ns3

View File

@@ -70,13 +70,13 @@ public:
* Values may range between -32768 and +32767.
*/
virtual void AddRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol, int16_t priority);
/**
* \brief Get the number of routing protocols.
* \return number of routing protocols in the list
*/
virtual uint32_t GetNRoutingProtocols (void) const;
/**
* \brief Get pointer to routing protocol stored at index,
*

View File

@@ -109,9 +109,9 @@ Ipv6RoutingTableEntry::~Ipv6RoutingTableEntry ()
bool Ipv6RoutingTableEntry::IsHost () const
{
if (m_destNetworkPrefix.IsEqual (Ipv6Prefix::GetOnes ()))
{
return true;
}
{
return true;
}
return false;
}
@@ -138,9 +138,9 @@ bool Ipv6RoutingTableEntry::IsNetwork () const
bool Ipv6RoutingTableEntry::IsDefault () const
{
if (m_dest.IsEqual (Ipv6Address::GetZero ()))
{
return true;
}
{
return true;
}
return false;
}
@@ -157,9 +157,9 @@ Ipv6Prefix Ipv6RoutingTableEntry::GetDestNetworkPrefix () const
bool Ipv6RoutingTableEntry::IsGateway () const
{
if (m_gateway.IsEqual (Ipv6Address::GetZero ()))
{
return false;
}
{
return false;
}
return true;
}
@@ -206,44 +206,44 @@ uint32_t Ipv6RoutingTableEntry::GetInterface () const
std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route)
{
if (route.IsDefault ())
{
NS_ASSERT (route.IsGateway ());
os << "default out =" << route.GetInterface () << ", next hop =" << route.GetGateway ();
}
{
NS_ASSERT (route.IsGateway ());
os << "default out =" << route.GetInterface () << ", next hop =" << route.GetGateway ();
}
else if (route.IsHost ())
{
if (route.IsGateway ())
{
os << "host ="<< route.GetDest () <<
", out =" << route.GetInterface () <<
", next hop =" << route.GetGateway ();
if (route.IsGateway ())
{
os << "host ="<< route.GetDest () <<
", out =" << route.GetInterface () <<
", next hop =" << route.GetGateway ();
}
else
{
os << "host =" << route.GetDest () <<
", out =" << route.GetInterface ();
}
}
else
{
os << "host =" << route.GetDest () <<
", out =" << route.GetInterface ();
}
}
else if (route.IsNetwork ())
{
if (route.IsGateway ())
{
os << "network =" << route.GetDestNetwork () <<
", mask =" << route.GetDestNetworkPrefix () <<
",out =" << route.GetInterface () <<
", next hop =" << route.GetGateway ();
if (route.IsGateway ())
{
os << "network =" << route.GetDestNetwork () <<
", mask =" << route.GetDestNetworkPrefix () <<
",out =" << route.GetInterface () <<
", next hop =" << route.GetGateway ();
}
else
{
os << "network =" << route.GetDestNetwork () <<
", mask =" << route.GetDestNetworkPrefix () <<
",out =" << route.GetInterface ();
}
}
else
{
os << "network =" << route.GetDestNetwork () <<
", mask =" << route.GetDestNetworkPrefix () <<
",out =" << route.GetInterface ();
}
}
else
{
NS_ASSERT (false);
}
{
NS_ASSERT (false);
}
return os;
}
@@ -320,9 +320,9 @@ std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const
", output interfaces =";
for (uint32_t i = 0; i < route.GetNOutputInterfaces (); ++i)
{
os << route.GetOutputInterface (i) << " ";
}
{
os << route.GetOutputInterface (i) << " ";
}
return os;
}

View File

@@ -36,227 +36,227 @@ namespace ns3
*/
class Ipv6RoutingTableEntry
{
public:
/**
* \brief Constructor.
*/
Ipv6RoutingTableEntry ();
public:
/**
* \brief Constructor.
*/
Ipv6RoutingTableEntry ();
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const & route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const & route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const* route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6RoutingTableEntry (Ipv6RoutingTableEntry const* route);
/**
* \brief Destructor
*/
~Ipv6RoutingTableEntry ();
/**
* \brief Destructor
*/
~Ipv6RoutingTableEntry ();
/**
* \brief Is the route entry correspond to a host ?
* \return true if the route is a host, false otherwise
*/
bool IsHost () const;
/**
* \brief Is the route entry correspond to a host ?
* \return true if the route is a host, false otherwise
*/
bool IsHost () const;
/**
* \brief Get the destination.
* \return the IPv6 address of the destination of this route
*/
Ipv6Address GetDest () const;
/**
* \brief Get the destination.
* \return the IPv6 address of the destination of this route
*/
Ipv6Address GetDest () const;
/**
* \brief Get the prefix to use (for multihomed link).
* \return prefix address to use
*/
Ipv6Address GetPrefixToUse () const;
/**
* \brief Get the prefix to use (for multihomed link).
* \return prefix address to use
*/
Ipv6Address GetPrefixToUse () const;
/**
* \brief Set the prefix to use.
* \param prefix prefix to use
*/
void SetPrefixToUse (Ipv6Address prefix);
/**
* \brief Set the prefix to use.
* \param prefix prefix to use
*/
void SetPrefixToUse (Ipv6Address prefix);
/**
* \brief Is the route entry correspond to a network ?
* \return true if the route is a network, false otherwise
*/
bool IsNetwork () const;
/**
* \brief Is the route entry correspond to a network ?
* \return true if the route is a network, false otherwise
*/
bool IsNetwork () const;
/**
* \brief Get the destination network.
* \return the destination network
*/
Ipv6Address GetDestNetwork () const;
/**
* \brief Get the destination network.
* \return the destination network
*/
Ipv6Address GetDestNetwork () const;
/**
* \brief Get the destination prefix.
* \return the destination prefix
*/
Ipv6Prefix GetDestNetworkPrefix () const;
/**
* \brief Get the destination prefix.
* \return the destination prefix
*/
Ipv6Prefix GetDestNetworkPrefix () const;
/**
* \brief Is it the default route ?
* \return true if this route is a default route, false otherwise
*/
bool IsDefault () const;
/**
* \brief Is it the default route ?
* \return true if this route is a default route, false otherwise
*/
bool IsDefault () const;
/**
* \brief Is it the gateway ?
* \return true if this route is a gateway, false otherwise
*/
bool IsGateway () const;
/**
* \brief Is it the gateway ?
* \return true if this route is a gateway, false otherwise
*/
bool IsGateway () const;
/**
* \brief Get the gateway.
* \return the IPv6 address of the gateway
*/
Ipv6Address GetGateway () const;
/**
* \brief Get the gateway.
* \return the IPv6 address of the gateway
*/
Ipv6Address GetGateway () const;
/**
* \brief Get the interface index.
* \return the index of the interface
*/
uint32_t GetInterface () const;
/**
* \brief Get the interface index.
* \return the index of the interface
*/
uint32_t GetInterface () const;
/**
* \brief Create a route to a host.
* \param dest destination address
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address ());
/**
* \brief Create a route to a host.
* \param dest destination address
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address ());
/**
* \brief Create a route to a host.
* \param dest destination address
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, uint32_t interface);
/**
* \brief Create a route to a host.
* \param dest destination address
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateHostRouteTo (Ipv6Address dest, uint32_t interface);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param nextHop next hop address to route the packet
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param nextHop next hop address to route the packet
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
/**
* \brief Create a route to a network.
* \param network network address
* \param networkPrefix network prefix
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
/**
* \brief Create a default route.
* \param nextHop next hop address to route the packet
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateDefaultRoute (Ipv6Address nextHop, uint32_t interface);
/**
* \brief Create a default route.
* \param nextHop next hop address to route the packet
* \param interface interface index
* \return IPv6Route object
*/
static Ipv6RoutingTableEntry CreateDefaultRoute (Ipv6Address nextHop, uint32_t interface);
private:
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param gateway the gateway
* \param interface the interface index
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface);
private:
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param gateway the gateway
* \param interface the interface index
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface);
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param interface the interface index
* \param prefixToUse prefix to use
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param interface the interface index
* \param prefixToUse prefix to use
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param gateway the gateway
* \param interface the interface index
* \param prefixToUse prefix to use
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Constructor.
* \param network network address
* \param prefix network prefix
* \param gateway the gateway
* \param interface the interface index
* \param prefixToUse prefix to use
*/
Ipv6RoutingTableEntry (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address gateway, uint32_t interface, Ipv6Address prefixToUse);
/**
* \brief Constructor.
* \param dest destination address
* \param prefix destiation prefix
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Prefix prefix, uint32_t interface);
/**
* \brief Constructor.
* \param dest destination address
* \param prefix destiation prefix
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Prefix prefix, uint32_t interface);
/**
* \brief Constructor.
* \param dest destination address
* \param gateway the gateway
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Address gateway, uint32_t interface);
/**
* \brief Constructor.
* \param dest destination address
* \param gateway the gateway
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, Ipv6Address gateway, uint32_t interface);
/**
* \brief Constructor.
* \param dest destination address
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, uint32_t interface);
/**
* \brief Constructor.
* \param dest destination address
* \param interface interface index
*/
Ipv6RoutingTableEntry (Ipv6Address dest, uint32_t interface);
/**
* \brief IPv6 address of the destination.
*/
Ipv6Address m_dest;
/**
* \brief IPv6 address of the destination.
*/
Ipv6Address m_dest;
/**
* \brief IPv6 prefix of the destination
*/
Ipv6Prefix m_destNetworkPrefix;
/**
* \brief IPv6 prefix of the destination
*/
Ipv6Prefix m_destNetworkPrefix;
/**
* \brief IPv6 address of the gateway.
*/
Ipv6Address m_gateway;
/**
* \brief IPv6 address of the gateway.
*/
Ipv6Address m_gateway;
/**
* \brief The interface index.
*/
uint32_t m_interface;
/**
* \brief The interface index.
*/
uint32_t m_interface;
/**
* \brief Prefix to use.
*/
Ipv6Address m_prefixToUse;
/**
* \brief Prefix to use.
*/
Ipv6Address m_prefixToUse;
};
@@ -268,100 +268,100 @@ std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route);
*/
class Ipv6MulticastRoutingTableEntry
{
public:
/**
* \brief Constructor.
*/
Ipv6MulticastRoutingTableEntry ();
public:
/**
* \brief Constructor.
*/
Ipv6MulticastRoutingTableEntry ();
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const & route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const & route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const* route);
/**
* \brief Copy constructor.
* \param route the route to copy
*/
Ipv6MulticastRoutingTableEntry (Ipv6MulticastRoutingTableEntry const* route);
/**
* \brief Get the source of this route
* \return IPv6 address of the source of this route
*/
Ipv6Address GetOrigin () const;
/**
* \brief Get the source of this route
* \return IPv6 address of the source of this route
*/
Ipv6Address GetOrigin () const;
/**
* \brief Get the group.
* \return IPv6 address of the multicast group of this route
*/
Ipv6Address GetGroup () const;
/**
* \brief Get the group.
* \return IPv6 address of the multicast group of this route
*/
Ipv6Address GetGroup () const;
/**
* \brief Get the input interface address.
* \return input interface index
*/
uint32_t GetInputInterface () const;
/**
* \brief Get the input interface address.
* \return input interface index
*/
uint32_t GetInputInterface () const;
/**
* \brief Get the number of output interfaces of this route.
* \return number of output interfaces of this route.
*/
uint32_t GetNOutputInterfaces () const;
/**
* \brief Get the number of output interfaces of this route.
* \return number of output interfaces of this route.
*/
uint32_t GetNOutputInterfaces () const;
/**
* \brief Get a specified output interface.
* \param n index
* \return a specified output interface
*/
uint32_t GetOutputInterface (uint32_t n) const;
/**
* \brief Get a specified output interface.
* \param n index
* \return a specified output interface
*/
uint32_t GetOutputInterface (uint32_t n) const;
/**
* \brief Get all of the output interfaces of this route.
* \return a vector of all output interfaces of this route
*/
std::vector<uint32_t> GetOutputInterfaces () const;
/**
* \brief Get all of the output interfaces of this route.
* \return a vector of all output interfaces of this route
*/
std::vector<uint32_t> GetOutputInterfaces () const;
/**
* \brief Create a multicast route.
* \param origin IPv6 address of the origin source
* \param group Ipv6Address of the group
* \param inputInterface interface number
* \param outputInterfaces list of output interface number
* \return a multicast route
*/
static Ipv6MulticastRoutingTableEntry CreateMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
/**
* \brief Create a multicast route.
* \param origin IPv6 address of the origin source
* \param group Ipv6Address of the group
* \param inputInterface interface number
* \param outputInterfaces list of output interface number
* \return a multicast route
*/
static Ipv6MulticastRoutingTableEntry CreateMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
private:
/**
* \brief Constructor.
* \param origin IPv6 address of the source
* \param group IPv6 address of the group
* \param inputInterface interface number
* \param outputInterfaces list of output interface number
*/
Ipv6MulticastRoutingTableEntry (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
private:
/**
* \brief Constructor.
* \param origin IPv6 address of the source
* \param group IPv6 address of the group
* \param inputInterface interface number
* \param outputInterfaces list of output interface number
*/
Ipv6MulticastRoutingTableEntry (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
/**
* \brief The IPv6 address of the source.
*/
Ipv6Address m_origin;
/**
* \brief The IPv6 address of the source.
*/
Ipv6Address m_origin;
/**
* \brief The IPv6 address of the group.
*/
Ipv6Address m_group;
/**
* \brief The IPv6 address of the group.
*/
Ipv6Address m_group;
/**
* \brief The input interface.
*/
uint32_t m_inputInterface;
/**
* \brief The input interface.
*/
uint32_t m_inputInterface;
/**
* \brief The output interfaces.
*/
std::vector<uint32_t> m_outputInterfaces;
/**
* \brief The output interfaces.
*/
std::vector<uint32_t> m_outputInterfaces;
};
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const& route);

View File

@@ -40,8 +40,8 @@ TypeId Ipv6StaticRouting::GetTypeId ()
return tid;
}
Ipv6StaticRouting::Ipv6StaticRouting ()
: m_ipv6 (0)
Ipv6StaticRouting::Ipv6StaticRouting ()
: m_ipv6 (0)
{
NS_LOG_FUNCTION_NOARGS ();
}
@@ -59,16 +59,16 @@ void Ipv6StaticRouting::SetIpv6 (Ptr<Ipv6> ipv6)
m_ipv6 = ipv6;
for (i = 0 ; i < m_ipv6->GetNInterfaces () ; i++)
{
if (m_ipv6->IsUp (i))
{
NotifyInterfaceUp (i);
if (m_ipv6->IsUp (i))
{
NotifyInterfaceUp (i);
}
else
{
NotifyInterfaceDown (i);
}
}
else
{
NotifyInterfaceDown (i);
}
}
}
void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric)
@@ -143,17 +143,17 @@ Ipv6MulticastRoutingTableEntry Ipv6StaticRouting::GetMulticastRoute (uint32_t in
NS_ASSERT_MSG (index < m_multicastRoutes.size (), "Ipv6StaticRouting::GetMulticastRoute () : Index out of range");
if (index < m_multicastRoutes.size ())
{
uint32_t tmp = 0;
for (MulticastRoutesCI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++)
{
if (tmp == index)
{
return *i;
}
tmp++;
uint32_t tmp = 0;
for (MulticastRoutesCI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++)
{
if (tmp == index)
{
return *i;
}
tmp++;
}
}
}
return 0;
}
@@ -161,17 +161,17 @@ bool Ipv6StaticRouting::RemoveMulticastRoute (Ipv6Address origin, Ipv6Address gr
{
NS_LOG_FUNCTION (this << origin << group << inputInterface);
for (MulticastRoutesI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i++)
{
Ipv6MulticastRoutingTableEntry *route = *i;
if (origin == route->GetOrigin () &&
group == route->GetGroup () &&
inputInterface == route->GetInputInterface ())
{
delete *i;
m_multicastRoutes.erase (i);
return true;
Ipv6MulticastRoutingTableEntry *route = *i;
if (origin == route->GetOrigin () &&
group == route->GetGroup () &&
inputInterface == route->GetInputInterface ())
{
delete *i;
m_multicastRoutes.erase (i);
return true;
}
}
}
return false;
}
@@ -181,15 +181,15 @@ void Ipv6StaticRouting::RemoveMulticastRoute (uint32_t index)
uint32_t tmp = 0;
for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++)
{
if (tmp == index)
{
delete *i;
m_multicastRoutes.erase (i);
return;
if (tmp == index)
{
delete *i;
m_multicastRoutes.erase (i);
return;
}
tmp++;
}
tmp++;
}
}
bool Ipv6StaticRouting::HasNetworkDest (Ipv6Address network, uint32_t interfaceIndex)
@@ -198,16 +198,16 @@ bool Ipv6StaticRouting::HasNetworkDest (Ipv6Address network, uint32_t interfaceI
/* in the network table */
for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++)
{
Ipv6RoutingTableEntry* rtentry = j->first;
Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix ();
Ipv6Address entry = rtentry->GetDestNetwork ();
if (prefix.IsMatch (network, entry) && rtentry->GetInterface () == interfaceIndex)
{
return true;
Ipv6RoutingTableEntry* rtentry = j->first;
Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix ();
Ipv6Address entry = rtentry->GetDestNetwork ();
if (prefix.IsMatch (network, entry) && rtentry->GetInterface () == interfaceIndex)
{
return true;
}
}
}
/* beuh!!! not route at all */
return false;
@@ -223,80 +223,80 @@ Ptr<Ipv6Route> Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr<NetDevice>
/* when sending on link-local multicast, there have to be interface specified */
if (dst == Ipv6Address::GetAllNodesMulticast () || dst.IsSolicitedMulticast () ||
dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ())
{
NS_ASSERT_MSG (interface, "Try to send on link-local multicast address, and no interface index is given!");
rtentry = Create<Ipv6Route> ();
rtentry->SetSource (SourceAddressSelection (m_ipv6->GetInterfaceForDevice (interface), dst));
rtentry->SetDestination (dst);
rtentry->SetGateway (Ipv6Address::GetZero ());
rtentry->SetOutputDevice (interface);
return rtentry;
}
{
NS_ASSERT_MSG (interface, "Try to send on link-local multicast address, and no interface index is given!");
rtentry = Create<Ipv6Route> ();
rtentry->SetSource (SourceAddressSelection (m_ipv6->GetInterfaceForDevice (interface), dst));
rtentry->SetDestination (dst);
rtentry->SetGateway (Ipv6Address::GetZero ());
rtentry->SetOutputDevice (interface);
return rtentry;
}
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
Ipv6RoutingTableEntry* j = it->first;
uint32_t metric = it->second;
Ipv6Prefix mask = j->GetDestNetworkPrefix ();
uint16_t maskLen = mask.GetPrefixLength ();
Ipv6Address entry = j->GetDestNetwork ();
NS_LOG_LOGIC ("Searching for route to " << dst << ", mask length " << maskLen << ", metric " << metric);
if (mask.IsMatch (dst, entry))
{
NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric);
Ipv6RoutingTableEntry* j = it->first;
uint32_t metric = it->second;
Ipv6Prefix mask = j->GetDestNetworkPrefix ();
uint16_t maskLen = mask.GetPrefixLength ();
Ipv6Address entry = j->GetDestNetwork ();
/* if interface is given, check the route will output on this interface */
if (!interface || interface == m_ipv6->GetNetDevice (j->GetInterface ()))
{
if (maskLen < longestMask)
{
NS_LOG_LOGIC ("Previous match longer, skipping");
continue;
}
NS_LOG_LOGIC ("Searching for route to " << dst << ", mask length " << maskLen << ", metric " << metric);
if (maskLen > longestMask)
if (mask.IsMatch (dst, entry))
{
shortestMetric = 0xffffffff;
}
NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric);
longestMask = maskLen;
if (metric > shortestMetric)
{
NS_LOG_LOGIC ("Equal mask length, but previous metric shorter, skipping");
continue;
}
/* if interface is given, check the route will output on this interface */
if (!interface || interface == m_ipv6->GetNetDevice (j->GetInterface ()))
{
if (maskLen < longestMask)
{
NS_LOG_LOGIC ("Previous match longer, skipping");
continue;
}
shortestMetric = metric;
Ipv6RoutingTableEntry* route = j;
uint32_t interfaceIdx = route->GetInterface ();
rtentry = Create<Ipv6Route> ();
if (maskLen > longestMask)
{
shortestMetric = 0xffffffff;
}
if (route->GetGateway ().IsAny ())
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetDest ()));
}
else if (route->GetDest ().IsAny ()) /* default route */
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? route->GetGateway () : route->GetPrefixToUse ()));
}
else
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetGateway ()));
}
longestMask = maskLen;
if (metric > shortestMetric)
{
NS_LOG_LOGIC ("Equal mask length, but previous metric shorter, skipping");
continue;
}
rtentry->SetDestination (route->GetDest ());
rtentry->SetGateway (route->GetGateway ());
rtentry->SetOutputDevice (m_ipv6->GetNetDevice (interfaceIdx));
}
shortestMetric = metric;
Ipv6RoutingTableEntry* route = j;
uint32_t interfaceIdx = route->GetInterface ();
rtentry = Create<Ipv6Route> ();
if (route->GetGateway ().IsAny ())
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetDest ()));
}
else if (route->GetDest ().IsAny ()) /* default route */
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetPrefixToUse ().IsAny () ? route->GetGateway () : route->GetPrefixToUse ()));
}
else
{
rtentry->SetSource (SourceAddressSelection (interfaceIdx, route->GetGateway ()));
}
rtentry->SetDestination (route->GetDest ());
rtentry->SetGateway (route->GetGateway ());
rtentry->SetOutputDevice (m_ipv6->GetNetDevice (interfaceIdx));
}
}
}
}
if(rtentry)
{
NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (throught " << rtentry->GetGateway () << ") at the end");
}
{
NS_LOG_LOGIC ("Matching route via " << rtentry->GetDestination () << " (throught " << rtentry->GetGateway () << ") at the end");
}
return rtentry;
}
@@ -305,15 +305,15 @@ void Ipv6StaticRouting::DoDispose ()
NS_LOG_FUNCTION_NOARGS ();
for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j = m_networkRoutes.erase (j))
{
delete j->first;
}
{
delete j->first;
}
m_networkRoutes.clear ();
for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i = m_multicastRoutes.erase (i))
{
delete (*i);
}
{
delete (*i);
}
m_multicastRoutes.clear ();
m_ipv6 = 0;
@@ -326,46 +326,46 @@ Ptr<Ipv6MulticastRoute> Ipv6StaticRouting::LookupStatic (Ipv6Address origin, Ipv
Ptr<Ipv6MulticastRoute> mrtentry = 0;
for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++)
{
Ipv6MulticastRoutingTableEntry* route = *i;
/*
We've been passed an origin address, a multicast group address and an
interface index. We have to decide if the current route in the list is
a match.
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).
*/
if (origin == route->GetOrigin () && group == route->GetGroup ())
{
/* skipping SSM case */
NS_LOG_LOGIC ("Find source specific multicast route" << *i);
}
Ipv6MulticastRoutingTableEntry* route = *i;
if (group == route->GetGroup ())
{
if (interface == Ipv6::IF_ANY || interface == route->GetInputInterface ())
{
NS_LOG_LOGIC ("Found multicast route" << *i);
mrtentry = Create<Ipv6MulticastRoute> ();
mrtentry->SetGroup (route->GetGroup ());
mrtentry->SetOrigin (route->GetOrigin ());
mrtentry->SetParent (route->GetInputInterface ());
for (uint32_t j = 0 ; j < route->GetNOutputInterfaces () ; j++)
/*
We've been passed an origin address, a multicast group address and an
interface index. We have to decide if the current route in the list is
a match.
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).
*/
if (origin == route->GetOrigin () && group == route->GetGroup ())
{
if (route->GetOutputInterface (j))
{
NS_LOG_LOGIC ("Setting output interface index " << route->GetOutputInterface (j));
mrtentry->SetOutputTtl (route->GetOutputInterface (j), Ipv6MulticastRoute::MAX_TTL - 1);
}
/* skipping SSM case */
NS_LOG_LOGIC ("Find source specific multicast route" << *i);
}
if (group == route->GetGroup ())
{
if (interface == Ipv6::IF_ANY || interface == route->GetInputInterface ())
{
NS_LOG_LOGIC ("Found multicast route" << *i);
mrtentry = Create<Ipv6MulticastRoute> ();
mrtentry->SetGroup (route->GetGroup ());
mrtentry->SetOrigin (route->GetOrigin ());
mrtentry->SetParent (route->GetInputInterface ());
for (uint32_t j = 0 ; j < route->GetNOutputInterfaces () ; j++)
{
if (route->GetOutputInterface (j))
{
NS_LOG_LOGIC ("Setting output interface index " << route->GetOutputInterface (j));
mrtentry->SetOutputTtl (route->GetOutputInterface (j), Ipv6MulticastRoute::MAX_TTL - 1);
}
}
return mrtentry;
}
}
return mrtentry;
}
}
}
return mrtentry;
}
@@ -382,34 +382,34 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetDefaultRoute ()
Ipv6RoutingTableEntry* result = 0;
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
Ipv6RoutingTableEntry* j = it->first;
uint32_t metric = it->second;
Ipv6Prefix mask = j->GetDestNetworkPrefix ();
uint16_t maskLen = mask.GetPrefixLength ();
Ipv6Address entry = j->GetDestNetwork ();
if (maskLen)
{
continue;
}
Ipv6RoutingTableEntry* j = it->first;
uint32_t metric = it->second;
Ipv6Prefix mask = j->GetDestNetworkPrefix ();
uint16_t maskLen = mask.GetPrefixLength ();
Ipv6Address entry = j->GetDestNetwork ();
if (metric > shortestMetric)
{
continue;
if (maskLen)
{
continue;
}
if (metric > shortestMetric)
{
continue;
}
shortestMetric = metric;
result = j;
}
shortestMetric = metric;
result = j;
}
if (result)
{
return result;
}
{
return result;
}
else
{
return Ipv6RoutingTableEntry ();
}
{
return Ipv6RoutingTableEntry ();
}
}
Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index)
@@ -418,13 +418,13 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index)
uint32_t tmp = 0;
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
if (tmp == index)
{
return it->first;
if (tmp == index)
{
return it->first;
}
tmp++;
}
tmp++;
}
NS_ASSERT (false);
// quiet compiler.
return 0;
@@ -436,13 +436,13 @@ uint32_t Ipv6StaticRouting::GetMetric (uint32_t index)
uint32_t tmp = 0;
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
if (tmp == index)
{
return it->second;
if (tmp == index)
{
return it->second;
}
tmp++;
}
tmp++;
}
NS_ASSERT (false);
// quiet compiler.
return 0;
@@ -454,15 +454,15 @@ void Ipv6StaticRouting::RemoveRoute (uint32_t index)
uint32_t tmp = 0;
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
if (tmp == index)
{
delete it->first;
m_networkRoutes.erase (it);
return;
if (tmp == index)
{
delete it->first;
m_networkRoutes.erase (it);
return;
}
tmp++;
}
tmp++;
}
NS_ASSERT (false);
}
@@ -471,16 +471,16 @@ void Ipv6StaticRouting::RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uin
NS_LOG_FUNCTION (this << network << prefix << ifIndex);
for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++)
{
Ipv6RoutingTableEntry* rtentry = it->first;
if (network == rtentry->GetDest () && rtentry->GetInterface () == ifIndex &&
rtentry->GetPrefixToUse () == prefixToUse)
{
delete it->first;
m_networkRoutes.erase (it);
return;
Ipv6RoutingTableEntry* rtentry = it->first;
if (network == rtentry->GetDest () && rtentry->GetInterface () == ifIndex &&
rtentry->GetPrefixToUse () == prefixToUse)
{
delete it->first;
m_networkRoutes.erase (it);
return;
}
}
}
}
Ptr<Ipv6Route> Ipv6StaticRouting::RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)
@@ -490,25 +490,25 @@ Ptr<Ipv6Route> Ipv6StaticRouting::RouteOutput (Ptr<Packet> p, const Ipv6Header &
Ptr<Ipv6Route> rtentry = 0;
if (destination.IsMulticast ())
{
// Note: Multicast routes for outbound packets are stored in the
// normal unicast table. An implication of this is that it is not
// possible to source multicast datagrams on multiple interfaces.
// This is a well-known property of sockets implementation on
// many Unix variants.
// So, we just log it and fall through to LookupStatic ()
NS_LOG_LOGIC ("RouteOutput ()::Multicast destination");
}
{
// Note: Multicast routes for outbound packets are stored in the
// normal unicast table. An implication of this is that it is not
// possible to source multicast datagrams on multiple interfaces.
// This is a well-known property of sockets implementation on
// many Unix variants.
// So, we just log it and fall through to LookupStatic ()
NS_LOG_LOGIC ("RouteOutput ()::Multicast destination");
}
rtentry = LookupStatic (destination, oif);
if (rtentry)
{
sockerr = Socket::ERROR_NOTERROR;
}
{
sockerr = Socket::ERROR_NOTERROR;
}
else
{
sockerr = Socket::ERROR_NOROUTETOHOST;
}
{
sockerr = Socket::ERROR_NOROUTETOHOST;
}
return rtentry;
}
@@ -524,30 +524,30 @@ bool Ipv6StaticRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &heade
Ipv6Address dst = header.GetDestinationAddress ();
if (dst.IsMulticast ())
{
NS_LOG_LOGIC ("Multicast destination");
Ptr<Ipv6MulticastRoute> mrtentry = LookupStatic (header.GetSourceAddress (),
header.GetDestinationAddress (), m_ipv6->GetInterfaceForDevice (idev));
if (mrtentry)
{
NS_LOG_LOGIC ("Multicast route found");
mcb (mrtentry, p, header); // multicast forwarding callback
return true;
}
else
{
NS_LOG_LOGIC ("Multicast route not found");
return false; // Let other routing protocols try to handle this
}
}
NS_LOG_LOGIC ("Multicast destination");
Ptr<Ipv6MulticastRoute> mrtentry = LookupStatic (header.GetSourceAddress (),
header.GetDestinationAddress (), m_ipv6->GetInterfaceForDevice (idev));
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
if (mrtentry)
{
NS_LOG_LOGIC ("Multicast route found");
mcb (mrtentry, p, header); // multicast forwarding callback
return true;
}
else
{
NS_LOG_LOGIC ("Multicast route not found");
return false; // Let other routing protocols try to handle this
}
}
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
for (uint32_t j = 0; j < m_ipv6->GetNInterfaces (); j++)
{
for (uint32_t i = 0; i < m_ipv6->GetNAddresses (j); i++)
@@ -582,37 +582,37 @@ bool Ipv6StaticRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &heade
Ptr<Ipv6Route> rtentry = LookupStatic (header.GetDestinationAddress ());
if (rtentry != 0)
{
NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
ucb (rtentry, p, header); // unicast forwarding callback
return true;
}
{
NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
ucb (rtentry, p, header); // unicast forwarding callback
return true;
}
else
{
NS_LOG_LOGIC ("Did not find unicast destination- returning false");
return false; // Let other routing protocols try to handle this
}
{
NS_LOG_LOGIC ("Did not find unicast destination- returning false");
return false; // Let other routing protocols try to handle this
}
}
void Ipv6StaticRouting::NotifyInterfaceUp (uint32_t i)
{
for (uint32_t j = 0 ; j < m_ipv6->GetNAddresses (i) ; j++)
{
if (m_ipv6->GetAddress (i, j).GetAddress () != Ipv6Address () &&
m_ipv6->GetAddress (i, j).GetPrefix () != Ipv6Prefix ())
{
if (m_ipv6->GetAddress (i, j).GetPrefix () == Ipv6Prefix (128))
{
/* host route */
AddHostRouteTo (m_ipv6->GetAddress (i, j).GetAddress (), i);
}
else
{
AddNetworkRouteTo (m_ipv6->GetAddress (i, j).GetAddress ().CombinePrefix (m_ipv6->GetAddress (i, j).GetPrefix ()),
m_ipv6->GetAddress (i, j).GetPrefix (), i);
}
if (m_ipv6->GetAddress (i, j).GetAddress () != Ipv6Address () &&
m_ipv6->GetAddress (i, j).GetPrefix () != Ipv6Prefix ())
{
if (m_ipv6->GetAddress (i, j).GetPrefix () == Ipv6Prefix (128))
{
/* host route */
AddHostRouteTo (m_ipv6->GetAddress (i, j).GetAddress (), i);
}
else
{
AddNetworkRouteTo (m_ipv6->GetAddress (i, j).GetAddress ().CombinePrefix (m_ipv6->GetAddress (i, j).GetPrefix ()),
m_ipv6->GetAddress (i, j).GetPrefix (), i);
}
}
}
}
}
void Ipv6StaticRouting::NotifyInterfaceDown (uint32_t i)
@@ -623,42 +623,42 @@ void Ipv6StaticRouting::NotifyInterfaceDown (uint32_t i)
/* remove all static routes that are going through this interface */
while (j < max)
{
Ipv6RoutingTableEntry route = GetRoute (j);
{
Ipv6RoutingTableEntry route = GetRoute (j);
if (route.GetInterface () == i)
{
RemoveRoute (j);
if (route.GetInterface () == i)
{
RemoveRoute (j);
}
else
{
j++;
}
}
else
{
j++;
}
}
}
void Ipv6StaticRouting::NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address)
{
if (!m_ipv6->IsUp (interface))
{
return;
}
{
return;
}
Ipv6Address networkAddress = address.GetAddress ().CombinePrefix (address.GetPrefix ());
Ipv6Prefix networkMask = address.GetPrefix ();
if (address.GetAddress () != Ipv6Address () && address.GetPrefix () != Ipv6Prefix ())
{
AddNetworkRouteTo (networkAddress, networkMask, interface);
}
{
AddNetworkRouteTo (networkAddress, networkMask, interface);
}
}
void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address)
{
if (!m_ipv6->IsUp (interface))
{
return;
}
{
return;
}
Ipv6Address networkAddress = address.GetAddress ().CombinePrefix (address.GetPrefix ());
Ipv6Prefix networkMask = address.GetPrefix ();
@@ -666,63 +666,63 @@ void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAd
// Remove all static routes that are going through this interface
// which reference this network
for (uint32_t j = 0 ; j < GetNRoutes () ; j++)
{
Ipv6RoutingTableEntry route = GetRoute (j);
if (route.GetInterface () == interface &&
route.IsNetwork () &&
route.GetDestNetwork () == networkAddress &&
route.GetDestNetworkPrefix () == networkMask)
{
RemoveRoute (j);
Ipv6RoutingTableEntry route = GetRoute (j);
if (route.GetInterface () == interface &&
route.IsNetwork () &&
route.GetDestNetwork () == networkAddress &&
route.GetDestNetworkPrefix () == networkMask)
{
RemoveRoute (j);
}
}
}
}
void Ipv6StaticRouting::NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse)
{
NS_LOG_INFO (this << dst << mask << nextHop << interface << prefixToUse);
if (dst != Ipv6Address::GetZero ())
{
AddNetworkRouteTo (dst, mask, nextHop, interface);
}
{
AddNetworkRouteTo (dst, mask, nextHop, interface);
}
else /* default route */
{
/* this case is mainly used by configuring default route following RA processing,
* in case of multipe prefix in RA, the first will configured default route
*/
{
/* this case is mainly used by configuring default route following RA processing,
* in case of multipe prefix in RA, the first will configured default route
*/
/* for the moment, all default route has the same metric
* so according to the longest prefix algorithm,
* the default route choosen will be the last added
*/
SetDefaultRoute (nextHop, interface, prefixToUse);
}
/* for the moment, all default route has the same metric
* so according to the longest prefix algorithm,
* the default route choosen will be the last added
*/
SetDefaultRoute (nextHop, interface, prefixToUse);
}
}
void Ipv6StaticRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse)
{
NS_LOG_FUNCTION (this << dst << mask << nextHop << interface);
if (dst != Ipv6Address::GetZero ())
{
for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++)
{
Ipv6RoutingTableEntry* rtentry = j->first;
Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix ();
Ipv6Address entry = rtentry->GetDestNetwork ();
for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++)
{
Ipv6RoutingTableEntry* rtentry = j->first;
Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix ();
Ipv6Address entry = rtentry->GetDestNetwork ();
if (dst == entry && prefix == mask && rtentry->GetInterface () == interface)
{
delete j->first;
m_networkRoutes.erase (j);
}
if (dst == entry && prefix == mask && rtentry->GetInterface () == interface)
{
delete j->first;
m_networkRoutes.erase (j);
}
}
}
}
else
{
/* default route case */
RemoveRoute (dst, mask, interface, prefixToUse);
}
{
/* default route case */
RemoveRoute (dst, mask, interface, prefixToUse);
}
}
Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6Address dest)
@@ -734,21 +734,21 @@ Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6A
ret = m_ipv6->GetAddress (interface, 0).GetAddress ();
if (dest == Ipv6Address::GetAllNodesMulticast () || dest == Ipv6Address::GetAllRoutersMulticast () || dest == Ipv6Address::GetAllHostsMulticast ())
{
return ret;
}
{
return ret;
}
/* useally IPv6 interfaces have one link-local address and one global address */
for (uint32_t i = 1 ; i < m_ipv6->GetNAddresses (interface) ; i++)
{
Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i);
if (test.GetAddress ().CombinePrefix (test.GetPrefix ()) == dest.CombinePrefix (test.GetPrefix ()))
{
return test.GetAddress ();
Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i);
if (test.GetAddress ().CombinePrefix (test.GetPrefix ()) == dest.CombinePrefix (test.GetPrefix ()))
{
return test.GetAddress ();
}
}
}
return ret;
}

View File

@@ -55,242 +55,242 @@ class Ipv6MulticastRoutingTableEntry;
*/
class Ipv6StaticRouting : public Ipv6RoutingProtocol
{
public:
/**
* \brief The interface Id associated with this class.
* \return type identifier
*/
static TypeId GetTypeId ();
public:
/**
* \brief The interface Id associated with this class.
* \return type identifier
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6StaticRouting ();
/**
* \brief Constructor.
*/
Ipv6StaticRouting ();
/**
* \brief Destructor.
*/
virtual ~Ipv6StaticRouting ();
/**
* \brief Destructor.
*/
virtual ~Ipv6StaticRouting ();
/**
* \brief Add route to host.
* \param dest destination address
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \param metric metric of route in case of multiple routes to same destination
*/
void AddHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
/**
* \brief Add route to host.
* \param dest destination address
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \param metric metric of route in case of multiple routes to same destination
*/
void AddHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
/**
* \brief Add route to host.
* \param dest destination address.
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddHostRouteTo (Ipv6Address dest, uint32_t interface, uint32_t metric = 0);
/**
* \brief Add route to host.
* \param dest destination address.
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddHostRouteTo (Ipv6Address dest, uint32_t interface, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix*
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix*
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix*
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix*
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix that should be used for source address for this destination
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface, uint32_t metric = 0);
/**
* \brief Add route to network.
* \param network network address
* \param networkPrefix network prefix
* \param interface interface index
* \param metric metric of route in case of multiple routes to same destination
*/
void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface, uint32_t metric = 0);
/**
* \brief Set the default route.
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix to use (i.e for multihoming)
* \param metric metric of route in case of multiple routes to same destination
*/
void SetDefaultRoute (Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
/**
* \brief Set the default route.
* \param nextHop next hop address to route the packet
* \param interface interface index
* \param prefixToUse prefix to use (i.e for multihoming)
* \param metric metric of route in case of multiple routes to same destination
*/
void SetDefaultRoute (Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
/**
* \brief Get the number or entries in the routing table.
* \return number of entries
*/
uint32_t GetNRoutes ();
/**
* \brief Get the number or entries in the routing table.
* \return number of entries
*/
uint32_t GetNRoutes ();
/**
* \brief Get the default route.
*
* If multiple default routes exist, the one with lowest metric is returned.
* \return default Ipv6Route
*/
Ipv6RoutingTableEntry GetDefaultRoute ();
/**
* \brief Get the default route.
*
* If multiple default routes exist, the one with lowest metric is returned.
* \return default Ipv6Route
*/
Ipv6RoutingTableEntry GetDefaultRoute ();
/**
* \brief Get a specified route.
* \param i index
* \return the route whose index is i
*/
Ipv6RoutingTableEntry GetRoute (uint32_t i);
/**
* \brief Get a specified route.
* \param i index
* \return the route whose index is i
*/
Ipv6RoutingTableEntry GetRoute (uint32_t i);
/**
* \brief Get a metric for route from the static unicast routing table.
* \param index The index (into the routing table) of the route to retrieve.
* \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned
*/
uint32_t GetMetric (uint32_t index);
/**
* \brief Get a metric for route from the static unicast routing table.
* \param index The index (into the routing table) of the route to retrieve.
* \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned
*/
uint32_t GetMetric (uint32_t index);
/**
* \brief Remove a route from the routing table.
* \param i index
*/
void RemoveRoute (uint32_t i);
/**
* \brief Remove a route from the routing table.
* \param i index
*/
void RemoveRoute (uint32_t i);
/**
* \brief Remove a route from the routing table.
* \param network IPv6 network
* \param prefix IPv6 prefix
* \param ifIndex interface index
* \param prefixToUse IPv6 prefix to use with this route (multihoming)
*/
void RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uint32_t ifIndex, Ipv6Address prefixToUse);
/**
* \brief Remove a route from the routing table.
* \param network IPv6 network
* \param prefix IPv6 prefix
* \param ifIndex interface index
* \param prefixToUse IPv6 prefix to use with this route (multihoming)
*/
void RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uint32_t ifIndex, Ipv6Address prefixToUse);
/**
* \brief Add a multicast route for a given multicast source and group.
* \param origin IPv6 address of the source
* \param group the multicast group address.
* \param inputInterface the interface index
* \param outputInterfaces the list of output interface indices over which the packet
* should be sent (excluding the inputInterface).
*/
void AddMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
/**
* \brief Add a multicast route for a given multicast source and group.
* \param origin IPv6 address of the source
* \param group the multicast group address.
* \param inputInterface the interface index
* \param outputInterfaces the list of output interface indices over which the packet
* should be sent (excluding the inputInterface).
*/
void AddMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
/**
* \brief Set the default multicast route.
* \param outputInterface default output interface
*/
void SetDefaultMulticastRoute (uint32_t outputInterface);
/**
* \brief Set the default multicast route.
* \param outputInterface default output interface
*/
void SetDefaultMulticastRoute (uint32_t outputInterface);
/**
* \brief Get the number of entries in the multicast routing table.
* \return number of entries
*/
uint32_t GetNMulticastRoutes () const;
/**
* \brief Get the number of entries in the multicast routing table.
* \return number of entries
*/
uint32_t GetNMulticastRoutes () const;
/**
* \brief Get the specified multicast route.
* \param i index
* \return the route whose index is i
*/
Ipv6MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const;
/**
* \brief Get the specified multicast route.
* \param i index
* \return the route whose index is i
*/
Ipv6MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const;
/**
* \brief Remove a static multicast route.
* \param origin IPv6 address of the source
* \param group the multicast group address.
* \param inputInterface the input interface index
*/
bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface);
/**
* \brief Remove a static multicast route.
* \param origin IPv6 address of the source
* \param group the multicast group address.
* \param inputInterface the input interface index
*/
bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface);
/**
* \brief Remove a multicast route.
* \param i index of route to remove
*/
void RemoveMulticastRoute (uint32_t i);
/**
* \brief Remove a multicast route.
* \param i index of route to remove
*/
void RemoveMulticastRoute (uint32_t i);
/**
* \brief If the destination is already present in network destination list.
* \param dest destination address
* \param interfaceIndex interface index
* \return true if dest is already in list, false otherwise
*/
bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex);
/**
* \brief If the destination is already present in network destination list.
* \param dest destination address
* \param interfaceIndex interface index
* \return true if dest is already in list, false otherwise
*/
bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex);
virtual Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
virtual Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
virtual bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb);
virtual bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb);
virtual void NotifyInterfaceUp (uint32_t interface);
virtual void NotifyInterfaceDown (uint32_t interface);
virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address);
virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void SetIpv6 (Ptr<Ipv6> ipv6);
virtual void NotifyInterfaceUp (uint32_t interface);
virtual void NotifyInterfaceDown (uint32_t interface);
virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address);
virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void SetIpv6 (Ptr<Ipv6> ipv6);
protected:
/**
* \brief Dispose this object.
*/
void DoDispose ();
protected:
/**
* \brief Dispose this object.
*/
void DoDispose ();
private:
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> > NetworkRoutes;
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
private:
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> > NetworkRoutes;
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
typedef std::list<Ipv6MulticastRoutingTableEntry *> MulticastRoutes;
typedef std::list<Ipv6MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
typedef std::list<Ipv6MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
typedef std::list<Ipv6MulticastRoutingTableEntry *> MulticastRoutes;
typedef std::list<Ipv6MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
typedef std::list<Ipv6MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
/**
* \brief Lookup in the forwarding table for destination.
* \param dest destination address
* \param interface output interface if any (put 0 otherwise)
* \return Ipv6Route to route the packet to reach dest address
*/
Ptr<Ipv6Route> LookupStatic (Ipv6Address dest, Ptr<NetDevice> = 0);
/**
* \brief Lookup in the forwarding table for destination.
* \param dest destination address
* \param interface output interface if any (put 0 otherwise)
* \return Ipv6Route to route the packet to reach dest address
*/
Ptr<Ipv6Route> LookupStatic (Ipv6Address dest, Ptr<NetDevice> = 0);
/**
* \brief Lookup in the multicast forwarding table for destination.
* \param origin source address
* \param group group multicast address
* \param ifIndex interface index
* \return Ipv6MulticastRoute to route the packet to reach dest address
*/
Ptr<Ipv6MulticastRoute> LookupStatic (Ipv6Address origin, Ipv6Address group, uint32_t ifIndex);
/**
* \brief Lookup in the multicast forwarding table for destination.
* \param origin source address
* \param group group multicast address
* \param ifIndex interface index
* \return Ipv6MulticastRoute to route the packet to reach dest address
*/
Ptr<Ipv6MulticastRoute> LookupStatic (Ipv6Address origin, Ipv6Address group, uint32_t ifIndex);
/**
* \brief Choose the source address to use with destination address.
* \param interface interface index
* \param dest IPv6 destination address
* \return IPv6 source address to use
*/
Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest);
/**
* \brief Choose the source address to use with destination address.
* \param interface interface index
* \param dest IPv6 destination address
* \return IPv6 source address to use
*/
Ipv6Address SourceAddressSelection (uint32_t interface, Ipv6Address dest);
/**
* \brief the forwarding table for network.
*/
NetworkRoutes m_networkRoutes;
/**
* \brief the forwarding table for network.
*/
NetworkRoutes m_networkRoutes;
/**
* \brief the forwarding table for multicast.
*/
MulticastRoutes m_multicastRoutes;
/**
* \brief the forwarding table for multicast.
*/
MulticastRoutes m_multicastRoutes;
/**
* \brief Ipv6 reference.
*/
Ptr<Ipv6> m_ipv6;
/**
* \brief Ipv6 reference.
*/
Ptr<Ipv6> m_ipv6;
};
} /* namespace ns3 */