# 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
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"
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]
}
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]
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
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
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]
proc textEnter { c x y } {
- global annotation_list
+ upvar 0 ::cf::[set ::curcfg]::annotation_list annotation_list
global curcanvas
set object [newObjectId annotation]
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
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]
-# $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.
# 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
#****
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]
#****
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 != "" } {
proc setCanvasSize { canvas x y } {
- global $canvas
+ upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
set i [lsearch [set $canvas] "size *"]
if { $i >= 0 } {
}
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 \{\}]
#****
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 \{\}]
#****
proc setCanvasName { canvas name } {
- global $canvas
+ upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
set i [lsearch [set $canvas] "name *"]
if { $i >= 0 } {
#****
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 \{\}]
#****
proc setCanvasBkg { canvas name } {
- global $canvas
+ upvar 0 ::cf::[set ::curcfg]::$canvas $canvas
set i [lsearch [set $canvas] "bkgImage *"]
if { $i >= 0 } {
# 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
#****
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" } {
}
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"
#****
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
continue
} elseif {"$object" == ""} {
set object $entry
- global $object
+ upvar 0 ::cf::[set ::curcfg]::$object $object
set $object {}
if {"$class" == "node"} {
lappend node_list $object
#****
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
# 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
#****
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)}]%"
# 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]
# * 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]
# * 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 == "" } {
# * 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
# * 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
# * 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 } {
# 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
# 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]
# 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
# * 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
# * 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] {
# 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
}
foreach node $node_list {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set type [nodeType $node]
if { $type == "pseudo" } {
continue
# 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
# 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
# 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"
}
}
-# 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
# 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";
# * 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
# * 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
# * 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];
# * 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];
# * 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 } {
# * 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];
# * 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 {
# 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;
# * 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 } {
# * 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;
}
# * 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
# * 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;
# * 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 {
# * 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;
# 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
#****
proc $MODULE.cfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfg {}
# 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
# 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
# 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
# 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
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/...
}
.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] {
# 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
#****
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
#****
proc getIpsecConfig { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
+
set ipsecCfg {}
set values [lsearch -all -inline [set $node] "ipsec-config *"]
#****
proc removeIpsecConfig { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set indices [lsearch -all [set $node] "ipsec-config *"]
set cnt 0
set $node [lreplace [set $node] $j $j]
incr cnt
}
- return
}
#****f* ipsec.tcl/getIpsecEnabled
#****
proc getIpsecEnabled { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
if { [lindex [lsearch -inline [set $node] "ipsec-enabled *"] 1] == true } {
return true
#****
proc setIpsecEnabled { node enabled } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "ipsec-enabled *"]
if { $i >= 0 } {
if { $enabled == true } {
lappend $node [list ipsec-enabled $enabled]
}
- return
}
#****f* ipsec.tcl/ipsecCfggen
#****
proc ipsecCfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set sourceSA ""
set destSA ""
# 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
#****
proc findFreeIPv4Net { mask } {
- global node_list
+ upvar 0 ::cf::[set ::curcfg]::node_list node_list
set ipnets {}
foreach node $node_list {
# 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
#****
proc findFreeIPv6Net { mask } {
- global node_list
+ upvar 0 ::cf::[set ::curcfg]::node_list node_list
set ipnets {}
foreach node $node_list {
# 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
#****
proc linkPeers { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "nodes {*}"]
return [lindex $entry 1]
#****
proc linkByPeers { node1 node2 } {
- global link_list
+ upvar 0 ::cf::[set ::curcfg]::link_list link_list
foreach link $link_list {
set peers [linkPeers $link]
#****
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]
#****
proc getLinkBandwidth { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "bandwidth *"]
return [lindex $entry 1]
#****
proc getLinkBandwidthString { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
+
set bandstr ""
set bandwidth [getLinkBandwidth $link]
if { $bandwidth > 0 } {
#****
proc setLinkBandwidth { link value } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set i [lsearch [set $link] "bandwidth *"]
if { $value <= 0 } {
# 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 == "" } {
}
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 == "" } {
}
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"]
#****
proc getLinkDelay { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "delay *"]
return [lindex $entry 1]
#****
proc getLinkDelayString { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set delay [getLinkDelay $link]
if { "$delay" != "" } {
#****
proc setLinkDelay { link value } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set i [lsearch [set $link] "delay *"]
if { $value <= 0 } {
#****
proc getLinkBER { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "ber *"]
return [lindex $entry 1]
#****
proc setLinkBER { link value } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set i [lsearch [set $link] "ber *"]
if { $value <= 0 } {
#****
proc getLinkDup { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "duplicate *"]
return [lindex $entry 1]
#****
proc setLinkDup { link value } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set i [lsearch [set $link] "duplicate *"]
if { $value <= 0 || $value > 50 } {
#****
proc getLinkMirror { link } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set entry [lsearch -inline [set $link] "mirror *"]
return [lindex $entry 1]
#****
proc setLinkMirror { link value } {
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set i [lsearch [set $link] "mirror *"]
if { $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]
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 {}
#****
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 == "" } {
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]
#****
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
}
set link [newObjectId link]
- global $link
+ upvar 0 ::cf::[set ::curcfg]::$link $link
set $link {}
set ifname1 [newIfc [chooseIfName $lnode1 $lnode2] $lnode1]
#****
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 {
# 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
#****
proc getCustomEnabled { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
if { [lindex [lsearch -inline [set $node] "custom-enabled *"] 1] == true } {
return true
#****
proc setCustomEnabled { node enabled } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "custom-enabled *"]
if { $i >= 0 } {
#****
proc getCustomCmd { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "custom-command *"] 1]
}
#****
proc setCustomCmd { node cmd } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "custom-command *"]
if { $i >= 0 } {
#****
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 *"]
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" } {
#****
proc netconfFetchSection { node sectionhead } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfgmode global
set section {}
#****
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]
#****
proc netconfInsertSection { node section } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set sectionhead [lindex $section 0]
netconfClearSection $node $sectionhead
#****
proc getStatIPv4routes { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set routes {}
set netconf [lindex [lsearch -inline [set $node] "network-config *"] 1]
#****
proc getStatIPv6routes { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set routes {}
set netconf [lindex [lsearch -inline [set $node] "network-config *"] 1]
#****
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]
#****
proc nodeType { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "type *"] 1]
}
#****
proc getNodeModel { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "model *"] 1]
}
#****
proc setNodeModel { node model } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "model *"]
if { $i >= 0 } {
#****
proc getNodeCoords { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "iconcoords *"] 1]
}
#****
proc setNodeCoords { node coords } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "iconcoords *"]
if { $i >= 0 } {
#****
proc getNodeLabelCoords { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "labelcoords *"] 1]
}
#****
proc setNodeLabelCoords { node coords } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "labelcoords *"]
if { $i >= 0 } {
#****
proc getNodeCPUConf { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [join [lrange [lsearch -inline [set $node] "cpu *"] 1 3]]
}
#****
proc setNodeCPUConf { node param_list } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "cpu *"]
if { $i >= 0 } {
#****
proc ifcList { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set interfaces ""
foreach entry [lsearch -all -inline [set $node] "interface-peer *"] {
#****
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]
#****
proc logicalPeerByIfc { node ifc } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set peer [peerByIfc $node $ifc]
if { [nodeType $peer] != "pseudo" } {
#****
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]
#****
proc ifcByLogicalPeer { node peer } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set ifc [ifcByPeer $node $peer]
if { $ifc == "" } {
#****
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]
#****
proc getNodeCanvas { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "canvas *"] 1]
}
#****
proc setNodeCanvas { node canvas } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "canvas *"]
if { $i >= 0 } {
#****
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" } {
#****
proc getNodeMirror { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
return [lindex [lsearch -inline [set $node] "mirror *"] 1]
}
#****
proc setNodeMirror { node value } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "mirror *"]
if { $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 } {
#****
proc setType { node type } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set i [lsearch [set $node] "type *"]
if { $i >= 0 } {
# 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
#****
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 {}
# 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]
# 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" } {
# 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
# * ==1 -- coords are not assigned to $node
#****
proc hasCoords {node} {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
+
return [lsearch [set $node] "iconcoords *"]
}
# 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
#****
proc $MODULE.cfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfg {}
# 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
#****
proc $MODULE.cfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfg {}
# 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
#****
proc $MODULE.cfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfg {}
# 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
#****
proc $MODULE.cfggen { node } {
- global $node
+ upvar 0 ::cf::[set ::curcfg]::$node $node
set cfg {}