remove Ipv4L3Protocol class.
--- a/SConstruct Fri Feb 16 10:04:02 2007 +0100
+++ b/SConstruct Sat Feb 17 09:28:02 2007 +0100
@@ -169,7 +169,6 @@
'drop-tail.cc',
'l3-demux.cc',
'l3-protocol.cc',
- 'ipv4-l3-protocol.cc',
'ipv4-l4-demux.cc',
'ipv4-l4-protocol.cc',
'udp-ipv4-l4-protocol.cc',
@@ -206,14 +205,12 @@
'udp.h',
'ipv4-l4-protocol.h',
'udp-ipv4-l4-protocol.h',
- 'ipv4-l3-protocol.h',
'arp-l3-protocol.h',
'arp-header.h',
'arp-cache-cache.h',
'arp.h',
'ipv4-loopback-interface.h',
'l3-demux.h',
- 'l3-protocol.h',
'ipv4-l4-demux.h',
'net-device-list.h',
'llc-snap-header.h',
@@ -233,6 +230,7 @@
'ipv4-interface.h',
'mac-address.h',
'ipv4.h',
+ 'l3-protocol.h',
'ipv4-route.h',
])
--- a/src/node/arp-ipv4-interface.cc Fri Feb 16 10:04:02 2007 +0100
+++ b/src/node/arp-ipv4-interface.cc Sat Feb 17 09:28:02 2007 +0100
@@ -26,6 +26,7 @@
#include "arp.h"
#include "node.h"
#include "net-device.h"
+#include "ipv4.h"
namespace ns3 {
@@ -44,7 +45,7 @@
bool found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination);
if (found)
{
- GetDevice ()->Send (p, hardwareDestination, 0x0800 /* XXX */);
+ GetDevice ()->Send (p, hardwareDestination, Ipv4::PROT_NUMBER);
}
}
--- a/src/node/internet-node.cc Fri Feb 16 10:04:02 2007 +0100
+++ b/src/node/internet-node.cc Sat Feb 17 09:28:02 2007 +0100
@@ -23,7 +23,6 @@
#include "net-device-list.h"
#include "l3-demux.h"
-#include "ipv4-l3-protocol.h"
#include "ipv4-l4-demux.h"
#include "internet-node.h"
#include "udp.h"
@@ -42,9 +41,8 @@
m_l3Demux = new L3Demux(this);
m_ipv4L4Demux = new Ipv4L4Demux(this);
m_udp = new Udp (this);
- m_ipv4 = new Ipv4 (this);
m_arp = new Arp (this);
- m_l3Demux->Insert (Ipv4L3Protocol (this));
+ m_l3Demux->Insert (Ipv4 (this));
m_l3Demux->Insert (ArpL3Protocol (this));
m_ipv4L4Demux->Insert (UdpIpv4L4Protocol (this));
SetupLoopback ();
@@ -56,7 +54,6 @@
m_l3Demux = o.m_l3Demux->Copy (this);
m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
m_udp = o.m_udp->Copy (this);
- m_ipv4 = o.m_ipv4->Copy (this);
m_arp = o.m_arp->Copy (this);
SetupLoopback ();
}
@@ -67,7 +64,6 @@
delete m_l3Demux;
delete m_ipv4L4Demux;
delete m_udp;
- delete m_ipv4;
delete m_arp;
}
@@ -77,8 +73,8 @@
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (this);
interface->SetAddress (Ipv4Address::GetLoopback ());
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
- uint32_t index = m_ipv4->AddInterface (interface);
- m_ipv4->AddHostRouteTo (Ipv4Address::GetLoopback (), index);
+ uint32_t index = GetIpv4 ()->AddInterface (interface);
+ GetIpv4 ()->AddHostRouteTo (Ipv4Address::GetLoopback (), index);
interface->SetUp ();
}
@@ -112,7 +108,7 @@
Ipv4 *
InternetNode::GetIpv4 (void) const
{
- return m_ipv4;
+ return static_cast<Ipv4*> (m_l3Demux->Lookup (Ipv4::PROT_NUMBER));
}
Udp *
InternetNode::GetUdp (void) const
--- a/src/node/internet-node.h Fri Feb 16 10:04:02 2007 +0100
+++ b/src/node/internet-node.h Sat Feb 17 09:28:02 2007 +0100
@@ -52,7 +52,6 @@
NetDeviceList* m_netDevices;
L3Demux* m_l3Demux;
Ipv4L4Demux* m_ipv4L4Demux;
- Ipv4 * m_ipv4;
Udp * m_udp;
Arp * m_arp;
};
--- a/src/node/ipv4-l3-protocol.cc Fri Feb 16 10:04:02 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
-//
-// Copyright (c) 2006 Georgia Tech Research Corporation
-// All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation;
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Author: George F. Riley <riley@ece.gatech.edu>
-//
-
-// NS3 - Layer 3 Protocol base class
-// George F. Riley, Georgia Tech, Spring 2007
-
-#include "ipv4-l3-protocol.h"
-#include "ipv4.h"
-#include "node.h"
-
-namespace ns3 {
-
-Ipv4L3Protocol::Ipv4L3Protocol (Node *node)
- : L3Protocol (0x0800, 4),
- m_node (node)
-{}
-Ipv4L3Protocol::~Ipv4L3Protocol ()
-{}
-
-Ipv4L3Protocol *
-Ipv4L3Protocol::Copy (Node *node) const
-{
- Ipv4L3Protocol *copy = new Ipv4L3Protocol (node);
- return copy;
-}
-void
-Ipv4L3Protocol::Receive(Packet& p, NetDevice &device)
-{
- Ipv4 *ipv4 = m_node->GetIpv4 ();
- if (ipv4 != 0)
- {
- ipv4->Receive (p, device);
- }
-}
-
-
-
-}//namespace ns3
--- a/src/node/ipv4-l3-protocol.h Fri Feb 16 10:04:02 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
-//
-// Copyright (c) 2006 Georgia Tech Research Corporation
-// All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation;
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Author: George F. Riley <riley@ece.gatech.edu>
-//
-
-// NS3 - Layer 3 Protocol base class
-// George F. Riley, Georgia Tech, Spring 2007
-
-#ifndef IPV4_L3_PROTOCOL_H
-#define IPV4_L3_PROTOCOL_H
-
-#include "l3-protocol.h"
-
-namespace ns3 {
-
-class Ipv4L3Protocol : public L3Protocol
-{
-public:
- Ipv4L3Protocol (Node *node);
- virtual ~Ipv4L3Protocol ();
-
- virtual Ipv4L3Protocol *Copy (Node *node) const;
- virtual void Receive (Packet& p, NetDevice &device);
-private:
- Node *m_node;
-};
-
-}//namespace ns3
-
-
-#endif /* IPV4_L3_PROTOCOL_H */
--- a/src/node/ipv4.cc Fri Feb 16 10:04:02 2007 +0100
+++ b/src/node/ipv4.cc Sat Feb 17 09:28:02 2007 +0100
@@ -36,8 +36,11 @@
namespace ns3 {
+const uint16_t Ipv4::PROT_NUMBER = 0x0800;
+
Ipv4::Ipv4(Node *node)
- : m_nInterfaces (0),
+ : L3Protocol (PROT_NUMBER, 4),
+ m_nInterfaces (0),
m_defaultTtl (64),
m_identification (0),
m_defaultRoute (0),
--- a/src/node/ipv4.h Fri Feb 16 10:04:02 2007 +0100
+++ b/src/node/ipv4.h Sat Feb 17 09:28:02 2007 +0100
@@ -25,6 +25,7 @@
#include <list>
#include <stdint.h>
#include "ipv4-address.h"
+#include "l3-protocol.h"
namespace ns3 {
@@ -40,8 +41,11 @@
/**
* ::Send is always defined in subclasses.
*/
-class Ipv4 {
+class Ipv4 : public L3Protocol
+{
public:
+ static const uint16_t PROT_NUMBER;
+
Ipv4(Node *node);
virtual ~Ipv4 ();
@@ -88,7 +92,7 @@
Ipv4Interface *FindInterfaceForDevice (NetDevice const*device);
- Ipv4* Copy(Node *node) const;
+ virtual Ipv4* Copy(Node *node) const;
/**
* Lower layer calls this method after calling L3Demux::Lookup
* The ARP subclass needs to know from which NetDevice this
@@ -96,7 +100,7 @@
* - implement a per-NetDevice ARP cache
* - send back arp replies on the right device
*/
- void Receive(Packet& p, NetDevice &device);
+ virtual void Receive(Packet& p, NetDevice &device);
void Send (Packet const &packet, Ipv4Address source,
Ipv4Address destination, uint8_t protocol);