rename internet-node.h to i-node-impl.h
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 14 May 2007 09:26:32 +0200
changeset 605 3a62e5c4de75
parent 604 0b6bef4e99bc
child 606 d9e3640ee24b
rename internet-node.h to i-node-impl.h
SConstruct
examples/simple-p2p.cc
samples/main-simple.cc
src/internet-node/i-node-impl.cc
src/internet-node/i-node-impl.h
src/internet-node/internet-node.cc
src/internet-node/internet-node.h
src/node/i-node.h
--- a/SConstruct	Mon May 14 09:09:43 2007 +0200
+++ b/SConstruct	Mon May 14 09:26:32 2007 +0200
@@ -243,6 +243,7 @@
 inode.add_deps (['node'])
 inode.add_sources ([
     'internet-node.cc',
+    'i-node-impl.cc',
     'l3-demux.cc',
     'l3-protocol.cc',
     'ipv4-l4-demux.cc',
@@ -296,7 +297,8 @@
     'ipv4-header.h',
     'udp-header.h',
     'ipv4-interface.h',
-    'sgi-hashmap.h'
+    'sgi-hashmap.h',
+    'i-node-impl.h',
 ])
 inode.add_inst_headers ([
     'internet-node.h',
--- a/examples/simple-p2p.cc	Mon May 14 09:09:43 2007 +0200
+++ b/examples/simple-p2p.cc	Mon May 14 09:26:32 2007 +0200
@@ -100,10 +100,10 @@
 
   // Here, we will explicitly create four nodes.  In more sophisticated
   // topologies, we could configure a node factory.
-  Ptr<Node> n0 = MakeNewObject<InternetNode> ();
-  Ptr<Node> n1 = MakeNewObject<InternetNode> (); 
-  Ptr<Node> n2 = MakeNewObject<InternetNode> (); 
-  Ptr<Node> n3 = MakeNewObject<InternetNode> ();
+  Ptr<Node> n0 = MakeInternetNode ();
+  Ptr<Node> n1 = MakeInternetNode (); 
+  Ptr<Node> n2 = MakeInternetNode (); 
+  Ptr<Node> n3 = MakeInternetNode ();
 
   // We create the channels first without any IP addressing information
   Ptr<PointToPointChannel> channel0 = 
--- a/samples/main-simple.cc	Mon May 14 09:09:43 2007 +0200
+++ b/samples/main-simple.cc	Mon May 14 09:26:32 2007 +0200
@@ -38,7 +38,7 @@
 void
 RunSimulation (void)
 {
-  Ptr<InternetNode> a = MakeNewObject<InternetNode> ();
+  Ptr<Node> a = MakeInternetNode ();
 
   Ptr<IUdp> udp = a->QueryInterface<IUdp> (IUdp::iid);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet-node/i-node-impl.cc	Mon May 14 09:26:32 2007 +0200
@@ -0,0 +1,126 @@
+// -*- 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>
+//
+// Implementation of the InternetNode class for ns3.
+// George F. Riley, Georgia Tech, Fall 2006
+
+#include "ns3/composite-trace-resolver.h"
+#include "ns3/net-device.h"
+
+#include "l3-demux.h"
+#include "ipv4-l4-demux.h"
+#include "i-node-impl.h"
+#include "udp.h"
+#include "ipv4.h"
+#include "arp.h"
+#include "i-udp-impl.h"
+#include "i-arp-private.h"
+#include "i-ipv4-impl.h"
+#include "i-ipv4-private.h"
+
+namespace ns3 {
+
+
+InternetNode::InternetNode()
+{
+  Construct ();
+}
+
+InternetNode::InternetNode(uint32_t systemId)
+{
+  Construct ();
+}
+
+InternetNode::~InternetNode ()
+{}
+
+void
+InternetNode::Construct (void)
+{
+  Ptr<Ipv4> ipv4 = MakeNewObject<Ipv4> (this);
+  Ptr<Arp> arp = MakeNewObject<Arp> (this);
+  Ptr<Udp> udp = MakeNewObject<Udp> (this);
+
+  Ptr<L3Demux> l3Demux = MakeNewObject<L3Demux> (this);
+  Ptr<Ipv4L4Demux> ipv4L4Demux = MakeNewObject<Ipv4L4Demux> (this);
+
+  l3Demux->Insert (ipv4);
+  l3Demux->Insert (arp);
+  ipv4L4Demux->Insert (udp);
+
+  Ptr<IUdpImpl> udpImpl = MakeNewObject<IUdpImpl> (udp);
+  Ptr<IArpPrivate> arpPrivate = MakeNewObject<IArpPrivate> (arp);
+  Ptr<IIpv4Impl> ipv4Impl = MakeNewObject<IIpv4Impl> (ipv4);
+  Ptr<IIpv4Private> ipv4Private = MakeNewObject<IIpv4Private> (ipv4);
+
+  Interface::AddInterface (ipv4Private);
+  Interface::AddInterface (ipv4Impl);
+  Interface::AddInterface (arpPrivate);
+  Interface::AddInterface (udpImpl);
+  Interface::AddInterface (l3Demux);
+  Interface::AddInterface (ipv4L4Demux);
+}
+
+void
+InternetNode::SetName (std::string name)
+{
+  m_name = name;
+}
+
+TraceResolver *
+InternetNode::DoCreateTraceResolver (TraceContext const &context)
+{
+  CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
+  Ptr<IIpv4Private> ipv4 = QueryInterface<IIpv4Private> (IIpv4Private::iid);
+  resolver->Add ("ipv4",
+                 MakeCallback (&IIpv4Private::CreateTraceResolver, PeekPointer (ipv4)),
+                 InternetNode::IPV4);
+
+  return resolver;
+}
+
+void 
+InternetNode::DoDispose()
+{
+  Node::DoDispose ();
+}
+
+void 
+InternetNode::DoAddDevice (Ptr<NetDevice> device) const
+{
+  device->SetReceiveCallback (MakeCallback (&InternetNode::ReceiveFromDevice, this));
+}
+
+bool
+InternetNode::ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const
+{
+  Ptr<L3Demux> demux = QueryInterface<L3Demux> (L3Demux::iid);
+  Ptr<L3Protocol> target = demux->GetProtocol (protocolNumber);
+  if (target != 0) 
+    {
+      Packet packet = p;
+      target->Receive(packet, device);
+      return true;
+    }
+  return false;
+}
+
+
+}//namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet-node/i-node-impl.h	Mon May 14 09:26:32 2007 +0200
@@ -0,0 +1,59 @@
+// -*- 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>
+//
+// Define a basic "Internet" node, with a protocol stack (l3 and l4),
+// network device list, process list, and routing.
+
+#ifndef I_NODE_IMPL_H
+#define I_NODE_IMPL_H
+
+#include <list>
+#include <string>
+
+#include "ns3/i-node.h"
+
+namespace ns3 {
+
+class Packet;
+
+class InternetNode : public Node 
+{
+public:
+  enum TraceType {
+    IPV4,
+  };
+  InternetNode();
+  InternetNode(uint32_t systemId);
+  virtual ~InternetNode ();
+
+  void SetName(std::string name);
+protected:
+  virtual void DoDispose(void);
+private:
+  virtual void DoAddDevice (Ptr<NetDevice> device) const;
+  virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
+  bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const;
+  void Construct (void);
+  std::string      m_name;
+};
+
+}//namespace ns3
+
+#endif /* I_NODE_IMPL_H */
--- a/src/internet-node/internet-node.cc	Mon May 14 09:09:43 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +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>
-//
-// Implementation of the InternetNode class for ns3.
-// George F. Riley, Georgia Tech, Fall 2006
-
-#include "ns3/composite-trace-resolver.h"
-#include "ns3/net-device.h"
-
-#include "l3-demux.h"
-#include "ipv4-l4-demux.h"
-#include "internet-node.h"
-#include "udp.h"
-#include "ipv4.h"
-#include "arp.h"
-#include "i-udp-impl.h"
-#include "i-arp-private.h"
-#include "i-ipv4-impl.h"
-#include "i-ipv4-private.h"
-
-namespace ns3 {
-
-
-InternetNode::InternetNode()
-{
-  Ptr<Ipv4> ipv4 = MakeNewObject<Ipv4> (this);
-  Ptr<Arp> arp = MakeNewObject<Arp> (this);
-  Ptr<Udp> udp = MakeNewObject<Udp> (this);
-
-  Ptr<L3Demux> l3Demux = MakeNewObject<L3Demux> (this);
-  Ptr<Ipv4L4Demux> ipv4L4Demux = MakeNewObject<Ipv4L4Demux> (this);
-
-  l3Demux->Insert (ipv4);
-  l3Demux->Insert (arp);
-  ipv4L4Demux->Insert (udp);
-
-  Ptr<IUdpImpl> udpImpl = MakeNewObject<IUdpImpl> (udp);
-  Ptr<IArpPrivate> arpPrivate = MakeNewObject<IArpPrivate> (arp);
-  Ptr<IIpv4Impl> ipv4Impl = MakeNewObject<IIpv4Impl> (ipv4);
-  Ptr<IIpv4Private> ipv4Private = MakeNewObject<IIpv4Private> (ipv4);
-
-  Interface::AddInterface (ipv4Private);
-  Interface::AddInterface (ipv4Impl);
-  Interface::AddInterface (arpPrivate);
-  Interface::AddInterface (udpImpl);
-  Interface::AddInterface (l3Demux);
-  Interface::AddInterface (ipv4L4Demux);
-}
-
-InternetNode::~InternetNode ()
-{}
-
-void
-InternetNode::SetName (std::string name)
-{
-  m_name = name;
-}
-
-TraceResolver *
-InternetNode::DoCreateTraceResolver (TraceContext const &context)
-{
-  CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
-  Ptr<IIpv4Private> ipv4 = QueryInterface<IIpv4Private> (IIpv4Private::iid);
-  resolver->Add ("ipv4",
-                 MakeCallback (&IIpv4Private::CreateTraceResolver, PeekPointer (ipv4)),
-                 InternetNode::IPV4);
-
-  return resolver;
-}
-
-void 
-InternetNode::DoDispose()
-{
-  Node::DoDispose ();
-}
-
-void 
-InternetNode::DoAddDevice (Ptr<NetDevice> device) const
-{
-  device->SetReceiveCallback (MakeCallback (&InternetNode::ReceiveFromDevice, this));
-}
-
-bool
-InternetNode::ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const
-{
-  Ptr<L3Demux> demux = QueryInterface<L3Demux> (L3Demux::iid);
-  Ptr<L3Protocol> target = demux->GetProtocol (protocolNumber);
-  if (target != 0) 
-    {
-      Packet packet = p;
-      target->Receive(packet, device);
-      return true;
-    }
-  return false;
-}
-
-
-}//namespace ns3
--- a/src/internet-node/internet-node.h	Mon May 14 09:09:43 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +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>
-//
-// Define a basic "Internet" node, with a protocol stack (l3 and l4),
-// network device list, process list, and routing.
-
-#ifndef INTERNET_NODE_H
-#define INTERNET_NODE_H
-
-#include <list>
-#include <string>
-
-#include "ns3/i-node.h"
-
-namespace ns3 {
-
-class Packet;
-
-class InternetNode : public Node 
-{
-public:
-  enum TraceType {
-    IPV4,
-  };
-  InternetNode();
-  virtual ~InternetNode ();
-
-  void SetName(std::string name);
-protected:
-  virtual void DoDispose(void);
-private:
-  virtual void DoAddDevice (Ptr<NetDevice> device) const;
-  virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
-  bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const;
-  std::string      m_name;
-};
-
-}//namespace ns3
-
-#endif /* INTERNET_NODE_H */
--- a/src/node/i-node.h	Mon May 14 09:09:43 2007 +0200
+++ b/src/node/i-node.h	Mon May 14 09:26:32 2007 +0200
@@ -22,8 +22,8 @@
 // Define the basic Node object for ns3.
 // George F. Riley, Georgia Tech, Fall 2006
 
-#ifndef __NODE_H__
-#define __NODE_H__
+#ifndef I_NODE_H
+#define I_NODE_H
 
 #include <vector>
 
@@ -169,4 +169,5 @@
 };
 
 } //namespace ns3
-#endif
+
+#endif /* I_NODE_H */