Backed out changeset df68dad55087ea649a33f04e78b4ff4cf324acdd
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 18 Jul 2007 12:17:53 +0100
changeset 934 1bfcc65213c7
parent 933 df68dad55087
child 935 53e1e53c373f
Backed out changeset df68dad55087ea649a33f04e78b4ff4cf324acdd
doc/build.txt
src/internet-node/arp-cache.cc
src/internet-node/arp-ipv4-interface.cc
src/internet-node/arp-l3-protocol.cc
src/internet-node/ipv4-l3-protocol.cc
src/node/ipv4-address.cc
src/node/ipv4-address.h
wscript
--- a/doc/build.txt	Wed Jul 18 11:43:39 2007 +0100
+++ b/doc/build.txt	Wed Jul 18 12:17:53 2007 +0100
@@ -60,15 +60,6 @@
     before running the program.  Note: the "program [args]" string is
     parsed using POSIX shell rules.
 
- 4.1 waf --run programname --command-template "... %s ..."
-
-    Same as --run, but uses a command template with %s replaced by the
-    actual program (whose name is given by --run).  This can be use to
-    run ns-3 programs with helper tools.  For example, to run unit
-    tests with valgrind, use the command:
-
-         waf --run run-tests --command-template "valgrind %s"
-
  5. waf --shell
     Starts a nested system shell with modified environment to run ns3 programs.
 
--- a/src/internet-node/arp-cache.cc	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/internet-node/arp-cache.cc	Wed Jul 18 12:17:53 2007 +0100
@@ -109,8 +109,6 @@
 ArpCache::Entry *
 ArpCache::Add (Ipv4Address to)
 {
-  NS_ASSERT (m_arpCache.find (to) == m_arpCache.end ());
-
   ArpCache::Entry *entry = new ArpCache::Entry (this);
   m_arpCache[to] = entry;  
   return entry;
--- a/src/internet-node/arp-ipv4-interface.cc	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/internet-node/arp-ipv4-interface.cc	Wed Jul 18 12:17:53 2007 +0100
@@ -21,7 +21,6 @@
  */
 
 #include "ns3/packet.h"
-#include "ns3/debug.h"
 #include "ns3/composite-trace-resolver.h"
 #include "ns3/node.h"
 #include "ns3/net-device.h"
@@ -61,19 +60,7 @@
     {
       Ptr<ArpPrivate> arp = m_node->QueryInterface<ArpPrivate> (ArpPrivate::iid);
       MacAddress hardwareDestination;
-      bool found;
-
-      if (dest.IsBroadcast ())
-        {
-           hardwareDestination = GetDevice ()->GetBroadcast ();
-           found = true;
-        }
-      else
-        {
-          Ptr<ArpPrivate> arp = m_node->QueryInterface<ArpPrivate> (ArpPrivate::iid);
-          found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination);
-        }
-
+      bool found = arp->Lookup (p, dest, GetDevice (), &hardwareDestination);
       if (found)
         {
           GetDevice ()->Send (p, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER);
--- a/src/internet-node/arp-l3-protocol.cc	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/internet-node/arp-l3-protocol.cc	Wed Jul 18 12:17:53 2007 +0100
@@ -87,13 +87,6 @@
   ArpCache *cache = FindCache (device);
   ArpHeader arp;
   packet.RemoveHeader (arp);
-  
-  NS_DEBUG ("ARP: received "<< (arp.IsRequest ()? "request" : "reply") <<
-            " node="<<m_node->GetId ()<<", got request from " <<
-            arp.GetSourceIpv4Address () << " for address " <<
-            arp.GetDestinationIpv4Address () << "; we have address " <<
-            cache->GetInterface ()->GetAddress ());
-
   if (arp.IsRequest () && 
       arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ()) 
     {
@@ -135,12 +128,6 @@
 	  // XXX report packet as dropped.
         }
     }
-  else
-    {
-      NS_DEBUG ("node="<<m_node->GetId ()<<", got request from " <<
-                arp.GetSourceIpv4Address () << " for unknown address " <<
-                arp.GetDestinationIpv4Address () << " -- drop");
-    }
 }
 bool 
 ArpL3Protocol::Lookup (Packet &packet, Ipv4Address destination, 
@@ -216,11 +203,6 @@
 ArpL3Protocol::SendArpRequest (ArpCache const *cache, Ipv4Address to)
 {
   ArpHeader arp;
-  NS_DEBUG ("ARP: sending request from node "<<m_node->GetId ()<<
-            " || src: " << cache->GetDevice ()->GetAddress () <<
-            " / " << cache->GetInterface ()->GetAddress () <<
-            " || dst: " << cache->GetDevice ()->GetBroadcast () <<
-            " / " << to);
   arp.SetRequest (cache->GetDevice ()->GetAddress (),
 		  cache->GetInterface ()->GetAddress (), 
                   cache->GetDevice ()->GetBroadcast (),
@@ -234,10 +216,6 @@
 ArpL3Protocol::SendArpReply (ArpCache const *cache, Ipv4Address toIp, MacAddress toMac)
 {
   ArpHeader arp;
-  NS_DEBUG ("ARP: sending reply from node "<<m_node->GetId ()<<
-            "|| src: " << cache->GetDevice ()->GetAddress () << 
-            " / " << cache->GetInterface ()->GetAddress () <<
-            " || dst: " << toMac << " / " << toIp);
   arp.SetReply (cache->GetDevice ()->GetAddress (),
                 cache->GetInterface ()->GetAddress (),
                 toMac, toIp);
--- a/src/internet-node/ipv4-l3-protocol.cc	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/internet-node/ipv4-l3-protocol.cc	Wed Jul 18 12:17:53 2007 +0100
@@ -404,40 +404,23 @@
 
   m_identification ++;
 
-  if (destination.IsBroadcast ())
-    {
-      uint32_t ifaceIndex = 0;
-      for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
-           ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
-        {
-          Ipv4Interface *outInterface = *ifaceIter;
-          Packet packetCopy = packet;
-
-          NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ());
-          packetCopy.AddHeader (ipHeader);
-          m_txTrace (packetCopy, ifaceIndex);
-          outInterface->Send (packetCopy, destination);
-        }
-    }
-  else
+  // XXX Note here that in most ipv4 stacks in the world,
+  // the route calculation for an outgoing packet is not
+  // done in the ip layer. It is done within the application
+  // socket when the first packet is sent to avoid this
+  // costly lookup on a per-packet basis.
+  // That would require us to get the route from the packet,
+  // most likely with a packet tag. The higher layers do not
+  // do this yet for us.
+  Ipv4Route *route = Lookup (ipHeader.GetDestination ());
+  if (route == 0) 
     {
-      // XXX Note here that in most ipv4 stacks in the world,
-      // the route calculation for an outgoing packet is not
-      // done in the ip layer. It is done within the application
-      // socket when the first packet is sent to avoid this
-      // costly lookup on a per-packet basis.
-      // That would require us to get the route from the packet,
-      // most likely with a packet tag. The higher layers do not
-      // do this yet for us.
-      Ipv4Route *route = Lookup (ipHeader.GetDestination ());
-      if (route == 0) 
-        {
-          NS_DEBUG ("not for me -- forwarding but no route to host. drop.");
-          m_dropTrace (packet);
-          return;
-        }
-      SendRealOut (packet, ipHeader, *route);
+      NS_DEBUG ("not for me -- forwarding but no route to host. drop.");
+      m_dropTrace (packet);
+      return;
     }
+
+  SendRealOut (packet, ipHeader, *route);
 }
 
 void
@@ -487,7 +470,7 @@
 	}
     }
       
-  if (ipHeader.GetDestination ().IsBroadcast ()) 
+  if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetBroadcast ())) 
     {
       NS_DEBUG ("for me 3");
       return false;
--- a/src/node/ipv4-address.cc	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/node/ipv4-address.cc	Wed Jul 18 12:17:53 2007 +0100
@@ -145,18 +145,6 @@
   }
 }
 
-bool
-Ipv4Address::IsBroadcast (void) const
-{
-  return (m_address == 0xffffffffU);
-}
-
-Ipv4Address
-Ipv4Address::CombineMask (Ipv4Mask const &mask) const
-{
-  return Ipv4Address (GetHostOrder () & mask.GetHostOrder ());
-}
-
 bool 
 Ipv4Address::IsMulticast (void)
 {
--- a/src/node/ipv4-address.h	Wed Jul 18 11:43:39 2007 +0100
+++ b/src/node/ipv4-address.h	Wed Jul 18 12:17:53 2007 +0100
@@ -27,8 +27,6 @@
 
 namespace ns3 {
 
-class Ipv4Mask;
-
 /** Ipv4 addresses are stored in host order in
   * this class.
   */
@@ -82,19 +80,8 @@
    */
   void Print (std::ostream &os) const;
 
-  bool IsBroadcast (void) const;
+  bool IsBroadcast (void);
   bool IsMulticast (void);
-  
-  /**
-   * \brief Combine this address with a network mask
-   *
-   * This method returns an IPv4 address that is this address combined
-   * (bitwise and) with a network mask, yielding an IPv4 network
-   * address.
-   *
-   * \param a network mask 
-   */
-  Ipv4Address CombineMask (Ipv4Mask const &mask) const;
 
   static Ipv4Address GetZero (void);
   static Ipv4Address GetAny (void);
--- a/wscript	Wed Jul 18 11:43:39 2007 +0100
+++ b/wscript	Wed Jul 18 12:17:53 2007 +0100
@@ -1,4 +1,5 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+import os
 import sys
 import shlex
 import shutil
@@ -65,14 +66,8 @@
                    dest='doxygen')
 
     opt.add_option('--run',
-                   help=('Run a locally built program; argument can be a program name,'
-                         ' or a command starting with the program name.'),
+                   help=('Run a locally built program'),
                    type="string", default='', dest='run')
-    opt.add_option('--command-template',
-                   help=('Template of the command used to run the program given by --run;'
-                         ' It should be a shell command string containing %s inside,'
-                         ' which will be replaced by the actual program.'),
-                   type="string", default=None, dest='command_template')
 
     opt.add_option('--shell',
                    help=('Run a shell with an environment suitably modified to run locally built programs'),
@@ -168,11 +163,7 @@
         doxygen()
 
     if Params.g_options.run:
-        run_program(Params.g_options.run, Params.g_options.command_template)
-        raise SystemExit(0)
-
-    if Params.g_options.command_template:
-        Params.fatal("Option --command-template requires the option --run to be given")
+        run_program(Params.g_options.run)
 
 def _find_program(program_name, env):
     launch_dir = os.path.abspath(Params.g_cwd_launch)
@@ -221,58 +212,33 @@
 
     retval = subprocess.Popen(argv, env=os_env).wait()
     if retval:
-        Params.fatal("Command %s exited with code %i" % (argv, retval))
+        raise SystemExit(retval)
 
 
-def run_program(program_string, command_template=None):
-    """
-    if command_template is not None, then program_string == program
-    name and argv is given by command_template with %s replaced by the
-    full path to the program.  Else, program_string is interpreted as
-    a shell command with first name being the program name.
-    """
+def run_program(program_string):
     env = Params.g_build.env_of_name('default')
-
-    if command_template is None:
-        argv = shlex.split(program_string)
-        program_name = argv[0]
-
-        try:
-            program_obj = _find_program(program_name, env)
-        except ValueError, ex:
-            Params.fatal(str(ex))
+    argv = shlex.split(program_string)
+    program_name = argv[0]
 
-        try:
-            program_node, = program_obj.m_linktask.m_outputs
-        except AttributeError:
-            Params.fatal("%s does not appear to be a program" % (program_name,))
-
-        execvec = [program_node.abspath(env)] + argv[1:]
-
-    else:
+    try:
+        program_obj = _find_program(program_name, env)
+    except ValueError, ex:
+        Params.fatal(str(ex))
 
-        program_name = program_string
-        try:
-            program_obj = _find_program(program_name, env)
-        except ValueError, ex:
-            Params.fatal(str(ex))
-        try:
-            program_node, = program_obj.m_linktask.m_outputs
-        except AttributeError:
-            Params.fatal("%s does not appear to be a program" % (program_name,))
+    try:
+        program_node, = program_obj.m_linktask.m_outputs
+    except AttributeError:
+        Params.fatal("%s does not appear to be a program" % (program_name,))
 
-        execvec = shlex.split(command_template % (program_node.abspath(env),))
-
+    execvec = [program_node.abspath(env)] + argv[1:]
 
     former_cwd = os.getcwd()
     os.chdir(Params.g_cwd_launch)
     try:
-        retval = _run_argv(execvec)
+        return _run_argv(execvec)
     finally:
         os.chdir(former_cwd)
 
-    return retval
-
 
 def run_shell():
     if sys.platform == 'win32':