1. Jing Wang
  2. imalse

Commits

Jing Conan Wang  committed bf85a22

gui add basic exportImalse function, add gui traceflag and role options

  • Participants
  • Parent commits d3ac809
  • Branches default

Comments (0)

Files changed (23)

File core/ns3/Topology.py

View file
  • Ignore whitespace
         return ndc, ipic
 
 
-def get_net(ipaddress, netmask):
-    ip = ipaddress.split(".")
-    netm = netmask.split(".")
-    network = str(int(ip[0])&int(netm[0]))+"."+str(int(ip[1])&int(netm[1]))+"."+str(int(ip[2])&int(netm[2]))+"."+str(int(ip[3])&int(netm[3]))
-    return network
-
-def get_net_addr(ipaddress, netmask):
-    ip = ipaddress.split(".")
-    netm = netmask.split(".")
-    addr = str(int(ip[0])&(~int(netm[0])))+"."+str(int(ip[1])&(~int(netm[1])))+"."+str(int(ip[2])& (~int(netm[2])))+"."+str(int(ip[3])&(~int(netm[3])))
-    return addr
-
-
-from util import len2mask
+from util import len2mask, get_net, get_net_addr, CIDR_to_subnet_mask
 import settings
 # import ns3
 class ManualTopologyNet(TopologyNet):
     """Topology network with manual ip settings"""
-    @staticmethod
-    def CIDR_to_subnet_mask(s_addr):
-        """change CIDR format to address, net address and mask address"""
-        addr, prefix_len = s_addr.rsplit('/')
-        mask = len2mask(int(prefix_len))
-        net = get_net(addr, mask)
-        return addr, net, mask
-
     def get_link_name(self, i):
         link = self.inFile.m_linksList[i]
         link_name = (int(link.GetFromNodeName()), int(link.GetToNodeName()) )
 
         # Create little subnets, one for each couple of nodes
         defaultAddressHelper = ns3.Ipv4AddressHelper()
-        defaultAddr, defaultNetBase, defaultMask = self.CIDR_to_subnet_mask(net_settings.ipv4_net_addr_base)
+        defaultAddr, defaultNetBase, defaultMask = CIDR_to_subnet_mask(net_settings.ipv4_net_addr_base)
         netAddr = get_net_addr(defaultAddr, defaultMask)
         defaultAddressHelper.SetBase(
                 network=ns3.Ipv4Address(defaultNetBase),
                 addressHelper.NewNetwork()
                 continue
 
-            addr, netBase, mask = self.CIDR_to_subnet_mask(ips[0])
+            addr, netBase, mask = CIDR_to_subnet_mask(ips[0])
             net_addr = get_net_addr(addr, mask)
             addressHelper.SetBase(
                     network=ns3.Ipv4Address(netBase),
             # ip1 = addressHelper.Assign(ns3.NetDeviceContainer(ndc[i].Get(0)))
             ip1 = addressHelper.Assign(ns3.NetDeviceContainer(self.get_link_ndc(i).Get(0)))
 
-            addr, netBase, mask = self.CIDR_to_subnet_mask(ips[1])
+            addr, netBase, mask = CIDR_to_subnet_mask(ips[1])
             net_addr = get_net_addr(addr, mask)
             addressHelper.SetBase(
                     network=ns3.Ipv4Address(netBase),

File experiments/ManualTopoExperiment.py

View file
  • Ignore whitespace
     def initparser(self, parser):
         TopoExperiment.initparser(self, parser)
 
-        parser.set_defaults(net_settings=settings.ROOT+"/net_config/net_settings.py",
+        parser.set_defaults(net_settings="net_config/net_settings.py",
                 )
         parser.add_option('--net_settings', dest="net_settings",
                 help='net settings file',
 
     def load_net_settings(self):
         s = {}
-        execfile(self.options.net_settings, s)
+        execfile(settings.ROOT + '/' + self.options.net_settings, s)
         return Namespace(s)
 
+    def load_exper_settings(self, ns):
+        from util import CIDR_to_subnet_mask
+        # botnet related configuration
+        self.server_id_set = ns.server_id_set
+        self.botmaster_id_set = ns.botmaster_id_set
+        self.client_id_set = ns.client_id_set
+        self.SERVER_ADDR, self.NETWORK_BASE, self.IP_MASK = CIDR_to_subnet_mask(ns.server_addr[0]);
+
     def setup(self):
         BaseClass.setup(self)
+        net_settings = self.load_net_settings()
+        self.load_exper_settings(net_settings)
+
         self.net = ManualTopologyNet(
-                os.path.abspath(self.options.topology_file),
+                # os.path.abspath(self.options.topology_file),
+                settings.ROOT + '/' + self.options.topology_file,
                 self.options.topology_type,
                 self.NodeCreator,
-                self.load_net_settings(),
+                net_settings,
                 )
         self.net.set_trace()
 

File experiments/TopoExperiment.py

View file
  • Ignore whitespace
 """
 import settings
 from core.ns3.Topology import TopologyNet
-import os
-
-NETWORK_BASE = "10.0.0.0"
-SERVER_ADDR = "10.0.0.1"
-# SERVER_ADDR = "127.0.0.1"
-IP_MASK = "255.255.255.0"
 
 class TopoExperiment(BaseClass):
+    NETWORK_BASE = "10.0.0.0"
+    SERVER_ADDR = "10.0.0.1"
+    # SERVER_ADDR = "127.0.0.1"
+    IP_MASK = "255.255.255.0"
+
     """This is pure ns-3 topology Experiment without emulated node"""
     def initparser(self, parser):
         # import pdb;pdb.set_trace()
         super(TopoExperiment, self).initparser(parser)
 
-        parser.set_defaults(topology_file=settings.ROOT+"/net_config/Inet_small_toposample.txt",
+        parser.set_defaults(topology_file="net_config/Inet_small_toposample.txt",
                 topology_type = 'Inet',
                 )
         parser.add_option("-f", "--topology_file", dest = "topology_file",
     def setup(self):
         super(TopoExperiment, self).setup()
         self.net = TopologyNet(
-                os.path.abspath(self.options.topology_file),
+                # os.path.abspath(self.options.topology_file),
+                settings.ROOT + '/' + self.options.topology_file,
                 self.options.topology_type,
                 self.NodeCreator,
-                ipv4Mask = IP_MASK,
-                ipv4NetworkBase=NETWORK_BASE,
-                ipv4AddrBase = SERVER_ADDR
+                ipv4Mask = self.IP_MASK,
+                ipv4NetworkBase= self.NETWORK_BASE,
+                ipv4AddrBase = self.SERVER_ADDR
                 )
 
-        self._install_cmds(srv_addr = SERVER_ADDR)
+        self._install_cmds(srv_addr = self.SERVER_ADDR)
         self.print_srv_addr()
         self._set_server_info()
         self.start_nodes()

File gui/cfgparse.tcl

View file
  • Ignore whitespace
 
 proc dumpputs {method dest string} {
     switch -exact -- $method {
-	file {
-	    puts $dest $string
-	}
-	string {
-	    global $dest
-	    append $dest "$string
-"
-	}
+        file {
+            puts $dest $string
+        }
+        string {
+            global $dest
+            append $dest "$string\n"
+        }
     }
 }
 
 
     global g_comments
     if { [info exists g_comments] && $g_comments != "" } {
-	dumpputs $method $dest "comments \{"
-	foreach line [split $g_comments "\n"] { dumpputs $method $dest "$line" }
-	dumpputs $method $dest "\}"
-	dumpputs $method $dest ""
+        dumpputs $method $dest "comments \{"
+        foreach line [split $g_comments "\n"] { 
+            dumpputs $method $dest "$line" 
+        }
+        dumpputs $method $dest "\}"
+        dumpputs $method $dest ""
     }
 
     foreach node $node_list {
-	global $node
-	upvar 0 $node lnode
-	dumpputs $method $dest "node $node \{"
+        global $node
+        upvar 0 $node lnode
+        dumpputs $method $dest "node $node \{"
 	foreach element $lnode {
 	    if { "[lindex $element 0]" == "network-config" } {
-		dumpputs $method $dest "    network-config \{"
-		foreach line [lindex $element 1] {
-		    dumpputs $method $dest "	$line"
-		}
-		dumpputs $method $dest "    \}"
+            dumpputs $method $dest "    network-config \{"
+            foreach line [lindex $element 1] {
+                dumpputs $method $dest "	$line"
+            }
+            dumpputs $method $dest "    \}"
 	    } elseif { "[lindex $element 0]" == "custom-config" } {
-		dumpputs $method $dest "    custom-config \{"
-		foreach line [lindex $element 1] {
-		    if { $line != {} } {
-			if { [catch {set str [lindex $line 0]} err] } {
-				puts "error loading config: $err"
-				puts "problem section: [lindex $element 0]"
-				puts "problem line: $line"
-				set str ""
-			}
-			if { $str == "config" } {
-			    dumpputs $method $dest "	config \{"
-			    foreach element [lindex $line 1] {
-				dumpputs $method $dest "	$element"
-			    }
-			    dumpputs $method $dest "	\}"
-			} else {
-			    dumpputs $method $dest "	$line"
-			}
-		    }
-		}
-		dumpputs $method $dest "    \}"
+            dumpputs $method $dest "    custom-config \{"
+            foreach line [lindex $element 1] {
+                if { $line != {} } {
+                if { [catch {set str [lindex $line 0]} err] } {
+                    puts "error loading config: $err"
+                    puts "problem section: [lindex $element 0]"
+                    puts "problem line: $line"
+                    set str ""
+                }
+                if { $str == "config" } {
+                    dumpputs $method $dest "	config \{"
+                    foreach element [lindex $line 1] {
+                    dumpputs $method $dest "	$element"
+                    }
+                    dumpputs $method $dest "	\}"
+                } else {
+                    dumpputs $method $dest "	$line"
+                }
+                }
+            }
+            dumpputs $method $dest "    \}"
 	    } elseif { "[lindex $element 0]" == "ipsec-config" } { 
-		dumpputs $method $dest "    ipsec-config \{"
-		foreach line [lindex $element 1] {
-		    if { $line != {} } {
-			dumpputs $method $dest "	$line"
-		    }
-		}
-		dumpputs $method $dest "    \}"
+            dumpputs $method $dest "    ipsec-config \{"
+            foreach line [lindex $element 1] {
+                if { $line != {} } {
+                dumpputs $method $dest "	$line"
+                }
+            }
+            dumpputs $method $dest "    \}"
 	    } elseif { "[lindex $element 0]" == "custom-pre-config-commands" } {
-		#Boeing custom pre config commands
-		dumpputs $method $dest "    custom-pre-config-commands \{"
-		foreach line [lindex $element 1] {
-		    dumpputs $method $dest "	$line"
-		}
-		dumpputs $method $dest "    \}"
-	    } elseif { "[lindex $element 0]" == "custom-post-config-commands" } {
-		#Boeing custom post config commands
-		dumpputs $method $dest "    custom-post-config-commands \{"
-		foreach line [lindex $element 1] {
-		    dumpputs $method $dest "	$line"
-		}
-		dumpputs $method $dest "    \}"
+            #Boeing custom pre config commands
+            dumpputs $method $dest "    custom-pre-config-commands \{"
+            foreach line [lindex $element 1] {
+                dumpputs $method $dest "	$line"
+            }
+            dumpputs $method $dest "    \}"
+        } elseif { "[lindex $element 0]" == "custom-post-config-commands" } {
+            #Boeing custom post config commands
+            dumpputs $method $dest "    custom-post-config-commands \{"
+            foreach line [lindex $element 1] {
+                dumpputs $method $dest "	$line"
+            }
+            dumpputs $method $dest "    \}"
 	    } elseif { "[lindex $element 0]" == "ine-config" } {
-	    # Boeing: INE config support
-		dumpputs $method $dest "    ine-config \{"
-		foreach line [lindex $element 1] {
-		    dumpputs $method $dest "	$line"
-		}
-		dumpputs $method $dest "    \}"
-	    # end Boeing
+            # Boeing: INE config support
+            dumpputs $method $dest "    ine-config \{"
+            foreach line [lindex $element 1] {
+                dumpputs $method $dest "	$line"
+            }
+            dumpputs $method $dest "    \}"
+            # end Boeing
 	    } else {
-		dumpputs $method $dest "    $element"
+            dumpputs $method $dest "    $element"
 	    }
 	}
 	dumpputs $method $dest "\}"
 			services {
 			    lappend $object "services {$value}"
 			}
-
+            role {
+                lappend $object "role {$value}"
+            }
+            traceflag {
+                lappend $object "traceflag {$value}"
+            }
 			default {
 			    # Boeing - added warning
 			    puts -nonewline "config file warning: unknown confi"

File gui/editor.tcl

View file
  • Ignore whitespace
     if { [clock seconds] == $clock_seconds } {
         update
         return
-}
-set clock_seconds [clock seconds]
-if { $cursorState } {
-    .c config -cursor watch
-    set cursorState 0
-} else {
-    .c config -cursor pirate
-    set cursorState 1
-}
-update
+    }
+    set clock_seconds [clock seconds]
+    if { $cursorState } {
+        .c config -cursor watch
+        set cursorState 0
+    } else {
+        .c config -cursor pirate
+        set cursorState 1
+    }
+    update
 }
 
 #****f* editor.tcl/removeGUILink
         removeNode [getNodeMirror $node1]
         removeNode $node1
         .c delete $node1
-} elseif { [nodeType $node2] == "pseudo" } {
-    removeLink [getLinkMirror $link]
-    removeLink $link
-    removeNode [getNodeMirror $node2]
-    removeNode $node2
-    .c delete $node2
-} else {
-    removeLink $link
-}
-.c delete $link
-if { $atomic == "atomic" } {
-    set changed 1
-    updateUndoLog
-}
+    } elseif { [nodeType $node2] == "pseudo" } {
+        removeLink [getLinkMirror $link]
+        removeLink $link
+        removeNode [getNodeMirror $node2]
+        removeNode $node2
+        .c delete $node2
+    } else {
+        removeLink $link
+    }
+    .c delete $link
+    if { $atomic == "atomic" } {
+        set changed 1
+        updateUndoLog
+    }
 }
 
 #****f* editor.tcl/removeGUINode
         set peer [peerByIfc $node $ifc]
         set link [lindex [.c gettags "link && $node && $peer"] 1]
         removeGUILink $link non-atomic
-}
-if { [lsearch -exact "oval rectangle label text marker" $type] != -1 } {
-    deleteAnnotation .c $type $node
-} elseif { $type != "pseudo" } {
-    removeNode $node
-    .c delete $node
-}
+    }
+    if { [lsearch -exact "oval rectangle label text marker" $type] != -1 } {
+        deleteAnnotation .c $type $node
+    } elseif { $type != "pseudo" } {
+        removeNode $node
+        .c delete $node
+    }
 }
 
 #****f* editor.tcl/updateUndoLog
         updateUndoRedoMenu ""
         # Boeing: XXX why is this set here?
         set changed 0
-}
+    }
 }
 
 #****f* editor.tcl/undo
         .c config -cursor watch
         loadCfg $undolog($undolevel)
         switchCanvas none
-}
+    }
 }
 
 #****f* editor.tcl/redo
         .c config -cursor watch
         loadCfg $undolog($undolevel)
         switchCanvas none
-}
+    }
 }
 
 proc updateUndoRedoMenu { forced } {
     if { $forced == "" } {
         if { $undolevel > 0 } { set undo "normal" } else { set undo "disabled" }
         if { $redolevel > $undolevel } { set redo "normal"
-} else { set redo "disabled" }
-} else {
-    set undo $forced
-    set redo $forced
-}
-
-.menubar.edit entryconfigure "Undo" -state $undo
-.menubar.edit entryconfigure "Redo" -state $redo
+        } else { set redo "disabled" }
+    } else {
+        set undo $forced
+        set redo $forced
+    }
+
+    .menubar.edit entryconfigure "Undo" -state $undo
+    .menubar.edit entryconfigure "Redo" -state $redo
 }
 
 #****f* editor.tcl/redrawAll
     set e_sizey [expr {int($sizey * $zoom)}]
     set border 28
     .c configure -scrollregion \
-    "-$border -$border [expr {$e_sizex + $border}] \
-    [expr {$e_sizey + $border}]"
+        "-$border -$border [expr {$e_sizex + $border}] \
+        [expr {$e_sizey + $border}]"
 
 
     .c delete all
     set background [.c create rectangle 0 0 $e_sizex $e_sizey \
-    -fill white -tags "background"]
-    # Boeing: wallpaper
+        -fill white -tags "background"]
+        # Boeing: wallpaper
     set wallpaper [lindex [getCanvasWallpaper $curcanvas] 0]
     set wallpaperStyle [lindex [getCanvasWallpaper $curcanvas] 1]
     if { $wallpaper != "" } {
         drawWallpaper .c $wallpaper $wallpaperStyle
-}
-# end Boeing
-
-if { $showAnnotations == 1 } {
-    foreach obj $annotation_list {
+    }
+    # end Boeing
+
+    if { $showAnnotations == 1 } {
+        foreach obj $annotation_list {
         # fix annotations having no canvas (from old config)
-        if { [getNodeCanvas $obj] == "" } { setNodeCanvas $obj $curcanvas}
-        if { [getNodeCanvas $obj] == $curcanvas } {
-            drawAnnotation $obj
-       }
-   } 
-}
-
-# Grid
-set e_grid [expr {int($grid * $zoom)}]
-set e_grid2 [expr {$e_grid * 2}]
-if { $showGrid } {
-    for { set x $e_grid } { $x < $e_sizex } { incr x $e_grid } {
-        if { [expr {$x % $e_grid2}] != 0 } {
-            if { $zoom > 0.5 } {
-                .c create line $x 1 $x $e_sizey \
-                -fill gray -dash {1 7} -tags "grid"
+            if { [getNodeCanvas $obj] == "" } { setNodeCanvas $obj $curcanvas}
+            if { [getNodeCanvas $obj] == $curcanvas } {
+                drawAnnotation $obj
+            }
+        } 
     }
-    } else {
-        .c create line $x 1 $x $e_sizey -fill gray -dash {1 3} \
-        -tags "grid"
+
+    # Grid
+    set e_grid [expr {int($grid * $zoom)}]
+    set e_grid2 [expr {$e_grid * 2}]
+    if { $showGrid } {
+        for { set x $e_grid } { $x < $e_sizex } { incr x $e_grid } {
+            if { [expr {$x % $e_grid2}] != 0 } {
+                if { $zoom > 0.5 } {
+                    .c create line $x 1 $x $e_sizey \
+                        -fill gray -dash {1 7} -tags "grid"
+                }
+            } else {
+                .c create line $x 1 $x $e_sizey -fill gray -dash {1 3} \
+                    -tags "grid"
+            }
+        }
+        for { set y $e_grid } { $y < $e_sizey } { incr y $e_grid } {
+            if { [expr {$y % $e_grid2}] != 0 } {
+                if { $zoom > 0.5 } {
+                    .c create line 1 $y $e_sizex $y \
+                        -fill gray -dash {1 7} -tags "grid"
+                }
+            } else {
+                .c create line 1 $y $e_sizex $y -fill gray -dash {1 3} \
+                    -tags "grid"
+            }
+        }
     }
-}
-for { set y $e_grid } { $y < $e_sizey } { incr y $e_grid } {
-    if { [expr {$y % $e_grid2}] != 0 } {
-        if { $zoom > 0.5 } {
-            .c create line 1 $y $e_sizex $y \
-            -fill gray -dash {1 7} -tags "grid"
+
+    .c lower -withtags background
+
+    foreach node $node_list {
+        if { [getNodeCanvas $node] == $curcanvas } {
+            drawNode .c $node
+        }
     }
-    } else {
-        .c create line 1 $y $e_sizex $y -fill gray -dash {1 3} \
-        -tags "grid"
+    foreach link $link_list {
+        set nodes [linkPeers $link]
+        if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
+             [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
+            continue
+        }
+        drawLink $link
+        redrawLink $link
+        updateLinkLabel $link
     }
-}
-}
-
-.c lower -withtags background
-
-foreach node $node_list {
-    if { [getNodeCanvas $node] == $curcanvas } {
-        drawNode .c $node
-}
-  }
-  foreach link $link_list {
-      set nodes [linkPeers $link]
-      if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
-          [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
-              continue
-}
-drawLink $link
-redrawLink $link
-updateLinkLabel $link
-}
-
-.c config -cursor left_ptr
-
-# Boeing
-global oper_mode execMode
-# TODO: instead of recalculating ranges, keep a list of wlanlinks
-#       and redraw them here
-if { $oper_mode == "exec" } {
-    foreach wlan [findWlanNodes ""] { updateAllRanges $wlan 1 }
-}
-raiseAll .c
-# end Boeing
+
+    .c config -cursor left_ptr
+
+    # Boeing
+    global oper_mode execMode
+    # TODO: instead of recalculating ranges, keep a list of wlanlinks
+    #       and redraw them here
+    if { $oper_mode == "exec" } {
+        foreach wlan [findWlanNodes ""] { updateAllRanges $wlan 1 }
+    }
+    raiseAll .c
+    # end Boeing
 }
 
 #****f* editor.tcl/drawNode
     if { $type == "router" } {
         set model [getNodeModel $node]
         set cimg [getNodeTypeImage $model normal]
-}
-set tmp [absPathname [getCustomImage $node]]
-if { $tmp != "" } { set cimg $tmp }
-if { $cimg != "" } {
+    }
+    set tmp [absPathname [getCustomImage $node]]
+    if { $tmp != "" } { set cimg $tmp }
+    if { $cimg != "" } {
     # name of global variable storing the image is the filename without path
-    set img [file tail $cimg] 
-    # create the variable if the image hasn't been loaded before
-    global [set img]
-    if { ![info exists $img] } {
-        if { [catch {
+        set img [file tail $cimg] 
+        # create the variable if the image hasn't been loaded before
+        global [set img]
+        if { ![info exists $img] } {
+            if { [catch {
                 set [set img] [image create photo -file $cimg]
                 createScaledImages $img
-    } e ] } { ;# problem loading image file
-        puts "icon error: $e"
-        set cimg "" ;# fall back to default model icon
+            } e ] } { ;# problem loading image file
+                      puts "icon error: $e"
+                      set cimg "" ;# fall back to default model icon
+            }
+        }
+        if { $cimg != "" } { ;# only if image file loaded
+                             global $img$imgzoom
+                             $c create image $x $y -image [set $img$imgzoom] -tags "node $node"
+        }
     }
-}
-if { $cimg != "" } { ;# only if image file loaded
-    global $img$imgzoom
-    $c create image $x $y -image [set $img$imgzoom] -tags "node $node"
-}
-}
-if { $cimg == "" } {
-    if { $type == "pseudo" } {
-        $c create image $x $y -image [set $type] -tags "node $node"
-} else {
-    # create scaled images based on zoom level
-    global $type$imgzoom
-    $c create image $x $y -image [set $type$imgzoom] \
-    -tags "node $node"
-}
-}
-set coords [getNodeLabelCoords $node]
-set x [expr {[lindex $coords 0] * $zoom}]
-set y [expr {[lindex $coords 1] * $zoom}]
-if { [nodeType $node] != "pseudo" } { ;# Boeing: show remote server
-    set loc [getNodeLocation $node]
-    set labelstr0 ""
-    if { $loc != "" } { set labelstr0 "([getNodeLocation $node]):" }
-    set labelstr1 [getNodeName $node];
-    set labelstr2 ""
-    if [info exists getNodePartition] { [getNodePartition $node]; }
-    set l [format "%s%s\n%s" $labelstr0 $labelstr1 $labelstr2];
-    set label [$c create text $x $y -fill blue \
-    -text "$l" \
-    -tags "nodelabel $node"]
-} else {
-    set pnode [getNodeName $node]
-    set pcanvas [getNodeCanvas $pnode]
-    set ifc [ifcByPeer $pnode [getNodeMirror $node]]
-    if { $pcanvas != $curcanvas } {
-        set label [$c create text $x $y -fill blue \
-        -text "[getNodeName $pnode]:$ifc
-        -tags "nodelabel $node" -justify center]
-} else {
-    set label [$c create text $x $y -fill blue \
-    -text "[getNodeName $pnode]:$ifc" \
-    -tags "nodelabel $node" -justify center]
-}
-}
-if { $showNodeLabels == 0} {
-    $c itemconfigure $label -state hidden
-}
-global invisible
-if { $invisible == 1 && [nodeType $node] == "pseudo" } {
-    $c itemconfigure $label -state hidden
-}
+    if { $cimg == "" } {
+        if { $type == "pseudo" } {
+            $c create image $x $y -image [set $type] -tags "node $node"
+        } else {
+        # create scaled images based on zoom level
+            global $type$imgzoom
+            $c create image $x $y -image [set $type$imgzoom] \
+                -tags "node $node"
+        }
+    }
+    set coords [getNodeLabelCoords $node]
+    set x [expr {[lindex $coords 0] * $zoom}]
+    set y [expr {[lindex $coords 1] * $zoom}]
+    if { [nodeType $node] != "pseudo" } { ;# Boeing: show remote server
+                                          set loc [getNodeLocation $node]
+                                          set labelstr0 ""
+                                          if { $loc != "" } { set labelstr0 "([getNodeLocation $node]):" }
+                                          set labelstr1 [getNodeName $node];
+                                          set labelstr2 ""
+                                          if [info exists getNodePartition] { [getNodePartition $node]; }
+                                          set l [format "%s%s\n%s" $labelstr0 $labelstr1 $labelstr2];
+                                          set label [$c create text $x $y -fill blue \
+                                              -text "$l" \
+                                              -tags "nodelabel $node"]
+    } else {
+        set pnode [getNodeName $node]
+        set pcanvas [getNodeCanvas $pnode]
+        set ifc [ifcByPeer $pnode [getNodeMirror $node]]
+        if { $pcanvas != $curcanvas } {
+            set label [$c create text $x $y -fill blue \
+                -text "[getNodeName $pnode]:$ifc
+                -tags "nodelabel $node" -justify center]
+        } else {
+            set label [$c create text $x $y -fill blue \
+                -text "[getNodeName $pnode]:$ifc" \
+                -tags "nodelabel $node" -justify center]
+        }
+    }
+    if { $showNodeLabels == 0} {
+        $c itemconfigure $label -state hidden
+    }
+    global invisible
+    if { $invisible == 1 && [nodeType $node] == "pseudo" } {
+        $c itemconfigure $label -state hidden
+    }
 }
 
 #****f* editor.tcl/drawLink
     set lwidth [getLinkWidth $link]
     if { [getLinkMirror $link] != "" } {
         set newlink [.c create line 0 0 0 0 \
-        -fill [getLinkColor $link] -width $lwidth \
-        -tags "link $link $lnode1 $lnode2" -arrow both]
-} else {
-    set newlink [.c create line 0 0 0 0 \
-    -fill [getLinkColor $link] -width $lwidth \
-    -tags "link $link $lnode1 $lnode2"]
-}
-# Boeing: links between two nodes on different servers
-if { [getNodeLocation $lnode1] != [getNodeLocation $lnode2]} {
-    .c itemconfigure $newlink -dash ",";
-}
-# end Boeing
-# XXX Invisible pseudo-liks
-global invisible
-if { $invisible == 1 && [getLinkMirror $link] != "" } {
-    .c itemconfigure $link -state hidden
-}
-# Boeing: wlan links are hidden
-if { [nodeType $lnode1] == "wlan" || [nodeType $lnode2] == "wlan" } {
-    global zoom
-    set imgzoom $zoom
-    if { $zoom == 0.75 || $zoom == 1.5 } { set imgzoom 1.0 }
-    global antenna$imgzoom
-    .c itemconfigure $link -state hidden
-    .c create image 0 0 -image [set antenna$imgzoom] \
-    -tags "antenna $lnode2 $link"
-    .c create text 0 0 -tags "interface $lnode1 $link" -justify center
-    .c create text 0 0 -tags "interface $lnode2 $link" -justify center
-    .c raise interface "link || linklabel || background"
-} else {
-    .c raise $newlink background
-    .c create text 0 0 -tags "linklabel $link" -justify center
-    .c create text 0 0 -tags "interface $lnode1 $link" -justify center
-    .c create text 0 0 -tags "interface $lnode2 $link" -justify center
-    .c raise linklabel "link || background"
-    .c raise interface "link || linklabel || background"
-}
-foreach n [list $lnode1 $lnode2] {
-    if { [getNodeHidden $n] } { hideNode $n }
-    statline "Hidden node(s) exist."
-}
+            -fill [getLinkColor $link] -width $lwidth \
+            -tags "link $link $lnode1 $lnode2" -arrow both]
+    } else {
+        set newlink [.c create line 0 0 0 0 \
+            -fill [getLinkColor $link] -width $lwidth \
+            -tags "link $link $lnode1 $lnode2"]
+    }
+    # Boeing: links between two nodes on different servers
+    if { [getNodeLocation $lnode1] != [getNodeLocation $lnode2]} {
+        .c itemconfigure $newlink -dash ",";
+    }
+    # end Boeing
+    # XXX Invisible pseudo-liks
+    global invisible
+    if { $invisible == 1 && [getLinkMirror $link] != "" } {
+        .c itemconfigure $link -state hidden
+    }
+    # Boeing: wlan links are hidden
+    if { [nodeType $lnode1] == "wlan" || [nodeType $lnode2] == "wlan" } {
+        global zoom
+        set imgzoom $zoom
+        if { $zoom == 0.75 || $zoom == 1.5 } { set imgzoom 1.0 }
+        global antenna$imgzoom
+        .c itemconfigure $link -state hidden
+        .c create image 0 0 -image [set antenna$imgzoom] \
+            -tags "antenna $lnode2 $link"
+        .c create text 0 0 -tags "interface $lnode1 $link" -justify center
+        .c create text 0 0 -tags "interface $lnode2 $link" -justify center
+        .c raise interface "link || linklabel || background"
+    } else {
+        .c raise $newlink background
+        .c create text 0 0 -tags "linklabel $link" -justify center
+        .c create text 0 0 -tags "interface $lnode1 $link" -justify center
+        .c create text 0 0 -tags "interface $lnode2 $link" -justify center
+        .c raise linklabel "link || background"
+        .c raise interface "link || linklabel || background"
+    }
+    foreach n [list $lnode1 $lnode2] {
+        if { [getNodeHidden $n] } { hideNode $n }
+        statline "Hidden node(s) exist."
+    }
 }
 
 
     set wlanlink [$c find withtag "wlanlink && $node1 && $node2 && $wlan"]
     if { $wlanlink != "" } {
         return $wlanlink ;# already exists
-}
-
-set color [getWlanColor $wlan]
-
-set xy [getNodeCoords $node1]
-set x [lindex $xy 0]; set y [lindex $xy 1]
-set pxy [getNodeCoords $node2]
-set px [lindex $pxy 0]; set py [lindex $pxy 1]
-
-set wlanlink [$c create line [expr {$x*$zoom}] [expr {$y*$zoom}] \
-[expr {$px*$zoom}] [expr {$py*$zoom}] \
--fill $color -width $defLinkWidth \
--tags "wlanlink $node1 $node2 $wlan"]
-$c raise $wlanlink "background || grid || oval || rectangle"
-return $wlanlink
+    }
+
+    set color [getWlanColor $wlan]
+
+    set xy [getNodeCoords $node1]
+    set x [lindex $xy 0]; set y [lindex $xy 1]
+    set pxy [getNodeCoords $node2]
+    set px [lindex $pxy 0]; set py [lindex $pxy 1]
+
+    set wlanlink [$c create line [expr {$x*$zoom}] [expr {$y*$zoom}] \
+        [expr {$px*$zoom}] [expr {$py*$zoom}] \
+        -fill $color -width $defLinkWidth \
+        -tags "wlanlink $node1 $node2 $wlan"]
+    $c raise $wlanlink "background || grid || oval || rectangle"
+    return $wlanlink
 }
 
 
     switch -exact -- [nodeType $lnode1] {
         pc {
             return eth
-}
-host {
-    return eth
-}
-hub {
-    return e
-}
-lanswitch {
-    return e
-}
-router {
-    return eth
-}
-rj45 {
-    return 
-}
-tunnel {
-    return e
-}
-ktunnel {
-    return
-}
-wlan {
-    return e
-}
-default {
-    return eth
-    # end Boeing: below
-}
-}
+        }
+        host {
+            return eth
+        }
+        hub {
+            return e
+        }
+        lanswitch {
+            return e
+        }
+        router {
+            return eth
+        }
+        rj45 {
+            return 
+        }
+        tunnel {
+            return e
+        }
+        ktunnel {
+            return
+        }
+        wlan {
+            return e
+        }
+        default {
+            return eth
+            # end Boeing: below
+        }
+    }
 }
 
 
         if { [ lsearch {lanswitch hub wlan} $type] != -1 } {
             if { [lsearch $l2peers $peer] == -1 } {
                 set l2peers [listLANnodes $peer $l2peers]
+            }
+        }
     }
-}
-}
-return $l2peers
+    return $l2peers
 }
 
 #****f* editor.tcl/calcDxDy
         set x 1
         set y 1
         return
-}
-switch -exact -- [nodeType $lnode] {
-    hub {
-        set x [expr {1.5 / $zoom}]
-        set y [expr {2.6 / $zoom}]
-}
-lanswitch {
-    set x [expr {1.5 / $zoom}]
-    set y [expr {2.6 / $zoom}]
-}
-router {
-    set x [expr {1 / $zoom}]
-    set y [expr {2 / $zoom}]
-}
-rj45 {
-    set x [expr {1 / $zoom}]
-    set y [expr {1 / $zoom}]
-}
-tunnel {
-    set x [expr {1 / $zoom}]
-    set y [expr {1 / $zoom}]
-}
-wlan {
-    set x [expr {1.5 / $zoom}]
-    set y [expr {2.6 / $zoom}]
-}
-default {
-    set x [expr {1 / $zoom}]
-    set y [expr {2 / $zoom}]
-}
-}
-return
+    }
+    switch -exact -- [nodeType $lnode] {
+        hub {
+            set x [expr {1.5 / $zoom}]
+            set y [expr {2.6 / $zoom}]
+        }
+        lanswitch {
+            set x [expr {1.5 / $zoom}]
+            set y [expr {2.6 / $zoom}]
+        }
+        router {
+            set x [expr {1 / $zoom}]
+            set y [expr {2 / $zoom}]
+        }
+        rj45 {
+            set x [expr {1 / $zoom}]
+            set y [expr {1 / $zoom}]
+        }
+        tunnel {
+            set x [expr {1 / $zoom}]
+            set y [expr {1 / $zoom}]
+        }
+        wlan {
+            set x [expr {1.5 / $zoom}]
+            set y [expr {2.6 / $zoom}]
+        }
+        default {
+            set x [expr {1 / $zoom}]
+            set y [expr {2 / $zoom}]
+        }
+    }
+    return
 }
 
 #****f* editor.tcl/updateIfcLabel
     set ifipv6addr [getIfcIPv6addr $lnode1 $ifc]
     if { $ifc == 0 } {
         set ifc ""
-}
-if { [getIfcOperState $lnode1 $ifc] == "down" } {
-    set labelstr "*"
-} else {
-    set labelstr ""
-}
-if { $showIfNames } {
-    set labelstr "$labelstr$ifc
-}
-if { $showIfIPaddrs && $ifipv4addr != "" } {
-    set labelstr "$labelstr$ifipv4addr
-}
-if { $showIfIPv6addrs && $ifipv6addr != "" } {
-    set labelstr "$labelstr$ifipv6addr
-}
-set labelstr \
-[string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
-.c itemconfigure "interface && $lnode1 && $link" \
--text "$labelstr"
-# Boeing: hide ifc label on wlans
-if { [nodeType $lnode1] == "wlan" } { 
-    .c itemconfigure "interface && $lnode1 && $link" -state hidden
-}
+    }
+    if { [getIfcOperState $lnode1 $ifc] == "down" } {
+        set labelstr "*"
+    } else {
+        set labelstr ""
+    }
+    if { $showIfNames } {
+        set labelstr "$labelstr$ifc
+    }
+    if { $showIfIPaddrs && $ifipv4addr != "" } {
+        set labelstr "$labelstr$ifipv4addr
+    }
+    if { $showIfIPv6addrs && $ifipv6addr != "" } {
+        set labelstr "$labelstr$ifipv6addr
+    }
+    set labelstr \
+        [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
+    .c itemconfigure "interface && $lnode1 && $link" \
+        -text "$labelstr"
+        # Boeing: hide ifc label on wlans
+    if { [nodeType $lnode1] == "wlan" } { 
+        .c itemconfigure "interface && $lnode1 && $link" -state hidden
+    }
 }
 
 
     set labelstr "$labelstr[getLinkBandwidthString $link]
     if { "$delstr" != "" } {
         set labelstr "$labelstr$delstr
-}
-if { "$ber" != "" } {
-    if { [lindex $systype 0] == "Linux" } { set berstr "per=$ber" 
-    } else { set berstr "ber=$ber" }
-    set labelstr "$labelstr$berstr
-}
-if { "$dup" != "" } {
-    set dupstr "dup=$dup%"
-    set labelstr "$labelstr$dupstr
-}
-set labelstr \
-[string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
-.c itemconfigure "linklabel && $link" -text "$labelstr"
-if { $showLinkLabels == 0} {
-    .c itemconfigure "linklabel && $link" -state hidden
-}
+    }
+    if { "$ber" != "" } {
+        if { [lindex $systype 0] == "Linux" } { set berstr "per=$ber" 
+        } else { set berstr "ber=$ber" }
+        set labelstr "$labelstr$berstr
+    }
+    if { "$dup" != "" } {
+        set dupstr "dup=$dup%"
+        set labelstr "$labelstr$dupstr
+    }
+    set labelstr \
+        [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
+    .c itemconfigure "linklabel && $link" -text "$labelstr"
+    if { $showLinkLabels == 0} {
+        .c itemconfigure "linklabel && $link" -state hidden
+    }
 }
 
 
     foreach link $link_list {
         set nodes [linkPeers $link]
         if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
-            [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
-                continue
-}
-redrawLink $link
-}
+             [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
+            continue
+        }
+        redrawLink $link
+    }
 }
 
 
     .c coords "linklabel && $link" $lx $ly
 
     set n [expr {sqrt (($x1 - $x2) * ($x1 - $x2) + \
-        ($y1 - $y2) * ($y1 - $y2)) * 0.015}]
-        if { $n < 1 } {
-            set n 1
-}
-
-calcDxDy $lnode1
-set lx [expr {($x1 * ($n * $dx - 1) + $x2) / $n / $dx}]
-set ly [expr {($y1 * ($n * $dy - 1) + $y2) / $n / $dy}]
-.c coords "interface && $lnode1 && $link" $lx $ly
-updateIfcLabel $lnode1 $lnode2
-
-calcDxDy $lnode2
-set lx [expr {($x1 + $x2 * ($n * $dx - 1)) / $n / $dx}]
-set ly [expr {($y1 + $y2 * ($n * $dy - 1)) / $n / $dy}]
-.c coords "interface && $lnode2 && $link" $lx $ly
-updateIfcLabel $lnode2 $lnode1
-# Boeing - wlan antennas
-if { [nodeType $lnode1] == "wlan" } {
-    global zoom
-    set an [lsearch -exact [findWlanNodes $lnode2] $lnode1]
-    if { $an < 0 || $an >= 5 } { set an 0 }
-    set dx [expr {20 - (10*$an)}]
-    .c coords "antenna && $lnode2 && $link" [expr {$x2-($dx*$zoom)}] \
-    [expr {$y2-(20*$zoom)}]
-}
+                 ($y1 - $y2) * ($y1 - $y2)) * 0.015}]
+    if { $n < 1 } {
+        set n 1
+    }
+
+    calcDxDy $lnode1
+    set lx [expr {($x1 * ($n * $dx - 1) + $x2) / $n / $dx}]
+    set ly [expr {($y1 * ($n * $dy - 1) + $y2) / $n / $dy}]
+    .c coords "interface && $lnode1 && $link" $lx $ly
+    updateIfcLabel $lnode1 $lnode2
+
+    calcDxDy $lnode2
+    set lx [expr {($x1 + $x2 * ($n * $dx - 1)) / $n / $dx}]
+    set ly [expr {($y1 + $y2 * ($n * $dy - 1)) / $n / $dy}]
+    .c coords "interface && $lnode2 && $link" $lx $ly
+    updateIfcLabel $lnode2 $lnode1
+    # Boeing - wlan antennas
+    if { [nodeType $lnode1] == "wlan" } {
+        global zoom
+        set an [lsearch -exact [findWlanNodes $lnode2] $lnode1]
+        if { $an < 0 || $an >= 5 } { set an 0 }
+        set dx [expr {20 - (10*$an)}]
+        .c coords "antenna && $lnode2 && $link" [expr {$x2-($dx*$zoom)}] \
+            [expr {$y2-(20*$zoom)}]
+    }
 }
 
 # Boeing
     set y2 [lindex [getNodeCoords $orig_node2] 1]
 
     setNodeCoords $new_node1 \
-    "[expr {($x1 + 0.4 * ($x2 - $x1)) / $zoom}] \
-    [expr {($y1 + 0.4 * ($y2 - $y1)) / $zoom}]"
+        "[expr {($x1 + 0.4 * ($x2 - $x1)) / $zoom}] \
+        [expr {($y1 + 0.4 * ($y2 - $y1)) / $zoom}]"
     setNodeCoords $new_node2 \
-    "[expr {($x1 + 0.6 * ($x2 - $x1)) / $zoom}] \
-    [expr {($y1 + 0.6 * ($y2 - $y1)) / $zoom}]"
+        "[expr {($x1 + 0.6 * ($x2 - $x1)) / $zoom}] \
+        [expr {($y1 + 0.6 * ($y2 - $y1)) / $zoom}]"
     setNodeLabelCoords $new_node1 [getNodeCoords $new_node1]
     setNodeLabelCoords $new_node2 [getNodeCoords $new_node2]
 
     $c addtag selected withtag "node && $node"
     if { [nodeType $node] == "pseudo" } {
         set bbox [$c bbox "nodelabel && $node"]
-} elseif { [nodeType $node] == "rectangle" } {
-    $c addtag selected withtag "rectangle && $node"
-    set bbox [$c bbox "rectangle && $node"]
-} elseif { [nodeType $node] == "text" } {
-    $c addtag selected withtag "text && $node"
-    set bbox [$c bbox "text && $node"]
-} elseif { [nodeType $node] == "oval" } {
-    $c addtag selected withtag "oval && $node"
-    set bbox [$c bbox "oval && $node"]
-} else {
-    set bbox [$c bbox "node && $node"]
-}
-set bx1 [expr {[lindex $bbox 0] - 2}]
-set by1 [expr {[lindex $bbox 1] - 2}]
-set bx2 [expr {[lindex $bbox 2] + 1}]
-set by2 [expr {[lindex $bbox 3] + 1}]
-$c delete -withtags "selectmark && $node"
-$c create line $bx1 $by1 $bx2 $by1 $bx2 $by2 $bx1 $by2 $bx1 $by1 \
--dash {6 4} -fill black -width 1 -tags "selectmark $node"
+    } elseif { [nodeType $node] == "rectangle" } {
+        $c addtag selected withtag "rectangle && $node"
+        set bbox [$c bbox "rectangle && $node"]
+    } elseif { [nodeType $node] == "text" } {
+        $c addtag selected withtag "text && $node"
+        set bbox [$c bbox "text && $node"]
+    } elseif { [nodeType $node] == "oval" } {
+        $c addtag selected withtag "oval && $node"
+        set bbox [$c bbox "oval && $node"]
+    } else {
+        set bbox [$c bbox "node && $node"]
+    }
+    set bx1 [expr {[lindex $bbox 0] - 2}]
+    set by1 [expr {[lindex $bbox 1] - 2}]
+    set bx2 [expr {[lindex $bbox 2] + 1}]
+    set by2 [expr {[lindex $bbox 3] + 1}]
+    $c delete -withtags "selectmark && $node"
+    $c create line $bx1 $by1 $bx2 $by1 $bx2 $by2 $bx1 $by2 $bx1 $by1 \
+        -dash {6 4} -fill black -width 1 -tags "selectmark $node"
 }
 
 proc selectNodes { nodelist } {
     foreach node $nodelist {
         selectNode .c [.c find withtag "node && $node"]
-}
+    }
 }
 
 proc selectedNodes {} {
     set selected {}
     foreach obj [.c find withtag "node && selected"] {
         lappend selected [lindex [.c gettags $obj] 1]
-}
-foreach obj [.c find withtag "oval && selected"] {
-    lappend selected [lindex [.c gettags $obj] 1]
-}
-foreach obj [.c find withtag "rectangle && selected"] {
-    lappend selected [lindex [.c gettags $obj] 1]
-}
-foreach obj [.c find withtag "text && selected"] {
-    lappend selected [lindex [.c gettags $obj] 1]
-}
-return $selected
+    }
+    foreach obj [.c find withtag "oval && selected"] {
+        lappend selected [lindex [.c gettags $obj] 1]
+    }
+    foreach obj [.c find withtag "rectangle && selected"] {
+        lappend selected [lindex [.c gettags $obj] 1]
+    }
+    foreach obj [.c find withtag "text && selected"] {
+        lappend selected [lindex [.c gettags $obj] 1]
+    }
+    return $selected
 }
 
 proc selectedRealNodes {} {
     foreach obj [.c find withtag "node && selected"] {
         set node [lindex [.c gettags $obj] 1]
         if { [getNodeMirror $node] != "" ||
-            [nodeType $node] == "rj45" } {
-                continue
-}
-lappend selected $node
-}
-return $selected
+             [nodeType $node] == "rj45" } {
+            continue
+        }
+        lappend selected $node
+    }
+    return $selected
 }
 
 proc selectAdjacent {} {
             set peer [peerByIfc $node $ifc]
             if { [getNodeMirror $peer] != "" } {
                 return
+            }
+            if { [lsearch $adjacent $peer] < 0 } {
+                lappend adjacent $peer
+            }
+        }
     }
-    if { [lsearch $adjacent $peer] < 0 } {
-        lappend adjacent $peer
-    }
-}
-}
-selectNodes $adjacent
+    selectNodes $adjacent
 }
 
 #****f* editor.tcl/button3link
         set link [lindex [$c gettags {linklabel && current}] 1]
         if { $link == "" } {
             return
-}
-}
-
-.button3menu delete 0 end
-
-#
-# Configure link
-#
-.button3menu add command -label "Configure" \
--command "popupConfigDialog $c"
-
-#
-# Delete link
-#
-if { $oper_mode != "exec" } {
-    .button3menu add command -label "Delete" \
-    -command "removeGUILink $link atomic"
-} else {
-    .button3menu add command -label "Delete" \
-    -state disabled
-}
-
-#
-# Split link
-#
-if { $oper_mode != "exec" && [getLinkMirror $link] == "" } {
-    .button3menu add command -label "Split" \
-    -command "splitGUILink $link"
-} else {
-    .button3menu add command -label "Split" \
-    -state disabled
-}
-
-#
-# Merge two pseudo nodes / links
-#
-if { $oper_mode != "exec" && [getLinkMirror $link] != "" &&
-    [getNodeCanvas [getNodeMirror [lindex [linkPeers $link] 1]]] ==
-    $curcanvas } {
+        }
+    }
+
+    .button3menu delete 0 end
+
+    #
+    # Configure link
+    #
+    .button3menu add command -label "Configure" \
+        -command "popupConfigDialog $c"
+
+        #
+        # Delete link
+        #
+    if { $oper_mode != "exec" } {
+        .button3menu add command -label "Delete" \
+            -command "removeGUILink $link atomic"
+    } else {
+        .button3menu add command -label "Delete" \
+            -state disabled
+    }
+
+    #
+    # Split link
+    #
+    if { $oper_mode != "exec" && [getLinkMirror $link] == "" } {
+        .button3menu add command -label "Split" \
+            -command "splitGUILink $link"
+    } else {
+        .button3menu add command -label "Split" \
+            -state disabled
+    }
+
+    #
+    # Merge two pseudo nodes / links
+    #
+    if { $oper_mode != "exec" && [getLinkMirror $link] != "" &&
+         [getNodeCanvas [getNodeMirror [lindex [linkPeers $link] 1]]] ==
+         $curcanvas } {
         .button3menu add command -label "Merge" \
-        -command "mergeGUINode [lindex [linkPeers $link] 1]"
-} else {
-    .button3menu add command -label "Merge" -state disabled
-}
-
-set x [winfo pointerx .]
-set y [winfo pointery .]
-tk_popup .button3menu $x $y
+            -command "mergeGUINode [lindex [linkPeers $link] 1]"
+    } else {
+        .button3menu add command -label "Merge" -state disabled
+    }
+
+    set x [winfo pointerx .]
+    set y [winfo pointery .]
+    tk_popup .button3menu $x $y
 }
 
 
     foreach node $selected_nodes {
         setNodeCanvas $node $canvas
         set changed 1
-}
-foreach obj [.c find withtag "linklabel"] {
-    set link [lindex [.c gettags $obj] 1]
-    set link_peers [linkPeers $link]
-    set peer1 [lindex $link_peers 0]
-    set peer2 [lindex $link_peers 1]
-    set peer1_in_selected [lsearch $selected_nodes $peer1]
-    set peer2_in_selected [lsearch $selected_nodes $peer2]
-    if { ($peer1_in_selected == -1 && $peer2_in_selected != -1) ||
-        ($peer1_in_selected != -1 && $peer2_in_selected == -1) } {
+    }
+    foreach obj [.c find withtag "linklabel"] {
+        set link [lindex [.c gettags $obj] 1]
+        set link_peers [linkPeers $link]
+        set peer1 [lindex $link_peers 0]
+        set peer2 [lindex $link_peers 1]
+        set peer1_in_selected [lsearch $selected_nodes $peer1]
+        set peer2_in_selected [lsearch $selected_nodes $peer2]
+        if { ($peer1_in_selected == -1 && $peer2_in_selected != -1) ||
+             ($peer1_in_selected != -1 && $peer2_in_selected == -1) } {
             if { [nodeType $peer2] == "pseudo" } {
                 setNodeCanvas $peer2 $canvas
                 if { [getNodeCanvas [getNodeMirror $peer2]] == $canvas } {
                     mergeLink $link
+                }
+                continue
+            }
+            set new_nodes [splitLink $link pseudo]
+            set new_node1 [lindex $new_nodes 0]
+            set new_node2 [lindex $new_nodes 1]
+            setNodeMirror $new_node1 $new_node2
+            setNodeMirror $new_node2 $new_node1
+            setNodeName $new_node1 $peer2
+            setNodeName $new_node2 $peer1
+            set link1 [linkByPeers $peer1 $new_node1]
+            set link2 [linkByPeers $peer2 $new_node2]
+            setLinkMirror $link1 $link2
+            setLinkMirror $link2 $link1
+        }
     }
-    continue
-    }
-    set new_nodes [splitLink $link pseudo]
-    set new_node1 [lindex $new_nodes 0]
-    set new_node2 [lindex $new_nodes 1]
-    setNodeMirror $new_node1 $new_node2
-    setNodeMirror $new_node2 $new_node1
-    setNodeName $new_node1 $peer2
-    setNodeName $new_node2 $peer1
-    set link1 [linkByPeers $peer1 $new_node1]
-    set link2 [linkByPeers $peer2 $new_node2]
-    setLinkMirror $link1 $link2
-    setLinkMirror $link2 $link1
-}
-}
-updateUndoLog
-redrawAll
+    updateUndoLog
+    redrawAll
 }
 
 
         set node [lindex [$c gettags {nodelabel && current}] 1]
         if { $node == "" } {
             return
-}
-}
-set mirror_node [getNodeMirror $node]
-
-if { [$c gettags "node && $node && selected"] == "" } {
-    $c dtag node selected
-    $c delete -withtags selectmark
-    selectNode $c [$c find withtag "current"]
-}
-
-# open up shells upon double-click or shift/ctrl-click
-set shell $g_prefs(shell)
-if { $button == "shift" || $button == "ctrl" } {
+        }
+    }
+    set mirror_node [getNodeMirror $node]
+
+    if { [$c gettags "node && $node && selected"] == "" } {
+        $c dtag node selected
+        $c delete -withtags selectmark
+        selectNode $c [$c find withtag "current"]
+    }
+
+    # open up shells upon double-click or shift/ctrl-click
+    set shell $g_prefs(shell)
+    if { $button == "shift" || $button == "ctrl" } {
     # only open bash shells for NETWORK nodes and remote routers
-    if { [[typemodel $node].layer] != "NETWORK" } {
-        if { [getNodeModel $node] != "remote" } {
-            return
+        if { [[typemodel $node].layer] != "NETWORK" } {
+            if { [getNodeModel $node] != "remote" } {
+                return
+            }
+        }
+        if { $button == "shift" } {	;# normal bash shell
+                                    spawnShell $node $shell
+        } else { 			;# right-click vtysh shell
+                    set cmd [[typemodel $node].shellcmd $node] 
+                    if { $cmd != "/bin/sh" && $cmd != "" } { spawnShell $node $cmd }
+        }
+        return ;# open shell, don't post a menu
     }
-}
-if { $button == "shift" } {	;# normal bash shell
-    spawnShell $node $shell
-} else { 			;# right-click vtysh shell
-    set cmd [[typemodel $node].shellcmd $node] 
-    if { $cmd != "/bin/sh" && $cmd != "" } { spawnShell $node $cmd }
-}
-return ;# open shell, don't post a menu
-}
-
-#
-# below here we build and post a menu
-#
-.button3menu delete 0 end
-
-#
-# Select adjacent
-#
-if { [nodeType $node] != "pseudo" } {
-    .button3menu add command -label "Select adjacent" \
-    -command "selectAdjacent"
-} else {
-    .button3menu add command -label "Select adjacent" \
-    -command "selectAdjacent" -state disabled
-}
-
-#
-# Configure node
-#
-if { [nodeType $node] != "pseudo" } {
-    .button3menu add command -label "Configure" \
-    -command "popupConfigDialog $c"
-} else {
-    .button3menu add command -label "Configure" \
-    -command "popupConfigDialog $c" -state disabled
-}
-
-#
-# Create a new link - can be between different canvases
-#
-.button3menu.connect delete 0 end
-if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
-    .button3menu add cascade -label "Create link to" \
-    -menu .button3menu.connect -state disabled
-} else {
-    .button3menu add cascade -label "Create link to" \
-    -menu .button3menu.connect
-}
-destroy .button3menu.connect.selected
-menu .button3menu.connect.selected -tearoff 0
-.button3menu.connect add cascade -label "Selected" \
--menu .button3menu.connect.selected
-.button3menu.connect.selected add command \
--label "Chain" -command "P \[selectedRealNodes\]"
-.button3menu.connect.selected add command \
--label "Star" \
--command "Kb \[lindex \[selectedRealNodes\] 0\] \
-\[lrange \[selectedNodes\] 1 end\]"
-.button3menu.connect.selected add command \
--label "Cycle" -command "C \[selectedRealNodes\]"
-.button3menu.connect.selected add command \
--label "Clique" -command "K \[selectedRealNodes\]"
-.button3menu.connect add separator
-foreach canvas $canvas_list {
-    destroy .button3menu.connect.$canvas
-    menu .button3menu.connect.$canvas -tearoff 0
-    .button3menu.connect add cascade -label [getCanvasName $canvas] \
-    -menu .button3menu.connect.$canvas
-}
-foreach peer_node $node_list {
-    set canvas [getNodeCanvas $peer_node]
-    if { $node != $peer_node && [nodeType $node] != "rj45" &&
-        [lsearch {pseudo rj45} [nodeType $peer_node]] < 0 &&
-        [ifcByLogicalPeer $node $peer_node] == "" } {
+
+    #
+    # below here we build and post a menu
+    #
+    .button3menu delete 0 end
+
+    #
+    # Select adjacent
+    #
+    if { [nodeType $node] != "pseudo" } {
+        .button3menu add command -label "Select adjacent" \
+            -command "selectAdjacent"
+    } else {
+        .button3menu add command -label "Select adjacent" \
+            -command "selectAdjacent" -state disabled
+    }
+
+    #
+    # Configure node
+    #
+    if { [nodeType $node] != "pseudo" } {
+        .button3menu add command -label "Configure" \
+            -command "popupConfigDialog $c"
+    } else {
+        .button3menu add command -label "Configure" \
+            -command "popupConfigDialog $c" -state disabled
+    }
+
+    #
+    # Create a new link - can be between different canvases
+    #
+    .button3menu.connect delete 0 end
+    if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
+        .button3menu add cascade -label "Create link to" \
+            -menu .button3menu.connect -state disabled
+    } else {
+        .button3menu add cascade -label "Create link to" \
+            -menu .button3menu.connect
+    }
+    destroy .button3menu.connect.selected
+    menu .button3menu.connect.selected -tearoff 0
+    .button3menu.connect add cascade -label "Selected" \
+        -menu .button3menu.connect.selected
+    .button3menu.connect.selected add command \
+        -label "Chain" -command "P \[selectedRealNodes\]"
+    .button3menu.connect.selected add command \
+        -label "Star" \
+        -command "Kb \[lindex \[selectedRealNodes\] 0\] \
+        \[lrange \[selectedNodes\] 1 end\]"
+    .button3menu.connect.selected add command \
+        -label "Cycle" -command "C \[selectedRealNodes\]"
+    .button3menu.connect.selected add command \
+        -label "Clique" -command "K \[selectedRealNodes\]"
+    .button3menu.connect add separator
+    foreach canvas $canvas_list {
+        destroy .button3menu.connect.$canvas
+        menu .button3menu.connect.$canvas -tearoff 0
+        .button3menu.connect add cascade -label [getCanvasName $canvas] \
+            -menu .button3menu.connect.$canvas
+    }
+    foreach peer_node $node_list {
+        set canvas [getNodeCanvas $peer_node]
+        if { $node != $peer_node && [nodeType $node] != "rj45" &&
+             [lsearch {pseudo rj45} [nodeType $peer_node]] < 0 &&
+             [ifcByLogicalPeer $node $peer_node] == "" } {
             .button3menu.connect.$canvas add command \
-            -label [getNodeName $peer_node] \
-            -command "newGUILink $node $peer_node"
-} elseif { [nodeType $peer_node] != "pseudo" } {
-    .button3menu.connect.$canvas add command \
-    -label [getNodeName $peer_node] \
-    -state disabled
-}
-}
-#
-# assign to emulation server
-#
-global exec_servers node_location
-.button3menu.assign delete 0 end
-.button3menu add cascade -label "Assign to" -menu .button3menu.assign
-.button3menu.assign add command -label "(none)" \
--command "assignSelection \"\""
-foreach server [lsort -dictionary [array names exec_servers]] {
-    .button3menu.assign add command -label "$server" \
-    -command "assignSelection $server"
-}
-
-#
-# wlan link to all nodes, recalculate
-#
-if { [nodeType $node] == "wlan" } {
-    .button3menu add command -label "Link to all routers" \
-    -command "linkAllNodes $node"
-    set msg "Select new WLAN $node members:"
-    set cmd "linkSelectedNodes $node"
-    .button3menu add command -label "Select WLAN members..." \
-    -command "popupSelectNodes \"$msg\" \"\" {$cmd}"
-    .button3menu add command -label "Recalculate all links" \
-    -command "recalculateAllRanges $node"
-}
-
-
-# make any calls defined by addons to 3 button3nodeHook
-global addon_hook_fns
-foreach addon [array names addon_hook_fns] {
-    [lindex $addon_hook_fns($addon) 3] .button3menu $node
-}
-
-#
-# Move to another canvas
-#
-.button3menu.moveto delete 0 end
-if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
-    .button3menu add cascade -label "Move to" \
-    -menu .button3menu.moveto -state disabled
-} else {
-    .button3menu add cascade -label "Move to" \
-    -menu .button3menu.moveto
-}
-.button3menu.moveto add command -label "Canvas:" -state disabled
-foreach canvas $canvas_list {
-    if { $canvas != $curcanvas } {
-        .button3menu.moveto add command \
-        -label [getCanvasName $canvas] \
-        -command "movetoCanvas $canvas"
-} else {
-    .button3menu.moveto add command \
-    -label [getCanvasName $canvas] -state disabled
-}
-}
-
-#
-# Merge two pseudo nodes / links
-#
-if { $oper_mode != "exec" && [nodeType $node] == "pseudo" && \
-    [getNodeCanvas $mirror_node] == $curcanvas } {
+                -label [getNodeName $peer_node] \
+                -command "newGUILink $node $peer_node"
+        } elseif { [nodeType $peer_node] != "pseudo" } {
+            .button3menu.connect.$canvas add command \
+                -label [getNodeName $peer_node] \
+                -state disabled
+        }
+    }
+    #
+    # assign to emulation server
+    #
+    global exec_servers node_location
+    .button3menu.assign delete 0 end
+    .button3menu add cascade -label "Assign to" -menu .button3menu.assign
+    .button3menu.assign add command -label "(none)" \
+        -command "assignSelection \"\""
+    foreach server [lsort -dictionary [array names exec_servers]] {
+        .button3menu.assign add command -label "$server" \
+            -command "assignSelection $server"
+    }
+
+    #
+    # wlan link to all nodes, recalculate
+    #
+    if { [nodeType $node] == "wlan" } {
+        .button3menu add command -label "Link to all routers" \
+            -command "linkAllNodes $node"
+        set msg "Select new WLAN $node members:"
+        set cmd "linkSelectedNodes $node"
+        .button3menu add command -label "Select WLAN members..." \
+            -command "popupSelectNodes \"$msg\" \"\" {$cmd}"
+        .button3menu add command -label "Recalculate all links" \
+            -command "recalculateAllRanges $node"
+    }
+
+
+    # make any calls defined by addons to 3 button3nodeHook
+    global addon_hook_fns
+    foreach addon [array names addon_hook_fns] {
+        [lindex $addon_hook_fns($addon) 3] .button3menu $node
+    }
+
+    #
+    # Move to another canvas
+    #
+    .button3menu.moveto delete 0 end
+    if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
+        .button3menu add cascade -label "Move to" \
+            -menu .button3menu.moveto -state disabled
+    } else {
+        .button3menu add cascade -label "Move to" \
+            -menu .button3menu.moveto
+    }
+    .button3menu.moveto add command -label "Canvas:" -state disabled
+    foreach canvas $canvas_list {
+        if { $canvas != $curcanvas } {
+            .button3menu.moveto add command \
+                -label [getCanvasName $canvas] \
+                -command "movetoCanvas $canvas"
+        } else {
+            .button3menu.moveto add command \
+                -label [getCanvasName $canvas] -state disabled
+        }
+    }
+
+    #
+    # Merge two pseudo nodes / links
+    #
+    if { $oper_mode != "exec" && [nodeType $node] == "pseudo" && \
+         [getNodeCanvas $mirror_node] == $curcanvas } {
         .button3menu add command -label "Merge" \
-        -command "mergeGUINode $node"
-} else {
-    .button3menu add command -label "Merge" -state disabled
-}
-
-#
-# Delete selection
-#
-if { $oper_mode != "exec" } {
-    .button3menu add command -label "Delete" -command deleteSelection
-} else {
-    .button3menu add command -label "Delete" -state disabled
-}
-
-.button3menu add command -label "Hide" -command "hideSelected"
-
-# Boeing: flag used below
-set execstate disabled
-if { $oper_mode == "exec" } { set execstate normal }
-
-#
-# Shell selection
-#
-.button3menu.shell delete 0 end
-if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } {
-    .button3menu add cascade -label "Shell window" \
-    -menu .button3menu.shell
-    set cmd [[typemodel $node].shellcmd $node]
-    if { $cmd != "/bin/sh" && $cmd != "" } { ;# typically adds vtysh
-        .button3menu.shell add command -label "$cmd" \
-        -command "spawnShell $node $cmd"
-}
-.button3menu.shell add command -label "/bin/sh" \
--command "spawnShell $node sh"
-.button3menu.shell add command -label "$shell" \
--command "spawnShell $node $shell"
-} else {
-    .button3menu add cascade -label "Shell window" \
-    -menu .button3menu.shell -state disabled
-}
-
-#
-# Tcpdump, gpsd
-#
-.button3menu.tcpdump delete 0 end
-if { [[typemodel $node].layer] == "NETWORK" } {
-    .button3menu add cascade -label "Tcpdump" \
-    -menu .button3menu.tcpdump -state $execstate
-    foreach ifc [ifcList $node] {
-        .button3menu.tcpdump add command -label "$ifc" \
-        -command "spawnShell $node \"tcpdump -n -l -i $ifc\"" \
-        -state $execstate
-}
-if { [lindex $systype 0] != "Linux" } {
-    .button3menu add command -label "gpsd" -state $execstate -command \
-    "spawnShell $node \"gpsd -b -N -n -D 4 /tmp/$eid\_$node/gpsdev0\""
-} else {
-    set name [getNodeName $node]
-    .button3menu add command -label "View log..." -state $execstate \
-    -command "spawnShell $node \"less ../$name.log\""
-}
-}
-
-#
-# Finally post the popup menu on current pointer position
-#
-set x [winfo pointerx .]
-set y [winfo pointery .]
-
-tk_popup .button3menu $x $y
+            -command "mergeGUINode $node"
+    } else {
+        .button3menu add command -label "Merge" -state disabled
+    }
+
+    #
+    # Delete selection
+    #
+    if { $oper_mode != "exec" } {
+        .button3menu add command -label "Delete" -command deleteSelection
+    } else {
+        .button3menu add command -label "Delete" -state disabled
+    }
+
+    .button3menu add command -label "Hide" -command "hideSelected"
+
+    # Boeing: flag used below
+    set execstate disabled
+    if { $oper_mode == "exec" } { set execstate normal }
+
+    #
+    # Shell selection
+    #
+    .button3menu.shell delete 0 end
+    if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } {
+        .button3menu add cascade -label "Shell window" \
+            -menu .button3menu.shell
+        set cmd [[typemodel $node].shellcmd $node]
+        if { $cmd != "/bin/sh" && $cmd != "" } { ;# typically adds vtysh
+                                                 .button3menu.shell add command -label "$cmd" \
+                                                     -command "spawnShell $node $cmd"
+        }
+        .button3menu.shell add command -label "/bin/sh" \
+            -command "spawnShell $node sh"
+        .button3menu.shell add command -label "$shell" \
+            -command "spawnShell $node $shell"
+    } else {
+        .button3menu add cascade -label "Shell window" \
+            -menu .button3menu.shell -state disabled
+    }
+
+    #
+    # Tcpdump, gpsd
+    #
+    .button3menu.tcpdump delete 0 end
+    if { [[typemodel $node].layer] == "NETWORK" } {
+        .button3menu add cascade -label "Tcpdump" \
+            -menu .button3menu.tcpdump -state $execstate
+        foreach ifc [ifcList $node] {
+            .button3menu.tcpdump add command -label "$ifc" \
+                -command "spawnShell $node \"tcpdump -n -l -i $ifc\"" \
+                -state $execstate
+        }
+        if { [lindex $systype 0] != "Linux" } {
+            .button3menu add command -label "gpsd" -state $execstate -command \
+                "spawnShell $node \"gpsd -b -N -n -D 4 /tmp/$eid\_$node/gpsdev0\""
+        } else {
+            set name [getNodeName $node]
+            .button3menu add command -label "View log..." -state $execstate \
+                -command "spawnShell $node \"less ../$name.log\""
+        }
+    }
+
+    #
+    # Finally post the popup menu on current pointer position
+    #
+    set x [winfo pointerx .]
+    set y [winfo pointery .]
+
+    tk_popup .button3menu $x $y
 }
 
 
 #   * cmd -- the path to the shell.
 #****
 proc spawnShell { node cmd } {
-    # request an interactive terminal
+# request an interactive terminal
     set sock [lindex [getEmulPlugin $node] 2]
     set flags 0x44 ;# set TTY, critical flags
     set exec_num [newExecCallbackRequest shell]
     set curobj [$c find withtag current]
     set curtype [lindex [$c gettags current] 0]
     if { $curtype == "node" || \
-        $curtype == "oval" || $curtype == "rectangle" || $curtype == "text" \
-        || ( $curtype == "nodelabel" && \
-        [nodeType [lindex [$c gettags $curobj] 1]] == "pseudo") } {
-            set node [lindex [$c gettags current] 1]
-            set wasselected \
+             $curtype == "oval" || $curtype == "rectangle" || $curtype == "text" \
+             || ( $curtype == "nodelabel" && \
+         [nodeType [lindex [$c gettags $curobj] 1]] == "pseudo") } {
+        set node [lindex [$c gettags current] 1]
+        set wasselected \
             [expr {[lsearch [$c find withtag "selected"] \
-                [$c find withtag "node && $node"]] > -1}]
-                if { $button == "ctrl" } {
-                    if { $wasselected } {
-                        $c dtag $node selected
-                        $c delete -withtags "selectmark && $node"
+            [$c find withtag "node && $node"]] > -1}]
+        if { $button == "ctrl" } {
+            if { $wasselected } {
+                $c dtag $node selected
+                $c delete -withtags "selectmark && $node"
+            }
+        } elseif { !$wasselected } {
+            $c dtag node selected
+            $c delete -withtags selectmark
+        }
+        if { $activetool == "select" && !$wasselected} {
+            selectNode $c $curobj
+        }
+    } elseif { $curtype == "selectmark" } {
+
+        set t1 [$c gettags current]
+        set o1 [lindex $t1 1]
+        set type1 [nodeType $o1]
+
+        if {$type1== "oval" || $type1== "rectangle"} { 
+            set resizeobj $o1
+            set bbox1 [$c bbox $o1]
+            set x1 [lindex $bbox1 0]
+            set y1 [lindex $bbox1 1]
+            set x2 [lindex $bbox1 2]
+            set y2 [lindex $bbox1 3]
+            set l 0 ;# left
+            set r 0 ;# right
+            set u 0 ;# up
+            set d 0 ;# down
+
+            if { $x < [expr $x1+($x2-$x1)/8.0]} { set l 1 }
+            if { $x > [expr $x2-($x2-$x1)/8.0]} { set r 1 }
+            if { $y < [expr $y1+($y2-$y1)/8.0]} { set u 1 }
+            if { $y > [expr $y2-($y2-$y1)/8.0]} { set d 1 }
+
+            if {$l==1} {
+                if {$u==1} { 
+                    set resizemode lu
+                } elseif {$d==1} { 
+                    set resizemode ld
+                } else { 
+                    set resizemode l
+                } 
+            } elseif {$r==1} {
+                if {$u==1} { 
+                    set resizemode ru
+                } elseif {$d==1} { 
+                    set resizemode rd
+                } else { 
+                    set resizemode r
+                } 
+            } elseif {$u==1} { 
+                set resizemode u
+            } elseif {$d==1} {
+                set resizemode d
+            } else {
+                set resizemode false
+            }
+        }
+    } elseif { $button != "ctrl" || $activetool != "select" } {
+        $c dtag node selected
+        $c delete -withtags selectmark
     }
-} elseif { !$wasselected } {
-    $c dtag node selected
-    $c delete -withtags selectmark
-}
-if { $activetool == "select" && !$wasselected} {
-    selectNode $c $curobj
-}
-} elseif { $curtype == "selectmark" } {
-
-    set t1 [$c gettags current]
-    set o1 [lindex $t1 1]
-    set type1 [nodeType $o1]
-
-    if {$type1== "oval" || $type1== "rectangle"} { 
-        set resizeobj $o1
-        set bbox1 [$c bbox $o1]
-        set x1 [lindex $bbox1 0]
-        set y1 [lindex $bbox1 1]
-        set x2 [lindex $bbox1 2]
-        set y2 [lindex $bbox1 3]
-        set l 0 ;# left
-        set r 0 ;# right
-        set u 0 ;# up
-        set d 0 ;# down
-
-        if { $x < [expr $x1+($x2-$x1)/8.0]} { set l 1 }
-        if { $x > [expr $x2-($x2-$x1)/8.0]} { set r 1 }
-        if { $y < [expr $y1+($y2-$y1)/8.0]} { set u 1 }
-        if { $y > [expr $y2-($y2-$y1)/8.0]} { set d 1 }
-
-        if {$l==1} {
-            if {$u==1} { 
-                set resizemode lu
-    } elseif {$d==1} { 
-        set resizemode ld
-    } else { 
-        set resizemode l
-    } 
-    } elseif {$r==1} {
-        if {$u==1} { 
-            set resizemode ru
-    } elseif {$d==1} { 
-        set resizemode rd
-    } else { 
-        set resizemode r
-    } 
-    } elseif {$u==1} { 
-        set resizemode u
-    } elseif {$d==1} {
-        set resizemode d
+    # user has clicked on a blank area or background item
+    if { [lsearch [.c gettags $curobj] background] != -1 ||
+         [lsearch [.c gettags $curobj] grid] != -1 ||
+         [lsearch [.c gettags $curobj] annotation] != -1 } {
+         # left mouse button pressed to create a new node
+        if { [lsearch {select marker link mobility twonode run stop oval \
+                       rectangle text} $activetool] < 0 } {
+            if { $activetoolp == "routers" } {
+                set node [newNode router]
+                setNodeModel $node $activetool
+            } else {
+                set node [newNode $activetool]
+            }
+            setNodeCanvas $node $curcanvas
+            setNodeCoords $node "[expr {$x / $zoom}] [expr {$y / $zoom}]"
+            set dy 32
+            if { [lsearch {router rj45} $activetool] >= 0 } {
+                set dy 28
+            } elseif { [lsearch {hub lanswitch} $activetool] >= 0 } {
+                set dy 24
+            }
+            setNodeLabelCoords $node "[expr {$x / $zoom}] \
+                [expr {$y / $zoom + $dy}]"
+            drawNode $c $node
+            selectNode $c [$c find withtag "node && $node"]
+            set changed 1
+            # remove any existing select box
+        } elseif { $activetool == "select" \
+        && $curtype != "node" && $curtype != "nodelabel"} {
+            $c config -cursor cross
+            set lastX $x
+            set lastY $y
+            if {$selectbox != ""} {
+            # We actually shouldn't get here!
+                $c delete $selectbox
+                set selectbox ""
+            }
+            # begin drawing an annotation
+        } elseif { $activetoolp == "bgobjs" } {
+            set newcursor cross
+            if { $activetool == "text" } { set newcursor xterm }
+            $c config -cursor $newcursor
+            set lastX $x
+            set lastY $y
+            # draw with the marker
+        } elseif { $activetool == "marker" } {
+            global markersize markercolor