Index: src/internet-stack/ipv4-l3-protocol.h |
=================================================================== |
--- a/src/internet-stack/ipv4-l3-protocol.h |
+++ b/src/internet-stack/ipv4-l3-protocol.h |
@@ -29,7 +29,8 @@ |
#include "ns3/ipv4.h" |
#include "ns3/traced-callback.h" |
#include "ns3/ipv4-header.h" |
-#include "ipv4-static-routing.h" |
+#include "ns3/ipv4-routing-protocol.h" |
+#include "ipv4-static-routing-impl.h" |
namespace ns3 { |
@@ -38,6 +39,7 @@ class Ipv4Interface; |
class Ipv4Interface; |
class Ipv4Address; |
class Ipv4Header; |
+class Ipv4RoutingTableEntry; |
class Ipv4Route; |
class Node; |
class Socket; |
@@ -63,6 +65,10 @@ public: |
virtual ~Ipv4L3Protocol (); |
void SetNode (Ptr<Node> node); |
+ |
+ // functions defined in base class Ipv4 |
+ void SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routing); |
+ Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (void) const; |
Ptr<Socket> CreateRawSocket (void); |
void DeleteRawSocket (Ptr<Socket> socket); |
@@ -105,15 +111,6 @@ public: |
void SetDefaultTtl (uint8_t ttl); |
/** |
- * \param device the device to match |
- * \returns the matching interface, zero if not found. |
- * |
- * Try to find an Ipv4Interface whose NetDevice is equal to |
- * the input NetDevice. |
- */ |
- Ptr<Ipv4Interface> FindInterfaceForDevice (Ptr<const NetDevice> device); |
- |
- /** |
* Lower layer calls this method after calling L3Demux::Lookup |
* The ARP subclass needs to know from which NetDevice this |
* packet is coming to: |
@@ -128,64 +125,21 @@ public: |
* \param source source address of packet |
* \param destination address of packet |
* \param protocol number of packet |
+ * \param route route entry |
* |
* Higher-level layers call this method to send a packet |
* down the stack to the MAC and PHY layers. |
*/ |
void Send (Ptr<Packet> packet, Ipv4Address source, |
- Ipv4Address destination, uint8_t protocol); |
- |
- |
- |
- void AddHostRouteTo (Ipv4Address dest, |
- Ipv4Address nextHop, |
- uint32_t interface); |
- void AddHostRouteTo (Ipv4Address dest, |
- uint32_t interface); |
- |
- void AddNetworkRouteTo (Ipv4Address network, |
- Ipv4Mask networkMask, |
- Ipv4Address nextHop, |
- uint32_t interface); |
- void AddNetworkRouteTo (Ipv4Address network, |
- Ipv4Mask networkMask, |
- uint32_t interface); |
- void SetDefaultRoute (Ipv4Address nextHop, |
- uint32_t interface); |
- |
- void Lookup (Ipv4Header const &ipHeader, |
- Ptr<Packet> packet, |
- Ipv4RoutingProtocol::RouteReplyCallback routeReply); |
- |
- uint32_t GetNRoutes (void); |
- Ipv4Route GetRoute (uint32_t i); |
- void RemoveRoute (uint32_t i); |
- |
- void AddMulticastRoute (Ipv4Address origin, |
- Ipv4Address group, |
- uint32_t inputInterface, |
- std::vector<uint32_t> outputInterfaces); |
- |
- void SetDefaultMulticastRoute (uint32_t onputInterface); |
- |
- uint32_t GetNMulticastRoutes (void) const; |
- Ipv4MulticastRoute GetMulticastRoute (uint32_t i) const; |
- |
- void RemoveMulticastRoute (Ipv4Address origin, |
- Ipv4Address group, |
- uint32_t inputInterface); |
- void RemoveMulticastRoute (uint32_t i); |
+ Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route); |
uint32_t AddInterface (Ptr<NetDevice> device); |
Ptr<Ipv4Interface> GetInterface (uint32_t i) const; |
uint32_t GetNInterfaces (void) const; |
- uint32_t FindInterfaceForAddr (Ipv4Address addr) const; |
- uint32_t FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const; |
- int32_t FindInterfaceForDevice (Ptr<NetDevice> device) const; |
- |
- void JoinMulticastGroup (Ipv4Address origin, Ipv4Address group); |
- void LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group); |
+ int32_t GetInterfaceForAddress (Ipv4Address addr) const; |
+ int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const; |
+ int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const; |
uint32_t AddAddress (uint32_t i, Ipv4InterfaceAddress address); |
Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const; |
@@ -193,9 +147,6 @@ public: |
void SetMetric (uint32_t i, uint16_t metric); |
uint16_t GetMetric (uint32_t i) const; |
- Ipv4Address GetSourceAddress (Ipv4Address destination) const; |
- bool GetInterfaceForDestination (Ipv4Address destination, |
- uint32_t& interface) const; |
uint16_t GetMtu (uint32_t i) const; |
bool IsUp (uint32_t i) const; |
void SetUp (uint32_t i); |
@@ -213,35 +164,44 @@ private: |
private: |
Ipv4L3Protocol(const Ipv4L3Protocol &); |
Ipv4L3Protocol &operator = (const Ipv4L3Protocol &); |
- void Lookup (uint32_t interface, |
- Ipv4Header const &ipHeader, |
+ |
+ virtual void SetIpForward (bool forward); |
+ virtual bool GetIpForward (void) const; |
+ |
+ Ipv4Header BuildHeader ( |
+ Ipv4Address source, |
+ Ipv4Address destination, |
+ uint8_t protocol, |
+ uint16_t payloadSize, |
+ uint8_t ttl, |
+ bool mayFragment); |
+ |
+ void |
+ SendRealOut (Ptr<Ipv4Route> route, |
Ptr<Packet> packet, |
- Ipv4RoutingProtocol::RouteReplyCallback routeReply); |
+ Ipv4Header const &ipHeader); |
- void SendRealOut (bool found, |
- Ipv4Route const &route, |
- Ptr<Packet> packet, |
- Ipv4Header const &ipHeader); |
- bool Forwarding (uint32_t interface, |
- Ptr<Packet> packet, |
- Ipv4Header &ipHeader, |
- Ptr<NetDevice> device); |
- void ForwardUp (Ptr<Packet> p, Ipv4Header const&ip, Ptr<Ipv4Interface> incomingInterface); |
+ void |
+ IpForward (Ptr<Ipv4Route> rtentry, |
+ Ptr<const Packet> p, |
+ const Ipv4Header &header); |
+ |
+ void |
+ IpMulticastForward (Ptr<Ipv4MulticastRoute> mrtentry, |
+ Ptr<const Packet> p, |
+ const Ipv4Header &header); |
+ |
+ void LocalDeliver (Ptr<const Packet> p, Ipv4Header const&ip, uint32_t iif); |
uint32_t AddIpv4Interface (Ptr<Ipv4Interface> interface); |
void SetupLoopback (void); |
Ptr<Icmpv4L4Protocol> GetIcmp (void) const; |
bool IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const; |
- void DoForward (uint32_t interface, |
- Ptr<Packet> packet, |
- Ipv4Header ipHeader); |
- |
typedef std::list<Ptr<Ipv4Interface> > Ipv4InterfaceList; |
- typedef std::list<std::pair<Ipv4Address, Ipv4Address> > Ipv4MulticastGroupList; |
- typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList; |
typedef std::list<Ptr<Ipv4RawSocketImpl> > SocketList; |
typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t; |
+ bool m_ipForward; |
L4List_t m_protocols; |
Ipv4InterfaceList m_interfaces; |
uint32_t m_nInterfaces; |
@@ -253,10 +213,8 @@ private: |
TracedCallback<Ptr<const Packet>, uint32_t> m_rxTrace; |
TracedCallback<Ptr<const Packet> > m_dropTrace; |
- Ipv4RoutingProtocolList m_routingProtocols; |
- |
- Ptr<Ipv4StaticRouting> m_staticRouting; |
- Ipv4MulticastGroupList m_multicastGroups; |
+ Ptr<Ipv4RoutingProtocol> m_routingProtocol; |
+ Ptr<Ipv4StaticRouting> GetStaticRouting (void) const; |
SocketList m_sockets; |
}; |