]> git.entuzijast.net Git - imunes.git/commitdiff
First in a series of commits aimed at (ab)using TCL namespaces for
authormarko <marko>
Wed, 2 Jan 2008 12:08:46 +0000 (12:08 +0000)
committermarko <marko>
Wed, 2 Jan 2008 12:08:46 +0000 (12:08 +0000)
removing configuration and per-object (node, link, canvas, annotation)
variables from the global namespace.  Once completed, this storage
reorganization should allow us to manage multiple independent IMUNES
configs in parallel and simplify implementation of cut/copy/paste
functionality in the GUI.

This change introduces a new top-level namespace ::cf, which holds
all configuration instances in subordinated namespaces.  So far only
::cf::cfg0 is used.

The new global variable "curconf" selects the working configuration
instance.  Inside most procedures, access to previously global
variables is replaced by variable aliasing to the appropriate
::cf namespace.  The change typically looks like this:

-    global $target
+    upvar 0 ::cf::[set ::curcfg]::$target $target

So far only storage for objects visible in a canvas has beend pushed out
of the global namespace.  Deciding on how to deal with the various GUI
options (option show) needs more thought.

Bug found by:
Submitted by:
Reviewed by:
Approved by:
Obtained from:

21 files changed:
annotations.tcl
canvas.tcl
cfgparse.tcl
editor.tcl
exec.tcl
filemgmt.tcl
gpgui.tcl
graph_partitioning.tcl
host.tcl
imunes.tcl
initgui.tcl
ipsec.tcl
ipv4.tcl
ipv6.tcl
linkcfg.tcl
nodecfg.tcl
ns2imunes.tcl
pc.tcl
quagga.tcl
static.tcl
xorp.tcl

index cb718aec90dee7a0d3c5c3fb915ae646ffd1e188..7cb57cc2562fac9f783932e3f30466d5affaa7d1 100644 (file)
@@ -23,7 +23,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: annotations.tcl,v 1.8 2008/01/01 18:22:59 marko Exp $
+# $Id: annotations.tcl,v 1.9 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/annotations.tcl
@@ -151,7 +151,8 @@ proc button3annotation { type c x y } {
 
 
 proc deleteAnnotation { c type target } {
-    global changed annotation_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    global changed
     
     $c delete -withtags "$type && $target"
     $c delete -withtags "new$type"
@@ -163,7 +164,8 @@ proc deleteAnnotation { c type target } {
 
 
 proc drawOval {oval} {
-    global $oval defFillColor zoom curcanvas
+    upvar 0 ::cf::[set ::curcfg]::$oval $oval
+    global defFillColor zoom curcanvas
     global defTextFontFamily defTextFontSize
 
     set coords [getNodeCoords $oval]
@@ -280,7 +282,8 @@ proc roundRect { w x0 y0 x3 y3 radius args } {
  }
 
 proc drawRect {rectangle} {
-    global $rectangle defFillColor zoom curcanvas
+    upvar 0 ::cf::[set ::curcfg]::$rectangle $rectangle
+    global defFillColor zoom curcanvas
     global defTextFontFamily defTextFontSize
 
     set coords [getNodeCoords $rectangle]
@@ -335,7 +338,8 @@ proc drawRect {rectangle} {
 
 
 proc popupAnnotationDialog { c target modify } {
-    global $target newrect newoval 
+    upvar 0 ::cf::[set ::curcfg]::$target $target
+    global newrect newoval 
     global width rad fontfamily fontsize
     global defFillColor defTextColor defTextFontFamily defTextFontSize
 
@@ -564,8 +568,9 @@ proc destroyNewRect { c } {
 
 
 proc popupAnnotationApply { c wi target type } {
-    global newrect newoval annotation_list
-    global $target
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::$target $target
+    global newrect newoval
     global changed
     global width rad
     global fontfamily fontsize textBold textItalic textUnderline
@@ -584,7 +589,7 @@ proc popupAnnotationApply { c wi target type } {
     if { $target == 0 } {
        # Create a new annotation object
        set target [newObjectId annotation]
-       global $target
+       upvar 0 ::cf::[set ::curcfg]::$target $target
        lappend annotation_list $target
        if {"$type" == "rectangle" } {
            set coords [$c coords $newrect]
@@ -744,7 +749,7 @@ proc selectmarkLeave {c x y} {
 
 
 proc textEnter { c x y } {
-    global annotation_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
     global curcanvas
 
     set object [newObjectId annotation]
@@ -754,7 +759,7 @@ proc textEnter { c x y } {
     set coords [$c coords "text && $object"]
     set iconcoords "iconcoords"
 
-    global $object
+    upvar 0 ::cf::[set ::curcfg]::$object $object
     set $object {}
     setType $object "text"
     lappend $iconcoords $coords
@@ -768,7 +773,8 @@ proc textEnter { c x y } {
 
 
 proc drawText {text} {
-    global $text defTextColor defTextFont defTextFontFamily defTextFontSize
+    upvar 0 ::cf::[set ::curcfg]::$text $text
+    global defTextColor defTextFont defTextFontFamily defTextFontSize
     global zoom curcanvas newfontsize
 
     set coords [getNodeCoords $text]
index c51201cf17987039ddd9909e0d67ea4bd14fdbc4..c8fdb61f8898dffebb9252deb9e155a6d5522bfd 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: canvas.tcl,v 1.12 2008/01/01 18:22:59 marko Exp $ 
+# $Id: canvas.tcl,v 1.13 2008/01/02 12:08:46 marko Exp $ 
 #
 #
 # Copyright 2005-2008 University of Zagreb, Croatia.
@@ -25,7 +25,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: canvas.tcl,v 1.12 2008/01/01 18:22:59 marko Exp $
+# $Id: canvas.tcl,v 1.13 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/canvas.tcl
@@ -53,7 +53,8 @@
 #****
 
 proc removeCanvas { canvas } {
-    global canvas_list $canvas
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set i [lsearch $canvas_list $canvas]
     set canvas_list [lreplace $canvas_list $i $i]
@@ -76,10 +77,10 @@ proc removeCanvas { canvas } {
 #****
 
 proc newCanvas { name } {
-    global canvas_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
 
     set canvas [newObjectId canvas]
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
     lappend canvas_list $canvas
     set $canvas {}
     if { $name != "" } {
@@ -93,7 +94,7 @@ proc newCanvas { name } {
 
 
 proc setCanvasSize { canvas x y } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set i [lsearch [set $canvas] "size *"]
     if { $i >= 0 } {
@@ -104,7 +105,7 @@ proc setCanvasSize { canvas x y } {
 }
 
 proc getCanvasSize { canvas } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set entry [lrange [lsearch -inline [set $canvas] "size *"] 1 end]
     set size [string trim $entry \{\}]
@@ -129,7 +130,7 @@ proc getCanvasSize { canvas } {
 #****
 
 proc getCanvasName { canvas } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set entry [lrange [lsearch -inline [set $canvas] "name *"] 1 end]
     return [string trim $entry \{\}]
@@ -148,7 +149,7 @@ proc getCanvasName { canvas } {
 #****
 
 proc setCanvasName { canvas name } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set i [lsearch [set $canvas] "name *"]
     if { $i >= 0 } {
@@ -172,7 +173,7 @@ proc setCanvasName { canvas name } {
 #****
 
 proc getCanvasBkg { canvas } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set entry [lrange [lsearch -inline [set $canvas] "bkgImage *"] 1 end]
     return [string trim $entry \{\}]
@@ -191,7 +192,7 @@ proc getCanvasBkg { canvas } {
 #****
 
 proc setCanvasBkg { canvas name } {
-    global $canvas
+    upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
 
     set i [lsearch [set $canvas] "bkgImage *"]
     if { $i >= 0 } {
index c0daf2d324adc7d3a0264d7f05578875bd151006..9027fb6759da6b10d58a32013b9d1e7ae45dc8f5 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: cfgparse.tcl,v 1.37 2008/01/01 18:22:59 marko Exp $
+# $Id: cfgparse.tcl,v 1.38 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/cfgparse.tcl
@@ -84,15 +84,18 @@ proc dumpputs {method dest string} {
 #****
 
 proc dumpCfg {method dest} {
-    global node_list link_list canvas_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    # the globals bellow should be placed in a namespace as well
     global showIfNames showNodeLabels showLinkLabels
     global showIfIPaddrs showIfIPv6addrs
     global showIPsecConfig
     global showBkgImage showGrid showAnnotations
 
     foreach node $node_list {
-       global $node
-       upvar 0 $node lnode
+       upvar 0 ::cf::[set ::curcfg]::$node lnode
        dumpputs $method $dest "node $node \{"
        foreach element $lnode {
            if { "[lindex $element 0]" == "network-config" } {
@@ -135,10 +138,9 @@ proc dumpCfg {method dest} {
     }
 
     foreach obj "link annotation canvas" {
-       upvar 0 ${obj}_list obj_list
+       upvar 0 ::cf::[set ::curcfg]::${obj}_list obj_list
        foreach elem $obj_list {
-           global $elem
-           upvar 0 $elem lelem
+           upvar 0 ::cf::[set ::curcfg]::$elem lelem
            dumpputs $method $dest "$obj $elem \{"
            foreach element $lelem {
                dumpputs $method $dest "    $element"
@@ -202,7 +204,10 @@ proc dumpCfg {method dest} {
 #****
 
 proc loadCfg { cfg } {
-    global node_list link_list canvas_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
     global showIfNames showNodeLabels showLinkLabels
     global showIfIPaddrs showIfIPv6addrs
     global showIPsecConfig
@@ -221,7 +226,7 @@ proc loadCfg { cfg } {
            continue
        } elseif {"$object" == ""} {
            set object $entry
-           global $object
+           upvar 0 ::cf::[set ::curcfg]::$object $object
            set $object {}
            if {"$class" == "node"} {
                lappend node_list $object
@@ -504,7 +509,10 @@ proc loadCfg { cfg } {
 #****
 
 proc newObjectId { type } {
-    global node_list link_list annotation_list canvas_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
 
     set mark [string range [set type] 0 0]
     set id 0
index 3b5ddfed6bf54b615bbccf801266eee9234968aa..105198e01261a4419268d1bc714726d933fd86e6 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: editor.tcl,v 1.85 2008/01/01 20:56:25 marko Exp $
+# $Id: editor.tcl,v 1.86 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/editor.tcl
@@ -218,7 +218,10 @@ proc redo {} {
 #****
 
 proc redrawAll {} {
-    global node_list link_list annotation_list background sizex sizey grid
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
+    global background sizex sizey grid
     global curcanvas zoom
     global showBkgImage showAnnotations showGrid bkgImage
     .bottom.zoom config -text "zoom [expr {int($zoom * 100)}]%"
@@ -637,7 +640,8 @@ proc updateLinkLabel { link } {
 #   Redraws all links on the current canvas.
 #****
 proc redrawAllLinks {} {
-    global link_list curcanvas
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    global curcanvas
 
     foreach link $link_list {
        set nodes [linkPeers $link]
@@ -867,7 +871,9 @@ proc selectAdjacent {} {
 #   * y -- y coordinate for popup menu
 #****
 proc button3link { c x y } {
-    global oper_mode env eid canvas_list node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    global oper_mode env eid
     global curcanvas
 
     set link [lindex [$c gettags {link && current}] 1]
@@ -1029,7 +1035,9 @@ proc mergeGUINode { node } {
 #   * y -- y coordinate for popup menu
 #****
 proc button3node { c x y } {
-    global oper_mode env eid canvas_list node_list curcanvas
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    global oper_mode env eid curcanvas
 
     set node [lindex [$c gettags {node && current}] 1]
     if { $node == "" } {
@@ -1294,7 +1302,8 @@ proc startethereal { node iface } {
 #   * button -- the keyboard button that is pressed.
 #****
 proc button1 { c x y button } {
-    global node_list curcanvas zoom
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    global curcanvas zoom
     global activetool newlink curobj changed def_router_model
     global router pc host lanswitch frswitch rj45 hub
     global oval rectangle text
@@ -1658,7 +1667,8 @@ proc newGUILink { lnode1 lnode2 } {
 #   * y -- y coordinate
 #****
 proc button1-release { c x y } {
-    global node_list activetool newlink curobj grid
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    global activetool newlink curobj grid
     global changed undolog undolevel redolevel selectbox
     global lastX lastY sizex sizey zoom
     global autorearrange_enabled
@@ -1875,7 +1885,8 @@ proc nodeEnter { c } {
 #   * c -- tk canvas
 #****
 proc linkEnter {c} {
-    global activetool link_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    global activetool
 
     set link [lindex [$c gettags current] 1]
     if { [lsearch $link_list $link] == -1 } {
@@ -2925,7 +2936,8 @@ proc align2grid {} {
 #   rearranged.
 #****
 proc rearrange { mode } {
-    global link_list autorearrange_enabled sizex sizey curcanvas zoom
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    global autorearrange_enabled sizex sizey curcanvas zoom
 
     set autorearrange_enabled 1
     .menubar.tools entryconfigure "Auto rearrange all" -state disabled
@@ -3095,7 +3107,8 @@ proc rearrange { mode } {
 #   previus, next -- next, first -- first, last -- last.
 #****
 proc switchCanvas { direction } {
-    global canvas_list curcanvas
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    global curcanvas
     global sizex sizey
 
     set i [lsearch $canvas_list $curcanvas]
index b68d7621d88dd801f03d9a13f549ee05b2e1281f..ad863fc8ff64962b9e14c32ecbe9cde97d124f1a 100755 (executable)
--- a/exec.tcl
+++ b/exec.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: exec.tcl,v 1.67 2008/01/01 18:22:59 marko Exp $
+# $Id: exec.tcl,v 1.68 2008/01/02 12:08:46 marko Exp $
 
 
 #****f* exec.tcl/nexec
@@ -91,7 +91,8 @@ proc nexec { args } {
 #   * mode -- the new operating mode. Can be edit or exec.
 #****
 proc setOperMode { mode } {
-    global oper_mode eid activetool node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    global oper_mode eid activetool
     global editor_only remote_exec execSock
     global undolevel redolevel
 
@@ -244,12 +245,12 @@ proc createIfc { eid type hook } {
 #   * node -- node id
 #****
 proc l3node.instantiate { eid node } {
+    global ngnodemap
     global mac_byte4 mac_byte5
     set node_id "$eid\.$node"
     nexec vimage -c $node_id
     nexec vimage $node_id hostname [getNodeName $node]
     nexec vimage $node_id sysctl vfs.morphing_symlinks=1
-    global ngnodemap
 
     foreach ifc [ifcList $node] {
        switch -exact [string range $ifc 0 2] {
@@ -494,8 +495,10 @@ proc l3node.destroy { eid node } {
 #   removed (vimageCleanup procedure).
 #****
 proc deployCfg {} {
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
     global eid
-    global node_list link_list supp_router_models
+    global supp_router_models
     global mac_byte4 mac_byte5
     global remote_exec
     global ngnodemap
@@ -611,7 +614,7 @@ proc deployCfg {} {
     }
 
     foreach node $node_list {
-       global $node
+       upvar 0 ::cf::[set ::curcfg]::$node $node
        set type [nodeType $node]
        if { $type == "pseudo" } {
            continue
index 66a375de469bd16cb29f15accb4d51957f55b4ea..c07f22cc3c08e4b113a2f80a7a422566eb86790d 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: filemgmt.tcl,v 1.14 2008/01/01 18:22:59 marko Exp $
+# $Id: filemgmt.tcl,v 1.15 2008/01/02 12:08:46 marko Exp $
 
 
 ##****h* imunes/filemgmt.tcl
@@ -90,8 +90,9 @@ set fileTypes {
 #   Loads an empty configuration, i.e. creates an empty project.
 #****
 proc newFile {} {
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
     global currentFile oper_mode eid
-    global canvas_list curcanvas undolevel redolevel
+    global curcanvas undolevel redolevel
 
     if { $oper_mode == "exec" } {
        vimageCleanup $eid
@@ -116,9 +117,10 @@ proc newFile {} {
 #   Loads the configuration from the file named currentFile.
 #****
 proc openFile {} {
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
     global currentFile 
     global undolevel redolevel undolog activetool
-    global canvas_list curcanvas
+    global curcanvas
     
     set fileName [file tail $currentFile]
     wm title . "IMUNES $fileName"
@@ -303,22 +305,6 @@ proc readConfigFile {} {
     }
 }
 
-# Currently not used
-#proc checkBkgImageFilenames {} {
-#    global canvas_list
-#    foreach canvas $canvas_list {
-#      global $canvas
-#      puts [set $canvas]
-#      set i [lsearch [set $canvas] "bkgImage *"]
-#      if { $i >= 0 } {
-#          set oldname [getCanvasBkg $canvas]
-#          set newname [relpath $oldname]
-#          puts "Staro ime: $oldname novo ime: $newname" 
-#          set $canvas [lreplace [set $canvas] $i $i "bkgImage {$newname}"]
-#      }
-#    }
-#}
-
 
 #****f* filemgmt.tcl/relpath
 # NAME
index a60c258f65418007d849d83cb18792e77d2ef643..cd19e6e01b62e6059e3433d3baebcfb86c67c56b 100644 (file)
--- a/gpgui.tcl
+++ b/gpgui.tcl
@@ -23,7 +23,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: gpgui.tcl,v 1.5 2008/01/01 18:22:59 marko Exp $
+# $Id: gpgui.tcl,v 1.6 2008/01/02 12:08:46 marko Exp $
 
 .menubar.tools add separator
 .menubar.tools add command -label "Topologie partitioning" -underline 0 -command "dialog";
@@ -112,8 +112,7 @@ proc dialog { } {
 #   *  wi -- parent window id
 #****
 proc displayAllNodeWeights {wi} {
-    #package require BWidget
-    global node_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
 
     set nw .pop
     toplevel $nw
@@ -173,8 +172,7 @@ proc displayAllNodeWeights {wi} {
 #   *  wi -- parent window id
 #****
 proc displayAllLinkWeights {wi} {
-    # package require BWidget
-    global link_list;
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     set lw .pop
     toplevel $lw
@@ -303,7 +301,7 @@ proc openWeightFile { op } {
 #   *  nw -- window id
 #****
 proc applyNodeWeights {nw} {
-    global node_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
 
     foreach node $node_list {
        writeWeightToNode $node [$nw.more.weights.w$node get];
@@ -323,7 +321,7 @@ proc applyNodeWeights {nw} {
 #   *  lw -- window id
 #****
 proc applyLinkWeights {lw} {
-    global link_list;
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     foreach link $link_list {
        setLinkBandwidth $link [$lw.more.weights.b$link get];
@@ -345,7 +343,7 @@ proc applyLinkWeights {lw} {
 #   *  weight -- weight of the node
 #****
 proc writeWeightToNode {node weight} {
-    global $node;
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set p [lsearch [set $node] "weight *"];
     if { $p >= 0 } {
@@ -372,7 +370,7 @@ proc writeWeightToNode {node weight} {
 #   * wgt -- weight of the node
 #****
 proc getNodeWeight {node} {
-    global $node;
+    upvar 0 ::cf::[set ::curcfg]::$node $node
     global node_weights;
   
     set wgt [lindex [lsearch -inline [set $node] "weight *"] 1];
@@ -445,7 +443,7 @@ proc changeDefaultWeights {wi} {
 #   *  wi -- window id
 #****
 proc popupApply { wi } {
-    global node_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     set partNum [$wi.pnum.e.p get]
     
     foreach node $node_list {
index fad682f4fd202f8a2e36644e62699d684f26f3b7..f322467f129ee03320552aa110fd498b6e37aef6 100644 (file)
@@ -23,7 +23,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: graph_partitioning.tcl,v 1.6 2008/01/01 18:22:59 marko Exp $
+# $Id: graph_partitioning.tcl,v 1.7 2008/01/02 12:08:46 marko Exp $
 
 
 #****f* graph_partitioning.tcl/writePartitions
 #   *  node_weight -- array of node weights
 #****
 proc writePartitions {node_weight} {
-    global nparts;
-    global node_list;
-    global link_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
     global split_list;
+    global nparts;
     global finalpartition;
 
     upvar $node_weight nweight;
@@ -97,7 +97,7 @@ proc writePartitions {node_weight} {
 #   *  partition -- partition of the node
 #****
 proc setPartition { node partition } {
-    global $node;
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set p [lsearch [set $node] "partition *"];
     if { $p >= 0 } {
@@ -121,7 +121,8 @@ proc setPartition { node partition } {
 #   * part -- the node's partition 
 #****
 proc getNodePartition { node } {
-    global $node;
+    upvar 0 ::cf::[set ::curcfg]::$node $node
+
     set part [lindex [lsearch -inline [set $node] "partition *"] 1];
     return $part;
 }
@@ -157,7 +158,9 @@ proc debug { message } {
 #   *  partNum -- number of partitions
 #****
 proc graphPartition {partNum} {
-    global node_list link_list finalpartition
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    global finalpartition
 
     global nparts tpwgts max_nweight
 
@@ -254,7 +257,7 @@ proc graphPartition {partNum} {
 #   *  node_weight -- empty array of node weights
 #****
 proc initNodes {node_weight} {
-    global node_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     upvar $node_weight nweight;
     
     set i 0;
@@ -281,7 +284,7 @@ proc initNodes {node_weight} {
 #   *  pnode -- pseudo node id
 #****
 proc mergePseudoLink { pnode } {
-    global node_list;
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     global split_list;
   
     foreach n $node_list {
@@ -318,7 +321,8 @@ proc mergePseudoLink { pnode } {
 #   *  edge_weight -- empty array 
 #****
 proc initNeighbours {node_neighbour edge_array edge_weight} {
-    global node_list link_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     upvar $edge_array earray;
     upvar $node_neighbour nneighbour;
index 661511ce6707e5ebe0184cf6eeb099c6677817a8..e762bb92b7449014410c769526734e9f457187a1 100755 (executable)
--- a/host.tcl
+++ b/host.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: host.tcl,v 1.18 2008/01/01 18:22:59 marko Exp $
+# $Id: host.tcl,v 1.19 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/host.tcl
@@ -79,7 +79,7 @@ proc $MODULE.layer {} {
 #****
 
 proc $MODULE.cfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfg {}
 
index cfa5bb37a9a75068bc1551449266aa3a64b83e85..b21ad007814c93f91b43935c63bd55ba28136055 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: imunes.tcl,v 1.31 2008/01/01 18:22:59 marko Exp $
+# $Id: imunes.tcl,v 1.32 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/imunes.tcl
@@ -132,30 +132,6 @@ source "$ROOTDIR/$LIBDIR/ns2imunes.tcl"
 # Global variables are initialized here
 #
 
-#****v* imunes.tcl/node_list
-# NAME
-#    node_list
-# FUNCTION
-#    Represents the list of all the nodes in the simulation. When starting 
-#    the program this list is empty.
-#*****
-
-#****v* imunes.tcl/link_list
-# NAME
-#    link_list
-# FUNCTION
-#    Represents the list of all the links in the simulation. When starting 
-#    the program this list is empty.
-#*****
-
-#****v* imunes.tcl/canvas_list
-# NAME
-#    canvas_list
-# FUNCTION
-#    Contains the list of all the canvases in the simulation. When starting 
-#    the program this list is empty.
-#*****
-
 #****v* imunes.tcl/prefs
 # NAME
 #    prefs
@@ -164,18 +140,14 @@ source "$ROOTDIR/$LIBDIR/ns2imunes.tcl"
 #    this list is empty.
 #*****
 
-#****v* imunes.tcl/eid
-# NAME
-#    eid -- experiment id.
-# FUNCTION
-#    The id of the current experiment. When starting a program this variable 
-#    is set to e0.
-#*****
+namespace eval cf::cfg0 {}
+
+set cf::cfg0::node_list {}
+set cf::cfg0::link_list {}
+set cf::cfg0::annotation_list {}
+set cf::cfg0::canvas_list {}
 
-set node_list {}
-set link_list {}
-set annotation_list {}
-set canvas_list {}
+set curcfg cfg0
 
 #****v* imunes.tcl/exec_hosts
 # NAME
index 3dc207f95461ad6606747a6998b996d89588a6aa..666f903ea4fc02b8eb2239da06093ae5a24980b1 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: initgui.tcl,v 1.41 2008/01/01 18:22:59 marko Exp $
+# $Id: initgui.tcl,v 1.42 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/initgui.tcl
@@ -109,7 +109,7 @@ set oper_mode edit
 set grid 24
 set showGrid 1
 set zoom 1.0
-set curcanvas [lindex $canvas_list 0]
+set curcanvas [lindex [set ::cf::[set ::curcfg]::canvas_list] 0]
 set autorearrange_enabled 0
 
 # resize Oval/Rectangle, "false" or direction: north/west/east/...
@@ -257,7 +257,8 @@ menu .menubar.canvas -tearoff 0
 }
 .menubar.canvas add command -label "Rename" -command { renameCanvasPopup 0 0 }
 .menubar.canvas add command -label "Delete" -command {
-    if { [llength $canvas_list] == 1 } {
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
+    if { [llength [set $canvas_list]] == 1 } {
         return
     }
     foreach obj [.c find withtag node] {
index 9dbbcfb05f3030ececa3468d56c018d5e65dff25..55462e15dc5ec2c9251770742e022c374e27d522 100755 (executable)
--- a/ipsec.tcl
+++ b/ipsec.tcl
@@ -23,7 +23,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: ipsec.tcl,v 1.11 2008/01/01 18:22:59 marko Exp $
+# $Id: ipsec.tcl,v 1.12 2008/01/02 12:08:46 marko Exp $
 
 
 #****f* ipsec.tcl/editIpsecCfg
@@ -805,13 +805,11 @@ proc getConfig { strlist str } {
 #****
 
 proc setIpsecConfig { node cfg } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     if { $cfg != {} } {
        lappend $node [list ipsec-config $cfg]
     }
-
-    return
 }
 
 #****f* ipsec.tcl/getIpsecConfig
@@ -828,7 +826,8 @@ proc setIpsecConfig { node cfg } {
 #****
 
 proc getIpsecConfig { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
+
     set ipsecCfg {}
 
     set values [lsearch -all -inline [set $node] "ipsec-config *"]
@@ -852,7 +851,7 @@ proc getIpsecConfig { node } {
 #****
 
 proc removeIpsecConfig { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set indices [lsearch -all [set $node] "ipsec-config *"]
     set cnt 0
@@ -861,7 +860,6 @@ proc removeIpsecConfig { node } {
        set $node [lreplace [set $node] $j $j]
        incr cnt
     }
-    return
 }
 
 #****f* ipsec.tcl/getIpsecEnabled
@@ -879,7 +877,7 @@ proc removeIpsecConfig { node } {
 #****
 
 proc getIpsecEnabled { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     if { [lindex [lsearch -inline [set $node] "ipsec-enabled *"] 1] == true } {
        return true
@@ -901,7 +899,7 @@ proc getIpsecEnabled { node } {
 #****
 
 proc setIpsecEnabled { node enabled } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "ipsec-enabled *"]
     if { $i >= 0 } {
@@ -910,7 +908,6 @@ proc setIpsecEnabled { node enabled } {
     if { $enabled == true } {
        lappend $node [list ipsec-enabled $enabled]
     }
-    return
 }
 
 #****f* ipsec.tcl/ipsecCfggen
@@ -928,7 +925,7 @@ proc setIpsecEnabled { node enabled } {
 #****
 
 proc ipsecCfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set sourceSA "" 
     set destSA ""
index 70d25c85a9b47f62f04a1529d9ea7407aa2c6aff..39432fe87b04d44f00f9eb230b761608bf1656ab 100755 (executable)
--- a/ipv4.tcl
+++ b/ipv4.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: ipv4.tcl,v 1.14 2008/01/01 18:22:59 marko Exp $
+# $Id: ipv4.tcl,v 1.15 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/ipv4.tcl
@@ -49,7 +49,7 @@
 #****
  
 proc findFreeIPv4Net { mask } {
-    global node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
 
     set ipnets {}
     foreach node $node_list {
index c2bf372afd0be09213d3ba0e55b78b7ecb0fd78e..0af271ac9b67ba178ed9e4b1ef00cbb2bc4ca133 100755 (executable)
--- a/ipv6.tcl
+++ b/ipv6.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: ipv6.tcl,v 1.12 2008/01/01 18:22:59 marko Exp $
+# $Id: ipv6.tcl,v 1.13 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/ipv6.tcl
@@ -49,7 +49,7 @@
 #****
  
 proc findFreeIPv6Net { mask } {
-    global node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
 
     set ipnets {}
     foreach node $node_list {
index a18ded67baa879d3f901c751af2793998b7b86c8..0846aa5b1f42d20ec229c32de0c617016f80ec1d 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: linkcfg.tcl,v 1.19 2008/01/01 18:22:59 marko Exp $
+# $Id: linkcfg.tcl,v 1.20 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/linkcfg.tcl
@@ -86,7 +86,7 @@
 #****
 
 proc linkPeers { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "nodes {*}"]
     return [lindex $entry 1]
@@ -109,7 +109,7 @@ proc linkPeers { link } {
 #****
 
 proc linkByPeers { node1 node2 } {
-    global link_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     foreach link $link_list {
        set peers [linkPeers $link]
@@ -132,11 +132,13 @@ proc linkByPeers { node1 node2 } {
 #****
 
 proc removeLink { link } {
-    global link_list $link
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set pnodes [linkPeers $link]
     foreach node $pnodes {
-       global $node
+       upvar 0 ::cf::[set ::curcfg]::$node $node
+
        set i [lsearch $pnodes $node]
        set peer [lreplace $pnodes $i $i]
        set ifc [ifcByPeer $node $peer]
@@ -168,7 +170,7 @@ proc removeLink { link } {
 #****
 
 proc getLinkBandwidth { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "bandwidth *"]
     return [lindex $entry 1]
@@ -190,7 +192,8 @@ proc getLinkBandwidth { link } {
 #****
 
 proc getLinkBandwidthString { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
+
     set bandstr ""
     set bandwidth [getLinkBandwidth $link]
     if { $bandwidth > 0 } {
@@ -224,7 +227,7 @@ proc getLinkBandwidthString { link } {
 #****
 
 proc setLinkBandwidth { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "bandwidth *"]
     if { $value <= 0 } {
@@ -238,7 +241,8 @@ proc setLinkBandwidth { link value } {
 # Marko - XXX document!
 #
 proc getLinkColor { link } {
-    global $link defLinkColor
+    upvar 0 ::cf::[set ::curcfg]::$link $link
+    global defLinkColor
 
     set entry [lsearch -inline [set $link] "color *"]
     if { $entry == "" } {
@@ -249,14 +253,15 @@ proc getLinkColor { link } {
 }
 
 proc setLinkColor { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "color *"]
     set $link [lreplace [set $link] $i $i "color $value"]
 }
 
 proc getLinkWidth { link } {
-    global $link defLinkWidth
+    upvar 0 ::cf::[set ::curcfg]::$link $link
+    global defLinkWidth
 
     set entry [lsearch -inline [set $link] "width *"]
     if { $entry == "" } {
@@ -267,7 +272,7 @@ proc getLinkWidth { link } {
 }
 
 proc setLinkWidth { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "width *"]
     set $link [lreplace [set $link] $i $i "width $value"]
@@ -287,7 +292,7 @@ proc setLinkWidth { link value } {
 #****
 
 proc getLinkDelay { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "delay *"]
     return [lindex $entry 1]
@@ -309,7 +314,7 @@ proc getLinkDelay { link } {
 #****
 
 proc getLinkDelayString { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set delay [getLinkDelay $link]
     if { "$delay" != "" } {
@@ -339,7 +344,7 @@ proc getLinkDelayString { link } {
 #****
 
 proc setLinkDelay { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "delay *"]
     if { $value <= 0 } {
@@ -363,7 +368,7 @@ proc setLinkDelay { link value } {
 #****
 
 proc getLinkBER { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "ber *"]
     return [lindex $entry 1]
@@ -382,7 +387,7 @@ proc getLinkBER { link } {
 #****
 
 proc setLinkBER { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "ber *"]
     if { $value <= 0 } {
@@ -406,7 +411,7 @@ proc setLinkBER { link value } {
 #****
 
 proc getLinkDup { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "duplicate *"]
     return [lindex $entry 1]
@@ -425,7 +430,7 @@ proc getLinkDup { link } {
 #****
 
 proc setLinkDup { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "duplicate *"]
     if { $value <= 0 || $value > 50 } {
@@ -451,7 +456,7 @@ proc setLinkDup { link value } {
 #****
 
 proc getLinkMirror { link } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set entry [lsearch -inline [set $link] "mirror *"]
     return [lindex $entry 1]
@@ -473,7 +478,7 @@ proc getLinkMirror { link } {
 #****
 
 proc setLinkMirror { link value } {
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set i [lsearch [set $link] "mirror *"]
     if { $value == "" } {
@@ -500,7 +505,8 @@ proc setLinkMirror { link value } {
 #****
 
 proc splitLink { link nodetype } {
-    global link_list $link
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::$link $link
 
     set orig_nodes [linkPeers $link]
     set orig_node1 [lindex $orig_nodes 0]
@@ -514,8 +520,12 @@ proc splitLink { link nodetype } {
     set ifc1 [ifcByPeer $orig_node1 $orig_node2]
     set ifc2 [ifcByPeer $orig_node2 $orig_node1]
 
-    global $orig_node1 $orig_node2 $new_node1 $new_node2
-    global $new_link1 $new_link2
+    upvar 0 ::cf::[set ::curcfg]::$orig_node1 $orig_node1
+    upvar 0 ::cf::[set ::curcfg]::$orig_node2 $orig_node2
+    upvar 0 ::cf::[set ::curcfg]::$new_node1 $new_node1
+    upvar 0 ::cf::[set ::curcfg]::$new_node2 $new_node2
+    upvar 0 ::cf::[set ::curcfg]::$new_link1 $new_link1
+    upvar 0 ::cf::[set ::curcfg]::$new_link2 $new_link2
     set $new_link1 {}
     set $new_link2 {}
 
@@ -572,7 +582,8 @@ proc splitLink { link nodetype } {
 #****
 
 proc mergeLink { link } {
-    global link_list node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     set mirror_link [getLinkMirror $link]
     if { $mirror_link == "" } {
@@ -586,8 +597,9 @@ proc mergeLink { link } {
     set pseudo_node1 [lindex $link1_peers 1]
     set pseudo_node2 [lindex $link2_peers 1]
     set new_link [newObjectId link]
-    global $orig_node1 $orig_node2
-    global $new_link
+    upvar 0 ::cf::[set ::curcfg]::$orig_node1 $orig_node1
+    upvar 0 ::cf::[set ::curcfg]::$orig_node2 $orig_node2
+    upvar 0 ::cf::[set ::curcfg]::$new_link $new_link
 
     set ifc1 [ifcByPeer $orig_node1 $pseudo_node1]
     set ifc2 [ifcByPeer $orig_node2 $pseudo_node2]
@@ -636,8 +648,9 @@ proc mergeLink { link } {
 #****
 
 proc newLink { lnode1 lnode2 } {
-    global link_list
-    global $lnode1 $lnode2
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::$lnode1 $lnode1
+    upvar 0 ::cf::[set ::curcfg]::$lnode2 $lnode2
     global defEthBandwidth defSerBandwidth defSerDelay
     global defLinkColor defLinkWidth
     global curcanvas
@@ -669,7 +682,7 @@ proc newLink { lnode1 lnode2 } {
     }
 
     set link [newObjectId link]
-    global $link
+    upvar 0 ::cf::[set ::curcfg]::$link $link
     set $link {}
 
     set ifname1 [newIfc [chooseIfName $lnode1 $lnode2] $lnode1]
@@ -732,7 +745,7 @@ proc newLink { lnode1 lnode2 } {
 #****
 
 proc linkByIfc { node ifc } {
-    global link_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
 
     set peer [peerByIfc $node $ifc]
     foreach link $link_list {
index 19fb50ba11347a7f8e74c4505083f3c529452b80..a14d61a43fb9b92967c94aaaf6cdd94f5f76f701 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: nodecfg.tcl,v 1.21 2008/01/01 18:22:59 marko Exp $
+# $Id: nodecfg.tcl,v 1.22 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/nodecfg.tcl
@@ -269,7 +269,7 @@ proc typemodel { node } {
 #****
 
 proc getCustomEnabled { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     if { [lindex [lsearch -inline [set $node] "custom-enabled *"] 1] == true } {
        return true
@@ -291,7 +291,7 @@ proc getCustomEnabled { node } {
 #****
 
 proc setCustomEnabled { node enabled } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "custom-enabled *"]
     if { $i >= 0 } {
@@ -316,7 +316,7 @@ proc setCustomEnabled { node enabled } {
 #****
 
 proc getCustomCmd { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "custom-command *"] 1]
 }
@@ -334,7 +334,7 @@ proc getCustomCmd { node } {
 #****
 
 proc setCustomCmd { node cmd } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "custom-command *"]
     if { $i >= 0 } {
@@ -358,9 +358,9 @@ proc setCustomCmd { node cmd } {
 #****
 
 proc getCustomConfig { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
+
     set customCfgList {}
-       
     set customcmd ""
     set customcfg ""
     set customcmd [lsearch -inline [set $node] "custom-command *"]
@@ -401,7 +401,7 @@ proc getCustomConfig { node } {
 
 proc setCustomConfig { node id cmd cfg delete addccfg } {
     global viewcustomid
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "custom-command *"]
     if { $i != "-1" } {
@@ -485,7 +485,7 @@ proc deleteCustomConfig { w node id cmd cfg delete } {
 #****
 
 proc netconfFetchSection { node sectionhead } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfgmode global
     set section {}
@@ -518,7 +518,7 @@ proc netconfFetchSection { node sectionhead } {
 #****
 
 proc netconfClearSection { node sectionhead } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "network-config *"]
     set netconf [lindex [lindex [set $node] $i] 1]
@@ -554,7 +554,7 @@ proc netconfClearSection { node sectionhead } {
 #****
 
 proc netconfInsertSection { node section } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set sectionhead [lindex $section 0]
     netconfClearSection $node $sectionhead
@@ -964,7 +964,7 @@ proc setIfcIPv6addr { node ifc addr } {
 #****
 
 proc getStatIPv4routes { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set routes {}
     set netconf [lindex [lsearch -inline [set $node] "network-config *"] 1]
@@ -1011,7 +1011,7 @@ proc setStatIPv4routes { node routes } {
 #****
 
 proc getStatIPv6routes { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set routes {}
     set netconf [lindex [lsearch -inline [set $node] "network-config *"] 1]
@@ -1058,7 +1058,7 @@ proc setStatIPv6routes { node routes } {
 #****
 
 proc getNodeName { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set netconf [lindex [lsearch -inline [set $node] "network-config *"] 1]
     return [lrange [lsearch -inline $netconf "hostname *"] 1 end]
@@ -1095,7 +1095,7 @@ proc setNodeName { node name } {
 #****
 
 proc nodeType { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "type *"] 1]
 }
@@ -1115,7 +1115,7 @@ proc nodeType { node } {
 #****
 
 proc getNodeModel { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "model *"] 1]
 }
@@ -1134,7 +1134,7 @@ proc getNodeModel { node } {
 #****
 
 proc setNodeModel { node model } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "model *"]
     if { $i >= 0 } {
@@ -1158,7 +1158,7 @@ proc setNodeModel { node model } {
 #****
 
 proc getNodeCoords { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "iconcoords *"] 1]
 }
@@ -1177,7 +1177,7 @@ proc getNodeCoords { node } {
 #****
 
 proc setNodeCoords { node coords } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "iconcoords *"]
     if { $i >= 0 } {
@@ -1201,7 +1201,7 @@ proc setNodeCoords { node coords } {
 #****
 
 proc getNodeLabelCoords { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "labelcoords *"] 1]
 }
@@ -1219,7 +1219,7 @@ proc getNodeLabelCoords { node } {
 #****
 
 proc setNodeLabelCoords { node coords } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "labelcoords *"]
     if { $i >= 0 } {
@@ -1243,7 +1243,7 @@ proc setNodeLabelCoords { node coords } {
 #****
 
 proc getNodeCPUConf { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [join [lrange [lsearch -inline [set $node] "cpu *"] 1 3]]
 }
@@ -1261,7 +1261,7 @@ proc getNodeCPUConf { node } {
 #****
 
 proc setNodeCPUConf { node param_list } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "cpu *"]
     if { $i >= 0 } {
@@ -1291,7 +1291,7 @@ proc setNodeCPUConf { node param_list } {
 #****
 
 proc ifcList { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set interfaces ""
     foreach entry [lsearch -all -inline [set $node] "interface-peer *"] {
@@ -1317,7 +1317,7 @@ proc ifcList { node } {
 #****
 
 proc peerByIfc { node ifc } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set entry [lsearch -inline [set $node] "interface-peer {$ifc *}"]
     return [lindex [lindex $entry 1] 1]
@@ -1341,7 +1341,7 @@ proc peerByIfc { node ifc } {
 #****
 
 proc logicalPeerByIfc { node ifc } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set peer [peerByIfc $node $ifc]
     if { [nodeType $peer] != "pseudo" } {
@@ -1371,7 +1371,7 @@ proc logicalPeerByIfc { node ifc } {
 #****
 
 proc ifcByPeer { node peer } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set entry [lsearch -inline [set $node] "interface-peer {* $peer}"]
     return [lindex [lindex $entry 1] 0]
@@ -1394,7 +1394,7 @@ proc ifcByPeer { node peer } {
 #****
 
 proc ifcByLogicalPeer { node peer } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set ifc [ifcByPeer $node $peer]
     if { $ifc == "" } {
@@ -1475,7 +1475,8 @@ proc hasIPv6Addr { node } {
 #****
 
 proc removeNode { node } {
-    global node_list $node
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     foreach ifc [ifcList $node] {
        set peer [peerByIfc $node $ifc]
@@ -1500,7 +1501,7 @@ proc removeNode { node } {
 #****
 
 proc getNodeCanvas { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "canvas *"] 1]
 }
@@ -1518,7 +1519,7 @@ proc getNodeCanvas { node } {
 #****
 
 proc setNodeCanvas { node canvas } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "canvas *"]
     if { $i >= 0 } {
@@ -1562,12 +1563,13 @@ proc newIfc { type node } {
 #****
 
 proc newNode { type } {
-    global node_list def_router_model
-       global viewid
-       catch {unset viewid}
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    global def_router_model
+    global viewid
+    catch {unset viewid}
        
     set node [newObjectId node]
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
     set $node {}
     lappend $node "type $type"
     if { $type == "router" } {
@@ -1616,7 +1618,7 @@ proc newNode { type } {
 #****
 
 proc getNodeMirror { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     return [lindex [lsearch -inline [set $node] "mirror *"] 1]
 }
@@ -1637,7 +1639,7 @@ proc getNodeMirror { node } {
 #****
 
 proc setNodeMirror { node value } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "mirror *"]
     if { $value == "" } {
@@ -1662,7 +1664,7 @@ proc setNodeMirror { node value } {
 #****
 
 proc setNodeType { node newtype } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
     
     set oldtype [nodeType $node]
     if { [lsearch "rj45 hub lanswitch" $newtype] >= 0 } {
@@ -1718,7 +1720,7 @@ proc setNodeType { node newtype } {
 #****
 
 proc setType { node type } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set i [lsearch [set $node] "type *"]
     if { $i >= 0 } {
index 115e8942aa66dd59d510d59537e6c91295c9c6f1..2f3512c02da4fdcd778b4b2281b6415a2fd31432 100755 (executable)
@@ -23,7 +23,7 @@
 # SUCH DAMAGE.
 #
 
-# $Id: ns2imunes.tcl,v 1.4 2008/01/01 18:22:59 marko Exp $
+# $Id: ns2imunes.tcl,v 1.5 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/ns2imunes.tcl
@@ -49,9 +49,9 @@
 #****
 
 proc ns2im { srcfile } {
-    global node_list
-    global link_list
-    global canvas_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
+    upvar 0 ::cf::[set ::curcfg]::link_list link_list
+    upvar 0 ::cf::[set ::curcfg]::canvas_list canvas_list
     global curcanvas
     global cfg
     set cfg {}
@@ -195,7 +195,7 @@ proc duplex-link { linkdata } {
 #   node if node has more than one neighbour.
 #****
 proc changeNodeType {} {
-    global node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     foreach node $node_list {
        set ifc [ifcList $node]
        set ifcnum [llength $ifc]
@@ -213,7 +213,7 @@ proc changeNodeType {} {
 #   setDefaultRoutes
 #****
 proc setDefaultRoutes {} {
-    global node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     foreach node $node_list {
        set type [nodeType $node] 
        if { $type == "pc" || $type == "host" } {
@@ -296,7 +296,7 @@ proc getQueingDiscipline { type } {
 #   node_list.
 #****
 proc arrangeNodes {} {
-    global node_list
+    upvar 0 ::cf::[set ::curcfg]::node_list node_list
     global activetool
 #with next foreach loop we divide nodes on layer3/router
 #nodes and edge (pc, host) nodes
@@ -391,6 +391,7 @@ proc getRegularPeers { node } {
 #   * ==1 -- coords are not assigned to $node
 #****
 proc hasCoords {node} {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
+
     return [lsearch [set $node] "iconcoords *"]
 }
diff --git a/pc.tcl b/pc.tcl
index c42ae31d7d2a6fc8cb1230f943a2d05bc592bcae..7a1686a3d6d062ce7921cc72741c513d193bb21b 100755 (executable)
--- a/pc.tcl
+++ b/pc.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: pc.tcl,v 1.16 2008/01/01 18:22:59 marko Exp $
+# $Id: pc.tcl,v 1.17 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/pc.tcl
@@ -76,7 +76,7 @@ proc $MODULE.layer {} {
 #****
 
 proc $MODULE.cfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfg {}
 
index 405eed198631d7d035aaaead708ae62849ccb67e..ee5758aef258ccc148a9adb30f2d81d80b601fd9 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: quagga.tcl,v 1.21 2008/01/01 18:22:59 marko Exp $
+# $Id: quagga.tcl,v 1.22 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/quagga.tcl
@@ -83,7 +83,7 @@ proc $MODULE.layer {} {
 #****
 
 proc $MODULE.cfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfg {}
 
index ca794d844e04259a6a1ba9573f9904fab94492c3..c75f22bf4c5a92dad730f40e1e614eed7771a245 100755 (executable)
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: static.tcl,v 1.17 2008/01/01 18:22:59 marko Exp $
+# $Id: static.tcl,v 1.18 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/static.tcl
@@ -81,7 +81,7 @@ proc $MODULE.layer {} {
 #****
 
 proc $MODULE.cfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfg {}
 
index b41c27dcf76cbaf3606834d3ee83ba9162437c92..6e094d8df58368aeb68c1572e72febd322a0633c 100755 (executable)
--- a/xorp.tcl
+++ b/xorp.tcl
@@ -26,7 +26,7 @@
 # and Technology through the research contract #IP-2003-143.
 #
 
-# $Id: xorp.tcl,v 1.23 2008/01/01 18:22:59 marko Exp $
+# $Id: xorp.tcl,v 1.24 2008/01/02 12:08:46 marko Exp $
 
 
 #****h* imunes/xorp.tcl
@@ -82,7 +82,7 @@ proc $MODULE.layer {} {
 #****
 
 proc $MODULE.cfggen { node } {
-    global $node
+    upvar 0 ::cf::[set ::curcfg]::$node $node
 
     set cfg {}