]> git.entuzijast.net Git - imunes.git/commitdiff
Attempt at automated whitespace cleanup.
authormarko <marko>
Thu, 19 Jul 2007 00:12:44 +0000 (00:12 +0000)
committermarko <marko>
Thu, 19 Jul 2007 00:12:44 +0000 (00:12 +0000)
Bug found by:
Submitted by:
Requested by:
Reviewed by:
Approved by:
Obtained from:

19 files changed:
annotations.tcl
canvas.tcl
cfgparse.tcl
decentralized/memberd.tcl
editor.tcl
exec.tcl
exec_server.tcl
filemgmt.tcl
host.tcl
imunes.tcl
initgui.tcl
ipsec.tcl
ipv4.tcl
ipv6.tcl
linkcfg.tcl
nodecfg.tcl
pc.tcl
static.tcl
xorp.tcl

index 4c33494d1522d552b01ef8f5780dabad8a0dd89e..a2b2d6402996d88c79e4b2553b2753b4700cb859 100644 (file)
@@ -28,18 +28,18 @@ proc annotationConfig { c target } {
     
     # set newoval $target
     switch -exact -- [nodeType $target] {
-        oval {
-            popupOvalDialog $c $target "true" $color $label $lcolor
-        }
-        rectangle {
-            popupRectDialog $c $target "true" $color $label $lcolor
-        }
-        text {
-            textConfig $c $target 
-        }
-        default {
-            puts "Unknown type [nodeType $target] for target $target"
-        }
+       oval {
+           popupOvalDialog $c $target "true" $color $label $lcolor
+       }
+       rectangle {
+           popupRectDialog $c $target "true" $color $label $lcolor
+       }
+       text {
+           textConfig $c $target 
+       }
+       default {
+           puts "Unknown type [nodeType $target] for target $target"
+       }
     }
     redrawAll
 }
@@ -73,7 +73,7 @@ proc popupOvalDialog { c target modify color label lcolor } {
 
     # do nothing, return, if coords are empty
     if { $target == 0 && [$c coords "$newoval"] == "" } {
-        return
+       return
     }
     set wi .popup
     catch {destroy $wi}
@@ -83,15 +83,15 @@ proc popupOvalDialog { c target modify color label lcolor } {
     wm resizable $wi 0 0
 
     if { $modify == "true" } {
-        set windowtitle "Configure oval"
+       set windowtitle "Configure oval"
     } else {
-        set windowtitle "Add a new oval"
+       set windowtitle "Add a new oval"
     }
     wm title $wi $windowtitle
     frame $wi.lab -borderwidth 4
     label $wi.lab.name_label -text "Text for top of oval:"
     entry $wi.lab.name -bg white -width 16 \
-        -validate focus -invcmd "focusAndFlash %W"
+       -validate focus -invcmd "focusAndFlash %W"
     $wi.lab.name insert 0 $label
     pack $wi.lab.name $wi.lab.name_label -side right -padx 4 -pady 4
     pack $wi.lab -side top
@@ -100,30 +100,30 @@ proc popupOvalDialog { c target modify color label lcolor } {
     frame $wi.colors -borderwidth 4
     label $wi.colors.label -text "Color:"
     if { $color == "" } {
-        set color $defOvalColor
+       set color $defOvalColor
     }
     if { $lcolor == "" } {
-        set lcolor black
+       set lcolor black
     }
     label $wi.colors.color -text $color -width 8 \
-            -bg $color -fg $lcolor
+           -bg $color -fg $lcolor
     button $wi.colors.fg -text "fg" -command \
-            "popupColor fg $wi.colors.color false"
+           "popupColor fg $wi.colors.color false"
     button $wi.colors.bg -text "bg" -command \
-            "popupColor bg $wi.colors.color true"
+           "popupColor bg $wi.colors.color true"
     pack $wi.colors.fg $wi.colors.bg $wi.colors.color $wi.colors.label \
-            -side right -padx 4 -pady 4
+           -side right -padx 4 -pady 4
     pack $wi.colors -side top
 
     set applycmd "popupOvalApply $c $wi $target"
 
     # Add new oval or modify old one?
     if { $modify == "true"  } {
-        set cancelcmd "destroy $wi"
-        set applytext "Modify oval"
+       set cancelcmd "destroy $wi"
+       set applytext "Modify oval"
     } else {
-        set cancelcmd "destroy $wi; destroyNewoval $c"
-        set applytext "Add oval"
+       set cancelcmd "destroy $wi; destroyNewoval $c"
+       set applytext "Add oval"
     }
    
     frame $wi.butt -borderwidth 6
@@ -134,7 +134,7 @@ proc popupOvalDialog { c target modify color label lcolor } {
     pack $wi.butt.cancel $wi.butt.apply -side right
     pack $wi.butt -side bottom
     after 100 {
-        grab .popup
+       grab .popup
     }
     return
 }
@@ -173,17 +173,17 @@ proc popupOvalApply { c wi target} {
 
     # build the oval object
     if {$target == 0} {
-        set object [newObjectId "oval"]
-        lappend oval_list $object
-        set coords [$c coords "$newoval"]
+       set object [newObjectId "oval"]
+       lappend oval_list $object
+       set coords [$c coords "$newoval"]
     } else {
-        set object $target
+       set object $target
     }
     global $object
     set $object {}
     lappend $iconcoords $coords
     lappend $object $iconcoords "color $color" \
-        "label {$caption}" "labelcolor $labelcolor"
+       "label {$caption}" "labelcolor $labelcolor"
    
     # draw it
     drawOval $object
@@ -201,32 +201,32 @@ proc popupOvalApply { c wi target} {
 proc button3annotation { type c x y } {
 
     if { $type == "oval" } {
-        set procname "Oval"
-        set item [lindex [$c gettags {oval && current}] 1]
+       set procname "Oval"
+       set item [lindex [$c gettags {oval && current}] 1]
     } elseif { $type == "rectangle" } {
-        set procname "Rectangle"
-        set item [lindex [$c gettags {rectangle && current}] 1]
+       set procname "Rectangle"
+       set item [lindex [$c gettags {rectangle && current}] 1]
     } elseif { $type == "label" } {
-        set procname "Label"
-        set item [lindex [$c gettags {label && current}] 1]
+       set procname "Label"
+       set item [lindex [$c gettags {label && current}] 1]
     } elseif { $type == "text" } {
-        set procname "Text"
-        set item [lindex [$c gettags {text && current}] 1]
+       set procname "Text"
+       set item [lindex [$c gettags {text && current}] 1]
     } else {
-        # ???
-        return
+       # ???
+       return
     }
     if { $item == "" } {
-        return
+       return
     }
     set menutext "$type $item"
 
     .button3menu delete 0 end
 
     .button3menu add command -label "Configure $menutext" \
-        -command "annotationConfig $c $item"
+       -command "annotationConfig $c $item"
     .button3menu add command -label "Delete $menutext" \
-        -command "deleteAnnotation $c $type $item"
+       -command "deleteAnnotation $c $type $item"
 
     set x [winfo pointerx .]
     set y [winfo pointery .]
@@ -262,17 +262,17 @@ proc drawOval {oval} {
     set ly [expr ($y1 + 20)]
 
     if { $color == "" } {
-        set color $defOvalColor
+       set color $defOvalColor
     }
     if { $lcolor == "" } {
-        set lcolor black
+       set lcolor black
     }
     # -outline red -stipple gray50
     set newoval [.c create oval $x1 $y1 $x2 $y2 \
-            -fill $color -width 2 -tags "oval $oval"]
+           -fill $color -width 2 -tags "oval $oval"]
     .c raise $newoval background
     .c create text $lx $ly -tags "oval $oval" -text $label \
-            -justify center -font $defOvalLabelFont -fill $lcolor
+           -justify center -font $defOvalLabelFont -fill $lcolor
     setNodeCanvas $oval $curcanvas
     setType $oval "oval"
 }
@@ -282,9 +282,9 @@ proc drawOval {oval} {
 proc popupColor { type l settext } {
     # popup color selection dialog with current color
     if { $type == "fg" } {
-        set initcolor [$l cget -fg]
+       set initcolor [$l cget -fg]
     } else {
-        set initcolor [$l cget -bg]
+       set initcolor [$l cget -bg]
     }
     set newcolor [tk_chooseColor -initialcolor $initcolor]
 
@@ -303,7 +303,7 @@ proc popupColor { type l settext } {
 #****f* annotations.tcl/roundRect
 # NAME
 #   roundRect -- Draw a rounded rectangle in the canvas.
-#                Called from drawRect procedure
+#              Called from drawRect procedure
 # SYNOPSIS
 #   roundRect $w $x0 $y0 $x3 $y3 $radius $args
 # FUNCTION
@@ -314,7 +314,7 @@ proc popupColor { type l settext } {
 #   * x0, y0 -- Coordinates of the upper left corner, in pixels
 #   * x3, y3 -- Coordinates of the lower right corner, in pixels
 #   * radius -- Radius of the bend at the corners, in any form
-#               acceptable to Tk_GetPixels
+#             acceptable to Tk_GetPixels
 #   * args   -- Other args suitable to a 'polygon' item on the canvas
 # Example:
 #   roundRect .c 100 50 500 250 $rad -fill white -outline black -tags rectangle
@@ -330,10 +330,10 @@ proc roundRect { w x0 y0 x3 y3 radius args } {
     set maxr 0.75
 
     if { $d > $maxr * ( $x3 - $x0 ) } {
-        set d [expr { $maxr * ( $x3 - $x0 ) }]
+       set d [expr { $maxr * ( $x3 - $x0 ) }]
     }
     if { $d > $maxr * ( $y3 - $y0 ) } {
-        set d [expr { $maxr * ( $y3 - $y0 ) }]
+       set d [expr { $maxr * ( $y3 - $y0 ) }]
     }
 
     set x1 [expr { $x0 + $d }]
@@ -353,8 +353,8 @@ proc drawRect {rectangle} {
 
     set coords [getNodeCoords $rectangle]
     if {$coords == ""} {
-        tk_messageBox -type ok -message "Prazne coords za $rectangle"
-        return
+       tk_messageBox -type ok -message "Prazne coords za $rectangle"
+       return
     }
 
     set x1 [expr {[lindex $coords 0] * $zoom}]
@@ -368,18 +368,18 @@ proc drawRect {rectangle} {
     set ly [expr ($y1 + 20)]
 
     if { $color == "" } {
-        set color $defRectColor
+       set color $defRectColor
     }
     if { $lcolor == "" } {
-        set lcolor black
+       set lcolor black
     }
     # rounded-rectangle radius
     set rad 25
     set newrect [roundRect .c $x1 $y1 $x2 $y2 $rad \
-            -fill $color -outline blue -tags "rectangle $rectangle"]
+           -fill $color -outline blue -tags "rectangle $rectangle"]
     .c raise $newrect background
     .c create text $lx $ly -tags "rectangle $rectangle" -text $label \
-            -justify center -font $defRectLabelFont -fill $lcolor
+           -justify center -font $defRectLabelFont -fill $lcolor
     setNodeCanvas $rectangle $curcanvas
     setType $rectangle "rectangle"
 }
@@ -391,7 +391,7 @@ proc popupRectDialog { c rectangle modify color label lcolor } {
 
     # do nothing, return, if coords are empty
     if { $rectangle == 0 && [$c coords "$newrect"] == "" } {
-        return
+       return
     }
     set wi .popup
     catch {destroy $wi}
@@ -401,15 +401,15 @@ proc popupRectDialog { c rectangle modify color label lcolor } {
     wm resizable $wi 0 0
 
     if { $modify == "true" } {
-        set windowtitle "Configure rectangle $rectangle"
+       set windowtitle "Configure rectangle $rectangle"
     } else {
-        set windowtitle "Add a new rectangle"
+       set windowtitle "Add a new rectangle"
     }
     wm title $wi $windowtitle
     frame $wi.lab -borderwidth 4
     label $wi.lab.name_label -text "Text for top of rectangle:"
     entry $wi.lab.name -bg white -width 16 \
-                -validate focus -invcmd "focusAndFlash %W"
+               -validate focus -invcmd "focusAndFlash %W"
     $wi.lab.name insert 0 $label
     pack $wi.lab.name $wi.lab.name_label -side right -padx 4 -pady 4
     pack $wi.lab -side top
@@ -418,28 +418,28 @@ proc popupRectDialog { c rectangle modify color label lcolor } {
     frame $wi.colors -borderwidth 4
     label $wi.colors.label -text "Color:"
     if { $color == "" } {
-        set color $defRectColor
+       set color $defRectColor
     }
     if { $lcolor == "" } {
-        set lcolor black
+       set lcolor black
     }
     label $wi.colors.color -text $color -width 8 \
-            -bg $color -fg $lcolor
+           -bg $color -fg $lcolor
     button $wi.colors.fg -text "fg" -command \
-            "popupColor fg $wi.colors.color false"
+           "popupColor fg $wi.colors.color false"
     button $wi.colors.bg -text "bg" -command \
-            "popupColor bg $wi.colors.color true"
+           "popupColor bg $wi.colors.color true"
     pack $wi.colors.fg $wi.colors.bg $wi.colors.color $wi.colors.label \
-            -side right -padx 4 -pady 4
+           -side right -padx 4 -pady 4
     pack $wi.colors -side top
 
     # Add new oval or modify old one?
     if { $modify == "true"  } {
-        set cancelcmd "destroy $wi"
-        set applytext "Modify rectangle"
+       set cancelcmd "destroy $wi"
+       set applytext "Modify rectangle"
     } else {
-        set cancelcmd "destroy $wi; destroyNewRect $c"
-        set applytext "Add rectangle"
+       set cancelcmd "destroy $wi; destroyNewRect $c"
+       set applytext "Add rectangle"
     }
     
     frame $wi.butt -borderwidth 6
@@ -451,7 +451,7 @@ proc popupRectDialog { c rectangle modify color label lcolor } {
     pack $wi.butt.cancel $wi.butt.apply -side right
     pack $wi.butt -side bottom
     after 100 {
-        grab .popup
+       grab .popup
     }
     return
 }
@@ -481,18 +481,18 @@ proc popupRectApply { c wi target } {
     # Prije: set object [newObjectId "rectangle"]
     set object $target
     if { $target == 0 } {
-        # Create a new rectangle object
-        set target [newObjectId "rectangle"]
-        global $target
-        lappend rectangle_list $target
-        set coords [$c coords $newrect]
+       # Create a new rectangle object
+       set target [newObjectId "rectangle"]
+       global $target
+       lappend rectangle_list $target
+       set coords [$c coords $newrect]
     } else {
-        set coords [getNodeCoords $target]
+       set coords [getNodeCoords $target]
     }
     set $target {}
     lappend $iconcoords $coords
     lappend $target $iconcoords "color $color" \
-        "label {$caption}" "labelcolor $labelcolor"
+       "label {$caption}" "labelcolor $labelcolor"
     
     # draw it
     drawRect $target
@@ -512,16 +512,16 @@ proc backgroundImage { c file } {
     set e_sizey [expr {int($sizey * $zoom)}]
 
     if {"$file" == ""} {
-        return
+       return
     }
 
     set error [catch "image create photo Photo -file $file" errorMsg]
     if { $error == "1" } {
-        after idle {.dialog1.msg configure -wraplength 4i}
-        tk_dialog .dialog1 "IMUNES error" \
-            "Couldn\'t set canvas background image:\n$errorMsg" \
-            info 0 Dismiss
-        return 2
+       after idle {.dialog1.msg configure -wraplength 4i}
+       tk_dialog .dialog1 "IMUNES error" \
+           "Couldn\'t set canvas background image:\n$errorMsg" \
+           info 0 Dismiss
+       return 2
     }
     set image_h [image height Photo]
     set image_w [image width Photo]
@@ -530,20 +530,20 @@ proc backgroundImage { c file } {
     set ry [expr $e_sizey  * 1.0/ $image_h]
     
     if { $rx < $ry } {
-        set faktor [expr $rx * 100]
+       set faktor [expr $rx * 100]
     } else {
-        set faktor [expr $ry * 100]
+       set faktor [expr $ry * 100]
     }
     
     set faktor [expr int($faktor)]
 
     if { $faktor > 100 || $image_w > 1280 || $image_h > 1024 } {
-        after idle {.dialog1.msg configure -wraplength 4i}
-        tk_dialog .dialog1 "IMUNES error" \
-            "Error: image should be >= $e_sizex*$e_sizey and <= 1280*1024 ($file is $image_h*$image_w)" \
-            info 0 Dismiss
-        image delete Photo
-        return 2
+       after idle {.dialog1.msg configure -wraplength 4i}
+       tk_dialog .dialog1 "IMUNES error" \
+           "Error: image should be >= $e_sizex*$e_sizey and <= 1280*1024 ($file is $image_h*$image_w)" \
+           info 0 Dismiss
+       image delete Photo
+       return 2
     }
     
     set image [image% Photo $faktor]
@@ -589,27 +589,27 @@ proc selectmarkEnter {c x y} {
     if { $y > [expr $y2-($y2-$y1)/8.0]} { set d 1 }
    
     if {$l==1} {
-        if {$u==1} { 
-            $c config -cursor top_left_corner
-        } elseif {$d==1} { 
-            $c config -cursor bottom_left_corner
-        } else { 
-            $c config -cursor left_side
-        
+       if {$u==1} { 
+           $c config -cursor top_left_corner
+       } elseif {$d==1} { 
+           $c config -cursor bottom_left_corner
+       } else { 
+           $c config -cursor left_side
+       } 
     } elseif {$r==1} {
-        if {$u==1} { 
-            $c config -cursor top_right_corner
-        } elseif {$d==1} { 
-            $c config -cursor bottom_right_corner
-        } else { 
-            $c config -cursor right_side
-        
+       if {$u==1} { 
+           $c config -cursor top_right_corner
+       } elseif {$d==1} { 
+           $c config -cursor bottom_right_corner
+       } else { 
+           $c config -cursor right_side
+       } 
     } elseif {$u==1} { 
-        $c config -cursor top_side
+       $c config -cursor top_side
     } elseif {$d==1} {
-        $c config -cursor bottom_side
+       $c config -cursor bottom_side
     } else {
-        $c config -cursor left_ptr
+       $c config -cursor left_ptr
     }
 }
 
@@ -648,30 +648,30 @@ proc drawText {text} {
 
     set coords [getNodeCoords $text]
     if {$coords == ""} {
-        puts "Empty coordinates for text $text" ;# MM debug
-        return
+       puts "Empty coordinates for text $text" ;# MM debug
+       return
     }
     set x [expr {[lindex $coords 0] * $zoom}]
     set y [expr {[lindex $coords 1] * $zoom}]
     set color [lindex [lsearch -inline [set $text] "color *"] 1]
     if { $color == "" } {
-        set color $defTextColor
+       set color $defTextColor
     }
     set label [lindex [lsearch -inline [set $text] "label *"] 1]
     set fontfamily [lindex [lsearch -inline [set $text] "fontfamily *"] 1]
     set fontsize [lindex [lsearch -inline [set $text] "fontsize *"] 1]
     if { $fontfamily == "" } {
-        set fontfamily $defTextFontFamily
+       set fontfamily $defTextFontFamily
     }
     if { $fontsize == "" } {
-        set fontsize $defTextFontSize
+       set fontsize $defTextFontSize
     }
     set newfontsize $fontsize
     set font [list "$fontfamily" $fontsize]
     set effects [lindex [lsearch -inline [set $text] "effects *"] 1]
     set newtext [.c create text $x $y -text $label -anchor w \
-                    -font "$font $effects" -justify left -fill $color \
-                    -tags "text $text"]
+                   -font "$font $effects" -justify left -fill $color \
+                   -tags "text $text"]
 
     .c addtag text withtag $newtext
     .c raise $text background
@@ -699,10 +699,10 @@ proc textConfig { c target } {
     if { [lsearch $effects underline ] != -1} {set textUnderline 1}
    
     if { $fontfamily == "" } {
-        set fontfamily $defTextFontFamily
+       set fontfamily $defTextFontFamily
     }
     if { $fontsize == "" } {
-        set fontsize $defTextFontSize
+       set fontsize $defTextFontSize
     }
 
     set wi .popup
@@ -727,8 +727,8 @@ proc textConfig { c target } {
     set sizemenu [tk_optionMenu $wi.prop.font.size fontsize "$fontsize"]
 
     pack $wi.prop.font.label \
-         $wi.prop.font.menu \
-         $wi.prop.font.size -side left -pady 2
+        $wi.prop.font.menu \
+        $wi.prop.font.size -side left -pady 2
 
     frame $wi.prop.format -relief groove -bd 2
     label $wi.prop.format.label -text "Effects:"
@@ -736,46 +736,46 @@ proc textConfig { c target } {
 
     # color selection 
     if { $color == "" } {
-        set color $defTextColor
+       set color $defTextColor
     }
     button $wi.prop.format.fg -text "Color" -command \
-                "popupColor fg $wi.text false"
+               "popupColor fg $wi.text false"
     checkbutton $wi.prop.format.bold -text "Bold" -variable textBold \
-         -command [list fontupdate $wi.text bold]
+        -command [list fontupdate $wi.text bold]
     checkbutton $wi.prop.format.italic -text "Italic" -variable textItalic \
-         -command [list fontupdate $wi.text italic]
+        -command [list fontupdate $wi.text italic]
     checkbutton $wi.prop.format.underline -text "Underline" -variable textUnderline \
-         -command [list fontupdate $wi.text underline]
+        -command [list fontupdate $wi.text underline]
 
     if {$textBold == 1} {      $wi.prop.format.bold select
-    } else {                   $wi.prop.format.bold deselect }
+    } else {              $wi.prop.format.bold deselect }
     if {$textItalic == 1} {    $wi.prop.format.italic select
-    } else {                   $wi.prop.format.italic deselect }
+    } else {              $wi.prop.format.italic deselect }
     if {$textUnderline == 1} { $wi.prop.format.underline select
-    } else {                   $wi.prop.format.underline deselect }
+    } else {              $wi.prop.format.underline deselect }
 
     pack $wi.prop.format.label \
-         $wi.prop.format.fg \
-         $wi.prop.format.bold \
-         $wi.prop.format.italic \
-         $wi.prop.format.underline \
-         -side left -pady 2 ;# -fill both
+        $wi.prop.format.fg \
+        $wi.prop.format.bold \
+        $wi.prop.format.italic \
+        $wi.prop.format.underline \
+        -side left -pady 2 ;# -fill both
 
     $wi.text insert end $label
     $wi.text configure -font [list "$fontfamily" $fontsize $effects] -fg $color
 
     $fontmenu delete 0
     foreach f [lsort -dictionary [font families]] {
-        $fontmenu add radiobutton -value "$f" -label $f \
-            -variable fontfamily \
-            -command [list fontupdate $wi.text fontfamily $f]
+       $fontmenu add radiobutton -value "$f" -label $f \
+           -variable fontfamily \
+           -command [list fontupdate $wi.text fontfamily $f]
     }
  
     $sizemenu delete 0
     foreach f {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} {
-        $sizemenu add radiobutton -value "$f" -label $f \
-            -variable fontsize \
-            -command [list fontupdate $wi.text fontsize $f]
+       $sizemenu add radiobutton -value "$f" -label $f \
+           -variable fontsize \
+           -command [list fontupdate $wi.text fontsize $f]
     }
  
     set applycmd "textConfigApply $c $wi $target "
@@ -789,8 +789,8 @@ proc textConfig { c target } {
     pack $wi.action.apply $wi.action.cancel -side left ;# -fill x
 
     after 100 {
-        focus .popup.text
-        grab .popup
+       focus .popup.text
+       grab .popup
     }
     return
 }
@@ -803,12 +803,12 @@ proc fontupdate { label type args} {
     if {"$textItalic"} {set italic "italic"} else {set italic {} }
     if {"$textUnderline"} {set underline "underline"} else {set underline {} }
     switch $type {
-        fontsize {
-            set fontsize $args
-        }
-        fontfamily {
-            set fontfamily "$args"
-        }
+       fontsize {
+           set fontsize $args
+       }
+       fontfamily {
+           set fontfamily "$args"
+       }
     }
     set f [list "$fontfamily" $fontsize]
     lappend f "$bold $italic $underline"
@@ -830,18 +830,18 @@ proc textConfigApply { c wi target } {
 
     # build the oval object
     if { $target == 0 } {
-        set target [newObjectId "target"]
-        global $target
-        lappend text_list $target
-        set coords [$c coords $newtext]
+       set target [newObjectId "target"]
+       global $target
+       lappend text_list $target
+       set coords [$c coords $newtext]
     } else {
-        set coords [getNodeCoords $target]
+       set coords [getNodeCoords $target]
     }
-        
+       
     set $target {}
     lappend $iconcoords $coords
     lappend $target $iconcoords "color $color" "label {$caption}"\
-        "fontfamily {$fontfamily}" "fontsize $fontsize"
+       "fontfamily {$fontfamily}" "fontsize $fontsize"
     set ef {}
     if {"$textBold" == 1}   { lappend ef bold} 
     if {"$textItalic" == 1} { lappend ef italic} 
@@ -861,7 +861,7 @@ proc textConfigApply { c wi target } {
 proc Call_Trace {{file stdout}} {
     puts $file "*** Tcl Call Trace:"
     for {set x [expr [info level]-1]} {$x > 0} {incr x -1} {
-        puts $file "  $x: [info level $x]"
+       puts $file "  $x: [info level $x]"
     }
 }
 
index 48d75bfe9126b54cec85f4a893cb3311fd399007..0a0b8694955cacba7e285b94d0ccf7e919dc5a33 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: canvas.tcl,v 1.9.2.2 2007/07/11 12:08:40 miljenko Exp $ 
+# $Id: canvas.tcl,v 1.9.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -219,14 +219,14 @@ set bkgImage ""
 proc selectBkgImage {} {
     global bkgImage imageFileTypes showBkgImage curcanvas
     set imageFileTypes {{"GIF images" {.gif}}
-                        {"All files"  {*}   }}
+                       {"All files"  {*}   }}
 
     set selectedFile [tk_getOpenFile -filetypes $imageFileTypes]
     if { $selectedFile != ""} {
-        set bkgImage $selectedFile
-        set showBkgImage 1
-        setCanvasBkg $curcanvas $bkgImage
-        redrawAll
+       set bkgImage $selectedFile
+       set showBkgImage 1
+       setCanvasBkg $curcanvas $bkgImage
+       redrawAll
     }
 }
 
index 7fc87729ab0a46339b52aa9ba4e59e18ac845b81..274a231f5e14bfa8f951adeba4ed6d4a9b342d9c 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: cfgparse.tcl,v 1.15.2.2 2007/07/11 12:11:12 miljenko Exp $ 
+# $Id: cfgparse.tcl,v 1.15.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
 
 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
 "
-        }
+       }
     }
 }
 
@@ -97,100 +97,100 @@ proc dumpCfg {method dest} {
     global oval_list rectangle_list text_list
 
     foreach node $node_list {
-        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 "    \}"
-            } elseif { "[lindex $element 0]" == "custom-config" } {
-                dumpputs $method $dest "    custom-config \{"
-                foreach line [lindex $element 1] {
-                    if { $line != {} } {
-                        set str [lindex $line 0]
-                        if { $str == "custom-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 "    \}"
-            } else {
-                dumpputs $method $dest "    $element"
-            }
-        }
-        dumpputs $method $dest "\}"
-        dumpputs $method $dest ""
+       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 "    \}"
+           } elseif { "[lindex $element 0]" == "custom-config" } {
+               dumpputs $method $dest "    custom-config \{"
+               foreach line [lindex $element 1] {
+                   if { $line != {} } {
+                       set str [lindex $line 0]
+                       if { $str == "custom-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 "    \}"
+           } else {
+               dumpputs $method $dest "    $element"
+           }
+       }
+       dumpputs $method $dest "\}"
+       dumpputs $method $dest ""
     }
 
     foreach obj "rectangle oval text link canvas" {
-        upvar 0 ${obj}_list obj_list
-        foreach elem $obj_list {
-            global $elem
-            upvar 0 $elem lelem
-            dumpputs $method $dest "$obj $elem \{"
-            foreach element $lelem {
-                dumpputs $method $dest "    $element"
-            }
-            dumpputs $method $dest "\}"
-            dumpputs $method $dest ""
-        }
+       upvar 0 ${obj}_list obj_list
+       foreach elem $obj_list {
+           global $elem
+           upvar 0 $elem lelem
+           dumpputs $method $dest "$obj $elem \{"
+           foreach element $lelem {
+               dumpputs $method $dest "    $element"
+           }
+           dumpputs $method $dest "\}"
+           dumpputs $method $dest ""
+       }
     }
 
     dumpputs $method $dest "option show \{"
     if {$showIfNames == 0} { 
-        dumpputs $method $dest "    interface_names no" 
+       dumpputs $method $dest "    interface_names no" 
     } else {
-        dumpputs $method $dest "    interface_names yes" }
+       dumpputs $method $dest "    interface_names yes" }
     if {$showIfIPaddrs == 0} { 
-        dumpputs $method $dest "    ip_addresses no" 
+       dumpputs $method $dest "    ip_addresses no" 
     } else {
-        dumpputs $method $dest "    ip_addresses yes" }
+       dumpputs $method $dest "    ip_addresses yes" }
     if {$showIfIPv6addrs == 0} { 
-        dumpputs $method $dest "    ipv6_addresses no" 
+       dumpputs $method $dest "    ipv6_addresses no" 
     } else {
-        dumpputs $method $dest "    ipv6_addresses yes" }
+       dumpputs $method $dest "    ipv6_addresses yes" }
     if {$showNodeLabels == 0} { 
-        dumpputs $method $dest "    node_labels no" 
+       dumpputs $method $dest "    node_labels no" 
     } else {
-        dumpputs $method $dest "    node_labels yes" }
+       dumpputs $method $dest "    node_labels yes" }
     if {$showLinkLabels == 0} { 
-        dumpputs $method $dest "    link_labels no" 
+       dumpputs $method $dest "    link_labels no" 
     } else {
-        dumpputs $method $dest "    link_labels yes" }
+       dumpputs $method $dest "    link_labels yes" }
     if {$showIPsecConfig == 0} {
-        dumpputs $method $dest "    ipsec_configs no"
+       dumpputs $method $dest "    ipsec_configs no"
     } else {
-        dumpputs $method $dest "    ipsec_configs yes" }
+       dumpputs $method $dest "    ipsec_configs yes" }
     if {$showBkgImage == 0} {
-        dumpputs $method $dest "    background_images no"
+       dumpputs $method $dest "    background_images no"
     } else {
-        dumpputs $method $dest "    background_images yes" }
+       dumpputs $method $dest "    background_images yes" }
     if {$showAnnotations == 0} {
-        dumpputs $method $dest "    annotations no"
+       dumpputs $method $dest "    annotations no"
     } else {
-        dumpputs $method $dest "    annotations yes" }
+       dumpputs $method $dest "    annotations yes" }
     if {$showGrid == 0} {
-        dumpputs $method $dest "    grid no"
+       dumpputs $method $dest "    grid no"
     } else {
-        dumpputs $method $dest "    grid yes" }
+       dumpputs $method $dest "    grid yes" }
     dumpputs $method $dest "\}"
     dumpputs $method $dest ""
 }
@@ -225,277 +225,277 @@ proc loadCfg { cfg } {
     set class ""
     set object ""
     foreach entry $cfg {
-        if {"$class" == ""} {
-            set class $entry
-            continue
-        } elseif {"$object" == ""} {
-            set object $entry
-            global $object
-            set $object {}
-            if {"$class" == "node"} {
-                lappend node_list $object
-            }
-            if {"$class" == "link"} {
-                lappend link_list $object
-            }
-            if {"$class" == "canvas"} {
-                lappend canvas_list $object
-            }
-            if {"$class" == "option"} {
-                # for future use
-                lappend prefs $object
-            }
-            if {"$class" == "rectangle"} {
-                lappend rectangle_list $object
-            }
-            if {"$class" == "oval"} {
-                lappend oval_list $object
-            }
-            if {"$class" == "text"} {
-                lappend text_list $object
-            }
-            continue
-        } else {
-            set line [concat $entry]
-            while {[llength $line] >= 2} {
-                set field [lindex $line 0]
-                if {"$field" == ""} {
-                    set line [lreplace $line 0 0]
-                    continue
-                }
+       if {"$class" == ""} {
+           set class $entry
+           continue
+       } elseif {"$object" == ""} {
+           set object $entry
+           global $object
+           set $object {}
+           if {"$class" == "node"} {
+               lappend node_list $object
+           }
+           if {"$class" == "link"} {
+               lappend link_list $object
+           }
+           if {"$class" == "canvas"} {
+               lappend canvas_list $object
+           }
+           if {"$class" == "option"} {
+               # for future use
+               lappend prefs $object
+           }
+           if {"$class" == "rectangle"} {
+               lappend rectangle_list $object
+           }
+           if {"$class" == "oval"} {
+               lappend oval_list $object
+           }
+           if {"$class" == "text"} {
+               lappend text_list $object
+           }
+           continue
+       } else {
+           set line [concat $entry]
+           while {[llength $line] >= 2} {
+               set field [lindex $line 0]
+               if {"$field" == ""} {
+                   set line [lreplace $line 0 0]
+                   continue
+               }
 
-                set value [lindex $line 1]
-                set line [lreplace $line 0 1]
+               set value [lindex $line 1]
+               set line [lreplace $line 0 1]
     
-                if {"$class" == "node"} {
-                    switch -exact -- $field {
-                        type {
-                            lappend $object "type $value"
-                        }
-                        mirror {
-                            lappend $object "mirror $value"
-                        }
-                        model {
-                            lappend $object "model $value"
-                        }
-                        cpu {
-                            lappend $object "cpu {$value}"
-                        }
-                        interface-peer {
-                            lappend $object "interface-peer {$value}"
-                        }
-                        network-config {
-                            set cfg ""
-                            foreach zline [split $value {
+               if {"$class" == "node"} {
+                   switch -exact -- $field {
+                       type {
+                           lappend $object "type $value"
+                       }
+                       mirror {
+                           lappend $object "mirror $value"
+                       }
+                       model {
+                           lappend $object "model $value"
+                       }
+                       cpu {
+                           lappend $object "cpu {$value}"
+                       }
+                       interface-peer {
+                           lappend $object "interface-peer {$value}"
+                       }
+                       network-config {
+                           set cfg ""
+                           foreach zline [split $value {
 }] {
-                                if { [string index "$zline" 0] == "    " } {
-                                    set zline [string replace "$zline" 0 0]
-                                }
-                                lappend cfg $zline
-                            }
-                            set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
-                            lappend $object "network-config {$cfg}"
-                        }
-                        custom-enabled {
-                            lappend $object "custom-enabled $value"
-                        }
-                        custom-command {
-                            lappend $object "custom-command {$value}"
-                        }
-                        custom-config {
-                            set cfg ""
-                        
-                            foreach zline [split $value {
+                               if { [string index "$zline" 0] == "     " } {
+                                   set zline [string replace "$zline" 0 0]
+                               }
+                               lappend cfg $zline
+                           }
+                           set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
+                           lappend $object "network-config {$cfg}"
+                       }
+                       custom-enabled {
+                           lappend $object "custom-enabled $value"
+                       }
+                       custom-command {
+                           lappend $object "custom-command {$value}"
+                       }
+                       custom-config {
+                           set cfg ""
+                       
+                           foreach zline [split $value {
 }] {
-                                if { [string index "$zline" 0] == "    " } {
-                                    set zline [string replace "$zline" 0 0]
-                                }
-                                lappend cfg $zline
-                            }
-                            set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
-                            lappend $object "custom-config {$cfg}"
-                        }
-                        ipsec-enabled {
-                            lappend $object "ipsec-enabled $value"
-                        }
-                        ipsec-config {
-                            set cfg ""
-                
-                            foreach zline [split $value {
+                               if { [string index "$zline" 0] == "     " } {
+                                   set zline [string replace "$zline" 0 0]
+                               }
+                               lappend cfg $zline
+                           }
+                           set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
+                           lappend $object "custom-config {$cfg}"
+                       }
+                       ipsec-enabled {
+                           lappend $object "ipsec-enabled $value"
+                       }
+                       ipsec-config {
+                           set cfg ""
+               
+                           foreach zline [split $value {
 }] {
-                                if { [string index "$zline" 0] == "    " } {
-                                    set zline [string replace "$zline" 0 0]
-                                }
-                                lappend cfg $zline
-                            }
-                            set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
-                                lappend $object "ipsec-config {$cfg}"
-                        }
-                        iconcoords {
-                            lappend $object "iconcoords {$value}"
-                        }
-                        labelcoords {
-                            lappend $object "labelcoords {$value}"
-                        }
-                        canvas {
-                            lappend $object "canvas $value"
-                        }
-                    }
-                } elseif {"$class" == "link"} {
-                    switch -exact -- $field {
-                        nodes {
-                            lappend $object "nodes {$value}"
-                        }
-                        mirror {
-                            lappend $object "mirror $value"
-                        }
-                        bandwidth {
-                            lappend $object "bandwidth $value"
-                        }
-                        delay {
-                            lappend $object "delay $value"
-                        }
-                        ber {
-                            lappend $object "ber $value"
-                        }
-                        duplicate {
-                            lappend $object "duplicate $value"
-                        }
-                        color {
-                            lappend $object "color $value"
-                        }
-                        width {
-                            lappend $object "width $value"
-                        }
-                    }
-                } elseif {"$class" == "canvas"} {
-                    switch -exact -- $field {
-                        name {
-                            lappend $object "name {$value}"
-                        }
-                        size {
-                            lappend $object "size {$value}"
-                        }
-                        bkgImage {
-                            lappend $object "bkgImage {$value}"
-                        }
-                    }
-                } elseif {"$class" == "option"} {
-                    switch -exact -- $field {
-                        interface_names {
-                            if { $value == "no" } {
-                                set showIfNames 0
-                            } elseif { $value == "yes" } {
-                                set showIfNames 1
-                            }
-                        }
-                        ip_addresses {
-                            if { $value == "no" } {
-                                set showIfIPaddrs 0
-                            } elseif { $value == "yes" } {
-                                set showIfIPaddrs 1
-                            }
-                        }
-                        ipv6_addresses {
-                            if { $value == "no" } {
-                                set showIfIPv6addrs 0
-                            } elseif { $value == "yes" } {
-                                set showIfIPv6addrs 1
-                            }
-                        }
-                        node_labels {
-                            if { $value == "no" } {
-                                set showNodeLabels 0
-                            } elseif { $value == "yes" } {
-                                set showNodeLabels 1
-                            }
-                        }
-                        link_labels {
-                            if { $value == "no" } {
-                                set showLinkLabels 0
-                            } elseif { $value == "yes" } {
-                                set showLinkLabels 1
-                            }
-                        }
-                        ipsec_configs {
-                            if { $value == "no" } {
-                                set showIPsecConfig 0
-                            } elseif { $value == "yes" } {
-                                set showIPsecConfig 1
-                            }
-                        }
-                        background_images {
-                            if { $value == "no" } {
-                                set showBkgImage 0
-                            } elseif { $value == "yes" } {
-                                set showBkgImage 1
-                            }
-                        }
-                        annotations {
-                            if { $value == "no" } {
-                                set showAnnotations 0
-                            } elseif { $value == "yes" } {
-                                set showAnnotations 1
-                            }
-                        }
-                        grid {
-                            if { $value == "no" } {
-                                set showGrid 0
-                            } elseif { $value == "yes" } {
-                                set showGrid 1
-                            }
-                        }
-                    }
-                } elseif {"$class" == "oval" \
-                               || "$class" == "rectangle" \
-                               || "$class" == "text"} {
-                    switch -exact -- $field {
-                        iconcoords {
-                            lappend $object "iconcoords {$value}"
-                        }
-                        color {
-                            lappend $object "color $value"
-                        }
-                        label {
-                            lappend $object "label {$value}"
-                        }
-                        labelcolor {
-                            lappend $object "labelcolor $value"
-                        }
-                        size {
-                            lappend $object "size $value"
-                        }
-                        canvas {
-                            lappend $object "canvas $value"
-                        }
-                        font {
-                            lappend $object "font {$value}"
-                        }
-                        fontfamily {
-                            lappend $object "fontfamily {$value}"
-                        }
-                        fontsize {
-                            lappend $object "fontsize {$value}"
-                        }
-                        effects {
-                            lappend $object "effects {$value}"
-                        }
-                    }
-                }
-            }
-        }
-        set class ""
-        set object ""
+                               if { [string index "$zline" 0] == "     " } {
+                                   set zline [string replace "$zline" 0 0]
+                               }
+                               lappend cfg $zline
+                           }
+                           set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]]
+                               lappend $object "ipsec-config {$cfg}"
+                       }
+                       iconcoords {
+                           lappend $object "iconcoords {$value}"
+                       }
+                       labelcoords {
+                           lappend $object "labelcoords {$value}"
+                       }
+                       canvas {
+                           lappend $object "canvas $value"
+                       }
+                   }
+               } elseif {"$class" == "link"} {
+                   switch -exact -- $field {
+                       nodes {
+                           lappend $object "nodes {$value}"
+                       }
+                       mirror {
+                           lappend $object "mirror $value"
+                       }
+                       bandwidth {
+                           lappend $object "bandwidth $value"
+                       }
+                       delay {
+                           lappend $object "delay $value"
+                       }
+                       ber {
+                           lappend $object "ber $value"
+                       }
+                       duplicate {
+                           lappend $object "duplicate $value"
+                       }
+                       color {
+                           lappend $object "color $value"
+                       }
+                       width {
+                           lappend $object "width $value"
+                       }
+                   }
+               } elseif {"$class" == "canvas"} {
+                   switch -exact -- $field {
+                       name {
+                           lappend $object "name {$value}"
+                       }
+                       size {
+                           lappend $object "size {$value}"
+                       }
+                       bkgImage {
+                           lappend $object "bkgImage {$value}"
+                       }
+                   }
+               } elseif {"$class" == "option"} {
+                   switch -exact -- $field {
+                       interface_names {
+                           if { $value == "no" } {
+                               set showIfNames 0
+                           } elseif { $value == "yes" } {
+                               set showIfNames 1
+                           }
+                       }
+                       ip_addresses {
+                           if { $value == "no" } {
+                               set showIfIPaddrs 0
+                           } elseif { $value == "yes" } {
+                               set showIfIPaddrs 1
+                           }
+                       }
+                       ipv6_addresses {
+                           if { $value == "no" } {
+                               set showIfIPv6addrs 0
+                           } elseif { $value == "yes" } {
+                               set showIfIPv6addrs 1
+                           }
+                       }
+                       node_labels {
+                           if { $value == "no" } {
+                               set showNodeLabels 0
+                           } elseif { $value == "yes" } {
+                               set showNodeLabels 1
+                           }
+                       }
+                       link_labels {
+                           if { $value == "no" } {
+                               set showLinkLabels 0
+                           } elseif { $value == "yes" } {
+                               set showLinkLabels 1
+                           }
+                       }
+                       ipsec_configs {
+                           if { $value == "no" } {
+                               set showIPsecConfig 0
+                           } elseif { $value == "yes" } {
+                               set showIPsecConfig 1
+                           }
+                       }
+                       background_images {
+                           if { $value == "no" } {
+                               set showBkgImage 0
+                           } elseif { $value == "yes" } {
+                               set showBkgImage 1
+                           }
+                       }
+                       annotations {
+                           if { $value == "no" } {
+                               set showAnnotations 0
+                           } elseif { $value == "yes" } {
+                               set showAnnotations 1
+                           }
+                       }
+                       grid {
+                           if { $value == "no" } {
+                               set showGrid 0
+                           } elseif { $value == "yes" } {
+                               set showGrid 1
+                           }
+                       }
+                   }
+               } elseif {"$class" == "oval" \
+                              || "$class" == "rectangle" \
+                              || "$class" == "text"} {
+                   switch -exact -- $field {
+                       iconcoords {
+                           lappend $object "iconcoords {$value}"
+                       }
+                       color {
+                           lappend $object "color $value"
+                       }
+                       label {
+                           lappend $object "label {$value}"
+                       }
+                       labelcolor {
+                           lappend $object "labelcolor $value"
+                       }
+                       size {
+                           lappend $object "size $value"
+                       }
+                       canvas {
+                           lappend $object "canvas $value"
+                       }
+                       font {
+                           lappend $object "font {$value}"
+                       }
+                       fontfamily {
+                           lappend $object "fontfamily {$value}"
+                       }
+                       fontsize {
+                           lappend $object "fontsize {$value}"
+                       }
+                       effects {
+                           lappend $object "effects {$value}"
+                       }
+                   }
+               }
+           }
+       }
+       set class ""
+       set object ""
     }
 
     #
     # Hack for comaptibility with old format files (no canvases)
     #
     if { $canvas_list == "" } {
-        set curcanvas [newCanvas ""]
-        foreach node $node_list {
-            setNodeCanvas $node $curcanvas
-        }
+       set curcanvas [newCanvas ""]
+       foreach node $node_list {
+           setNodeCanvas $node $curcanvas
+       }
     }
 }
 
@@ -524,7 +524,7 @@ proc newObjectId { type } {
     set mark [string range [set type] 0 0]
     set id 0
     while {[lsearch [set [set type]_list] "$mark$id"]  != -1} {
-        incr id
+       incr id
     }
     return $mark$id
 }
index c461a84180dcaff1bcbb38f62650de24a3393a58..13a16a879f9c9691f94e419b93cf10b721a80513 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: memberd.tcl,v 1.1.2.1 2007/05/07 08:20:10 ana Exp $ 
+# $Id: memberd.tcl,v 1.1.2.2 2007/07/19 00:12:45 marko Exp $ 
 #!/usr/local/bin/tclsh8.4
 
 #
@@ -205,7 +205,7 @@ proc OpenPeering { so peer port } {
     if { [catch { puts $so "open $iv" }] } {
        catch { close $so }
     } else {
-        # XXX TODO: Configure TX encription using key + iv
+       # XXX TODO: Configure TX encription using key + iv
        AddPeering $so $peer $port
     }
 }
@@ -330,9 +330,9 @@ proc ReadSocket { peer_id } {
 
     if { [gets $so line] < 0} {
        if { [eof $so] } {
-            DestroyPeering $peer_id
-            return
-        }
+           DestroyPeering $peer_id
+           return
+       }
     } else {
        set deadline($peer_id) [clock seconds]
        set cmd [lindex $line 0]
@@ -536,7 +536,7 @@ proc ProcessAnnounce { peer_id host_id path line } {
        if { [lsearch $host_paths_tbl($host_id) "$peer_id *"] >= 0 } {
            # Duplicate entry from single peer - this must never happen!
            VerboseDestroyPeering $peer_id \
-               "rcvd duplicate announcement from $peer_id: $path"
+               "rcvd duplicate announcement from $peer_id: $path"
            return
        }
        set old_best [BestPath $host_id]
index afceb728081d241c55df728190d3b6a3c11e3f64..94534f6e90614fd8336dd79c145ccb36167d1525 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: editor.tcl,v 1.62.2.2 2007/07/11 12:11:12 miljenko Exp $ 
+# $Id: editor.tcl,v 1.62.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -50,16 +50,16 @@ proc animateCursor {} {
     global clock_seconds
 
     if { [clock seconds] == $clock_seconds } {
-        update
-        return
+       update
+       return
     }
     set clock_seconds [clock seconds]
     if { $cursorState } {
-        .c config -cursor watch
-        set cursorState 0
+       .c config -cursor watch
+       set cursorState 0
     } else {
-        .c config -cursor pirate
-        set cursorState 1
+       .c config -cursor pirate
+       set cursorState 1
     }
     update
 }
@@ -86,24 +86,24 @@ proc removeGUILink { link atomic } {
     set node1 [lindex $nodes 0]
     set node2 [lindex $nodes 1]
     if { [nodeType $node1] == "pseudo" } {
-        removeLink [getLinkMirror $link]
-        removeLink $link
-        removeNode [getNodeMirror $node1]
-        removeNode $node1
-        .c delete $node1
+       removeLink [getLinkMirror $link]
+       removeLink $link
+       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
+       removeLink [getLinkMirror $link]
+       removeLink $link
+       removeNode [getNodeMirror $node2]
+       removeNode $node2
+       .c delete $node2
     } else {
-        removeLink $link
+       removeLink $link
     }
     .c delete $link
     if { $atomic == "atomic" } {
-        set changed 1
-        updateUndoLog
+       set changed 1
+       updateUndoLog
     }
 }
 
@@ -122,13 +122,13 @@ proc removeGUILink { link atomic } {
 proc removeGUINode { node } {
     set type [nodeType $node]
     foreach ifc [ifcList $node] {
-        set peer [peerByIfc $node $ifc]
-        set link [lindex [.c gettags "link && $node && $peer"] 1]
-        removeGUILink $link non-atomic
+       set peer [peerByIfc $node $ifc]
+       set link [lindex [.c gettags "link && $node && $peer"] 1]
+       removeGUILink $link non-atomic
     }
     if { $type != "pseudo" } {
-        removeNode $node
-        .c delete $node
+       removeNode $node
+       .c delete $node
     }
 }
 
@@ -146,16 +146,16 @@ proc updateUndoLog {} {
     global changed undolog undolevel redolevel
 
     if { $changed } {
-        global t_undolog undolog
-        set t_undolog ""
-        dumpCfg string t_undolog
-        incr undolevel
-        if { $undolevel == 1 } {
-            .menubar.edit entryconfigure "Undo" -state normal
-        }
-        set undolog($undolevel) $t_undolog
-        set redolevel $undolevel
-        set changed 0
+       global t_undolog undolog
+       set t_undolog ""
+       dumpCfg string t_undolog
+       incr undolevel
+       if { $undolevel == 1 } {
+           .menubar.edit entryconfigure "Undo" -state normal
+       }
+       set undolog($undolevel) $t_undolog
+       set redolevel $undolevel
+       set changed 0
     }
 }
 
@@ -173,14 +173,14 @@ proc undo {} {
     global undolevel undolog oper_mode
 
     if {$oper_mode == "edit" && $undolevel > 0} {
-        .menubar.edit entryconfigure "Redo" -state normal
-        incr undolevel -1
-        if { $undolevel == 0 } {
-            .menubar.edit entryconfigure "Undo" -state disabled
-        }
-        .c config -cursor watch
-        loadCfg $undolog($undolevel)
-        switchCanvas none
+       .menubar.edit entryconfigure "Redo" -state normal
+       incr undolevel -1
+       if { $undolevel == 0 } {
+           .menubar.edit entryconfigure "Undo" -state disabled
+       }
+       .c config -cursor watch
+       loadCfg $undolog($undolevel)
+       switchCanvas none
     }
 }
 
@@ -200,16 +200,16 @@ proc redo {} {
     global undolevel redolevel undolog oper_mode
 
     if {$oper_mode == "edit" && $redolevel > $undolevel} {
-        incr undolevel
-        if { $undolevel == 1 } {
-            .menubar.edit entryconfigure "Undo" -state normal
-        }
-        if {$redolevel <= $undolevel} {
-            .menubar.edit entryconfigure "Redo" -state disabled
-        }
-        .c config -cursor watch
-        loadCfg $undolog($undolevel)
-        switchCanvas none
+       incr undolevel
+       if { $undolevel == 1 } {
+           .menubar.edit entryconfigure "Undo" -state normal
+       }
+       if {$redolevel <= $undolevel} {
+           .menubar.edit entryconfigure "Redo" -state disabled
+       }
+       .c config -cursor watch
+       loadCfg $undolog($undolevel)
+       switchCanvas none
     }
 }
 
@@ -232,88 +232,88 @@ proc 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 canvasBkgImage [getCanvasBkg $curcanvas]
     if { $showBkgImage == 1 && "$canvasBkgImage" != ""} {
-        set ret [backgroundImage .c $canvasBkgImage]
-        if { "$ret" == 2 } {
-            set background [.c create rectangle 0 0 $e_sizex $e_sizey \
-                    -fill white -tags "background"]
-        } else {
-            set background [.c create rectangle 0 0 $e_sizex $e_sizey \
-                    -tags "background"]
-        }
+       set ret [backgroundImage .c $canvasBkgImage]
+       if { "$ret" == 2 } {
+           set background [.c create rectangle 0 0 $e_sizex $e_sizey \
+                   -fill white -tags "background"]
+       } else {
+           set background [.c create rectangle 0 0 $e_sizex $e_sizey \
+                   -tags "background"]
+       }
     } else {
-        set background [.c create rectangle 0 0 $e_sizex $e_sizey \
-           -fill white -tags "background"]
+       set background [.c create rectangle 0 0 $e_sizex $e_sizey \
+          -fill white -tags "background"]
     }
 
     if { $showAnnotations == 1 } {
-        foreach rect $rectangle_list {
-            if { [getNodeCanvas $rect] == $curcanvas } {
-                drawRect $rect
-            }
-        
-        foreach oval $oval_list {
-            if { [getNodeCanvas $oval] == $curcanvas } {
-                drawOval $oval
-            }
-        
-        foreach text $text_list {
-            if { [getNodeCanvas $text] == $curcanvas } {
-                drawText $text
-            }
-        
+       foreach rect $rectangle_list {
+           if { [getNodeCanvas $rect] == $curcanvas } {
+               drawRect $rect
+           }
+       } 
+       foreach oval $oval_list {
+           if { [getNodeCanvas $oval] == $curcanvas } {
+               drawOval $oval
+           }
+       } 
+       foreach text $text_list {
+           if { [getNodeCanvas $text] == $curcanvas } {
+               drawText $text
+           }
+       } 
     }
 
     # 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 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"
+           }
+       }
     }
 
     .c lower -withtags background
 
     foreach node $node_list {
-        if { [getNodeCanvas $node] == $curcanvas } {
-            drawNode $node
-        }
+       if { [getNodeCanvas $node] == $curcanvas } {
+           drawNode $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
+       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
@@ -349,31 +349,31 @@ proc drawNode { node } {
     set x [expr {[lindex $coords 0] * $zoom}]
     set y [expr {[lindex $coords 1] * $zoom}]
     if { [nodeType $node] != "pseudo" } {
-        set label [.c create text $x $y -fill blue \
-            -text "[getNodeName $node]" \
-            -tags "nodelabel $node"]
+       set label [.c create text $x $y -fill blue \
+           -text "[getNodeName $node]" \
+           -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
+       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
 @[getCanvasName $pcanvas]" \
-                -tags "nodelabel $node" -justify center]
-        } else {
-            set label [.c create text $x $y -fill blue \
-                -text "[getNodeName $pnode]:$ifc" \
-                -tags "nodelabel $node" -justify center]
-        }
+               -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
+       .c itemconfigure $label -state hidden
     }
     # XXX Invisible pseudo-node labels
     global invisible
     if { $invisible == 1 && [nodeType $node] == "pseudo" } {
-        .c itemconfigure $label -state hidden
+       .c itemconfigure $label -state hidden
     }
 }
 
@@ -396,23 +396,23 @@ proc drawLink { link } {
     set lnode2 [lindex $nodes 1]
     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]
+       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"]
+       set newlink [.c create line 0 0 0 0 \
+           -fill [getLinkColor $link] -width $lwidth \
+       -tags "link $link $lnode1 $lnode2"]
     }
     # XXX Invisible pseudo-liks
     global invisible
     if { $invisible == 1 && [getLinkMirror $link] != "" } {
-        .c itemconfigure $link -state hidden
+       .c itemconfigure $link -state hidden
     }
     .c raise $newlink background
     set newlink [.c create line 0 0 0 0 \
-        -fill white -width [expr {$lwidth + 4}] \
-        -tags "link $link $lnode1 $lnode2"]
+       -fill white -width [expr {$lwidth + 4}] \
+       -tags "link $link $lnode1 $lnode2"]
     .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
@@ -441,27 +441,27 @@ proc chooseIfName { lnode1 lnode2 } {
     global $lnode1 $lnode2
 
     switch -exact -- [nodeType $lnode1] {
-        pc {
-            return eth
-        }
-        host {
-            return eth
-        }
-        hub {
-            return e
-        }
-        lanswitch {
-            return e
-        }
-        frswitch {
-            return f
-        }
-        router {
-            return eth
-        }
-        rj45 {
-            return 
-        }
+       pc {
+           return eth
+       }
+       host {
+           return eth
+       }
+       hub {
+           return e
+       }
+       lanswitch {
+           return e
+       }
+       frswitch {
+           return f
+       }
+       router {
+           return eth
+       }
+       rj45 {
+           return 
+       }
     }
 }
 
@@ -484,13 +484,13 @@ proc chooseIfName { lnode1 lnode2 } {
 proc listLANnodes { l2node l2peers } {
     lappend l2peers $l2node
     foreach ifc [ifcList $l2node] {
-        set peer [logicalPeerByIfc $l2node $ifc]
-        set type [nodeType $peer]
-        if { [ lsearch {lanswitch hub} $type] != -1 } {
-            if { [lsearch $l2peers $peer] == -1 } {
-                set l2peers [listLANnodes $peer $l2peers]
-            }
-        }
+       set peer [logicalPeerByIfc $l2node $ifc]
+       set type [nodeType $peer]
+       if { [ lsearch {lanswitch hub} $type] != -1 } {
+           if { [lsearch $l2peers $peer] == -1 } {
+               set l2peers [listLANnodes $peer $l2peers]
+           }
+       }
     }
     return $l2peers
 }
@@ -513,47 +513,47 @@ proc calcDxDy { lnode } {
     upvar dy y
 
     if { $zoom > 1.0 } {
-        set x 1
-        set y 1
-        return
+       set x 1
+       set y 1
+       return
     }
     switch -exact -- [nodeType $lnode] {
-        frswitch {
-            set x [expr {1.8 / $zoom}]
-        set y [expr {1.8 / $zoom}]
-        }
-        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}]
-        }
-        pc {
-            if { $showIfIPaddrs || $showIfIPv6addrs } {
-                set x [expr {1.1 / $zoom}]
-            } else {
-                set x [expr {1.4 / $zoom}]
-            }
-            set y [expr {1.5 / $zoom}]
-        }
-        host {
-            if { $showIfIPaddrs || $showIfIPv6addrs } {
-                set x [expr {1 / $zoom}]
-            } else {
-                set x [expr {1.5 / $zoom}]
-            }
-            set y [expr {1.5 / $zoom}]
-        }
-        rj45 {
-            set x [expr {1 / $zoom}]
-            set y [expr {1 / $zoom}]
-        }
+       frswitch {
+           set x [expr {1.8 / $zoom}]
+       set y [expr {1.8 / $zoom}]
+       }
+       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}]
+       }
+       pc {
+           if { $showIfIPaddrs || $showIfIPv6addrs } {
+               set x [expr {1.1 / $zoom}]
+           } else {
+               set x [expr {1.4 / $zoom}]
+           }
+           set y [expr {1.5 / $zoom}]
+       }
+       host {
+           if { $showIfIPaddrs || $showIfIPv6addrs } {
+               set x [expr {1 / $zoom}]
+           } else {
+               set x [expr {1.5 / $zoom}]
+           }
+           set y [expr {1.5 / $zoom}]
+       }
+       rj45 {
+           set x [expr {1 / $zoom}]
+           set y [expr {1 / $zoom}]
+       }
     }
 }
 
@@ -579,29 +579,29 @@ proc updateIfcLabel { lnode1 lnode2 } {
     set ifipv4addr [getIfcIPv4addr $lnode1 $ifc]
     set ifipv6addr [getIfcIPv6addr $lnode1 $ifc]
     if { $ifc == 0 } {
-        set ifc ""
+       set ifc ""
     }
     if { [getIfcOperState $lnode1 $ifc] == "down" } {
-        set labelstr "*"
+       set labelstr "*"
     } else {
-        set labelstr ""
+       set labelstr ""
     }
     if { $showIfNames } {
-        set labelstr "$labelstr$ifc
+       set labelstr "$labelstr$ifc
 "
     }
     if { $showIfIPaddrs && $ifipv4addr != "" } {
-        set labelstr "$labelstr$ifipv4addr
+       set labelstr "$labelstr$ifipv4addr
 "
     }
     if { $showIfIPv6addrs && $ifipv6addr != "" } {
-        set labelstr "$labelstr$ifipv6addr
+       set labelstr "$labelstr$ifipv6addr
 "
     }
     set labelstr \
-        [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
+       [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
     .c itemconfigure "interface && $lnode1 && $link" \
-        -text "$labelstr"
+       -text "$labelstr"
 }
 
 
@@ -626,24 +626,24 @@ proc updateLinkLabel { link } {
     set labelstr "$labelstr[getLinkBandwidthString $link]
 "
     if { "$delstr" != "" } {
-        set labelstr "$labelstr$delstr
+       set labelstr "$labelstr$delstr
 "
     }
     if { "$ber" != "" } {
-        set berstr "ber=$ber"
-        set labelstr "$labelstr$berstr
+       set berstr "ber=$ber"
+       set labelstr "$labelstr$berstr
 "
     }
     if { "$dup" != "" } {
-        set dupstr "dup=$dup%"
-        set labelstr "$labelstr$dupstr
+       set dupstr "dup=$dup%"
+       set labelstr "$labelstr$dupstr
 "
     }
     set labelstr \
-        [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
+       [string range $labelstr 0 [expr {[string length $labelstr] - 2}]]
     .c itemconfigure "linklabel && $link" -text "$labelstr"
     if { $showLinkLabels == 0} {
-        .c itemconfigure "linklabel && $link" -state hidden
+       .c itemconfigure "linklabel && $link" -state hidden
     }
 }
 
@@ -660,12 +660,12 @@ proc redrawAllLinks {} {
     global link_list curcanvas
 
     foreach link $link_list {
-        set nodes [linkPeers $link]
-        if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
-            [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
-            continue
-        }
-        redrawLink $link
+       set nodes [linkPeers $link]
+       if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
+           [getNodeCanvas [lindex $nodes 1]] != $curcanvas } {
+           continue
+       }
+       redrawLink $link
     }
 }
 
@@ -706,9 +706,9 @@ proc redrawLink { link } {
     .c coords "linklabel && $link" $lx $ly
 
     set n [expr {sqrt (($x1 - $x2) * ($x1 - $x2) + \
-        ($y1 - $y2) * ($y1 - $y2)) * 0.015}]
+       ($y1 - $y2) * ($y1 - $y2)) * 0.015}]
     if { $n < 1 } {
-        set n 1
+       set n 1
     }
 
     calcDxDy $lnode1
@@ -760,11 +760,11 @@ proc splitGUILink { link } {
     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]
 
@@ -791,18 +791,18 @@ proc selectNode { c obj } {
 
     $c addtag selected withtag "node && $node"
     if { [nodeType $node] == "pseudo" } {
-        set bbox [$c bbox "nodelabel && $node"]
+       set bbox [$c bbox "nodelabel && $node"]
     } elseif { [nodeType $node] == "rectangle" } {
-        $c addtag selected withtag "rectangle && $node"
-        set bbox [$c bbox "rectangle && $node"]
+       $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"]
+       $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"]
+       $c addtag selected withtag "oval && $node"
+       set bbox [$c bbox "oval && $node"]
     } else {
-        set bbox [$c bbox "node && $node"]
+       set bbox [$c bbox "node && $node"]
     }
     set bx1 [expr {[lindex $bbox 0] - 2}]
     set by1 [expr {[lindex $bbox 1] - 2}]
@@ -810,28 +810,28 @@ proc selectNode { c obj } {
     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"
+       -dash {6 4} -fill black -width 1 -tags "selectmark $node"
 }
 
 proc selectNodes { nodelist } {
     foreach node $nodelist {
-        selectNode .c [.c find withtag "node && $node"]
+       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]
+       lappend selected [lindex [.c gettags $obj] 1]
     }
     foreach obj [.c find withtag "oval && selected"] {
-        lappend selected [lindex [.c gettags $obj] 1]
+       lappend selected [lindex [.c gettags $obj] 1]
     }
     foreach obj [.c find withtag "rectangle && selected"] {
-        lappend selected [lindex [.c gettags $obj] 1]
+       lappend selected [lindex [.c gettags $obj] 1]
     }
     foreach obj [.c find withtag "text && selected"] {
-        lappend selected [lindex [.c gettags $obj] 1]
+       lappend selected [lindex [.c gettags $obj] 1]
     }
     return $selected
 }
@@ -839,12 +839,12 @@ proc selectedNodes {} {
 proc selectedRealNodes {} {
     set selected {}
     foreach obj [.c find withtag "node && selected"] {
-        set node [lindex [.c gettags $obj] 1]
-        if { [getNodeMirror $node] != "" ||
-            [nodeType $node] == "rj45" } {
-            continue
-        }
-        lappend selected $node
+       set node [lindex [.c gettags $obj] 1]
+       if { [getNodeMirror $node] != "" ||
+           [nodeType $node] == "rj45" } {
+           continue
+       }
+       lappend selected $node
     }
     return $selected
 }
@@ -855,15 +855,15 @@ proc selectAdjacent {} {
     set selected [selectedNodes]
     set adjacent {}
     foreach node $selected {
-        foreach ifc [ifcList $node] {
-            set peer [peerByIfc $node $ifc]
-            if { [getNodeMirror $peer] != "" } {
-                return
-            }
-            if { [lsearch $adjacent $peer] < 0 } {
-                lappend adjacent $peer
-            }
-        }
+       foreach ifc [ifcList $node] {
+           set peer [peerByIfc $node $ifc]
+           if { [getNodeMirror $peer] != "" } {
+               return
+           }
+           if { [lsearch $adjacent $peer] < 0 } {
+               lappend adjacent $peer
+           }
+       }
     }
     selectNodes $adjacent
 }
@@ -894,10 +894,10 @@ proc button3link { c x y } {
 
     set link [lindex [$c gettags {link && current}] 1]
     if { $link == "" } {
-        set link [lindex [$c gettags {linklabel && current}] 1]
-        if { $link == "" } {
-            return
-        }
+       set link [lindex [$c gettags {linklabel && current}] 1]
+       if { $link == "" } {
+           return
+       }
     }
 
     .button3menu delete 0 end
@@ -906,40 +906,40 @@ proc button3link { c x y } {
     # Configure link
     #
     .button3menu add command -label "Configure" \
-        -command "popupConfigDialog $c"
+       -command "popupConfigDialog $c"
 
     #
     # Delete link
     #
     if { $oper_mode != "exec" } {
-        .button3menu add command -label "Delete" \
-            -command "removeGUILink $link atomic"
+       .button3menu add command -label "Delete" \
+           -command "removeGUILink $link atomic"
     } else {
-        .button3menu add command -label "Delete" \
-            -state disabled
+       .button3menu add command -label "Delete" \
+           -state disabled
     }
 
     #
     # Split link
     #
     if { $oper_mode != "exec" && [getLinkMirror $link] == "" } {
-        .button3menu add command -label "Split" \
-            -command "splitGUILink $link"
+       .button3menu add command -label "Split" \
+           -command "splitGUILink $link"
     } else {
-        .button3menu add command -label "Split" \
-            -state disabled
+       .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]"
+       [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
+       .button3menu add command -label "Merge" -state disabled
     }
 
     set x [winfo pointerx .]
@@ -964,37 +964,37 @@ proc movetoCanvas { canvas } {
 
     set selected_nodes [selectedNodes]
     foreach node $selected_nodes {
-        setNodeCanvas $node $canvas
-        set changed 1
+       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) } {
-            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
-        }
+       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
+       }
     }
     updateUndoLog
     redrawAll
@@ -1055,17 +1055,17 @@ proc button3node { c x y } {
 
     set node [lindex [$c gettags {node && current}] 1]
     if { $node == "" } {
-        set node [lindex [$c gettags {nodelabel && current}] 1]
-        if { $node == "" } {
-            return
-        }
+       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"]
+       $c dtag node selected
+       $c delete -withtags selectmark
+       selectNode $c [$c find withtag "current"]
     }
 
     .button3menu delete 0 end
@@ -1074,22 +1074,22 @@ proc button3node { c x y } {
     # Select adjacent
     #
     if { [nodeType $node] != "pseudo" } {
-        .button3menu add command -label "Select adjacent" \
-            -command "selectAdjacent"
+       .button3menu add command -label "Select adjacent" \
+           -command "selectAdjacent"
     } else {
-        .button3menu add command -label "Select adjacent" \
-            -command "selectAdjacent" -state disabled
+       .button3menu add command -label "Select adjacent" \
+           -command "selectAdjacent" -state disabled
     }
 
     #
     # Configure node
     #
     if { [nodeType $node] != "pseudo" } {
-        .button3menu add command -label "Configure" \
-            -command "popupConfigDialog $c"
+       .button3menu add command -label "Configure" \
+           -command "popupConfigDialog $c"
     } else {
-        .button3menu add command -label "Configure" \
-            -command "popupConfigDialog $c" -state disabled
+       .button3menu add command -label "Configure" \
+           -command "popupConfigDialog $c" -state disabled
     }
 
     #
@@ -1097,46 +1097,46 @@ proc button3node { c x y } {
     #
     .button3menu.connect delete 0 end
     if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
-        .button3menu add cascade -label "Create link to" \
-            -menu .button3menu.connect -state disabled
+       .button3menu add cascade -label "Create link to" \
+           -menu .button3menu.connect -state disabled
     } else {
-        .button3menu add cascade -label "Create link to" \
-            -menu .button3menu.connect
+       .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
+       -menu .button3menu.connect.selected
     .button3menu.connect.selected add command \
-            -label "Chain" -command "P \[selectedRealNodes\]"
+           -label "Chain" -command "P \[selectedRealNodes\]"
     .button3menu.connect.selected add command \
-            -label "Star" \
-            -command "Kb \[lindex \[selectedRealNodes\] 0\] \
-                \[lrange \[selectedNodes\] 1 end\]"
+           -label "Star" \
+           -command "Kb \[lindex \[selectedRealNodes\] 0\] \
+               \[lrange \[selectedNodes\] 1 end\]"
     .button3menu.connect.selected add command \
-            -label "Cycle" -command "C \[selectedRealNodes\]"
+           -label "Cycle" -command "C \[selectedRealNodes\]"
     .button3menu.connect.selected add command \
-            -label "Clique" -command "K \[selectedRealNodes\]"
+           -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
+       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
-        }
+       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
+       }
     }
 
     #
@@ -1144,42 +1144,42 @@ proc button3node { c x y } {
     #
     .button3menu.moveto delete 0 end
     if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } {
-        .button3menu add cascade -label "Move to" \
-            -menu .button3menu.moveto -state disabled
+       .button3menu add cascade -label "Move to" \
+           -menu .button3menu.moveto -state disabled
     } else {
-        .button3menu add cascade -label "Move to" \
-            -menu .button3menu.moveto
+       .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
-        }
+       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"
+       [getNodeCanvas $mirror_node] == $curcanvas } {
+       .button3menu add command -label "Merge" \
+           -command "mergeGUINode $node"
     } else {
-        .button3menu add command -label "Merge" -state disabled
+       .button3menu add command -label "Merge" -state disabled
     }
 
     #
     # Delete selection
     #
     if { $oper_mode != "exec" } {
-        .button3menu add command -label "Delete" -command deleteSelection
+       .button3menu add command -label "Delete" -command deleteSelection
     } else {
-        .button3menu add command -label "Delete" -state disabled
+       .button3menu add command -label "Delete" -state disabled
     }
 
     #
@@ -1187,18 +1187,18 @@ proc button3node { c x y } {
     #
     .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 != "" } {
-            .button3menu.shell add command -label "$cmd" \
-                -command "spawnShell $node $cmd"
-        }
-        .button3menu.shell add command -label "/bin/sh" \
-            -command "spawnShell $node /bin/sh"
+       .button3menu add cascade -label "Shell window" \
+           -menu .button3menu.shell
+       set cmd [[typemodel $node].shellcmd $node]
+       if { $cmd != "/bin/sh" && $cmd != "" } {
+           .button3menu.shell add command -label "$cmd" \
+               -command "spawnShell $node $cmd"
+       }
+       .button3menu.shell add command -label "/bin/sh" \
+           -command "spawnShell $node /bin/sh"
     } else {
-        .button3menu add cascade -label "Shell window" \
-            -menu .button3menu.shell -state disabled
+       .button3menu add cascade -label "Shell window" \
+           -menu .button3menu.shell -state disabled
     }
 
     #
@@ -1206,30 +1206,30 @@ proc button3node { c x y } {
     #
     .button3menu.ethereal delete 0 end
     if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } {
-        .button3menu add cascade -label "Ethereal" \
-            -menu .button3menu.ethereal
-        foreach ifc [ifcList $node] {
-            set label "$ifc"
-            if { [getIfcIPv4addr $node $ifc] != "" } {
-                set label "$label ([getIfcIPv4addr $node $ifc])"
-            }
-            if { [getIfcIPv6addr $node $ifc] != "" } {
-                set label "$label ([getIfcIPv6addr $node $ifc])"
-            }
-            .button3menu.ethereal add command -label $label \
-                -command "startethereal $node $ifc"
-        }
-        .button3menu add command -label Start \
-            -command "[typemodel $node].start $eid $node"
-        .button3menu add command -label Stop \
-            -command "[typemodel $node].shutdown $eid $node" 
+       .button3menu add cascade -label "Ethereal" \
+           -menu .button3menu.ethereal
+       foreach ifc [ifcList $node] {
+           set label "$ifc"
+           if { [getIfcIPv4addr $node $ifc] != "" } {
+               set label "$label ([getIfcIPv4addr $node $ifc])"
+           }
+           if { [getIfcIPv6addr $node $ifc] != "" } {
+               set label "$label ([getIfcIPv6addr $node $ifc])"
+           }
+           .button3menu.ethereal add command -label $label \
+               -command "startethereal $node $ifc"
+       }
+       .button3menu add command -label Start \
+           -command "[typemodel $node].start $eid $node"
+       .button3menu add command -label Stop \
+           -command "[typemodel $node].shutdown $eid $node" 
     } else {
-        .button3menu add cascade -label "Ethereal" \
-            -menu .button3menu.ethereal -state disabled
-        .button3menu add command -label start \
-            -command "[typemodel $node].start $eid $node" -state disabled
-        .button3menu add command -label stop \
-            -command "[typemodel $node].stop $eid $node" -state disabled 
+       .button3menu add cascade -label "Ethereal" \
+           -menu .button3menu.ethereal -state disabled
+       .button3menu add command -label start \
+           -command "[typemodel $node].start $eid $node" -state disabled
+       .button3menu add command -label stop \
+           -command "[typemodel $node].stop $eid $node" -state disabled 
     }
 
     #
@@ -1260,18 +1260,18 @@ proc spawnShell { node cmd } {
     set node_id $eid\_$node
 
     if { $remote_exec } {
-        nexec vimageShellServer.sh $node_id 1234 $cmd &
-        if { $gui_unix } {
-            exec xterm -sb -rightbar \
-                    -T "IMUNES: [getNodeName $node] (console)" \
-                    -e "nc $exec_host 1234" &
-        } else {
-            exec cmd /c nc $exec_host 1234 &
-        }
+       nexec vimageShellServer.sh $node_id 1234 $cmd &
+       if { $gui_unix } {
+           exec xterm -sb -rightbar \
+                   -T "IMUNES: [getNodeName $node] (console)" \
+                   -e "nc $exec_host 1234" &
+       } else {
+           exec cmd /c nc $exec_host 1234 &
+       }
     } else {
-        nexec xterm -sb -rightbar \
-                -T "IMUNES: [getNodeName $node] (console)" \
-                -e "vimage $node_id $cmd" &
+       nexec xterm -sb -rightbar \
+               -T "IMUNES: [getNodeName $node] (console)" \
+               -e "vimage $node_id $cmd" &
     }
 }
 
@@ -1331,123 +1331,123 @@ proc button1 { c x y button } {
     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 \
-        [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"
-            }
-        } elseif { !$wasselected } {
-            $c dtag node selected
-            $c delete -withtags selectmark
-        }
-        if { $activetool == "select" && !$wasselected} {
-            selectNode $c $curobj
-        }
+        $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"
+           }
+       } 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]
+       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 {$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
-            }
-        }
+           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
+       $c dtag node selected
+       $c delete -withtags selectmark
     }
     if { [lsearch [.c gettags $curobj] background] != -1  ||
-         [lsearch [.c gettags $curobj] grid] != -1 } {
-        if { [lsearch {select link oval rectangle text} $activetool] < 0 } {
-            set node [newNode $activetool]
-            setNodeCanvas $node $curcanvas
-            setNodeCoords $node "[expr {$x / $zoom}] [expr {$y / $zoom}]"
-            set dy 32
-            if { [lsearch {router hub lanswitch rj45} $activetool] >= 0 } {
-                set dy 24
-            }
-            setNodeLabelCoords $node "[expr {$x / $zoom}] \
-                [expr {$y / $zoom + $dy}]"
-            drawNode $node
-            selectNode $c [$c find withtag "node && $node"]
-            set changed 1
-        } 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 ""
-            }
-        } elseif { $activetool == "oval" || $activetool == "rectangle" } {
-            $c config -cursor cross
-            set lastX $x
-            set lastY $y
-        } elseif { $activetool == "text" } {
-            $c config -cursor xterm
-            set lastX $x
-            set lastY $y
-        }
+        [lsearch [.c gettags $curobj] grid] != -1 } {
+       if { [lsearch {select link oval rectangle text} $activetool] < 0 } {
+           set node [newNode $activetool]
+           setNodeCanvas $node $curcanvas
+           setNodeCoords $node "[expr {$x / $zoom}] [expr {$y / $zoom}]"
+           set dy 32
+           if { [lsearch {router hub lanswitch rj45} $activetool] >= 0 } {
+               set dy 24
+           }
+           setNodeLabelCoords $node "[expr {$x / $zoom}] \
+               [expr {$y / $zoom + $dy}]"
+           drawNode $node
+           selectNode $c [$c find withtag "node && $node"]
+           set changed 1
+       } 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 ""
+           }
+       } elseif { $activetool == "oval" || $activetool == "rectangle" } {
+           $c config -cursor cross
+           set lastX $x
+           set lastY $y
+       } elseif { $activetool == "text" } {
+           $c config -cursor xterm
+           set lastX $x
+           set lastY $y
+       }
     } else {
-        if {$curtype == "node" || $curtype == "nodelabel"} {
-            $c config -cursor fleur
-        }
-        if {$activetool == "link" && $curtype == "node"} {
-            $c config -cursor cross
-            set lastX [lindex [$c coords $curobj] 0]
-            set lastY [lindex [$c coords $curobj] 1]
-            set newlink [$c create line $lastX $lastY $x $y \
-                -fill $defLinkColor -width $defLinkWidth \
-                    -tags "link"]
-        }
+       if {$curtype == "node" || $curtype == "nodelabel"} {
+           $c config -cursor fleur
+       }
+       if {$activetool == "link" && $curtype == "node"} {
+           $c config -cursor cross
+           set lastX [lindex [$c coords $curobj] 0]
+           set lastY [lindex [$c coords $curobj] 1]
+           set newlink [$c create line $lastX $lastY $x $y \
+               -fill $defLinkColor -width $defLinkWidth \
+                   -tags "link"]
+       }
     }
 
     raiseAll $c
@@ -1479,126 +1479,126 @@ proc button1-motion { c x y } {
     set curobj [$c find withtag current]
     set curtype [lindex [$c gettags current] 0]
     if {$activetool == "link" && $newlink != ""} {
-        $c coords $newlink $lastX $lastY $x $y
+       $c coords $newlink $lastX $lastY $x $y
     } elseif { $activetool == "select" && \
-        ( $curobj == $selectbox || $curtype == "background" || $curtype == "grid")} {
+       ( $curobj == $selectbox || $curtype == "background" || $curtype == "grid")} {
     if {$selectbox == ""} {
-        set selectbox [$c create line \
-            $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY \
-            -dash {10 4} -fill black -width 1 -tags "selectbox"]
-        $c raise $selectbox "background || link || linklabel || interface"
-        } else {
-            $c coords $selectbox \
-                $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY
-        }
+       set selectbox [$c create line \
+           $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY \
+           -dash {10 4} -fill black -width 1 -tags "selectbox"]
+       $c raise $selectbox "background || link || linklabel || interface"
+       } else {
+           $c coords $selectbox \
+               $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY
+       }
     } elseif { $activetool == "select" && $curtype == "text" } {
-        $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}]
-        set changed 1
-        set lastX $x
-        set lastY $y
-        $c delete [$c find withtag "selectmark"]
+       $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}]
+       set changed 1
+       set lastX $x
+       set lastY $y
+       $c delete [$c find withtag "selectmark"]
     } elseif { $activetool == "select" && $curtype == "nodelabel" \
-        && [nodeType [lindex [$c gettags $curobj] 1]] != "pseudo" } {
-        $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}]
-        set changed 1
-        set lastX $x
-        set lastY $y
-                        # actually we should check if curobj==bkgImage
+       && [nodeType [lindex [$c gettags $curobj] 1]] != "pseudo" } {
+       $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}]
+       set changed 1
+       set lastX $x
+       set lastY $y
+                       # actually we should check if curobj==bkgImage
     } elseif { $activetool == "oval" && \
       ( $curobj == $newoval || $curobj == $background || $curtype == "background" || $curtype == "grid")} {
       # Draw a new oval
-        if {$newoval == ""} {
-            set newoval [$c create oval $lastX $lastY $x $y \
-                        -dash {10 4} -width 1 -tags "newoval"]
-            $c raise $newoval "background || link || linklabel || interface"
-        } else {
-            $c coords $newoval \
-                $lastX $lastY $x $y
-        }
-                        # actually we should check if curobj==bkgImage
+       if {$newoval == ""} {
+           set newoval [$c create oval $lastX $lastY $x $y \
+                       -dash {10 4} -width 1 -tags "newoval"]
+           $c raise $newoval "background || link || linklabel || interface"
+       } else {
+           $c coords $newoval \
+               $lastX $lastY $x $y
+       }
+                       # actually we should check if curobj==bkgImage
     } elseif { $activetool == "rectangle" && \
       ( $curobj == $newrect || $curobj == $background || $curtype == "background") || $curtype == "grid"} {
       # Draw a new rectangle
-        if {$newrect == ""} {
-            set newrect [$c create rectangle $lastX $lastY $x $y \
-                        -outline blue \
-                        -dash {10 4} -width 1 -tags "newrect"]
-            $c raise $newrect "oval || background || link || linklabel || interface"
-        } else {
-            $c coords $newrect $lastX $lastY $x $y
-        }
+       if {$newrect == ""} {
+           set newrect [$c create rectangle $lastX $lastY $x $y \
+                       -outline blue \
+                       -dash {10 4} -width 1 -tags "newrect"]
+           $c raise $newrect "oval || background || link || linklabel || interface"
+       } else {
+           $c coords $newrect $lastX $lastY $x $y
+       }
     } elseif { $curtype == "selectmark" } {
-        foreach o [$c find withtag "selected"] { 
-            set node [lindex [$c gettags $o] 1]
-            set tagovi [$c gettags $o]
-            set koord [getNodeCoords $node]
-
-            set oldX1 [lindex $koord 0]
-            set oldY1 [lindex $koord 1]
-            set oldX2 [lindex $koord 2]
-            set oldY2 [lindex $koord 3]
-            switch -exact -- $resizemode {
-                lu {
-                    set oldX1 $x
-                    set oldY1 $y
-                }
-                ld {
-                    set oldX1 $x
-                    set oldY2 $y
-                }
-                l {
-                    set oldX1 $x
-                }
-                ru {
-                    set oldX2 $x
-                    set oldY1 $y
-                }
-                rd {
-                    set oldX2 $x
-                    set oldY2 $y
-                }
-                r {
-                    set oldX2 $x
-                }
-                u {
-                    set oldY1 $y
-                }
-                d {
-                    set oldY2 $y
-                }
-            }
-            if {$selectbox == ""} {
-                set selectbox [$c create line \
-                    $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 $oldY2 $oldX1 $oldY1 \
-                    -dash {10 4} -fill black -width 1 -tags "selectbox"]
-                $c raise $selectbox "background || link || linklabel || interface"
-            } else {
-                $c coords $selectbox \
-                    $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 $oldY2 $oldX1 $oldY1
-            }
-        }
+       foreach o [$c find withtag "selected"] { 
+           set node [lindex [$c gettags $o] 1]
+           set tagovi [$c gettags $o]
+           set koord [getNodeCoords $node]
+
+           set oldX1 [lindex $koord 0]
+           set oldY1 [lindex $koord 1]
+           set oldX2 [lindex $koord 2]
+           set oldY2 [lindex $koord 3]
+           switch -exact -- $resizemode {
+               lu {
+                   set oldX1 $x
+                   set oldY1 $y
+               }
+               ld {
+                   set oldX1 $x
+                   set oldY2 $y
+               }
+               l {
+                   set oldX1 $x
+               }
+               ru {
+                   set oldX2 $x
+                   set oldY1 $y
+               }
+               rd {
+                   set oldX2 $x
+                   set oldY2 $y
+               }
+               r {
+                   set oldX2 $x
+               }
+               u {
+                   set oldY1 $y
+               }
+               d {
+                   set oldY2 $y
+               }
+           }
+           if {$selectbox == ""} {
+               set selectbox [$c create line \
+                   $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 $oldY2 $oldX1 $oldY1 \
+                   -dash {10 4} -fill black -width 1 -tags "selectbox"]
+               $c raise $selectbox "background || link || linklabel || interface"
+           } else {
+               $c coords $selectbox \
+                   $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 $oldY2 $oldX1 $oldY1
+           }
+       }
     } else {
-        foreach img [$c find withtag "selected"] {
-            set node [lindex [$c gettags $img] 1]
-            set img [$c find withtag "selectmark && $node"]
-            if {$curtype == "oval" || $curtype == "rectangle"} {
-                $c move $img [expr {($x - $lastX) / 2}] [expr {($y - $lastY) / 2}]
-            } else {
-                $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
-                set img [$c find withtag "node && $node"]
-                $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
-                set img [$c find withtag "nodelabel && $node"]
-                $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
-                $c addtag need_redraw withtag "link && $node"
-            }
-        }
-        foreach link [$c find withtag "link && need_redraw"] {
-            redrawLink [lindex [$c gettags $link] 1]
-        }
-        $c dtag link need_redraw
-        set changed 1
-        set lastX $x
-        set lastY $y
+       foreach img [$c find withtag "selected"] {
+           set node [lindex [$c gettags $img] 1]
+           set img [$c find withtag "selectmark && $node"]
+           if {$curtype == "oval" || $curtype == "rectangle"} {
+               $c move $img [expr {($x - $lastX) / 2}] [expr {($y - $lastY) / 2}]
+           } else {
+               $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
+               set img [$c find withtag "node && $node"]
+               $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
+               set img [$c find withtag "nodelabel && $node"]
+               $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}]
+               $c addtag need_redraw withtag "link && $node"
+           }
+       }
+       foreach link [$c find withtag "link && need_redraw"] {
+           redrawLink [lindex [$c gettags $link] 1]
+       }
+       $c dtag link need_redraw
+       set changed 1
+       set lastX $x
+       set lastY $y
     }
 }
 
@@ -1637,23 +1637,23 @@ proc newGUILink { lnode1 lnode2 } {
 
     set link [newLink $lnode1 $lnode2]
     if { $link == "" } {
-        return
+       return
     }
     if { [getNodeCanvas $lnode1] != [getNodeCanvas $lnode2] } {
-        set new_nodes [splitLink $link pseudo]
-        set orig_nodes [linkPeers $link]
-        set new_node1 [lindex $new_nodes 0]
-        set new_node2 [lindex $new_nodes 1]
-        set orig_node1 [lindex $orig_nodes 0]
-        set orig_node2 [lindex $orig_nodes 1]
-        set new_link1 [linkByPeers $orig_node1 $new_node1]
-        set new_link2 [linkByPeers $orig_node2 $new_node2]
-        setNodeMirror $new_node1 $new_node2
-        setNodeMirror $new_node2 $new_node1
-        setNodeName $new_node1 $orig_node2
-        setNodeName $new_node2 $orig_node1
-        setLinkMirror $new_link1 $new_link2
-        setLinkMirror $new_link2 $new_link1
+       set new_nodes [splitLink $link pseudo]
+       set orig_nodes [linkPeers $link]
+       set new_node1 [lindex $new_nodes 0]
+       set new_node2 [lindex $new_nodes 1]
+       set orig_node1 [lindex $orig_nodes 0]
+       set orig_node2 [lindex $orig_nodes 1]
+       set new_link1 [linkByPeers $orig_node1 $new_node1]
+       set new_link2 [linkByPeers $orig_node2 $new_node2]
+       setNodeMirror $new_node1 $new_node2
+       setNodeMirror $new_node2 $new_node1
+       setNodeName $new_node1 $orig_node2
+       setNodeName $new_node2 $orig_node1
+       setLinkMirror $new_link1 $new_link2
+       setLinkMirror $new_link2 $new_link1
     }
     redrawAll
     set changed 1
@@ -1689,147 +1689,147 @@ proc button1-release { c x y } {
 
     $c config -cursor left_ptr
     if {$activetool == "link" && $newlink != ""} {
-        $c delete $newlink
-        set newlink ""
-        set destobj ""
-        foreach obj [$c find overlapping $x $y $x $y] {
-            if {[lindex [$c gettags $obj] 0] == "node"} {
-                set destobj $obj
-                break
-            }
-        }
-        if {$destobj != "" && $curobj != "" && $destobj != $curobj} {
-            set lnode1 [lindex [$c gettags $curobj] 1]
-            set lnode2 [lindex [$c gettags $destobj] 1]
-            if { [ifcByLogicalPeer $lnode1 $lnode2] == "" } {
-                set link [newLink $lnode1 $lnode2]
-                if { $link != "" } {
-                    drawLink $link
-                    redrawLink $link
-                    updateLinkLabel $link
-                    set changed 1
-                }
-            }
-        }
+       $c delete $newlink
+       set newlink ""
+       set destobj ""
+       foreach obj [$c find overlapping $x $y $x $y] {
+           if {[lindex [$c gettags $obj] 0] == "node"} {
+               set destobj $obj
+               break
+           }
+       }
+       if {$destobj != "" && $curobj != "" && $destobj != $curobj} {
+           set lnode1 [lindex [$c gettags $curobj] 1]
+           set lnode2 [lindex [$c gettags $destobj] 1]
+           if { [ifcByLogicalPeer $lnode1 $lnode2] == "" } {
+               set link [newLink $lnode1 $lnode2]
+               if { $link != "" } {
+                   drawLink $link
+                   redrawLink $link
+                   updateLinkLabel $link
+                   set changed 1
+               }
+           }
+       }
     } elseif {$activetool == "rectangle" } {
-        popupRectDialog $c 0 "false" "" "" ""
+       popupRectDialog $c 0 "false" "" "" ""
     } elseif {$activetool == "oval" } {
-        popupOvalDialog $c 0 "false" "" "" ""
+       popupOvalDialog $c 0 "false" "" "" ""
     } elseif {$activetool == "text" } {
-        textEnter $c $x $y
+       textEnter $c $x $y
     }
 
     if { $changed == 1 } {
-        set regular true
-        if { [lindex [$c gettags $curobj] 0] == "nodelabel" } {
-            set node [lindex [$c gettags $curobj] 1]
-            selectNode $c [$c find withtag "node && $node"]
-        }
-        set selected {}
-        foreach img [$c find withtag "selected"] {
-            set node [lindex [$c gettags $img] 1]
-            lappend selected $node
-            set coords [$c coords $img]
-            set x [expr {[lindex $coords 0] / $zoom}]
-            set y [expr {[lindex $coords 1] / $zoom}]
-            if { $autorearrange_enabled == 0} {
-                set dx [expr {(int($x / $grid + 0.5) * $grid - $x) * $zoom}]
-                set dy [expr {(int($y / $grid + 0.5) * $grid - $y) * $zoom}]
-                $c move $img $dx $dy
-                set coords [$c coords $img]
-                set x [expr {[lindex $coords 0] / $zoom}]
-                set y [expr {[lindex $coords 1] / $zoom}]
-            } else {
-                set dx 0
-                set dy 0
-            }
-            setNodeCoords $node "$x $y"
-            if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} {
-                set regular false
-            }
-            if { [lindex [$c gettags $node] 0] == "oval" ||
-                 [lindex [$c gettags $node] 0] == "rectangle" } {
-                set bbox [$c bbox "selectmark && $node"]
-                setNodeCoords $node "$bbox"
-                set redrawNeeded 1
-            }
-            if {[$c find withtag "nodelabel && $node"] != "" } {
-                $c move "nodelabel && $node" $dx $dy
-                set coords [$c coords "nodelabel && $node"]
-                set x [expr {[lindex $coords 0] / $zoom}]
-                set y [expr {[lindex $coords 1] / $zoom}]
-                setNodeLabelCoords $node "$x $y"
-                if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} {
-                    set regular false
-                }
-            }
-            $c move "selectmark && $node" $dx $dy
-            $c addtag need_redraw withtag "link && $node"
-            set changed 1
-        } ;# end of: foreach img selected
-        if {$regular == "true"} {
-            foreach link [$c find withtag "link && need_redraw"] {
-                redrawLink [lindex [$c gettags $link] 1]
-            }
-        } else {
-            .c config -cursor watch
-            loadCfg $undolog($undolevel)
-            redrawAll
-            if {$activetool == "select" } {
-                selectNodes $selected
-            }
-            set changed 0
-        }
-        $c dtag link need_redraw
+       set regular true
+       if { [lindex [$c gettags $curobj] 0] == "nodelabel" } {
+           set node [lindex [$c gettags $curobj] 1]
+           selectNode $c [$c find withtag "node && $node"]
+       }
+       set selected {}
+       foreach img [$c find withtag "selected"] {
+           set node [lindex [$c gettags $img] 1]
+           lappend selected $node
+           set coords [$c coords $img]
+           set x [expr {[lindex $coords 0] / $zoom}]
+           set y [expr {[lindex $coords 1] / $zoom}]
+           if { $autorearrange_enabled == 0} {
+               set dx [expr {(int($x / $grid + 0.5) * $grid - $x) * $zoom}]
+               set dy [expr {(int($y / $grid + 0.5) * $grid - $y) * $zoom}]
+               $c move $img $dx $dy
+               set coords [$c coords $img]
+               set x [expr {[lindex $coords 0] / $zoom}]
+               set y [expr {[lindex $coords 1] / $zoom}]
+           } else {
+               set dx 0
+               set dy 0
+           }
+           setNodeCoords $node "$x $y"
+           if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} {
+               set regular false
+           }
+           if { [lindex [$c gettags $node] 0] == "oval" ||
+                [lindex [$c gettags $node] 0] == "rectangle" } {
+               set bbox [$c bbox "selectmark && $node"]
+               setNodeCoords $node "$bbox"
+               set redrawNeeded 1
+           }
+           if {[$c find withtag "nodelabel && $node"] != "" } {
+               $c move "nodelabel && $node" $dx $dy
+               set coords [$c coords "nodelabel && $node"]
+               set x [expr {[lindex $coords 0] / $zoom}]
+               set y [expr {[lindex $coords 1] / $zoom}]
+               setNodeLabelCoords $node "$x $y"
+               if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} {
+                   set regular false
+               }
+           }
+           $c move "selectmark && $node" $dx $dy
+           $c addtag need_redraw withtag "link && $node"
+           set changed 1
+       } ;# end of: foreach img selected
+       if {$regular == "true"} {
+           foreach link [$c find withtag "link && need_redraw"] {
+               redrawLink [lindex [$c gettags $link] 1]
+           }
+       } else {
+           .c config -cursor watch
+           loadCfg $undolog($undolevel)
+           redrawAll
+           if {$activetool == "select" } {
+               selectNodes $selected
+           }
+           set changed 0
+       }
+       $c dtag link need_redraw
 
     # $changed!=1
     } elseif {$activetool == "select" } { 
-        if {$selectbox == ""} {
-            set x1 $x
-            set y1 $y
-            set autorearrange_enabled 0
-        } else {
-            set coords [$c coords $selectbox]
-            set x [lindex $coords 0]
-            set y [lindex $coords 1]
-            set x1 [lindex $coords 4]
-            set y1 [lindex $coords 5]
-            $c delete $selectbox
-            set selectbox ""
-        }
-
-        if { $resizemode == "false" } {
-            set enclosed {}
-            foreach obj [$c find enclosed $x $y $x1 $y1] {
-                set tags [$c gettags $obj]
-                if {[lindex $tags 0] == "node" && [lsearch $tags selected] == -1} {
-                    lappend enclosed $obj
-                }
-                if {[lindex $tags 0] == "oval" && [lsearch $tags selected] == -1} {
-                    lappend enclosed $obj
-                }
-                if {[lindex $tags 0] == "rectangle" && [lsearch $tags selected] == -1} {
-                    lappend enclosed $obj
-                }
-                if {[lindex $tags 0] == "text" && [lsearch $tags selected] == -1} {
-                    lappend enclosed $obj
-                }
-            }
-            foreach obj $enclosed {
-                selectNode $c $obj
-            }
-        } else {
-           setNodeCoords $resizeobj "$x $y $x1 $y1"
-           set redrawNeeded 1
-           set resizemode false
-        }
+       if {$selectbox == ""} {
+           set x1 $x
+           set y1 $y
+           set autorearrange_enabled 0
+       } else {
+           set coords [$c coords $selectbox]
+           set x [lindex $coords 0]
+           set y [lindex $coords 1]
+           set x1 [lindex $coords 4]
+           set y1 [lindex $coords 5]
+           $c delete $selectbox
+           set selectbox ""
+       }
+
+       if { $resizemode == "false" } {
+           set enclosed {}
+           foreach obj [$c find enclosed $x $y $x1 $y1] {
+               set tags [$c gettags $obj]
+               if {[lindex $tags 0] == "node" && [lsearch $tags selected] == -1} {
+                   lappend enclosed $obj
+               }
+               if {[lindex $tags 0] == "oval" && [lsearch $tags selected] == -1} {
+                   lappend enclosed $obj
+               }
+               if {[lindex $tags 0] == "rectangle" && [lsearch $tags selected] == -1} {
+                   lappend enclosed $obj
+               }
+               if {[lindex $tags 0] == "text" && [lsearch $tags selected] == -1} {
+                   lappend enclosed $obj
+               }
+           }
+           foreach obj $enclosed {
+               selectNode $c $obj
+           }
+       } else {
+          setNodeCoords $resizeobj "$x $y $x1 $y1"
+          set redrawNeeded 1
+          set resizemode false
+       }
     }
 
     if { $redrawNeeded } {
-        set redrawNeeded 0
-        redrawAll
+       set redrawNeeded 0
+       redrawAll
     } else {
-        raiseAll $c
+       raiseAll $c
     }
     update
     updateUndoLog
@@ -1870,14 +1870,14 @@ proc nodeEnter { c } {
     set name [getNodeName $node]
     set model [getNodeModel $node]
     if { $model != "" } {
-        set line "{$node} $name ($model):"
+       set line "{$node} $name ($model):"
     } else {
-        set line "{$node} $name:"
+       set line "{$node} $name:"
     }
     if { $type != "rj45" } {
-        foreach ifc [ifcList $node] {
-            set line "$line $ifc:[getIfcIPv4addr $node $ifc]"
-        }
+       foreach ifc [ifcList $node] {
+           set line "$line $ifc:[getIfcIPv4addr $node $ifc]"
+       }
     }
     .bottom.textbox config -text "$line"
 }
@@ -1901,7 +1901,7 @@ proc linkEnter {c} {
 
     set link [lindex [$c gettags current] 1]
     if { [lsearch $link_list $link] == -1 } {
-        return
+       return
     }
     set line "$link: [getLinkBandwidthString $link] [getLinkDelayString $link]"
     .bottom.textbox config -text "$line"
@@ -1943,17 +1943,17 @@ proc anyLeave {c} {
 #****
 proc checkIntRange { str low high } {
     if { $str == "" } {
-        return 1
+       return 1
     }
     set str [string trimleft $str 0]
     if { $str == "" } {
-        set str 0
+       set str 0
     }
     if { ![string is integer $str] } {
-        return 0
+       return 0
     }
     if { $str < $low || $str > $high } {
-        return 0
+       return 0
     }
     return 1
 }
@@ -1980,22 +1980,22 @@ proc focusAndFlash {W {count 9}} {
     set bg white
 
     if { $badentry == -1 } {
-        return
+       return
     } else {
-        set badentry 1
+       set badentry 1
     }
 
     focus -force $W
     if {$count<1} {
-        $W configure -foreground $fg -background $bg
-        set badentry 0
+       $W configure -foreground $fg -background $bg
+       set badentry 0
     } else {
-        if {$count%2} {
-            $W configure -foreground $bg -background $fg
-        } else {
-            $W configure -foreground $fg -background $bg
-        }
-        after 200 [list focusAndFlash $W [expr {$count - 1}]]
+       if {$count%2} {
+           $W configure -foreground $bg -background $fg
+       } else {
+           $W configure -foreground $fg -background $bg
+       }
+       after 200 [list focusAndFlash $W [expr {$count - 1}]]
     }
 }
 
@@ -2026,391 +2026,391 @@ proc popupConfigDialog { c } {
     set tk_type [lindex [$c gettags current] 0]
     set target [lindex [$c gettags current] 1]
     if { [lsearch {node nodelabel interface} $tk_type] > -1 } {
-        set object_type node
+       set object_type node
     }
     if { [lsearch {link linklabel} $tk_type] > -1 } {
-        set object_type link
+       set object_type link
     }
     if { [lsearch {oval} $tk_type] > -1 } {
-        set object_type oval
+       set object_type oval
     }
     if { [lsearch {rectangle} $tk_type] > -1 } {
-        set object_type rectangle
+       set object_type rectangle
     }
     if { [lsearch {text} $tk_type] > -1 } {
-        set object_type text
+       set object_type text
     }
     if { "$object_type" == ""} {
-        destroy $wi
-        return
+       destroy $wi
+       return
     }
     if { $object_type == "link" } {
-        set n0 [lindex [linkPeers $target] 0]
-        set n1 [lindex [linkPeers $target] 1]
-        if { [nodeType $n0] == "rj45" || [nodeType $n1] == "rj45" } {
-            destroy $wi
-            return
-        }
+       set n0 [lindex [linkPeers $target] 0]
+       set n1 [lindex [linkPeers $target] 1]
+       if { [nodeType $n0] == "rj45" || [nodeType $n1] == "rj45" } {
+           destroy $wi
+           return
+       }
     }
     $c dtag node selected
     $c delete -withtags selectmark
 
     switch -exact -- $object_type {
     node {
-        set type [nodeType $target]
-        if { $type == "pseudo" } {
-            #
-            # Hyperlink to another canvas
-            #
-            destroy $wi
-            set curcanvas [getNodeCanvas [getNodeMirror $target]]
-            switchCanvas none
-            return
-        }
-        set model [getNodeModel $target]
-        set router_model $model
-        wm title $wi "$type configuration"
-        frame $wi.ftop -borderwidth 4
-        if { $type == "rj45" } {
-            label $wi.ftop.name_label -text "Physical interface:"
-        } else {
-            label $wi.ftop.name_label -text "Node name:"
-        }
-        entry $wi.ftop.name -bg white -width 16 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.ftop.name insert 0 [getNodeName $target]
-        pack $wi.ftop.name $wi.ftop.name_label -side right -padx 4 -pady 4
-        pack $wi.ftop -side top
-        if { $type == "router" } {
-            frame $wi.model -borderwidth 4
-            label $wi.model.label -text "Model:"
-            if { $oper_mode == "edit" } {
-                eval tk_optionMenu $wi.model.menu router_model \
-                    $supp_router_models
-            } else {
-                tk_optionMenu $wi.model.menu router_model $model
-            }
-            pack $wi.model.menu $wi.model.label -side right -padx 0 -pady 0
-            pack $wi.model -side top
-        }
-
-        if { $type != "rj45" } {
-            foreach ifc [lsort -ascii [ifcList $target]] {
-                labelframe $wi.if$ifc -padx 4 -pady 4
-                frame $wi.if$ifc.label
-                label $wi.if$ifc.label.txt -text "Interface $ifc:"
-                pack $wi.if$ifc.label.txt -side left -anchor w
-                if {[[typemodel $target].layer] == "NETWORK"} {
-                    global ifoper$ifc
-                    set ifoper$ifc [getIfcOperState $target $ifc]
-                    radiobutton $wi.if$ifc.label.up -text "up" \
-                        -variable ifoper$ifc -value up
-                    radiobutton $wi.if$ifc.label.down -text "down" \
-                        -variable ifoper$ifc -value down
-                    label $wi.if$ifc.label.mtul -text "MTU" \
-                        -anchor e -width 5
-                    spinbox $wi.if$ifc.label.mtuv -bg white -width 4 \
-                        -validate focus -invcmd "focusAndFlash %W"
-                    $wi.if$ifc.label.mtuv insert 0 \
-                        [getIfcMTU $target $ifc]
-                    if {![string first eth $ifc]} {
-                        $wi.if$ifc.label.mtuv configure \
-                            -from 256 -to 1500 -increment 2 \
-                            -vcmd {checkIntRange %P 256 1500}
-                    } else {
-                        $wi.if$ifc.label.mtuv configure \
-                            -from 256 -to 2044 -increment 2 \
-                            -vcmd {checkIntRange %P 256 2044}
-                    }
-                    pack $wi.if$ifc.label.up $wi.if$ifc.label.down \
-                        $wi.if$ifc.label.mtul $wi.if$ifc.label.mtuv \
-                        -side left -anchor w
-                }
-                pack $wi.if$ifc.label -side top -anchor w
-                frame $wi.if$ifc.tab -width 10
-                frame $wi.if$ifc.cfg
-
-                #
-                # Queue config
-                #
-                global ifqdisc$ifc ifqdrop$ifc
-                set ifqdisc$ifc [getIfcQDisc $target $ifc]
-                set ifqdrop$ifc [getIfcQDrop $target $ifc]
-                frame $wi.if$ifc.cfg.q
-                label $wi.if$ifc.cfg.q.l1 -text "Queue" -anchor w
-                tk_optionMenu $wi.if$ifc.cfg.q.disc ifqdisc$ifc \
-                    FIFO DRR WFQ
-                tk_optionMenu $wi.if$ifc.cfg.q.drop ifqdrop$ifc \
-                    drop-tail drop-head
-                label $wi.if$ifc.cfg.q.l2 -text "len" \
-                    -anchor e -width 3
-                spinbox $wi.if$ifc.cfg.q.len -bg white -width 4 \
-                    -validate focus -invcmd "focusAndFlash %W"
-                $wi.if$ifc.cfg.q.len insert 0 [getIfcQLen $target $ifc]
-                $wi.if$ifc.cfg.q.len configure \
-                    -from 5 -to 4096 -increment 1 \
-                    -vcmd {checkIntRange %P 5 4096}
-                pack $wi.if$ifc.cfg.q.l1 $wi.if$ifc.cfg.q.disc \
-                    $wi.if$ifc.cfg.q.drop -side left -anchor w
-                pack $wi.if$ifc.cfg.q.l2 $wi.if$ifc.cfg.q.len \
-                    -side left -anchor e
-                pack $wi.if$ifc.cfg.q -side top -anchor w
-
-                if {[lsearch {router pc host} $type] >= 0} {
-                    #
-                    # IPv4 address
-                    #
-                    frame $wi.if$ifc.cfg.ipv4
-                    label $wi.if$ifc.cfg.ipv4.addrl -text "IPv4 address" \
-                        -anchor w
-                    entry $wi.if$ifc.cfg.ipv4.addrv -bg white -width 30 \
-                        -validate focus -invcmd "focusAndFlash %W"
-                    $wi.if$ifc.cfg.ipv4.addrv insert 0 \
-                        [getIfcIPv4addr $target $ifc]
-                    $wi.if$ifc.cfg.ipv4.addrv configure \
-                        -vcmd {checkIPv4Net %P}
-                    pack $wi.if$ifc.cfg.ipv4.addrl \
-                        $wi.if$ifc.cfg.ipv4.addrv -side left
-                    pack $wi.if$ifc.cfg.ipv4 -side top -anchor w
-
-                    #
-                    # IPv6 address
-                    #
-                    frame $wi.if$ifc.cfg.ipv6
-                    label $wi.if$ifc.cfg.ipv6.addrl -text "IPv6 address" \
-                        -anchor w
-                    entry $wi.if$ifc.cfg.ipv6.addrv -bg white -width 30 \
-                        -validate focus -invcmd "focusAndFlash %W"
-                    $wi.if$ifc.cfg.ipv6.addrv insert 0 \
-                        [getIfcIPv6addr $target $ifc]
-                    $wi.if$ifc.cfg.ipv6.addrv configure -vcmd {checkIPv6Net %P}
-                    pack $wi.if$ifc.cfg.ipv6.addrl \
-                        $wi.if$ifc.cfg.ipv6.addrv -side left
-                    pack $wi.if$ifc.cfg.ipv6 -side top -anchor w
-                }
-                pack $wi.if$ifc.tab $wi.if$ifc.cfg -side left
-                pack $wi.if$ifc -side top -anchor w -fill both
-            }
-        }
-
-        if {[lsearch {router pc host} $type] >= 0} {
-            #
-            # Static routes
-            #
-            set routes [concat [getStatIPv4routes $target] \
-                [getStatIPv6routes $target]]
-            labelframe $wi.statrt -padx 4 -pady 4
-            label $wi.statrt.label -text "Static routes:"
-            pack $wi.statrt.label -side top -anchor w
-            frame $wi.statrt.tab -width 10
-            frame $wi.statrt.tab1 -width 10
-            frame $wi.statrt.cfg
-            set h [expr {[llength $routes] + 1}]
-            if { $h < 2 } {
-                set h 2
-            }
-            text $wi.statrt.cfg.text -font arial -bg white \
-                -width 42 -height $h -takefocus 0
-            foreach route $routes {
-                $wi.statrt.cfg.text insert end "$route
+       set type [nodeType $target]
+       if { $type == "pseudo" } {
+           #
+           # Hyperlink to another canvas
+           #
+           destroy $wi
+           set curcanvas [getNodeCanvas [getNodeMirror $target]]
+           switchCanvas none
+           return
+       }
+       set model [getNodeModel $target]
+       set router_model $model
+       wm title $wi "$type configuration"
+       frame $wi.ftop -borderwidth 4
+       if { $type == "rj45" } {
+           label $wi.ftop.name_label -text "Physical interface:"
+       } else {
+           label $wi.ftop.name_label -text "Node name:"
+       }
+       entry $wi.ftop.name -bg white -width 16 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.ftop.name insert 0 [getNodeName $target]
+       pack $wi.ftop.name $wi.ftop.name_label -side right -padx 4 -pady 4
+       pack $wi.ftop -side top
+       if { $type == "router" } {
+           frame $wi.model -borderwidth 4
+           label $wi.model.label -text "Model:"
+           if { $oper_mode == "edit" } {
+               eval tk_optionMenu $wi.model.menu router_model \
+                   $supp_router_models
+           } else {
+               tk_optionMenu $wi.model.menu router_model $model
+           }
+           pack $wi.model.menu $wi.model.label -side right -padx 0 -pady 0
+           pack $wi.model -side top
+       }
+
+       if { $type != "rj45" } {
+           foreach ifc [lsort -ascii [ifcList $target]] {
+               labelframe $wi.if$ifc -padx 4 -pady 4
+               frame $wi.if$ifc.label
+               label $wi.if$ifc.label.txt -text "Interface $ifc:"
+               pack $wi.if$ifc.label.txt -side left -anchor w
+               if {[[typemodel $target].layer] == "NETWORK"} {
+                   global ifoper$ifc
+                   set ifoper$ifc [getIfcOperState $target $ifc]
+                   radiobutton $wi.if$ifc.label.up -text "up" \
+                       -variable ifoper$ifc -value up
+                   radiobutton $wi.if$ifc.label.down -text "down" \
+                       -variable ifoper$ifc -value down
+                   label $wi.if$ifc.label.mtul -text "MTU" \
+                       -anchor e -width 5
+                   spinbox $wi.if$ifc.label.mtuv -bg white -width 4 \
+                       -validate focus -invcmd "focusAndFlash %W"
+                   $wi.if$ifc.label.mtuv insert 0 \
+                       [getIfcMTU $target $ifc]
+                   if {![string first eth $ifc]} {
+                       $wi.if$ifc.label.mtuv configure \
+                           -from 256 -to 1500 -increment 2 \
+                           -vcmd {checkIntRange %P 256 1500}
+                   } else {
+                       $wi.if$ifc.label.mtuv configure \
+                           -from 256 -to 2044 -increment 2 \
+                           -vcmd {checkIntRange %P 256 2044}
+                   }
+                   pack $wi.if$ifc.label.up $wi.if$ifc.label.down \
+                       $wi.if$ifc.label.mtul $wi.if$ifc.label.mtuv \
+                       -side left -anchor w
+               }
+               pack $wi.if$ifc.label -side top -anchor w
+               frame $wi.if$ifc.tab -width 10
+               frame $wi.if$ifc.cfg
+
+               #
+               # Queue config
+               #
+               global ifqdisc$ifc ifqdrop$ifc
+               set ifqdisc$ifc [getIfcQDisc $target $ifc]
+               set ifqdrop$ifc [getIfcQDrop $target $ifc]
+               frame $wi.if$ifc.cfg.q
+               label $wi.if$ifc.cfg.q.l1 -text "Queue" -anchor w
+               tk_optionMenu $wi.if$ifc.cfg.q.disc ifqdisc$ifc \
+                   FIFO DRR WFQ
+               tk_optionMenu $wi.if$ifc.cfg.q.drop ifqdrop$ifc \
+                   drop-tail drop-head
+               label $wi.if$ifc.cfg.q.l2 -text "len" \
+                   -anchor e -width 3
+               spinbox $wi.if$ifc.cfg.q.len -bg white -width 4 \
+                   -validate focus -invcmd "focusAndFlash %W"
+               $wi.if$ifc.cfg.q.len insert 0 [getIfcQLen $target $ifc]
+               $wi.if$ifc.cfg.q.len configure \
+                   -from 5 -to 4096 -increment 1 \
+                   -vcmd {checkIntRange %P 5 4096}
+               pack $wi.if$ifc.cfg.q.l1 $wi.if$ifc.cfg.q.disc \
+                   $wi.if$ifc.cfg.q.drop -side left -anchor w
+               pack $wi.if$ifc.cfg.q.l2 $wi.if$ifc.cfg.q.len \
+                   -side left -anchor e
+               pack $wi.if$ifc.cfg.q -side top -anchor w
+
+               if {[lsearch {router pc host} $type] >= 0} {
+                   #
+                   # IPv4 address
+                   #
+                   frame $wi.if$ifc.cfg.ipv4
+                   label $wi.if$ifc.cfg.ipv4.addrl -text "IPv4 address" \
+                       -anchor w
+                   entry $wi.if$ifc.cfg.ipv4.addrv -bg white -width 30 \
+                       -validate focus -invcmd "focusAndFlash %W"
+                   $wi.if$ifc.cfg.ipv4.addrv insert 0 \
+                       [getIfcIPv4addr $target $ifc]
+                   $wi.if$ifc.cfg.ipv4.addrv configure \
+                       -vcmd {checkIPv4Net %P}
+                   pack $wi.if$ifc.cfg.ipv4.addrl \
+                       $wi.if$ifc.cfg.ipv4.addrv -side left
+                   pack $wi.if$ifc.cfg.ipv4 -side top -anchor w
+
+                   #
+                   # IPv6 address
+                   #
+                   frame $wi.if$ifc.cfg.ipv6
+                   label $wi.if$ifc.cfg.ipv6.addrl -text "IPv6 address" \
+                       -anchor w
+                   entry $wi.if$ifc.cfg.ipv6.addrv -bg white -width 30 \
+                       -validate focus -invcmd "focusAndFlash %W"
+                   $wi.if$ifc.cfg.ipv6.addrv insert 0 \
+                       [getIfcIPv6addr $target $ifc]
+                   $wi.if$ifc.cfg.ipv6.addrv configure -vcmd {checkIPv6Net %P}
+                   pack $wi.if$ifc.cfg.ipv6.addrl \
+                       $wi.if$ifc.cfg.ipv6.addrv -side left
+                   pack $wi.if$ifc.cfg.ipv6 -side top -anchor w
+               }
+               pack $wi.if$ifc.tab $wi.if$ifc.cfg -side left
+               pack $wi.if$ifc -side top -anchor w -fill both
+           }
+       }
+
+       if {[lsearch {router pc host} $type] >= 0} {
+           #
+           # Static routes
+           #
+           set routes [concat [getStatIPv4routes $target] \
+               [getStatIPv6routes $target]]
+           labelframe $wi.statrt -padx 4 -pady 4
+           label $wi.statrt.label -text "Static routes:"
+           pack $wi.statrt.label -side top -anchor w
+           frame $wi.statrt.tab -width 10
+           frame $wi.statrt.tab1 -width 10
+           frame $wi.statrt.cfg
+           set h [expr {[llength $routes] + 1}]
+           if { $h < 2 } {
+               set h 2
+           }
+           text $wi.statrt.cfg.text -font arial -bg white \
+               -width 42 -height $h -takefocus 0
+           foreach route $routes {
+               $wi.statrt.cfg.text insert end "$route
 "
-            }
-            pack $wi.statrt.cfg.text -expand yes
-            pack $wi.statrt.tab $wi.statrt.cfg $wi.statrt.tab1 -side left
-            pack $wi.statrt -side top -anchor w -fill both
-        }
-
-        if {[lsearch {router pc host} $type] >= 0} {
-            #
-            # Custom startup config
-            #
-            global customEnabled
-            labelframe $wi.custom -padx 4 -pady 4
-            frame $wi.custom.label
-            label $wi.custom.label.txt -text "Custom startup config:"
-            pack $wi.custom.label.txt -side left -anchor w
-            set customEnabled [getCustomEnabled $target]
-            radiobutton $wi.custom.label.enabled -text "enabled" \
-                -variable customEnabled -value true
-            radiobutton $wi.custom.label.disabled -text "disabled" \
-                -variable customEnabled -value false
-            pack $wi.custom.label.enabled $wi.custom.label.disabled \
-                -side left -anchor w
-            pack $wi.custom.label -side top -anchor w
-            frame $wi.custom.cfg
-            button $wi.custom.cfg.generate -text "Generate" \
-                -command "cfgGenerate $target"
-            button $wi.custom.cfg.edit -text "Edit" \
-                -command "editStartupCfg $target 0"
-            button $wi.custom.cfg.clear -text "Clear" \
-                -command "setCustomConfig $target {} {} {} 0"
-            pack $wi.custom.cfg.generate $wi.custom.cfg.edit \
-                $wi.custom.cfg.clear -side left
-
-            pack $wi.custom.label -side top -anchor w
-            pack $wi.custom.cfg -side top
-            pack $wi.custom -side top -anchor w -fill both
-
-            #
-            # IPsec configuration:
-            #
-            global ipsecEnabled
-            global showIPsecConfig
-            if { $showIPsecConfig == 1 } {
-                labelframe $wi.ipsec -padx 4 -pady 4
-                frame $wi.ipsec.label
-                label $wi.ipsec.label.txt -text "Manual IPsec configuration:"
-                pack $wi.ipsec.label.txt -side left -anchor w
-                set ipsecEnabled [getIpsecEnabled $target]
-                radiobutton $wi.ipsec.label.enabled -text "enabled" \
-                    -variable ipsecEnabled -value true
-                radiobutton $wi.ipsec.label.disabled -text "disabled" \
-                    -variable ipsecEnabled -value false
-                pack $wi.ipsec.label.enabled $wi.ipsec.label.disabled \
-                    -side left -anchor w
-                pack $wi.ipsec.label -side top -anchor w
-                frame $wi.ipsec.cfg
-                set delete "0"
-                set view "0"
-                button $wi.ipsec.cfg.add -text "Add SA/SP" \
-                    -command "viewIpsecCfg $target $delete $view"
-                set delete "0"
-                set view "1"
-                button $wi.ipsec.cfg.view -text "Edit SAs/SPs" \
-                    -command "viewIpsecCfg $target $delete $view"
-                pack $wi.ipsec.cfg.add $wi.ipsec.cfg.view -side left
-                pack $wi.ipsec.label -side top -anchor w
-                pack $wi.ipsec.cfg -side top
-                pack $wi.ipsec -side top -anchor w -fill both
-            }
-                
-            #
-            # CPU scheduling parameters
-            #
-            labelframe $wi.cpu -padx 4 -pady 4
-            label $wi.cpu.minl -text "CPU  min%" -anchor w
-            spinbox $wi.cpu.mine -bg white -width 3 \
-                -validate focus -invcmd "focusAndFlash %W"
-            $wi.cpu.mine insert 0 [lindex \
-                [lsearch -inline [getNodeCPUConf $target] {min *}] 1]
-            $wi.cpu.mine configure \
-                -vcmd {checkIntRange %P 1 90} \
-                -from 0 -to 90 -increment 1
-            label $wi.cpu.maxl -text "  max%" -anchor w
-            spinbox $wi.cpu.maxe -bg white -width 3 \
-                -validate focus -invcmd "focusAndFlash %W"
-            set cpumax [lindex \
-                [lsearch -inline [getNodeCPUConf $target] {max *}] 1]
-            if { $cpumax == "" } {
-                set cpumax 100
-            }
-            $wi.cpu.maxe insert 0 $cpumax
-            $wi.cpu.maxe configure \
-                -vcmd {checkIntRange %P 1 100} \
-                -from 1 -to 100 -increment 1
-            label $wi.cpu.weightl -text "  weight" -anchor w
-            spinbox $wi.cpu.weighte -bg white -width 2 \
-                -validate focus -invcmd "focusAndFlash %W"
-            $wi.cpu.weighte insert 0 [lindex \
-                [lsearch -inline [getNodeCPUConf $target] {weight *}] 1]
-            $wi.cpu.weighte configure \
-                -vcmd {checkIntRange %P 1 10} \
-                -from 1 -to 10 -increment 1
-            pack $wi.cpu.minl $wi.cpu.mine \
-                $wi.cpu.maxl $wi.cpu.maxe \
-                $wi.cpu.weightl $wi.cpu.weighte -side left
-            pack $wi.cpu -side top -anchor w -fill both
-        }
+           }
+           pack $wi.statrt.cfg.text -expand yes
+           pack $wi.statrt.tab $wi.statrt.cfg $wi.statrt.tab1 -side left
+           pack $wi.statrt -side top -anchor w -fill both
+       }
+
+       if {[lsearch {router pc host} $type] >= 0} {
+           #
+           # Custom startup config
+           #
+           global customEnabled
+           labelframe $wi.custom -padx 4 -pady 4
+           frame $wi.custom.label
+           label $wi.custom.label.txt -text "Custom startup config:"
+           pack $wi.custom.label.txt -side left -anchor w
+           set customEnabled [getCustomEnabled $target]
+           radiobutton $wi.custom.label.enabled -text "enabled" \
+               -variable customEnabled -value true
+           radiobutton $wi.custom.label.disabled -text "disabled" \
+               -variable customEnabled -value false
+           pack $wi.custom.label.enabled $wi.custom.label.disabled \
+               -side left -anchor w
+           pack $wi.custom.label -side top -anchor w
+           frame $wi.custom.cfg
+           button $wi.custom.cfg.generate -text "Generate" \
+               -command "cfgGenerate $target"
+           button $wi.custom.cfg.edit -text "Edit" \
+               -command "editStartupCfg $target 0"
+           button $wi.custom.cfg.clear -text "Clear" \
+               -command "setCustomConfig $target {} {} {} 0"
+           pack $wi.custom.cfg.generate $wi.custom.cfg.edit \
+               $wi.custom.cfg.clear -side left
+
+           pack $wi.custom.label -side top -anchor w
+           pack $wi.custom.cfg -side top
+           pack $wi.custom -side top -anchor w -fill both
+
+           #
+           # IPsec configuration:
+           #
+           global ipsecEnabled
+           global showIPsecConfig
+           if { $showIPsecConfig == 1 } {
+               labelframe $wi.ipsec -padx 4 -pady 4
+               frame $wi.ipsec.label
+               label $wi.ipsec.label.txt -text "Manual IPsec configuration:"
+               pack $wi.ipsec.label.txt -side left -anchor w
+               set ipsecEnabled [getIpsecEnabled $target]
+               radiobutton $wi.ipsec.label.enabled -text "enabled" \
+                   -variable ipsecEnabled -value true
+               radiobutton $wi.ipsec.label.disabled -text "disabled" \
+                   -variable ipsecEnabled -value false
+               pack $wi.ipsec.label.enabled $wi.ipsec.label.disabled \
+                   -side left -anchor w
+               pack $wi.ipsec.label -side top -anchor w
+               frame $wi.ipsec.cfg
+               set delete "0"
+               set view "0"
+               button $wi.ipsec.cfg.add -text "Add SA/SP" \
+                   -command "viewIpsecCfg $target $delete $view"
+               set delete "0"
+               set view "1"
+               button $wi.ipsec.cfg.view -text "Edit SAs/SPs" \
+                   -command "viewIpsecCfg $target $delete $view"
+               pack $wi.ipsec.cfg.add $wi.ipsec.cfg.view -side left
+               pack $wi.ipsec.label -side top -anchor w
+               pack $wi.ipsec.cfg -side top
+               pack $wi.ipsec -side top -anchor w -fill both
+           }
+               
+           #
+           # CPU scheduling parameters
+           #
+           labelframe $wi.cpu -padx 4 -pady 4
+           label $wi.cpu.minl -text "CPU  min%" -anchor w
+           spinbox $wi.cpu.mine -bg white -width 3 \
+               -validate focus -invcmd "focusAndFlash %W"
+           $wi.cpu.mine insert 0 [lindex \
+               [lsearch -inline [getNodeCPUConf $target] {min *}] 1]
+           $wi.cpu.mine configure \
+               -vcmd {checkIntRange %P 1 90} \
+               -from 0 -to 90 -increment 1
+           label $wi.cpu.maxl -text "  max%" -anchor w
+           spinbox $wi.cpu.maxe -bg white -width 3 \
+               -validate focus -invcmd "focusAndFlash %W"
+           set cpumax [lindex \
+               [lsearch -inline [getNodeCPUConf $target] {max *}] 1]
+           if { $cpumax == "" } {
+               set cpumax 100
+           }
+           $wi.cpu.maxe insert 0 $cpumax
+           $wi.cpu.maxe configure \
+               -vcmd {checkIntRange %P 1 100} \
+               -from 1 -to 100 -increment 1
+           label $wi.cpu.weightl -text "  weight" -anchor w
+           spinbox $wi.cpu.weighte -bg white -width 2 \
+               -validate focus -invcmd "focusAndFlash %W"
+           $wi.cpu.weighte insert 0 [lindex \
+               [lsearch -inline [getNodeCPUConf $target] {weight *}] 1]
+           $wi.cpu.weighte configure \
+               -vcmd {checkIntRange %P 1 10} \
+               -from 1 -to 10 -increment 1
+           pack $wi.cpu.minl $wi.cpu.mine \
+               $wi.cpu.maxl $wi.cpu.maxe \
+               $wi.cpu.weightl $wi.cpu.weighte -side left
+           pack $wi.cpu -side top -anchor w -fill both
+       }
     }
     oval {
-        destroy $wi
-        annotationConfig $c $target
-        return
+       destroy $wi
+       annotationConfig $c $target
+       return
     }
     rectangle {
-        destroy $wi
-        annotationConfig $c $target
-        return
+       destroy $wi
+       annotationConfig $c $target
+       return
     }
     text {
-        destroy $wi
-        textConfig $c $target
-        return
+       destroy $wi
+       textConfig $c $target
+       return
     }
     link {
-        wm title $wi "link configuration"
-        frame $wi.ftop -borderwidth 6
-        set nam0 [getNodeName $n0]
-        set nam1 [getNodeName $n1]
-        label $wi.ftop.name_label -justify left -text \
-        "Link from $nam0 to $nam1"
-        pack $wi.ftop.name_label -side right
-        pack $wi.ftop -side top
-
-        frame $wi.bandwidth -borderwidth 4
-        label $wi.bandwidth.label -anchor e \
-        -text "Bandwidth (bps):"
-        spinbox $wi.bandwidth.value -bg white -justify right -width 10 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.bandwidth.value insert 0 [getLinkBandwidth $target]
-        $wi.bandwidth.value configure \
-            -vcmd {checkIntRange %P 0 1000000000} \
-            -from 0 -to 1000000000 -increment 1000
-        pack $wi.bandwidth.value $wi.bandwidth.label \
-        -side right
-        pack $wi.bandwidth -side top -anchor e
-
-        frame $wi.delay -borderwidth 4
-        label $wi.delay.label -anchor e -text "Delay (us):"
-        spinbox $wi.delay.value -bg white -justify right -width 10 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.delay.value insert 0 [getLinkDelay $target]
-        $wi.delay.value configure \
-            -vcmd {checkIntRange %P 0 10000000} \
-            -from 0 -to 10000000 -increment 5
-        pack $wi.delay.value $wi.delay.label -side right
-        pack $wi.delay -side top -anchor e
-
-        frame $wi.ber -borderwidth 4
-        label $wi.ber.label -anchor e -text "BER (1/N):"
-        spinbox $wi.ber.value -bg white -justify right -width 10 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.ber.value insert 0 [getLinkBER $target]
-        $wi.ber.value configure \
-            -vcmd {checkIntRange %P 0 10000000000000} \
-            -from 0 -to 10000000000000 -increment 1000
-        pack $wi.ber.value $wi.ber.label -side right
-        pack $wi.ber -side top -anchor e
-
-        frame $wi.dup -borderwidth 4
-        label $wi.dup.label -anchor e -text "Duplicate (%):"
-        spinbox $wi.dup.value -bg white -justify right -width 10 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.dup.value insert 0 [getLinkDup $target]
-        $wi.dup.value configure \
-            -vcmd {checkIntRange %P 0 50} \
-            -from 0 -to 50 -increment 1
-        pack $wi.dup.value $wi.dup.label -side right
-        pack $wi.dup -side top -anchor e
-
-        frame $wi.color -borderwidth 4
-        label $wi.color.label -anchor e -text "Color:"
-        set link_color [getLinkColor $target]
-        tk_optionMenu $wi.color.value link_color \
-            Red Green Blue Yellow Magenta Cyan Black
-        pack $wi.color.value $wi.color.label -side right
-        pack $wi.color -side top -anchor e
-
-        frame $wi.width -borderwidth 4
-        label $wi.width.label -anchor e -text "Width:"
-        spinbox $wi.width.value -bg white -justify right -width 10 \
-            -validate focus -invcmd "focusAndFlash %W"
-        $wi.width.value insert 0 [getLinkWidth $target]
-        $wi.width.value configure \
-            -vcmd {checkIntRange %P 1 8} \
-            -from 1 -to 8 -increment 1
-        pack $wi.width.value $wi.width.label -side right
-        pack $wi.width -side top -anchor e
+       wm title $wi "link configuration"
+       frame $wi.ftop -borderwidth 6
+       set nam0 [getNodeName $n0]
+       set nam1 [getNodeName $n1]
+       label $wi.ftop.name_label -justify left -text \
+       "Link from $nam0 to $nam1"
+       pack $wi.ftop.name_label -side right
+       pack $wi.ftop -side top
+
+       frame $wi.bandwidth -borderwidth 4
+       label $wi.bandwidth.label -anchor e \
+       -text "Bandwidth (bps):"
+       spinbox $wi.bandwidth.value -bg white -justify right -width 10 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.bandwidth.value insert 0 [getLinkBandwidth $target]
+       $wi.bandwidth.value configure \
+           -vcmd {checkIntRange %P 0 1000000000} \
+           -from 0 -to 1000000000 -increment 1000
+       pack $wi.bandwidth.value $wi.bandwidth.label \
+       -side right
+       pack $wi.bandwidth -side top -anchor e
+
+       frame $wi.delay -borderwidth 4
+       label $wi.delay.label -anchor e -text "Delay (us):"
+       spinbox $wi.delay.value -bg white -justify right -width 10 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.delay.value insert 0 [getLinkDelay $target]
+       $wi.delay.value configure \
+           -vcmd {checkIntRange %P 0 10000000} \
+           -from 0 -to 10000000 -increment 5
+       pack $wi.delay.value $wi.delay.label -side right
+       pack $wi.delay -side top -anchor e
+
+       frame $wi.ber -borderwidth 4
+       label $wi.ber.label -anchor e -text "BER (1/N):"
+       spinbox $wi.ber.value -bg white -justify right -width 10 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.ber.value insert 0 [getLinkBER $target]
+       $wi.ber.value configure \
+           -vcmd {checkIntRange %P 0 10000000000000} \
+           -from 0 -to 10000000000000 -increment 1000
+       pack $wi.ber.value $wi.ber.label -side right
+       pack $wi.ber -side top -anchor e
+
+       frame $wi.dup -borderwidth 4
+       label $wi.dup.label -anchor e -text "Duplicate (%):"
+       spinbox $wi.dup.value -bg white -justify right -width 10 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.dup.value insert 0 [getLinkDup $target]
+       $wi.dup.value configure \
+           -vcmd {checkIntRange %P 0 50} \
+           -from 0 -to 50 -increment 1
+       pack $wi.dup.value $wi.dup.label -side right
+       pack $wi.dup -side top -anchor e
+
+       frame $wi.color -borderwidth 4
+       label $wi.color.label -anchor e -text "Color:"
+       set link_color [getLinkColor $target]
+       tk_optionMenu $wi.color.value link_color \
+           Red Green Blue Yellow Magenta Cyan Black
+       pack $wi.color.value $wi.color.label -side right
+       pack $wi.color -side top -anchor e
+
+       frame $wi.width -borderwidth 4
+       label $wi.width.label -anchor e -text "Width:"
+       spinbox $wi.width.value -bg white -justify right -width 10 \
+           -validate focus -invcmd "focusAndFlash %W"
+       $wi.width.value insert 0 [getLinkWidth $target]
+       $wi.width.value configure \
+           -vcmd {checkIntRange %P 1 8} \
+           -from 1 -to 8 -increment 1
+       pack $wi.width.value $wi.width.label -side right
+       pack $wi.width -side top -anchor e
     }
     }
 
@@ -2425,7 +2425,7 @@ proc popupConfigDialog { c } {
     bind $wi <Key-Escape> "set badentry -1; destroy $wi"
     bind $wi <Key-Return> "popupConfigApply $wi $object_type $target 0"
     after 100 {
-        grab .popup
+       grab .popup
     }
 }
 
@@ -2443,7 +2443,7 @@ proc popupConfigDialog { c } {
 #   * node_id -- node id
 #****
 proc cfgGenerate { node } {
-    set id "generic"        
+    set id "generic"   
     set cmd [[typemodel $node].bootcmd $node]
     set cfg [[typemodel $node].cfggen $node]
     setCustomConfig $node $id $cmd $cfg 0
@@ -2460,8 +2460,8 @@ proc cfgGenerate { node } {
 # INPUTS
 #   * node_id -- node id
 #   * deleted -- if deleted is set to 1, editStartupCfg
-#                has been invoked after deleting custom-config
-#                with specified custom-config-id.
+#              has been invoked after deleting custom-config
+#              with specified custom-config-id.
 #****
 proc editStartupCfg { node deleted } {
     global viewcustomid
@@ -2470,102 +2470,102 @@ proc editStartupCfg { node deleted } {
     set customCfgList [getCustomConfig $node]
     set customidlist {}
     foreach customCfg $customCfgList {
-        set customid [lindex [lsearch -inline $customCfg \
-            "custom-config-id *"] 1]
-        lappend customidlist $customid
+       set customid [lindex [lsearch -inline $customCfg \
+           "custom-config-id *"] 1]
+       lappend customidlist $customid
     }
 
     set edit 1
     if { $deleted == "1" } {
-        set viewcustomid [lindex $customidlist 0]
+       set viewcustomid [lindex $customidlist 0]
     }
 
     if { $customidlist == "" } {
-        set warning "Custom config list is empty."
-            tk_messageBox -message $warning -type ok -icon warning \
-            -title "Custom configuration warning"        
+       set warning "Custom config list is empty."
+           tk_messageBox -message $warning -type ok -icon warning \
+           -title "Custom configuration warning"        
     } else {
-        set w .cfgeditor
-        catch {destroy $w}
-        toplevel $w -takefocus 1
-        grab $w
-        wm title $w "Custom config $node"
-        wm iconname $w "$node"
-        labelframe $w.custom -padx 4 -pady 4 
-        if { $edit == "1" } {
-            frame $w.custom.viewid -borderwidth 4
-            label $w.custom.viewid.label -text "View custom-config:"
-            pack $w.custom.viewid.label -side left -anchor w
-            eval {tk_optionMenu $w.custom.viewid.optmenu viewcustomid} \
-                $customidlist
-            pack $w.custom.viewid.label $w.custom.viewid.optmenu \
-                -side left -anchor w
-            pack $w.custom.viewid -side top -anchor w
-            button $w.custom.viewid.button -text View \
-                -command "editStartupCfg $node 0"
-            pack $w.custom.viewid.button -side right
-
-            foreach element $customCfgList {
-                set cid \
-                    [lindex [lsearch -inline $element "custom-config-id *"] 1]
-                if { $viewcustomid == $cid } {
-                    set customCfg $element
-                }
-            }
-        }
-
-        frame $w.custom.id -borderwidth 4
-        label $w.custom.id.label -text "Custom config id:"
-        entry $w.custom.id.text -bg white -width 30
-        if { $customCfg != {} } {
-            set ccfg [getConfig $customCfg "custom-config-id"]
-        } else {
-            set ccfg ""
-        }
-        $w.custom.id.text insert 0 $ccfg
-        pack $w.custom.id.text $w.custom.id.label -side right -padx 4 -pady 4
-        pack $w.custom.id -side top -anchor w
-        pack $w.custom -side top -anchor w -fill both
-        
-        frame $w.ftop -borderwidth 4
-        label $w.ftop.label -text "Startup command:"
-        entry $w.ftop.cmd -bg white -width 64
-        if { $customCfg != {} } {
-            set ccmd [getConfig $customCfg "custom-command"]
-        } else {
-            set ccmd ""
-        }
-        $w.ftop.cmd insert 0 $ccmd 
-        pack $w.ftop.cmd $w.ftop.label -side right -padx 4 -pady 4
-        pack $w.ftop -side top -anchor w
-
-        text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" \
-            -setgrid 1 -height 20 -undo 1 -autosep 1 -background white
-        focus $w.text
-        scrollbar $w.scroll -command "$w.text yview"
-
-        frame $w.buttons
-        pack $w.buttons -side bottom
-        button $w.buttons.apply -text "Apply" \
-            -command "customConfigApply $w $node"
-        button $w.buttons.close -text Close -command "destroy $w"
-        button $w.buttons.delete -text Delete -command \
-            "deleteCustomConfig $w $node $viewcustomid {} {} 1"
-        pack $w.buttons.apply $w.buttons.close $w.buttons.delete -side left
-
-        pack $w.scroll -side right -fill y
-        pack $w.text -expand yes -fill both
-
-        if { $customCfg != {} } {
-            set ccfg [getConfig $customCfg "config"]
-        } else {
-            set ccfg ""
-        }
-
-        foreach line $ccfg {
-            $w.text insert end "$line\n"
-        }
-        $w.text mark set insert 0.0
+       set w .cfgeditor
+       catch {destroy $w}
+       toplevel $w -takefocus 1
+       grab $w
+       wm title $w "Custom config $node"
+       wm iconname $w "$node"
+       labelframe $w.custom -padx 4 -pady 4 
+       if { $edit == "1" } {
+           frame $w.custom.viewid -borderwidth 4
+           label $w.custom.viewid.label -text "View custom-config:"
+           pack $w.custom.viewid.label -side left -anchor w
+           eval {tk_optionMenu $w.custom.viewid.optmenu viewcustomid} \
+               $customidlist
+           pack $w.custom.viewid.label $w.custom.viewid.optmenu \
+               -side left -anchor w
+           pack $w.custom.viewid -side top -anchor w
+           button $w.custom.viewid.button -text View \
+               -command "editStartupCfg $node 0"
+           pack $w.custom.viewid.button -side right
+
+           foreach element $customCfgList {
+               set cid \
+                   [lindex [lsearch -inline $element "custom-config-id *"] 1]
+               if { $viewcustomid == $cid } {
+                   set customCfg $element
+               }
+           }
+       }
+
+       frame $w.custom.id -borderwidth 4
+       label $w.custom.id.label -text "Custom config id:"
+       entry $w.custom.id.text -bg white -width 30
+       if { $customCfg != {} } {
+           set ccfg [getConfig $customCfg "custom-config-id"]
+       } else {
+           set ccfg ""
+       }
+       $w.custom.id.text insert 0 $ccfg
+       pack $w.custom.id.text $w.custom.id.label -side right -padx 4 -pady 4
+       pack $w.custom.id -side top -anchor w
+       pack $w.custom -side top -anchor w -fill both
+       
+       frame $w.ftop -borderwidth 4
+       label $w.ftop.label -text "Startup command:"
+       entry $w.ftop.cmd -bg white -width 64
+       if { $customCfg != {} } {
+           set ccmd [getConfig $customCfg "custom-command"]
+       } else {
+           set ccmd ""
+       }
+       $w.ftop.cmd insert 0 $ccmd 
+       pack $w.ftop.cmd $w.ftop.label -side right -padx 4 -pady 4
+       pack $w.ftop -side top -anchor w
+
+       text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" \
+           -setgrid 1 -height 20 -undo 1 -autosep 1 -background white
+       focus $w.text
+       scrollbar $w.scroll -command "$w.text yview"
+
+       frame $w.buttons
+       pack $w.buttons -side bottom
+       button $w.buttons.apply -text "Apply" \
+           -command "customConfigApply $w $node"
+       button $w.buttons.close -text Close -command "destroy $w"
+       button $w.buttons.delete -text Delete -command \
+           "deleteCustomConfig $w $node $viewcustomid {} {} 1"
+       pack $w.buttons.apply $w.buttons.close $w.buttons.delete -side left
+
+       pack $w.scroll -side right -fill y
+       pack $w.text -expand yes -fill both
+
+       if { $customCfg != {} } {
+           set ccfg [getConfig $customCfg "config"]
+       } else {
+           set ccfg ""
+       }
+
+       foreach line $ccfg {
+           $w.text insert end "$line\n"
+       }
+       $w.text mark set insert 0.0
     }
 }
 
@@ -2589,11 +2589,11 @@ proc customConfigApply { w node } {
     set newid [$w.custom.id.text get]
     set newconf [split [$w.text get 0.0 end] "\n"]
     while { [lindex $newconf end] == {} && $newconf != {} } {
-        set newconf [lreplace $newconf end end]
+       set newconf [lreplace $newconf end end]
     }
     if { [getCustomCmd $node] != $newcmd || \
-        [getCustomConfig $node] != $newconf } {
-        set changed 1
+       [getCustomConfig $node] != $newconf } {
+       set changed 1
     }
     setCustomConfig $node $newid $newcmd $newconf 0
     destroy $w
@@ -2625,246 +2625,246 @@ proc popupConfigApply { wi object_type target phase } {
     global customEnabled ipsecEnabled
     global eid
     global showIPsecConfig
-        
+       
     $wi config -cursor watch
     update
     if { $phase == 0 } {
-        set badentry 0
-        focus .
-        after 100 "popupConfigApply $wi $object_type $target 1"
-        return
+       set badentry 0
+       focus .
+       after 100 "popupConfigApply $wi $object_type $target 1"
+       return
     } elseif { $badentry } {
-        $wi config -cursor left_ptr
-        return
+       $wi config -cursor left_ptr
+       return
     }
     switch -exact -- $object_type {
     #
     # Node
     #
     node {
-        set type [nodeType $target]
-        set model [getNodeModel $target]
-        set name [string trim [$wi.ftop.name get]]
-        if { $name != [getNodeName $target] } {
-            setNodeName $target $name
-            set changed 1
-        }
-        if { $oper_mode == "edit" && $type == "router" && \
-            $router_model != $model } {
-            setNodeModel $target $router_model
-            set changed 1
-        }
-
-        #
-        # Queue config
-        #
-        foreach ifc [ifcList $target] {
-            if { [nodeType [peerByIfc $target $ifc]] != "rj45" && \
-                [nodeType $target] != "rj45" } {
-                global ifqdisc$ifc ifqdrop$ifc
-                set qdisc [subst $[subst ifqdisc$ifc]]
-                set oldqdisc [getIfcQDisc $target $ifc]
-                if { $qdisc != $oldqdisc } {
-                    setIfcQDisc $target $ifc $qdisc
-                    set changed 1
-                }
-                set qdrop [subst $[subst ifqdrop$ifc]]
-                set oldqdrop [getIfcQDrop $target $ifc]
-                if { $qdrop != $oldqdrop } {
-                    setIfcQDrop $target $ifc $qdrop
-                    set changed 1
-                }
-                set len [$wi.if$ifc.cfg.q.len get]
-                set oldlen [getIfcQLen $target $ifc]
-                if { $len != $oldlen } {
-                    setIfcQLen $target $ifc $len
-                    set changed 1
-                }
-            }
-        }
-
-        if {[[typemodel $target].layer] == "NETWORK"} {
-        foreach ifc [ifcList $target] {
-            #
-            # Operational state
-            #
-            global [subst ifoper$ifc]
-            set ifoperstate [subst $[subst ifoper$ifc]]
-            set oldifoperstate [getIfcOperState $target $ifc]
-            if { $ifoperstate != $oldifoperstate } {
-            setIfcOperState $target $ifc $ifoperstate
-            set changed 1
-            }
-
-            #
-            # IPv4 / IPv6 address & MTU
-            #
-            set ipaddr [$wi.if$ifc.cfg.ipv4.addrv get]
-            set oldipaddr [getIfcIPv4addr $target $ifc]
-            if { $ipaddr != $oldipaddr } {
-            setIfcIPv4addr $target $ifc $ipaddr
-            set changed 1
-            }
-            set ipaddr [$wi.if$ifc.cfg.ipv6.addrv get]
-            set oldipaddr [getIfcIPv6addr $target $ifc]
-            if { $ipaddr != $oldipaddr } {
-            setIfcIPv6addr $target $ifc $ipaddr
-            set changed 1
-            }
-
-            set mtu [$wi.if$ifc.label.mtuv get]
-            set oldmtu [getIfcMTU $target $ifc]
-            if { $mtu != $oldmtu } {
-            setIfcMTU $target $ifc $mtu
-            set changed 1
-            }
-
-        }
-
-        set oldIPv4statrtes [lsort [getStatIPv4routes $target]]
-        set oldIPv6statrtes [lsort [getStatIPv6routes $target]]
-        set newIPv4statrtes {}
-        set newIPv6statrtes {}
-        set i 1
-        while { 1 } {
-            set text [$wi.statrt.cfg.text get $i.0 $i.end]
-            set rtentry [lrange [split [string trim $text]] 0 2]
-            if { $rtentry == "" } {
-            break
-            }
-            set dst [lindex $rtentry 0]
-            set gw [lindex $rtentry 1]
-            set metric [lindex $rtentry 2]
-            if { [string is integer $metric] != 1 || \
-              $metric > 65535 } {
-            break
-            }
-            if { [checkIPv4Net $dst] == 1 } {
-            if { [checkIPv4Addr $gw] == 1 } {
-                lappend newIPv4statrtes \
-                [string trim "$dst $gw $metric"]
-            } else {
-                break
-            }
-            } elseif { [checkIPv6Net $dst] == 1 } {
-            if { [checkIPv6Addr $gw] == 1 } {
-                lappend newIPv6statrtes \
-                [string trim "$dst $gw $metric"]
-            } else {
-                break
-            }
-            } else {
-            break
-            }
-            incr i
-        }
-        set newIPv4statrtes [lsort $newIPv4statrtes]
-        if { $oldIPv4statrtes != $newIPv4statrtes } {
-            setStatIPv4routes $target $newIPv4statrtes
-            set changed 1
-        }
-        set newIPv6statrtes [lsort $newIPv6statrtes]
-        if { $oldIPv6statrtes != $newIPv6statrtes } {
-            setStatIPv6routes $target $newIPv6statrtes
-            set changed 1
-        }
-
-        set oldcustomenabled [getCustomEnabled $target]
-        if {$oldcustomenabled != $customEnabled} {
-            setCustomEnabled $target $customEnabled
-            set changed 1
-        }
-
-                if { $showIPsecConfig == 0 } {
-                        set ipsecEnabled 0
-                }
-        set oldipsecenabled [getIpsecEnabled $target]
-        if {$oldipsecenabled != $ipsecEnabled} {
-            setIpsecEnabled $target $ipsecEnabled
-            set changed 1
-        }
-        
-        set oldcpuconf [getNodeCPUConf $target]
-        set newcpuconf {}
-        set cpumin [$wi.cpu.mine get]
-        set cpumax [$wi.cpu.maxe get]
-        set cpuweight [$wi.cpu.weighte get]
-        if { $cpumin != "" } {
-            lappend newcpuconf "min $cpumin"
-        }
-        if { $cpumax != "" } {
-            lappend newcpuconf "max $cpumax"
-        }
-        if { $cpuweight != "" } {
-            lappend newcpuconf "weight $cpuweight"
-        }
-        if { $oldcpuconf != $newcpuconf } {
-            setNodeCPUConf $target [list $newcpuconf]
-            set changed 1
-        }
-        }
+       set type [nodeType $target]
+       set model [getNodeModel $target]
+       set name [string trim [$wi.ftop.name get]]
+       if { $name != [getNodeName $target] } {
+           setNodeName $target $name
+           set changed 1
+       }
+       if { $oper_mode == "edit" && $type == "router" && \
+           $router_model != $model } {
+           setNodeModel $target $router_model
+           set changed 1
+       }
+
+       #
+       # Queue config
+       #
+       foreach ifc [ifcList $target] {
+           if { [nodeType [peerByIfc $target $ifc]] != "rj45" && \
+               [nodeType $target] != "rj45" } {
+               global ifqdisc$ifc ifqdrop$ifc
+               set qdisc [subst $[subst ifqdisc$ifc]]
+               set oldqdisc [getIfcQDisc $target $ifc]
+               if { $qdisc != $oldqdisc } {
+                   setIfcQDisc $target $ifc $qdisc
+                   set changed 1
+               }
+               set qdrop [subst $[subst ifqdrop$ifc]]
+               set oldqdrop [getIfcQDrop $target $ifc]
+               if { $qdrop != $oldqdrop } {
+                   setIfcQDrop $target $ifc $qdrop
+                   set changed 1
+               }
+               set len [$wi.if$ifc.cfg.q.len get]
+               set oldlen [getIfcQLen $target $ifc]
+               if { $len != $oldlen } {
+                   setIfcQLen $target $ifc $len
+                   set changed 1
+               }
+           }
+       }
+
+       if {[[typemodel $target].layer] == "NETWORK"} {
+       foreach ifc [ifcList $target] {
+           #
+           # Operational state
+           #
+           global [subst ifoper$ifc]
+           set ifoperstate [subst $[subst ifoper$ifc]]
+           set oldifoperstate [getIfcOperState $target $ifc]
+           if { $ifoperstate != $oldifoperstate } {
+           setIfcOperState $target $ifc $ifoperstate
+           set changed 1
+           }
+
+           #
+           # IPv4 / IPv6 address & MTU
+           #
+           set ipaddr [$wi.if$ifc.cfg.ipv4.addrv get]
+           set oldipaddr [getIfcIPv4addr $target $ifc]
+           if { $ipaddr != $oldipaddr } {
+           setIfcIPv4addr $target $ifc $ipaddr
+           set changed 1
+           }
+           set ipaddr [$wi.if$ifc.cfg.ipv6.addrv get]
+           set oldipaddr [getIfcIPv6addr $target $ifc]
+           if { $ipaddr != $oldipaddr } {
+           setIfcIPv6addr $target $ifc $ipaddr
+           set changed 1
+           }
+
+           set mtu [$wi.if$ifc.label.mtuv get]
+           set oldmtu [getIfcMTU $target $ifc]
+           if { $mtu != $oldmtu } {
+           setIfcMTU $target $ifc $mtu
+           set changed 1
+           }
+
+       }
+
+       set oldIPv4statrtes [lsort [getStatIPv4routes $target]]
+       set oldIPv6statrtes [lsort [getStatIPv6routes $target]]
+       set newIPv4statrtes {}
+       set newIPv6statrtes {}
+       set i 1
+       while { 1 } {
+           set text [$wi.statrt.cfg.text get $i.0 $i.end]
+           set rtentry [lrange [split [string trim $text]] 0 2]
+           if { $rtentry == "" } {
+           break
+           }
+           set dst [lindex $rtentry 0]
+           set gw [lindex $rtentry 1]
+           set metric [lindex $rtentry 2]
+           if { [string is integer $metric] != 1 || \
+             $metric > 65535 } {
+           break
+           }
+           if { [checkIPv4Net $dst] == 1 } {
+           if { [checkIPv4Addr $gw] == 1 } {
+               lappend newIPv4statrtes \
+               [string trim "$dst $gw $metric"]
+           } else {
+               break
+           }
+           } elseif { [checkIPv6Net $dst] == 1 } {
+           if { [checkIPv6Addr $gw] == 1 } {
+               lappend newIPv6statrtes \
+               [string trim "$dst $gw $metric"]
+           } else {
+               break
+           }
+           } else {
+           break
+           }
+           incr i
+       }
+       set newIPv4statrtes [lsort $newIPv4statrtes]
+       if { $oldIPv4statrtes != $newIPv4statrtes } {
+           setStatIPv4routes $target $newIPv4statrtes
+           set changed 1
+       }
+       set newIPv6statrtes [lsort $newIPv6statrtes]
+       if { $oldIPv6statrtes != $newIPv6statrtes } {
+           setStatIPv6routes $target $newIPv6statrtes
+           set changed 1
+       }
+
+       set oldcustomenabled [getCustomEnabled $target]
+       if {$oldcustomenabled != $customEnabled} {
+           setCustomEnabled $target $customEnabled
+           set changed 1
+       }
+
+               if { $showIPsecConfig == 0 } {
+                       set ipsecEnabled 0
+               }
+       set oldipsecenabled [getIpsecEnabled $target]
+       if {$oldipsecenabled != $ipsecEnabled} {
+           setIpsecEnabled $target $ipsecEnabled
+           set changed 1
+       }
+       
+       set oldcpuconf [getNodeCPUConf $target]
+       set newcpuconf {}
+       set cpumin [$wi.cpu.mine get]
+       set cpumax [$wi.cpu.maxe get]
+       set cpuweight [$wi.cpu.weighte get]
+       if { $cpumin != "" } {
+           lappend newcpuconf "min $cpumin"
+       }
+       if { $cpumax != "" } {
+           lappend newcpuconf "max $cpumax"
+       }
+       if { $cpuweight != "" } {
+           lappend newcpuconf "weight $cpuweight"
+       }
+       if { $oldcpuconf != $newcpuconf } {
+           setNodeCPUConf $target [list $newcpuconf]
+           set changed 1
+       }
+       }
     }
 
     #
     # Link
     #
     link {
-        set mirror [getLinkMirror $target]
-        set bw [$wi.bandwidth.value get]
-        if { $bw != [getLinkBandwidth $target] } {
-            setLinkBandwidth $target [$wi.bandwidth.value get]
-            if { $mirror != "" } {
-                setLinkBandwidth $mirror [$wi.bandwidth.value get]
-            }
-            set changed 1
-        }
-        set dly [$wi.delay.value get]
-        if { $dly != [getLinkDelay $target] } {
-            setLinkDelay $target [$wi.delay.value get]
-            if { $mirror != "" } {
-                setLinkDelay $mirror [$wi.delay.value get]
-            }
-            set changed 1
-        }
-        set ber [$wi.ber.value get]
-        if { $ber != [getLinkBER $target] } {
-            setLinkBER $target [$wi.ber.value get]
-            if { $mirror != "" } {
-                setLinkBER $mirror [$wi.ber.value get]
-            }
-            set changed 1
-        }
-        set dup [$wi.dup.value get]
-        if { $dup != [getLinkDup $target] } {
-            setLinkDup $target [$wi.dup.value get]
-            if { $mirror != "" } {
-                setLinkDup $mirror [$wi.dup.value get]
-            }
-            set changed 1
-        }
-        if { $link_color != [getLinkColor $target] } {
-            setLinkColor $target $link_color
-            if { $mirror != "" } {
-                setLinkColor $mirror $link_color
-            }
-            set changed 1
-        }
-        set width [$wi.width.value get]
-        if { $width != [getLinkWidth $target] } {
-            setLinkWidth $target [$wi.width.value get]
-            if { $mirror != "" } {
-                setLinkWidth $mirror [$wi.width.value get]
-            }
-            set changed 1
-        }
-        if { $changed == 1 && $oper_mode == "exec" } {
-            execSetLinkParams $eid $target
-        }
+       set mirror [getLinkMirror $target]
+       set bw [$wi.bandwidth.value get]
+       if { $bw != [getLinkBandwidth $target] } {
+           setLinkBandwidth $target [$wi.bandwidth.value get]
+           if { $mirror != "" } {
+               setLinkBandwidth $mirror [$wi.bandwidth.value get]
+           }
+           set changed 1
+       }
+       set dly [$wi.delay.value get]
+       if { $dly != [getLinkDelay $target] } {
+           setLinkDelay $target [$wi.delay.value get]
+           if { $mirror != "" } {
+               setLinkDelay $mirror [$wi.delay.value get]
+           }
+           set changed 1
+       }
+       set ber [$wi.ber.value get]
+       if { $ber != [getLinkBER $target] } {
+           setLinkBER $target [$wi.ber.value get]
+           if { $mirror != "" } {
+               setLinkBER $mirror [$wi.ber.value get]
+           }
+           set changed 1
+       }
+       set dup [$wi.dup.value get]
+       if { $dup != [getLinkDup $target] } {
+           setLinkDup $target [$wi.dup.value get]
+           if { $mirror != "" } {
+               setLinkDup $mirror [$wi.dup.value get]
+           }
+           set changed 1
+       }
+       if { $link_color != [getLinkColor $target] } {
+           setLinkColor $target $link_color
+           if { $mirror != "" } {
+               setLinkColor $mirror $link_color
+           }
+           set changed 1
+       }
+       set width [$wi.width.value get]
+       if { $width != [getLinkWidth $target] } {
+           setLinkWidth $target [$wi.width.value get]
+           if { $mirror != "" } {
+               setLinkWidth $mirror [$wi.width.value get]
+           }
+           set changed 1
+       }
+       if { $changed == 1 && $oper_mode == "exec" } {
+           execSetLinkParams $eid $target
+       }
     }
     }
     if { $changed == 1 } {
-        redrawAll
-        updateUndoLog
+       redrawAll
+       updateUndoLog
     }
     destroy $wi
 }
@@ -2909,10 +2909,10 @@ proc deleteSelection { } {
     .c config -cursor watch; update
 
     foreach lnode [selectedNodes] {
-        if { $lnode != "" } {
-            removeGUINode $lnode
-        }
-        set changed 1
+       if { $lnode != "" } {
+           removeGUINode $lnode
+       }
+       set changed 1
     }
     raiseAll .c
     updateUndoLog
@@ -2926,29 +2926,29 @@ proc align2grid {} {
 
     set node_objects [.c find withtag node]
     if { [llength $node_objects] == 0 } {
-        return
+       return
     }
 
     set step [expr {$grid * 4}]
 
     for { set x $step } { $x <= [expr {$sizex - $step}] } { incr x $step } {
-        for { set y $step } { $y <= [expr {$sizey - $step}] } { incr y $step } {
-            if { [llength $node_objects] == 0 } {
-                set changed 1
-                updateUndoLog
-                redrawAll
-                return
-            }
-            set node [lindex [.c gettags [lindex $node_objects 0]] 1]
-            set node_objects [lreplace $node_objects 0 0]
-            setNodeCoords $node "$x $y"
-            set dy 32
-            if { [lsearch {router hub lanswitch rj45} \
-                [nodeType $node]] >= 0 } {
-                set dy 24
-            }
-            setNodeLabelCoords $node "$x [expr {$y + $dy}]"
-        }
+       for { set y $step } { $y <= [expr {$sizey - $step}] } { incr y $step } {
+           if { [llength $node_objects] == 0 } {
+               set changed 1
+               updateUndoLog
+               redrawAll
+               return
+           }
+           set node [lindex [.c gettags [lindex $node_objects 0]] 1]
+           set node_objects [lreplace $node_objects 0 0]
+           setNodeCoords $node "$x $y"
+           set dy 32
+           if { [lsearch {router hub lanswitch rj45} \
+               [nodeType $node]] >= 0 } {
+               set dy 24
+           }
+           setNodeLabelCoords $node "$x [expr {$y + $dy}]"
+       }
     }
 }
 
@@ -2974,149 +2974,149 @@ proc rearrange { mode } {
     .menubar.tools entryconfigure "Auto rearrange selected" -state disabled
     .bottom.mbuf config -text "autorearrange"
     if { $mode == "selected" } {
-        set tagmatch "node && selected"
+       set tagmatch "node && selected"
     } else {
-        set tagmatch "node"
+       set tagmatch "node"
     }
     set otime [clock clicks -milliseconds]
     while { $autorearrange_enabled } {
-        set ntime [clock clicks -milliseconds]
-        if { $otime == $ntime } {
-            set dt 0.001
-        } else {
-            set dt [expr {($ntime - $otime) * 0.001}]
-            if { $dt > 0.2 } {
-                set dt 0.2
-            }
-            set otime $ntime
-        }
-
-        set objects [.c find withtag $tagmatch]
-        set peer_objects [.c find withtag node]
-        foreach obj $peer_objects {
-            set node [lindex [.c gettags $obj] 1]
-            set coords [.c coords $obj]
-            set x [expr {[lindex $coords 0] / $zoom}]
-            set y [expr {[lindex $coords 1] / $zoom}]
-            set x_t($node) $x
-            set y_t($node) $y
-
-            if { $x > 0 } {
-                set fx [expr {1000 / ($x * $x + 100)}]
-            } else {
-                set fx 10
-            }
-            set dx [expr {$sizex - $x}]
-            if { $dx > 0 } {
-                set fx [expr {$fx - 1000 / ($dx * $dx + 100)}]
-            } else {
-                set fx [expr {$fx - 10}]
-            }
-
-            if { $y > 0 } {
-                set fy [expr {1000 / ($y * $y + 100)}]
-            } else {
-                set fy 10
-            }
-            set dy [expr {$sizey - $y}]
-            if { $dy > 0 } {
-                set fy [expr {$fy - 1000 / ($dy * $dy + 100)}]
-            } else {
-                set fy [expr {$fy - 10}]
-            }
-            set fx_t($node) $fx
-            set fy_t($node) $fy
-        }
-
-        foreach obj $objects {
-            set node [lindex [.c gettags $obj] 1]
-            set i [lsearch -exact $peer_objects $obj]
-            set peer_objects [lreplace $peer_objects $i $i]
-            set x $x_t($node)
-            set y $y_t($node)
-            foreach other_obj $peer_objects {
-                set other [lindex [.c gettags $other_obj] 1]
-                set o_x $x_t($other)
-                set o_y $y_t($other)
-                set dx [expr {$x - $o_x}]
-                set dy [expr {$y - $o_y}]
-                set d [expr {hypot($dx, $dy)}]
-                set d2 [expr {$d * $d}]
-                set p_fx [expr {1000.0 * $dx / ($d2 * $d + 100)}]
-                set p_fy [expr {1000.0 * $dy / ($d2 * $d + 100)}]
-                if {[linkByPeers $node $other] != ""} {
-                    set p_fx [expr {$p_fx - $dx * $d2 * .0000000005}]
-                    set p_fy [expr {$p_fy - $dy * $d2 * .0000000005}]
-                }
-                set fx_t($node) [expr {$fx_t($node) + $p_fx}]
-                set fy_t($node) [expr {$fy_t($node) + $p_fy}]
-                set fx_t($other) [expr {$fx_t($other) - $p_fx}]
-                set fy_t($other) [expr {$fy_t($other) - $p_fy}]
-            }
-
-            foreach link $link_list {
-                set nodes [linkPeers $link]
-                if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
-                    [getNodeCanvas [lindex $nodes 1]] != $curcanvas ||
-                    [getLinkMirror $link] != "" } {
-                    continue
-                }
-                set peers [linkPeers $link]
-                set coords0 [getNodeCoords [lindex $peers 0]]
-                set coords1 [getNodeCoords [lindex $peers 1]]
-                set o_x \
-                    [expr {([lindex $coords0 0] + [lindex $coords1 0]) * .5}]
-                set o_y \
-                    [expr {([lindex $coords0 1] + [lindex $coords1 1]) * .5}]
-                set dx [expr {$x - $o_x}]
-                set dy [expr {$y - $o_y}]
-                set d [expr {hypot($dx, $dy)}]
-                set d2 [expr {$d * $d}]
-                set fx_t($node) \
-                    [expr {$fx_t($node) + 500.0 * $dx / ($d2 * $d + 100)}]
-                set fy_t($node) \
-                    [expr {$fy_t($node) + 500.0 * $dy / ($d2 * $d + 100)}]
-            }
-        }
-
-        foreach obj $objects {
-            set node [lindex [.c gettags $obj] 1]
-            if { [catch "set v_t($node)" v] } {
-                set vx 0.0
-                set vy 0.0
-            } else {
-                set vx [lindex $v_t($node) 0]
-                set vy [lindex $v_t($node) 1]
-            }
-            set vx [expr {$vx + 1000.0 * $fx_t($node) * $dt}]
-            set vy [expr {$vy + 1000.0 * $fy_t($node) * $dt}]
-            set dampk [expr {0.5 + ($vx * $vx + $vy * $vy) * 0.00001}]
-            set vx [expr {$vx * exp( - $dampk * $dt)}]
-            set vy [expr {$vy * exp( - $dampk * $dt)}]
-            set dx [expr {$vx * $dt}]
-            set dy [expr {$vy * $dt}]
-            set x [expr {$x_t($node) + $dx}]
-            set y [expr {$y_t($node) + $dy}]
-            set v_t($node) "$vx $vy"
-
-            setNodeCoords $node "$x $y"
-            set e_dx [expr {$dx * $zoom}]
-            set e_dy [expr {$dy * $zoom}]
-            .c move $obj $e_dx $e_dy
-            set img [.c find withtag "selectmark && $node"]
-            .c move $img $e_dx $e_dy
-            set img [.c find withtag "nodelabel && $node"]
-            .c move $img $e_dx $e_dy
-            set x [expr {[lindex [.c coords $img] 0] / $zoom}]
-            set y [expr {[lindex [.c coords $img] 1] / $zoom}]
-            setNodeLabelCoords $node "$x $y"
-            .c addtag need_redraw withtag "link && $node"
-        }
-        foreach link [.c find withtag "link && need_redraw"] {
-            redrawLink [lindex [.c gettags $link] 1]
-        }
-        .c dtag link need_redraw
-        update
+       set ntime [clock clicks -milliseconds]
+       if { $otime == $ntime } {
+           set dt 0.001
+       } else {
+           set dt [expr {($ntime - $otime) * 0.001}]
+           if { $dt > 0.2 } {
+               set dt 0.2
+           }
+           set otime $ntime
+       }
+
+       set objects [.c find withtag $tagmatch]
+       set peer_objects [.c find withtag node]
+       foreach obj $peer_objects {
+           set node [lindex [.c gettags $obj] 1]
+           set coords [.c coords $obj]
+           set x [expr {[lindex $coords 0] / $zoom}]
+           set y [expr {[lindex $coords 1] / $zoom}]
+           set x_t($node) $x
+           set y_t($node) $y
+
+           if { $x > 0 } {
+               set fx [expr {1000 / ($x * $x + 100)}]
+           } else {
+               set fx 10
+           }
+           set dx [expr {$sizex - $x}]
+           if { $dx > 0 } {
+               set fx [expr {$fx - 1000 / ($dx * $dx + 100)}]
+           } else {
+               set fx [expr {$fx - 10}]
+           }
+
+           if { $y > 0 } {
+               set fy [expr {1000 / ($y * $y + 100)}]
+           } else {
+               set fy 10
+           }
+           set dy [expr {$sizey - $y}]
+           if { $dy > 0 } {
+               set fy [expr {$fy - 1000 / ($dy * $dy + 100)}]
+           } else {
+               set fy [expr {$fy - 10}]
+           }
+           set fx_t($node) $fx
+           set fy_t($node) $fy
+       }
+
+       foreach obj $objects {
+           set node [lindex [.c gettags $obj] 1]
+           set i [lsearch -exact $peer_objects $obj]
+           set peer_objects [lreplace $peer_objects $i $i]
+           set x $x_t($node)
+           set y $y_t($node)
+           foreach other_obj $peer_objects {
+               set other [lindex [.c gettags $other_obj] 1]
+               set o_x $x_t($other)
+               set o_y $y_t($other)
+               set dx [expr {$x - $o_x}]
+               set dy [expr {$y - $o_y}]
+               set d [expr {hypot($dx, $dy)}]
+               set d2 [expr {$d * $d}]
+               set p_fx [expr {1000.0 * $dx / ($d2 * $d + 100)}]
+               set p_fy [expr {1000.0 * $dy / ($d2 * $d + 100)}]
+               if {[linkByPeers $node $other] != ""} {
+                   set p_fx [expr {$p_fx - $dx * $d2 * .0000000005}]
+                   set p_fy [expr {$p_fy - $dy * $d2 * .0000000005}]
+               }
+               set fx_t($node) [expr {$fx_t($node) + $p_fx}]
+               set fy_t($node) [expr {$fy_t($node) + $p_fy}]
+               set fx_t($other) [expr {$fx_t($other) - $p_fx}]
+               set fy_t($other) [expr {$fy_t($other) - $p_fy}]
+           }
+
+           foreach link $link_list {
+               set nodes [linkPeers $link]
+               if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas ||
+                   [getNodeCanvas [lindex $nodes 1]] != $curcanvas ||
+                   [getLinkMirror $link] != "" } {
+                   continue
+               }
+               set peers [linkPeers $link]
+               set coords0 [getNodeCoords [lindex $peers 0]]
+               set coords1 [getNodeCoords [lindex $peers 1]]
+               set o_x \
+                   [expr {([lindex $coords0 0] + [lindex $coords1 0]) * .5}]
+               set o_y \
+                   [expr {([lindex $coords0 1] + [lindex $coords1 1]) * .5}]
+               set dx [expr {$x - $o_x}]
+               set dy [expr {$y - $o_y}]
+               set d [expr {hypot($dx, $dy)}]
+               set d2 [expr {$d * $d}]
+               set fx_t($node) \
+                   [expr {$fx_t($node) + 500.0 * $dx / ($d2 * $d + 100)}]
+               set fy_t($node) \
+                   [expr {$fy_t($node) + 500.0 * $dy / ($d2 * $d + 100)}]
+           }
+       }
+
+       foreach obj $objects {
+           set node [lindex [.c gettags $obj] 1]
+           if { [catch "set v_t($node)" v] } {
+               set vx 0.0
+               set vy 0.0
+           } else {
+               set vx [lindex $v_t($node) 0]
+               set vy [lindex $v_t($node) 1]
+           }
+           set vx [expr {$vx + 1000.0 * $fx_t($node) * $dt}]
+           set vy [expr {$vy + 1000.0 * $fy_t($node) * $dt}]
+           set dampk [expr {0.5 + ($vx * $vx + $vy * $vy) * 0.00001}]
+           set vx [expr {$vx * exp( - $dampk * $dt)}]
+           set vy [expr {$vy * exp( - $dampk * $dt)}]
+           set dx [expr {$vx * $dt}]
+           set dy [expr {$vy * $dt}]
+           set x [expr {$x_t($node) + $dx}]
+           set y [expr {$y_t($node) + $dy}]
+           set v_t($node) "$vx $vy"
+
+           setNodeCoords $node "$x $y"
+           set e_dx [expr {$dx * $zoom}]
+           set e_dy [expr {$dy * $zoom}]
+           .c move $obj $e_dx $e_dy
+           set img [.c find withtag "selectmark && $node"]
+           .c move $img $e_dx $e_dy
+           set img [.c find withtag "nodelabel && $node"]
+           .c move $img $e_dx $e_dy
+           set x [expr {[lindex [.c coords $img] 0] / $zoom}]
+           set y [expr {[lindex [.c coords $img] 1] / $zoom}]
+           setNodeLabelCoords $node "$x $y"
+           .c addtag need_redraw withtag "link && $node"
+       }
+       foreach link [.c find withtag "link && need_redraw"] {
+           redrawLink [lindex [.c gettags $link] 1]
+       }
+       .c dtag link need_redraw
+       update
     }
     .menubar.tools entryconfigure "Auto rearrange all" -state normal
     .menubar.tools entryconfigure "Auto rearrange selected" -state normal
@@ -3143,26 +3143,26 @@ proc switchCanvas { direction } {
     set i [lsearch $canvas_list $curcanvas]
     switch -exact -- $direction {
     prev {
-        incr i -1
-        if { $i < 0 } {
-        set curcanvas [lindex $canvas_list end]
-        } else {
-        set curcanvas [lindex $canvas_list $i]
-        }
+       incr i -1
+       if { $i < 0 } {
+       set curcanvas [lindex $canvas_list end]
+       } else {
+       set curcanvas [lindex $canvas_list $i]
+       }
     }
     next {
-        incr i
-        if { $i >= [llength $canvas_list] } {
-        set curcanvas [lindex $canvas_list 0]
-        } else {
-        set curcanvas [lindex $canvas_list $i]
-        }
+       incr i
+       if { $i >= [llength $canvas_list] } {
+       set curcanvas [lindex $canvas_list 0]
+       } else {
+       set curcanvas [lindex $canvas_list $i]
+       }
     }
     first {
-        set curcanvas [lindex $canvas_list 0]
+       set curcanvas [lindex $canvas_list 0]
     }
     last {
-        set curcanvas [lindex $canvas_list end]
+       set curcanvas [lindex $canvas_list end]
     }
     }
 
@@ -3170,15 +3170,15 @@ proc switchCanvas { direction } {
     set x 0
     foreach canvas $canvas_list {
     set text [.hframe.t create text 0 0 \
-        -text "[getCanvasName $canvas]" -tags "text $canvas"]
+       -text "[getCanvasName $canvas]" -tags "text $canvas"]
     set ox [lindex [.hframe.t bbox $text] 2]
     set oy [lindex [.hframe.t bbox $text] 3]
     set tab [.hframe.t create polygon $x 0 [expr {$x + 7}] 18 \
-        [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 $x 0 \
-        -fill gray -tags "tab $canvas"]
+       [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 $x 0 \
+       -fill gray -tags "tab $canvas"]
     set line [.hframe.t create line 0 0 $x 0 [expr {$x + 7}] 18 \
-        [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 999 0 \
-        -fill #808080 -width 2 -tags "line $canvas"]
+       [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 999 0 \
+       -fill #808080 -width 2 -tags "line $canvas"]
     .hframe.t coords $text [expr {$x + $ox + 12}] [expr {$oy + 2}]
     .hframe.t raise $text
     incr x [expr {2 * $ox + 17}]
@@ -3194,10 +3194,10 @@ proc switchCanvas { direction } {
     set lmargin [expr {[lindex [.hframe.t xview] 0] * $x - 1}]
     set rmargin [expr {[lindex [.hframe.t xview] 1] * $x + 1}]
     if { $lborder < $lmargin } {
-        .hframe.t xview moveto [expr {1.0 * ($lborder - 10) / $x}]
+       .hframe.t xview moveto [expr {1.0 * ($lborder - 10) / $x}]
     }
     if { $rborder > $rmargin } {
-        .hframe.t xview moveto [expr {1.0 * ($rborder - $width + 10) / $x}]
+       .hframe.t xview moveto [expr {1.0 * ($rborder - $width + 10) / $x}]
     }
 
     set sizex [lindex [getCanvasSize $curcanvas] 0]
@@ -3223,12 +3223,12 @@ proc renameCanvasPopup {} {
     toplevel $w -takefocus 1
 
     if { $x == 0 && $y == 0 } {
-        set screen [wm maxsize .]
-        set x [expr {[lindex $screen 0] / 2}]
-        set y [expr {[lindex $screen 1] / 2}]
+       set screen [wm maxsize .]
+       set x [expr {[lindex $screen 0] / 2}]
+       set y [expr {[lindex $screen 1] / 2}]
     } else {
-        set x [expr {$x + 10}]
-        set y [expr {$y - 90}]
+       set x [expr {$x + 10}]
+       set y [expr {$y - 90}]
     }
     wm geometry $w +$x+$y
     wm title $w "Canvas rename"
@@ -3278,16 +3278,16 @@ proc resizeCanvasPopup {} {
     frame $w.size
     pack $w.size -side top -fill x -pady 2m
     spinbox $w.size.x -bg white -width 4 \
-        -validate focus -invcmd "focusAndFlash %W"
+       -validate focus -invcmd "focusAndFlash %W"
     $w.size.x insert 0 [lindex [getCanvasSize $curcanvas] 0]
     $w.size.x configure -from 800 -to 4096 -increment 2 \
-        -vcmd {checkIntRange %P 800 4096}
+       -vcmd {checkIntRange %P 800 4096}
     label $w.size.label -text "*"
     spinbox $w.size.y -bg white -width 4 \
-        -validate focus -invcmd "focusAndFlash %W"
+       -validate focus -invcmd "focusAndFlash %W"
     $w.size.y insert 0 [lindex [getCanvasSize $curcanvas] 1]
     $w.size.y configure -from 600 -to 4096 -increment 2 \
-        -vcmd {checkIntRange %P 600 4096}
+       -vcmd {checkIntRange %P 600 4096}
 
     pack $w.size.x $w.size.label $w.size.y -side left -pady 5 -padx 2 -fill x
 }
@@ -3309,7 +3309,7 @@ proc renameCanvasApply { w } {
     set newname [$w.e1 get]
     destroy $w
     if { $newname != [getCanvasName $curcanvas] } {
-        set changed 1
+       set changed 1
     }
     setCanvasName $curcanvas $newname
     switchCanvas none
@@ -3323,7 +3323,7 @@ proc resizeCanvasApply { w } {
     set y [$w.size.y get]
     destroy $w
     if { "$x $y" != [getCanvasSize $curcanvas] } {
-        set changed 1
+       set changed 1
     }
     setCanvasSize $curcanvas $x $y
     switchCanvas none
@@ -3345,13 +3345,13 @@ proc animate {} {
     .c itemconfigure "selectmark || selectbox" -dashoffset $animatephase
     incr animatephase 2
     if { $animatephase == 100 } {
-        set animatephase 0
+       set animatephase 0
     }
 
     if { $oper_mode == "edit" } {
-        after 250 animate
+       after 250 animate
     } else {
-        after 1500 animate
+       after 1500 animate
     }
 }
 
@@ -3375,9 +3375,9 @@ proc configRemoteHosts {} {
     set old_remote_exec $remote_exec
 
     if { $remote_exec } {
-        set state normal
+       set state normal
     } else {
-        set state disabled
+       set state disabled
     }
 
     set wi .popup
@@ -3389,17 +3389,17 @@ proc configRemoteHosts {} {
     wm title $wi "Remote host(s) configuration"
 
     labelframe $wi.select -pady 2 -text "Experiment running:" \
-        -padx 2 -borderwidth 2
+       -padx 2 -borderwidth 2
 
     radiobutton $wi.select.remote -text "remotely" \
-        -command "enable_disable $wi"\
-        -variable remote_exec -value true
+       -command "enable_disable $wi"\
+       -variable remote_exec -value true
     radiobutton $wi.select.local -text "locally" \
-        -command "enable_disable $wi"\
-        -variable remote_exec -value false
+       -command "enable_disable $wi"\
+       -variable remote_exec -value false
     checkbutton $wi.select.editor -text "edit mode only" \
-        -command "enable_disable $wi"\
-        -variable editor_only -onvalue true -offvalue false
+       -command "enable_disable $wi"\
+       -variable editor_only -onvalue true -offvalue false
     pack $wi.select.local $wi.select.remote $wi.select.editor -side left
 
     labelframe $wi.hosts -pady 2 -text "Remote hosts:" -padx 2
@@ -3424,29 +3424,29 @@ proc configRemoteHosts {} {
     set i 0
     foreach host_elem $exec_hosts {
 
-        eval label $wi.hosts.labels.v$i -text "$i. " -anchor e
+       eval label $wi.hosts.labels.v$i -text "$i. " -anchor e
 
-        eval entry $wi.hosts.address.v$i -bg white -width 15 \
-            -validate focus -invcmd "focusAndFlash"
-        $wi.hosts.address.v$i insert 0 [lindex $host_elem 0]
+       eval entry $wi.hosts.address.v$i -bg white -width 15 \
+           -validate focus -invcmd "focusAndFlash"
+       $wi.hosts.address.v$i insert 0 [lindex $host_elem 0]
 
-        eval entry $wi.hosts.ports.v$i -bg white -width 5 \
-            -validate focus -invcmd "focusAndFlash"
-        $wi.hosts.ports.v$i insert 0 [lindex $host_elem 1]
+       eval entry $wi.hosts.ports.v$i -bg white -width 5 \
+           -validate focus -invcmd "focusAndFlash"
+       $wi.hosts.ports.v$i insert 0 [lindex $host_elem 1]
 
-        eval entry $wi.hosts.monitors.v$i -bg white -width 5 \
-        -validate focus -invcmd "focusAndFlash"
-        $wi.hosts.monitors.v$i insert 0 [lindex $host_elem 2]
+       eval entry $wi.hosts.monitors.v$i -bg white -width 5 \
+       -validate focus -invcmd "focusAndFlash"
+       $wi.hosts.monitors.v$i insert 0 [lindex $host_elem 2]
 
-        eval checkbutton $wi.hosts.active.v$i \
-            -variable active_host($i) -onvalue true -offvalue false
+       eval checkbutton $wi.hosts.active.v$i \
+           -variable active_host($i) -onvalue true -offvalue false
 
 #   eval entry $wi.hosts.weight.v$i -bg white -width 5 \
 #       -validate focus -invcmd "focusAndFlash"
 #   $wi.hosts.weight.v$i insert 0 [lindex $host_elem 4]
  
     eval checkbutton $wi.hosts.ssh.v$i \
-        -variable active_ssh($i) -onvalue true -offvalue false  
+       -variable active_ssh($i) -onvalue true -offvalue false  
     #    -command {
     #   if { active_ssh(0) } {
     #       eval $wi.hosts.userName.v$i -configure state normal
@@ -3456,27 +3456,27 @@ proc configRemoteHosts {} {
     #    } 
 
     eval entry $wi.hosts.userName.v$i -bg white -width 5 \
-        -validate focus -invcmd "focusAndFlash"
+       -validate focus -invcmd "focusAndFlash"
     $wi.hosts.userName.v$i insert 0 [lindex $host_elem 5]
 
-        incr i
+       incr i
     }
 
     foreach j [list labels address ports monitors active ssh userName] {
-        eval pack $wi.hosts.$j.label -side top -padx 4 -pady 2 -fill x
-        set n [llength $exec_hosts]
-        for {set i 0} {$i < $n} {incr i} {
-            eval pack $wi.hosts.$j.v$i -side top -padx 4 -pady 2 -fill x
-        }
+       eval pack $wi.hosts.$j.label -side top -padx 4 -pady 2 -fill x
+       set n [llength $exec_hosts]
+       for {set i 0} {$i < $n} {incr i} {
+           eval pack $wi.hosts.$j.v$i -side top -padx 4 -pady 2 -fill x
+       }
     }
     pack $wi.hosts.labels $wi.hosts.address $wi.hosts.ports \
-         $wi.hosts.monitors $wi.hosts.active  \
+        $wi.hosts.monitors $wi.hosts.active  \
      $wi.hosts.ssh $wi.hosts.userName -side left -fill x
     pack $wi.select $wi.hosts -side top -fill x -padx 4
 
     frame $wi.butt -borderwidth 4
     button $wi.butt.apply -text "Apply" -command \
-          "configRemoteHostsApply $wi; destroy $wi"
+         "configRemoteHostsApply $wi; destroy $wi"
     focus $wi.butt.apply
     button $wi.butt.cancel -text "Cancel" -command \
     "set remote_exec $old_remote_exec; destroy $wi"
@@ -3486,7 +3486,7 @@ proc configRemoteHosts {} {
     enable_disable $wi
 
     after 100 {
-        grab .popup
+       grab .popup
     }
     ;# Apply and Cancel explicitly destroy $wi
     vwait forever
@@ -3512,17 +3512,17 @@ proc configRemoteHostsApply { wi } {
     set exec_hosts []
     set at_least_one_up false
     for {set i 0} {$i < $n} {incr i} {
-        set ent [list [$wi.hosts.address.v$i get] \
-                      [$wi.hosts.ports.v$i get]   \
-                      [$wi.hosts.monitors.v$i get]\
-                      $active_host($i) \
-              $active_ssh($i)\
-              [$wi.hosts.userName.v$i get]]
-        lappend exec_hosts $ent
-        if { $active_host($i) } { set at_least_one_up true }
+       set ent [list [$wi.hosts.address.v$i get] \
+                     [$wi.hosts.ports.v$i get]   \
+                     [$wi.hosts.monitors.v$i get]\
+                     $active_host($i) \
+             $active_ssh($i)\
+             [$wi.hosts.userName.v$i get]]
+       lappend exec_hosts $ent
+       if { $active_host($i) } { set at_least_one_up true }
     }
     if { $remote_exec && ! $at_least_one_up } {
-        set editor_only true
+       set editor_only true
     .menubar.experiment entryconfigure "Execute" -state disabled
     }
 #    catch { unset exec_sock monitor_sock } message
@@ -3547,22 +3547,22 @@ proc enable_disable { wi } {
     set i 0
 
     if { ! $remote_exec || $editor_only } {
-        set state disabled
+       set state disabled
     } else {
-        set state normal
+       set state normal
     }
 
     if { $editor_only } {
     .menubar.experiment entryconfigure "Execute" -state disabled
     } else {
-        .menubar.experiment entryconfigure "Execute" -state normal
+       .menubar.experiment entryconfigure "Execute" -state normal
     }
 
     foreach host_elem $exec_hosts {
-        eval $wi.hosts.address.v$i configure -state $state
-        eval $wi.hosts.ports.v$i configure -state $state
-        eval $wi.hosts.monitors.v$i configure -state $state
-        #eval $wi.hosts.weight.v$i configure -state $state
+       eval $wi.hosts.address.v$i configure -state $state
+       eval $wi.hosts.ports.v$i configure -state $state
+       eval $wi.hosts.monitors.v$i configure -state $state
+       #eval $wi.hosts.weight.v$i configure -state $state
     eval $wi.hosts.ssh.v$i configure -state $state
     eval $wi.hosts.userName.v$i configure -state $state
     incr i 
@@ -3578,46 +3578,46 @@ proc zoom { dir } {
     set minzoom [lindex $stops 0]
     set maxzoom [lindex $stops [expr [llength $stops] - 1]]
     switch -exact -- $dir {
-        "down" {
-            if {$zoom > $maxzoom} {
-                set zoom $maxzoom
-            } elseif {$zoom < $minzoom} {
-                ; # leave it unchanged
-            } else {
-                set newzoom $minzoom
-                foreach z $stops {
-                    if {$zoom <= $z} {
-                        break
-                    } else {
-                        set newzoom $z
-                    }
-                }
-                set zoom $newzoom 
-            }
-            redrawAll
-        }
-        "up" {
-            if {$zoom < $minzoom} {
-                set zoom $minzoom
-            } elseif {$zoom > $maxzoom} {
-                ; # leave it unchanged
-            } else {
-                foreach z [lrange $stops 1 end] {
-                    set newzoom $z
-                    if {$zoom < $z} {
-                        break
-                    }
-                }
-                set zoom $newzoom 
-            }
-            redrawAll
-        }
-        default {
-            if { $i < [expr [llength $stops] - 1] } {
-                set zoom [lindex $stops [expr $i + 1]]
-                redrawAll
-            }
-        }
+       "down" {
+           if {$zoom > $maxzoom} {
+               set zoom $maxzoom
+           } elseif {$zoom < $minzoom} {
+               ; # leave it unchanged
+           } else {
+               set newzoom $minzoom
+               foreach z $stops {
+                   if {$zoom <= $z} {
+                       break
+                   } else {
+                       set newzoom $z
+                   }
+               }
+               set zoom $newzoom 
+           }
+           redrawAll
+       }
+       "up" {
+           if {$zoom < $minzoom} {
+               set zoom $minzoom
+           } elseif {$zoom > $maxzoom} {
+               ; # leave it unchanged
+           } else {
+               foreach z [lrange $stops 1 end] {
+                   set newzoom $z
+                   if {$zoom < $z} {
+                       break
+                   }
+               }
+               set zoom $newzoom 
+           }
+           redrawAll
+       }
+       default {
+           if { $i < [expr [llength $stops] - 1] } {
+               set zoom [lindex $stops [expr $i + 1]]
+               redrawAll
+           }
+       }
     }
 }
 
@@ -3637,7 +3637,7 @@ proc double1onGrid { c x y } {
     set tags [$c gettags $obj]
     set node [lindex $tags 1]
     if {[lsearch $tags grid] != -1 || [lsearch $tags background] != -1} {
-        return
+       return
     }
     # Is this really necessary?
     set coords [getNodeCoords $node] 
@@ -3646,10 +3646,10 @@ proc double1onGrid { c x y } {
     set x2 [lindex $coords 2]
     set y2 [lindex $coords 3]
     if {$x < $x1 || $x > $x2 || $y < $y1 || $y > $y2} {
-        # cursor is not ON the closest object
-        return
+       # cursor is not ON the closest object
+       return
     } else {
-        annotationConfig $c $node
+       annotationConfig $c $node
     }
 }
 
@@ -3662,12 +3662,12 @@ proc setZoom { x y } {
     toplevel $w -takefocus 1
 
     if { $x == 0 && $y == 0 } {
-        set screen [wm maxsize .]
-        set x [expr {[lindex $screen 0] / 2}]
-        set y [expr {[lindex $screen 1] / 2}]
+       set screen [wm maxsize .]
+       set x [expr {[lindex $screen 0] / 2}]
+       set y [expr {[lindex $screen 1] / 2}]
     } else {
-        set x [expr {$x + 10}]
-        set y [expr {$y - 90}]
+       set x [expr {$x + 10}]
+       set y [expr {$y - 90}]
     }
     wm geometry $w +$x+$y
     wm title $w "Set zoom %"
@@ -3697,8 +3697,8 @@ proc setZoomApply { w } {
 
     set newzoom [expr [$w.e1 get] / 100.0]
     if { $newzoom != $zoom } {
-        set zoom $newzoom
-        redrawAll
+       set zoom $newzoom
+       redrawAll
     }
     destroy $w
 }
@@ -3714,12 +3714,12 @@ proc selectZoom { x y } {
     toplevel $w -takefocus 1
 
     if { $x == 0 && $y == 0 } {
-        set screen [wm maxsize .]
-        set x [expr {[lindex $screen 0] / 2}]
-        set y [expr {[lindex $screen 1] / 2}]
+       set screen [wm maxsize .]
+       set x [expr {[lindex $screen 0] / 2}]
+       set y [expr {[lindex $screen 1] / 2}]
     } else {
-        set x [expr {$x + 10}]
-        set y [expr {$y - 90}]
+       set x [expr {$x + 10}]
+       set y [expr {$y - 90}]
     }
     wm geometry $w +$x+$y
     wm title $w "Select zoom %"
index 56fb8316613b180c55cbf8495f3dd9f1ae671400..ea7eb5f484a6d1b5577c33e80aaeb4d76e728b74 100755 (executable)
--- a/exec.tcl
+++ b/exec.tcl
@@ -1,4 +1,4 @@
-# $Id: exec.tcl,v 1.46.2.3 2007/07/11 12:15:35 miljenko Exp $ 
+# $Id: exec.tcl,v 1.46.2.4 2007/07/19 00:12:45 marko Exp $ 
 
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -55,8 +55,8 @@ proc nexec { args } {
     global execSock
 
     if { $remote_exec } {
-        if { ![info exists execSock] || $execSock == "" } {
-            remoteStart 
+       if { ![info exists execSock] || $execSock == "" } {
+           remoteStart 
        }
     }
 
@@ -70,7 +70,7 @@ proc nexec { args } {
     if { $remote_exec } {
        rexec $execSock $args   
     } else {
-        eval exec $args
+       eval exec $args
     }
 }
 
@@ -103,15 +103,15 @@ proc nexec_monitor { args } {
 
     if { $editor_only } {
       tk_messageBox -title "Editor only" \
-         -message "Running in editor only mode. Cannot execute commands. Please report this problem." \
-         -type ok
+        -message "Running in editor only mode. Cannot execute commands. Please report this problem." \
+        -type ok
       exit 5
     }
 
     if { $remote_exec } {
        rexec $monSock $args 
     } else {
-        eval exec $args
+       eval exec $args
     }
 }
 
@@ -145,11 +145,11 @@ proc setOperMode { mode } {
     global undolevel redolevel
 
     if { $mode == "exec" } { ;# let's try something, sockets should be opened
-        nexec id -u
-        if { $editor_only } { ;# if set in nexec or open_exec_sockets
+       nexec id -u
+       if { $editor_only } { ;# if set in nexec or open_exec_sockets
            .menubar.experiment entryconfigure "Execute" -state disabled
-            return
-        }
+           return
+       }
     }
 
     # Verify that links to external interfaces are properly configured
@@ -205,10 +205,10 @@ proc setOperMode { mode } {
        }
     } else {
        if {$oper_mode != "edit"} {
-            # it is faster to remove everything
+           # it is faster to remove everything
            vimageCleanup
-            # cleanupCfg is used for multi user/experiment 
-            # environments (not supported in this version)
+           # cleanupCfg is used for multi user/experiment 
+           # environments (not supported in this version)
            #cleanupCfg
            .menubar.tools entryconfigure "Auto rearrange all" -state normal
            .menubar.tools entryconfigure "Auto rearrange selected" -state normal
@@ -220,15 +220,15 @@ proc setOperMode { mode } {
        }
        .menubar.experiment entryconfigure "Terminate" -state disabled
        if { $undolevel > 0 } {
-            .menubar.edit entryconfigure "Undo" -state normal
-        } else {
-            .menubar.edit entryconfigure "Undo" -state disabled
-        }
-        if { $redolevel > $undolevel } {
-            .menubar.edit entryconfigure "Redo" -state normal
-        } else {
-            .menubar.edit entryconfigure "Redo" -state disabled
-        }
+           .menubar.edit entryconfigure "Undo" -state normal
+       } else {
+           .menubar.edit entryconfigure "Undo" -state disabled
+       }
+       if { $redolevel > $undolevel } {
+           .menubar.edit entryconfigure "Redo" -state normal
+       } else {
+           .menubar.edit entryconfigure "Redo" -state disabled
+       }
        set oper_mode edit
        remoteClose
     }
@@ -251,10 +251,10 @@ proc statline {line} {
     global execMode
 
     if {$execMode == "batch"} {
-        puts $line
+       puts $line
     } else {
-        .bottom.textbox config -text "$line"
-        animateCursor
+       .bottom.textbox config -text "$line"
+       animateCursor
     }
 }
 
@@ -415,14 +415,14 @@ proc l3node.start { eid node } {
        global viewcustomid
     set check [info exists viewcustomid]
     if { $check == 0 } {
-        set viewcustomid generic
+       set viewcustomid generic
     }
     if { [getCustomEnabled $node] == true } {
     set customCfg ""
        set customCfgList ""
     set customCfgList [getCustomConfig $node]
     foreach element $customCfgList {
-        set cid [lindex [lsearch -inline $element "custom-config-id *"] 1]
+       set cid [lindex [lsearch -inline $element "custom-config-id *"] 1]
                if { $cid == $viewcustomid } {
                        set customCfg $element
                }
@@ -440,17 +440,17 @@ proc l3node.start { eid node } {
 
        set ipsecCfg ""
     if { [getIpsecEnabled $node] == true } {
-        set setkeycfg [ipsecCfggen $node]
-        set setkeyFileId [open /tmp/$node_id/setkey.conf w+]
-        foreach line $setkeycfg {
-            puts $setkeyFileId $line
-        }
-        close $setkeyFileId
+       set setkeycfg [ipsecCfggen $node]
+       set setkeyFileId [open /tmp/$node_id/setkey.conf w+]
+       foreach line $setkeycfg {
+           puts $setkeyFileId $line
+       }
+       close $setkeyFileId
 
                set error ""
                set errorstr ""
-        set error [catch "nexec vimage $node_id setkey -f \
-            /tmp/$node_id/setkey.conf" errorstr]
+       set error [catch "nexec vimage $node_id setkey -f \
+           /tmp/$node_id/setkey.conf" errorstr]
                if { $error == "1" } {
                        setkeyError $node_id $errorstr
                }
@@ -461,11 +461,11 @@ proc l3node.start { eid node } {
        set bootcmd [[typemodel $node].bootcmd $node]
     }
     if { ! $remote_exec } {
-        set fileId [open /tmp/$node_id/boot.conf w]
-        foreach line $bootcfg {
+       set fileId [open /tmp/$node_id/boot.conf w]
+       foreach line $bootcfg {
            puts $fileId $line
-        }
-        close $fileId
+       }
+       close $fileId
     } else {
        nexec create_conf_file /tmp/$node_id/boot.conf
        foreach line $bootcfg {
@@ -521,11 +521,11 @@ proc l3node.destroy {eid node } {
     set node_id "$eid\_$node"
     foreach ifc [ifcList $node] {
        catch { nexec ngctl msg $ifc@$node_id: shutdown }
-        set ifnum [string range $ifc 3 end]
-        set ifname [string range $ifc 0 2]
-        if { $ifname == "ser" } {
+       set ifnum [string range $ifc 3 end]
+       set ifname [string range $ifc 0 2]
+       if { $ifname == "ser" } {
            catch { nexec ngctl msg hdlc$ifnum@$node_id: shutdown }
-        }
+       }
     }
     catch {nexec vimage -d $node_id}
     nexec rm -fr /tmp/$node_id
@@ -600,10 +600,10 @@ proc deployCfg {} {
        }
 
        set lname $eid\_$lnode1-$lnode2
-        set bandwidth [expr [getLinkBandwidth $link] + 0]
-        set delay [expr [getLinkDelay $link] + 0]
-        set ber [expr [getLinkBER $link] + 0]
-        set dup [expr [getLinkDup $link] + 0]
+       set bandwidth [expr [getLinkBandwidth $link] + 0]
+       set delay [expr [getLinkDelay $link] + 0]
+       set ber [expr [getLinkBER $link] + 0]
+       set dup [expr [getLinkDup $link] + 0]
 
        set ngpeer1 \
                [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 0]
@@ -621,11 +621,11 @@ proc deployCfg {} {
        nexec ngctl msg $lname: setcfg "{ header_offset=14 }"
 
        # Link parameters
-        ;# Not working: execSetLinkParams $eid $link
-        nexec ngctl msg $lname: setcfg \
-            "{ bandwidth=$bandwidth delay=$delay \
-               upstream={ BER=$ber duplicate=$dup } \
-               downstream={ BER=$ber duplicate=$dup } }"
+       ;# Not working: execSetLinkParams $eid $link
+       nexec ngctl msg $lname: setcfg \
+           "{ bandwidth=$bandwidth delay=$delay \
+              upstream={ BER=$ber duplicate=$dup } \
+              downstream={ BER=$ber duplicate=$dup } }"
 
        # Queues
        foreach node [list $lnode1 $lnode2] {
@@ -988,8 +988,8 @@ proc cleanupCfg { } {
 proc openFwrd { lPort rPort rHost } {
     global tcl_platform platform
     if { $tcl_platform(platform) == "unix" } {
-        set pid [exec ssh -N -L $lPort:localhost:$rPort $rHost &]
-        return $pid
+       set pid [exec ssh -N -L $lPort:localhost:$rPort $rHost &]
+       return $pid
     }
 }
 
@@ -1038,7 +1038,7 @@ proc open_sock { rHost rPort } {
        catch { set sock [socket $rHost $rPort] }
     }
     if { [info exists sock] } {
-        return $sock
+       return $sock
     } else  {
        return ""
     }
@@ -1083,21 +1083,21 @@ proc rexec { io command } {
 
     gets $io line
     if { $line == "Kraj rada" } {
-        close $io
+       close $io
     }
     if {$line != "Kraj" } {
-        set response $line
+       set response $line
        if { [string match "imunes -b *" $command] } {
            statline $line
        } 
-        gets $io line
+       gets $io line
     }
     while { $line != "Kraj" } {
-        append response "\n" $line
-        if { [string match "imunes -b *" $command] } {
-            statline $line
-        }
-        gets $io line
+       append response "\n" $line
+       if { [string match "imunes -b *" $command] } {
+           statline $line
+       }
+       gets $io line
     }
     return $response
 }
@@ -1121,7 +1121,7 @@ proc remoteStart {} {
     set remote_exec false
     set n [llength $exec_hosts]
     for { set i 0 } { $i < $n } { incr i } {
-        if { [lindex [lindex $exec_hosts $i] 3] } {
+       if { [lindex [lindex $exec_hosts $i] 3] } {
            set rHost [lindex [lindex $exec_hosts $i] 0]
            set rePort [lindex [lindex $exec_hosts $i] 1]
            set rmPort [lindex [lindex $exec_hosts $i] 2]
@@ -1130,7 +1130,7 @@ proc remoteStart {} {
            set remote_exec true
            set exec_host $rHost
            break
-        }
+       }
     }
 
     if { ! $remote_exec } { return }
@@ -1152,9 +1152,9 @@ proc remoteStart {} {
     } 
     if { $monSock == ""  || $execSock == "" } {
        set sel [tk_dialog .box "Socket problems" \
-            "Cannot open sockets" \
-             "" 0 "Retry" "Configure remote hosts" "Editor only mode" ]
-        switch $sel {    
+           "Cannot open sockets" \
+            "" 0 "Retry" "Configure remote hosts" "Editor only mode" ]
+       switch $sel {    
            0 {
                remoteStart  
            }
index 9a24f3d1443ee148a876d808807b4ebc46944e7b..d2dd6709d720b690a2df97e453f7a68eca53e2a4 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: exec_server.tcl,v 1.3.2.1 2007/05/07 08:20:09 ana Exp $ 
+# $Id: exec_server.tcl,v 1.3.2.2 2007/07/19 00:12:45 marko Exp $ 
 #! /usr/local/bin/tclsh8.4
 
 #######
@@ -61,51 +61,51 @@ proc Exec_command {sock} {
        close $sock
        puts "Close $client(addr,$sock)"
        unset client(addr,$sock)
-        return
+       return
     } 
 
     if { $debug_output } { puts "$server_port/K: >$line<" }
 
     if { $line == "Kraj" } {
-        puts "Kraj rada."
-        puts $sock "Kraj"
-        close $sock
-        exit 0
+       puts "Kraj rada."
+       puts $sock "Kraj"
+       close $sock
+       exit 0
     }
 
 
     if {$spremam_conf_fajl} {
        if { $line == "close_conf_file" } {
-            if { $debug_output} { puts "Zatvaram conf fajl" }
-            close $fileId
-            set spremam_conf_fajl false
+           if { $debug_output} { puts "Zatvaram conf fajl" }
+           close $fileId
+           set spremam_conf_fajl false
            puts $sock "Kraj"
        } else {
-            catch {puts $fileId $line} odg
-            if { $debug_output && ($odg != "") } { 
-                puts "$server_port/puts greska: $odg" 
-            }
+           catch {puts $fileId $line} odg
+           if { $debug_output && ($odg != "") } { 
+               puts "$server_port/puts greska: $odg" 
+           }
        }
     } else {
        if { [lindex $line 0] == "create_conf_file" } {
-            set conf_fajl [lindex $line 1]
-            if { $debug_output} { puts "Spremam conf fajl: $conf_fajl" }
-            set fileId [open "$conf_fajl" w]
-            ;# dodati provjeru!!!
-            set spremam_conf_fajl true
-
-        } else {
-            if { [llength $line] == 0 } { return} 
-            catch {eval exec $line} odg
-            if { $debug_output } { puts "$server_port/O: $odg" }
-            puts $sock $odg 
-        }
+           set conf_fajl [lindex $line 1]
+           if { $debug_output} { puts "Spremam conf fajl: $conf_fajl" }
+           set fileId [open "$conf_fajl" w]
+           ;# dodati provjeru!!!
+           set spremam_conf_fajl true
+
+       } else {
+           if { [llength $line] == 0 } { return} 
+           catch {eval exec $line} odg
+           if { $debug_output } { puts "$server_port/O: $odg" }
+           puts $sock $odg 
+       }
 
        puts $sock "Kraj"
     }
     catch {flush $sock} rez
     if { $rez != "" } {
-        puts "Socket closed on remote.\n$rez"
+       puts "Socket closed on remote.\n$rez"
     }
 }
 
index f4442df8749617130b8a4fe720ef669dec8935d9..15ccb457e31a6adb3f3a0ab6c842a44331448f8a 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: filemgmt.tcl,v 1.7.2.2 2007/07/11 12:11:12 miljenko Exp $ 
+# $Id: filemgmt.tcl,v 1.7.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -82,7 +82,7 @@
 set currentFile ""
 
 set fileTypes {{"IMUNES network configuration" {.imn} }
-           { "All files" {*}}}
+          { "All files" {*}}}
 
           
 #****f* filemgmt.tcl/newFile
@@ -129,7 +129,7 @@ proc openFile {} {
     set fileId [open $currentFile r]
     set cfg ""
     foreach entry [read $fileId] {
-        lappend cfg $entry
+       lappend cfg $entry
     }
     close $fileId
     loadCfg $cfg
@@ -157,12 +157,12 @@ proc openFile {} {
 proc saveFile { selectedFile } {
     global currentFile 
     if { $selectedFile != ""} {
-        set currentFile $selectedFile
-        set fileName [file tail $currentFile]
-        wm title . "IMUNES $fileName"
-        set fileId [open $currentFile w]
-        dumpCfg file $fileId
-        close $fileId
+       set currentFile $selectedFile
+       set fileName [file tail $currentFile]
+       wm title . "IMUNES $fileName"
+       set fileId [open $currentFile w]
+       dumpCfg file $fileId
+       close $fileId
        .bottom.textbox config -text "Saved $fileName"
     }
 }
@@ -182,8 +182,8 @@ proc fileOpenStartUp {} {
     global currentFile
 
     if { $argv != "" } {
-        set currentFile $argv
-        openFile
+       set currentFile $argv
+       openFile
     }
 }
 
@@ -200,15 +200,15 @@ proc fileNewDialogBox {} {
     global currentFile
 
     set choice [tk_messageBox -type yesnocancel -default yes\
-          -message "Save changes?" -icon question]
+         -message "Save changes?" -icon question]
     
     if { $choice != "cancel"} {
-        if { $choice == "yes"} {
-            fileSaveDialogBox    
-            newFile
-        } else {
-            newFile
-        }
+       if { $choice == "yes"} {
+           fileSaveDialogBox    
+           newFile
+       } else {
+           newFile
+       }
     }
 }
 
@@ -226,8 +226,8 @@ proc fileOpenDialogBox {} {
     global fileTypes
     set selectedFile [tk_getOpenFile -filetypes $fileTypes]
     if { $selectedFile != ""} {
-        set currentFile $selectedFile
-        openFile
+       set currentFile $selectedFile
+       openFile
     }
 }
 
@@ -246,11 +246,11 @@ proc fileSaveDialogBox {} {
     global fileTypes
     
     if { $currentFile == "" } {
-        set selectedFile [tk_getSaveFile -filetypes $fileTypes -initialfile\
-                   untitled -defaultextension .imn]
-        saveFile $selectedFile
+       set selectedFile [tk_getSaveFile -filetypes $fileTypes -initialfile\
+                  untitled -defaultextension .imn]
+       saveFile $selectedFile
     } else {
-        saveFile $currentFile
+       saveFile $currentFile
     }
 }
 
@@ -267,7 +267,7 @@ proc fileSaveAsDialogBox {} {
     global currentFile 
     global fileTypes
     set selectedFile [tk_getSaveFile -filetypes $fileTypes -initialfile\
-               untitled -defaultextension .imn]
+              untitled -defaultextension .imn]
 
     saveFile $selectedFile 
 }
@@ -295,15 +295,15 @@ proc readConfigFile {} {
     global exec_hosts remote_exec editor_only
     global env
     if { [file exists ".imunesrc"] } {
-        source ".imunesrc"
+       source ".imunesrc"
     } else {
-        if { [catch {set myhome $env(HOME)}] } {
-            ;# not running on UNIX
-        } else {
-            if { [file exists "$myhome/.imunesrc"] } {
-               source "$myhome/.imunesrc"
-            }
-        }
+       if { [catch {set myhome $env(HOME)}] } {
+           ;# not running on UNIX
+       } else {
+           if { [file exists "$myhome/.imunesrc"] } {
+              source "$myhome/.imunesrc"
+           }
+       }
     }
 }
 
@@ -311,15 +311,15 @@ proc readConfigFile {} {
 #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}"]
-#        }
+#      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}"]
+#      }
 #    }
 #}
 
@@ -349,20 +349,20 @@ proc relpath {target} {
     set tparts [file split [file normalize $target]]
 
     if {[lindex $bparts 0] eq [lindex $tparts 0]} {
-        # If the first part doesn't match - there is no good relative path
-        set blen [expr {[llength $bparts] - 1}]
-        set tlen [llength $tparts]
-        for {set i 1} {$i < $blen && $i < $tlen} {incr i} {
-            if {[lindex $bparts $i] ne [lindex $tparts $i]} { break }
-        }
-        set path [lrange $tparts $i end]
-        for {} {$i < $blen} {incr i} {
-            set path [linsert $path 0 ..]
-        }
-        # Full name:
-        # [file normalize [join $path [file separator]]]
-        # Relative file name:
-        return [join $path [file separator]]
+       # If the first part doesn't match - there is no good relative path
+       set blen [expr {[llength $bparts] - 1}]
+       set tlen [llength $tparts]
+       for {set i 1} {$i < $blen && $i < $tlen} {incr i} {
+           if {[lindex $bparts $i] ne [lindex $tparts $i]} { break }
+       }
+       set path [lrange $tparts $i end]
+       for {} {$i < $blen} {incr i} {
+           set path [linsert $path 0 ..]
+       }
+       # Full name:
+       # [file normalize [join $path [file separator]]]
+       # Relative file name:
+       return [join $path [file separator]]
     }
     return $target
 }
index 5a19802054ed157329850692f36d72dc2ab4eda5..d4a16c1968b50660c82b6356caadc5d72962244a 100755 (executable)
--- a/host.tcl
+++ b/host.tcl
@@ -1,4 +1,4 @@
-# $Id: host.tcl,v 1.13.2.1 2007/05/07 08:20:09 ana Exp $ 
+# $Id: host.tcl,v 1.13.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -152,14 +152,14 @@ proc $MODULE.bootcmd { node } {
 proc $MODULE.shellcmd { node } {
     set ret [nexec whereis -b bash]
     if { [llength $ret] == 2 } {
-        return [lindex $ret 1]
+       return [lindex $ret 1]
     } else {
-        set ret [nexec whereis -b tcsh]
-        if { [llength $ret] == 2 } {
-            return [lindex $ret 1]
-        } else {
-            return "/bin/sh"
-        }
+       set ret [nexec whereis -b tcsh]
+       if { [llength $ret] == 2 } {
+           return [lindex $ret 1]
+       } else {
+           return "/bin/sh"
+       }
     }
 }
 
index 0ca915ff92586a92dcc65583cfd77acec0e3d999..6018d515dbcda7efc093688d7762d1604fb1191d 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: imunes.tcl,v 1.19.2.2 2007/07/11 12:21:08 miljenko Exp $ 
+# $Id: imunes.tcl,v 1.19.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -41,7 +41,7 @@
 #    Starts imunes in batch or interactive mode. Include procedures from
 #    external files and initializes global variables.
 #
-#        imunes [-b|--batch] [filename]
+#      imunes [-b|--batch] [filename]
 #    
 #    When starting the program in batch mode the option -b or --batch must 
 #    be specified. 
@@ -174,7 +174,7 @@ set eid e0
 #    List can be overwritten in config file .imunesrc 
 #*****
 
-#         IP            port  monitor_port
+#       IP            port  monitor_port
 set exec_hosts [list \
     [list 192.168.1.100 2547  2548 false ] \
     [list 10.0.0.1      1234  5678 false ] \
index f2e9ad493c0c62f76455c879f8412d88f884d05e..55ec92aa0e212158bdd60cdc6ce01e2c5f939d1b 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: initgui.tcl,v 1.34.2.2 2007/07/11 12:11:12 miljenko Exp $ 
+# $Id: initgui.tcl,v 1.34.2.3 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -266,10 +266,10 @@ 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 } {
-         return
+        return
     }
     foreach obj [.c find withtag node] {
-        selectNode .c $obj
+       selectNode .c $obj
     }
     deleteSelection
     set i [lsearch $canvas_list $curcanvas]
@@ -398,7 +398,7 @@ menu .menubar.view -tearoff 0
        set showNodeLabels 1
        set showLinkLabels 1
        redrawAllLinks
-        foreach object [.c find withtag linklabel] {
+       foreach object [.c find withtag linklabel] {
            .c itemconfigure $object -state normal
        }
     }
@@ -410,7 +410,7 @@ menu .menubar.view -tearoff 0
        set showNodeLabels 0
        set showLinkLabels 0
        redrawAllLinks
-        foreach object [.c find withtag linklabel] {
+       foreach object [.c find withtag linklabel] {
            .c itemconfigure $object -state hidden
        }
     }
@@ -478,15 +478,15 @@ foreach b {select link hub lanswitch router host pc rj45} {
     pack .left.$b -side top
     # hover status line
     switch -exact -- $b {
-        select { set msg "Select tool" }
-        link { set msg "Create link" }
-        hub { set msg "Add new Hub" }
-        lanswitch { set msg "Add new LAN switch" }
-        router { set msg "Add new Router" }
-        host { set msg "Add new Host" }
-        pc { set msg "Add new PC" }
-        rj45 { set msg "Add new external interface" }
-        default { set msg "" }
+       select { set msg "Select tool" }
+       link { set msg "Create link" }
+       hub { set msg "Add new Hub" }
+       lanswitch { set msg "Add new LAN switch" }
+       router { set msg "Add new Router" }
+       host { set msg "Add new Host" }
+       pc { set msg "Add new PC" }
+       rj45 { set msg "Add new external interface" }
+       default { set msg "" }
     }
     bind .left.$b <Any-Enter> ".bottom.textbox config -text {$msg}"
     bind .left.$b <Any-Leave> ".bottom.textbox config -text {}"
@@ -503,10 +503,10 @@ foreach b {rectangle oval text} {
     pack .left.$b -side bottom
     # hover status line
     switch -exact -- $b {
-        rectangle { set msg "Rectangle" }
-        oval { set msg "Oval" }
-        text { set msg "Text" }
-        default { set msg "" }
+       rectangle { set msg "Rectangle" }
+       oval { set msg "Oval" }
+       text { set msg "Text" }
+       default { set msg "" }
     }
     bind .left.$b <Any-Enter> ".bottom.textbox config -text {$msg}"
     bind .left.$b <Any-Leave> ".bottom.textbox config -text {}"
index a68e4698b6a699bcef2b626b21b5ea1f6a992215..592dd0b7db65e49c218d366438905f8abb8f6d03 100755 (executable)
--- a/ipsec.tcl
+++ b/ipsec.tcl
@@ -1,4 +1,4 @@
-# $Id: ipsec.tcl,v 1.3.2.4 2007/07/11 13:23:06 test Exp $ 
+# $Id: ipsec.tcl,v 1.3.2.5 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -163,22 +163,22 @@ proc viewIpsecCfg { node delete view } {
     set ipsecCfgList [getIpsecConfig $node]
     set len [llength $ipsecCfgList]
     foreach ipsecCfg $ipsecCfgList {
-        set id [lindex [lsearch -inline $ipsecCfg "ipsec-config-id *"] 1]
-        lappend idlist $id
+       set id [lindex [lsearch -inline $ipsecCfg "ipsec-config-id *"] 1]
+       lappend idlist $id
     }
     if { $delete == "1" } {
-        set viewid [lindex $idlist 0]
+       set viewid [lindex $idlist 0]
     }
     if { $view == "0" } {
-        catch {unset viewid}
+       catch {unset viewid}
     }
 
     set ipsecCfg ""
 
     if { $view == "1" && $idlist == {} } {
 
-        set error "There are no ipsec-config entries with specified ipsec-config-id."
-        showIpsecErrors $error
+       set error "There are no ipsec-config entries with specified ipsec-config-id."
+       showIpsecErrors $error
 
     } else {
 
@@ -1114,7 +1114,7 @@ proc checkSPrange { SPrange } {
 
 proc checkIPv46AddrPort { str } {
     if { $str == "" } {
-        return 1
+       return 1
     }
        set addr [lindex [split $str "\["] 0]
        set SAaddress [checkSAaddress $addr]
@@ -1149,7 +1149,7 @@ proc checkIPv46AddrPort { str } {
 
 proc checkSAaddress { str } {
     if { $str == "" } {
-        return 1
+       return 1
     }
        if { [checkIPv4Addr $str] == 1 } {
                return 1
@@ -1175,7 +1175,7 @@ proc checkSAaddress { str } {
 
 proc checkSPnet { str } {
     if { $str == "" } {
-        return 1
+       return 1
     }
        if { [checkIPv4Net $str] == 1 } {
                return 1
index 121f52189a33800074286669965faf98b1e8e125..a1f4380b24071882c0f6e54fa9b609db8a82a294 100755 (executable)
--- a/ipv4.tcl
+++ b/ipv4.tcl
@@ -1,4 +1,4 @@
-# $Id: ipv4.tcl,v 1.10.2.1 2007/05/07 08:20:09 ana Exp $ 
+# $Id: ipv4.tcl,v 1.10.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -58,20 +58,20 @@ proc findFreeIPv4Net { mask } {
 
     set ipnets {}
     foreach node $node_list {
-        foreach ifc [ifcList $node] {
-            set ipnet [lrange [split [getIfcIPv4addr $node $ifc] .] 0 2]
-            if {[lsearch $ipnets $ipnet] == -1} {
-                lappend ipnets $ipnet
-            }
-        }
+       foreach ifc [ifcList $node] {
+           set ipnet [lrange [split [getIfcIPv4addr $node $ifc] .] 0 2]
+           if {[lsearch $ipnets $ipnet] == -1} {
+               lappend ipnets $ipnet
+           }
+       }
     }
     for { set i 0 } { $i <= 255 } { incr i } {
-        for { set j 0 } { $j <= 255 } { incr j } {
-            if {[lsearch $ipnets "10 $i $j"] == -1} {
-                set ipnet "10.$i.$j"
-                return $ipnet
-            }
-        }
+       for { set j 0 } { $j <= 255 } { incr j } {
+           if {[lsearch $ipnets "10 $i $j"] == -1} {
+               set ipnet "10.$i.$j"
+               return $ipnet
+           }
+       }
     }
 }
 
@@ -106,14 +106,14 @@ proc autoIPv4addr { node iface } {
 
     if { [[typemodel $peer_node].layer] == "LINK" } {
        foreach l2node [listLANnodes $peer_node {}] {
-            foreach ifc [ifcList $l2node] {
+           foreach ifc [ifcList $l2node] {
                set peer [logicalPeerByIfc $l2node $ifc]
                set peer_if [ifcByLogicalPeer $peer $l2node]
                set peer_ip4addr [getIfcIPv4addr $peer $peer_if]
                if { $peer_ip4addr != "" } {
                    lappend peer_ip4addrs [lindex [split $peer_ip4addr /] 0]
                }
-            }
+           }
        }
     } else {
        set peer_if [ifcByLogicalPeer $peer_node $node]
@@ -121,27 +121,27 @@ proc autoIPv4addr { node iface } {
        set peer_ip4addrs [lindex [split $peer_ip4addr /] 0]
     }
     switch -exact -- [nodeType $node] {
-        router {
-            set targetbyte 1
-        }
-        host {
-            set targetbyte 10
-        }
-        pc {
-            set targetbyte 20
-        }
+       router {
+           set targetbyte 1
+       }
+       host {
+           set targetbyte 10
+       }
+       pc {
+           set targetbyte 20
+       }
     }
     if { $peer_ip4addrs != "" } {
-        set ipnums [split [lindex $peer_ip4addrs 0] .]
-        set net "[lindex $ipnums 0].[lindex $ipnums 1].[lindex $ipnums 2]"
-        set ipaddr $net.$targetbyte
-        while { [lsearch $peer_ip4addrs $ipaddr] >= 0 } {
-            incr targetbyte
-            set ipaddr $net.$targetbyte
-        }
-        setIfcIPv4addr $node $iface "$ipaddr/24"
+       set ipnums [split [lindex $peer_ip4addrs 0] .]
+       set net "[lindex $ipnums 0].[lindex $ipnums 1].[lindex $ipnums 2]"
+       set ipaddr $net.$targetbyte
+       while { [lsearch $peer_ip4addrs $ipaddr] >= 0 } {
+           incr targetbyte
+           set ipaddr $net.$targetbyte
+       }
+       setIfcIPv4addr $node $iface "$ipaddr/24"
     } else {
-        setIfcIPv4addr $node $iface "[findFreeIPv4Net 24].$targetbyte/24"
+       setIfcIPv4addr $node $iface "[findFreeIPv4Net 24].$targetbyte/24"
     }
 }
 
@@ -172,7 +172,7 @@ proc autoIPv4defaultroute { node iface } {
 
     if { [[typemodel $peer_node].layer] == "LINK" } {
        foreach l2node [listLANnodes $peer_node {}] {
-            foreach ifc [ifcList $l2node] {
+           foreach ifc [ifcList $l2node] {
                set peer [logicalPeerByIfc $l2node $ifc]
                if { [nodeType $peer] != "router" } {
                    continue
@@ -184,7 +184,7 @@ proc autoIPv4defaultroute { node iface } {
                    setStatIPv4routes $node [list "0.0.0.0/0 $gw"]
                    return
                }
-            }
+           }
        }
     } else {
        if { [nodeType $peer_node] != "router" } {
@@ -219,29 +219,29 @@ proc autoIPv4defaultroute { node iface } {
 proc checkIPv4Addr { str } {
     set n 0
     if { $str == "" } {
-        return 1
+       return 1
     }
     while { $n < 4 } {
-        if { $n < 3 } {
-            set i [string first . $str]
-        } else {
-            set i [string length $str]
-        }
-        if { $i < 1 } {
-            return 0
-        }
-        set part [string range $str 0 [expr $i - 1]]
-        if { [string length [string trim $part]] != $i } {
-            return 0
-        }
-        if { ![string is integer $part] } {
-            return 0
-        }
-        if { $part < 0 || $part > 255 } {
-            return 0
-        }
-        set str [string range $str [expr $i + 1] end]
-        incr n
+       if { $n < 3 } {
+           set i [string first . $str]
+       } else {
+           set i [string length $str]
+       }
+       if { $i < 1 } {
+           return 0
+       }
+       set part [string range $str 0 [expr $i - 1]]
+       if { [string length [string trim $part]] != $i } {
+           return 0
+       }
+       if { ![string is integer $part] } {
+           return 0
+       }
+       if { $part < 0 || $part > 255 } {
+           return 0
+       }
+       set str [string range $str [expr $i + 1] end]
+       incr n
     }
     return 1
 }
@@ -263,14 +263,14 @@ proc checkIPv4Addr { str } {
 
 proc checkIPv4Net { str } {
     if { $str == "" } {
-        return 1
+       return 1
     }
     if { ![checkIPv4Addr [lindex [split $str /] 0]]} {
-        return 0
+       return 0
     }
     set net [string trim [lindex [split $str /] 1]]
     if { [string length $net] == 0 } {
-        return 0
+       return 0
     }
     return [checkIntRange $net 0 32]
 }
index 31aa6ff75ffff510c77d9ddf019c4abb2f20428e..023d4b373ca2e84906d1dc1a1ebb907c6b334a97 100755 (executable)
--- a/ipv6.tcl
+++ b/ipv6.tcl
@@ -1,4 +1,4 @@
-# $Id: ipv6.tcl,v 1.8.2.1 2007/05/07 08:20:09 ana Exp $ 
+# $Id: ipv6.tcl,v 1.8.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -58,18 +58,18 @@ proc findFreeIPv6Net { mask } {
 
     set ipnets {}
     foreach node $node_list {
-        foreach ifc [ifcList $node] {
-            set ipnet [lrange [split [getIfcIPv6addr $node $ifc] :] 0 1]
-            if {[lsearch $ipnets $ipnet] == -1} {
-                lappend ipnets $ipnet
-            }
-        }
+       foreach ifc [ifcList $node] {
+           set ipnet [lrange [split [getIfcIPv6addr $node $ifc] :] 0 1]
+           if {[lsearch $ipnets $ipnet] == -1} {
+               lappend ipnets $ipnet
+           }
+       }
     }
     for { set i 0 } { $i <= 9999 } { incr i } {
-        if {[lsearch $ipnets "a $i"] == -1} {
-            set ipnet "a:$i"
-            return $ipnet
-        }
+       if {[lsearch $ipnets "a $i"] == -1} {
+           set ipnet "a:$i"
+           return $ipnet
+       }
     }
 }
 
@@ -95,14 +95,14 @@ proc autoIPv6addr { node iface } {
 
     if { [[typemodel $peer_node].layer] == "LINK" } {
        foreach l2node [listLANnodes $peer_node {}] {
-            foreach ifc [ifcList $l2node] {
+           foreach ifc [ifcList $l2node] {
                set peer [logicalPeerByIfc $l2node $ifc]
                set peer_if [ifcByLogicalPeer $peer $l2node]
                set peer_ip6addr [getIfcIPv6addr $peer $peer_if]
                if { $peer_ip6addr != "" } {
                    lappend peer_ip6addrs [lindex [split $peer_ip6addr /] 0]
                }
-            }
+           }
        }
     } else {
        set peer_if [ifcByLogicalPeer $peer_node $node]
@@ -110,27 +110,27 @@ proc autoIPv6addr { node iface } {
        set peer_ip6addrs [lindex [split $peer_ip6addr /] 0]
     }
     switch -exact -- [nodeType $node] {
-        router {
-            set targetbyte 1
-        }
-        host {
-            set targetbyte 10
-        }
-        pc {
-            set targetbyte 20
-        }
+       router {
+           set targetbyte 1
+       }
+       host {
+           set targetbyte 10
+       }
+       pc {
+           set targetbyte 20
+       }
     }
     if { $peer_ip6addrs != "" } {
-        set ipnums [split [lindex $peer_ip6addrs 0] :]
-        set net "[lindex $ipnums 0]:[lindex $ipnums 1]"
-        set ipaddr $net\::$targetbyte
-        while { [lsearch $peer_ip6addrs $ipaddr] >= 0 } {
-            incr targetbyte
-            set ipaddr $net\::$targetbyte
-        }
-        setIfcIPv6addr $node $iface "$ipaddr/64"
+       set ipnums [split [lindex $peer_ip6addrs 0] :]
+       set net "[lindex $ipnums 0]:[lindex $ipnums 1]"
+       set ipaddr $net\::$targetbyte
+       while { [lsearch $peer_ip6addrs $ipaddr] >= 0 } {
+           incr targetbyte
+           set ipaddr $net\::$targetbyte
+       }
+       setIfcIPv6addr $node $iface "$ipaddr/64"
     } else {
-        setIfcIPv6addr $node $iface "[findFreeIPv6Net 64]::$targetbyte/64"
+       setIfcIPv6addr $node $iface "[findFreeIPv6Net 64]::$targetbyte/64"
     }
 }
 
@@ -207,32 +207,32 @@ proc checkIPv6Addr { str } {
     set wordlist [split $str :]
     set wordcnt [expr [llength $wordlist] - 1]
     if { $wordcnt < 2 || $wordcnt > 7 } {
-        return 0
+       return 0
     }
     if { [lindex $wordlist 0] == "" } {
-        set wordlist [lreplace $wordlist 0 0 0]
+       set wordlist [lreplace $wordlist 0 0 0]
     }
     if { [lindex $wordlist $wordcnt] == "" } {
-        set wordlist [lreplace $wordlist $wordcnt $wordcnt 0]
+       set wordlist [lreplace $wordlist $wordcnt $wordcnt 0]
     }
     for { set i 0 } { $i <= $wordcnt } { incr i } {
-        set word [lindex $wordlist $i]
-        if { $word == "" } {
-            if { $doublec == "true" } {
-                return 0
-            }
-            set doublec true
-        }
-        if { [string length $word] > 4 } {
-            if { $i == $wordcnt } {
-                return [checkIPv4Addr $word]
-            } else {
-                return 0
-            }
-        }
-        if { [string is xdigit $word] == 0 } {
-            return 0
-        }
+       set word [lindex $wordlist $i]
+       if { $word == "" } {
+           if { $doublec == "true" } {
+               return 0
+           }
+           set doublec true
+       }
+       if { [string length $word] > 4 } {
+           if { $i == $wordcnt } {
+               return [checkIPv4Addr $word]
+           } else {
+               return 0
+           }
+       }
+       if { [string is xdigit $word] == 0 } {
+           return 0
+       }
     }
     return 1
 }
@@ -253,14 +253,14 @@ proc checkIPv6Addr { str } {
 
 proc checkIPv6Net { str } {
     if { $str == "" } {
-        return 1
+       return 1
     }
     if { ![checkIPv6Addr [lindex [split $str /] 0]]} {
-        return 0
+       return 0
     }
     set net [string trim [lindex [split $str /] 1]]
     if { [string length $net] == 0 } {
-        return 0
+       return 0
     }
     return [checkIntRange $net 0 128]
 }
index e2de7e360d33aee7dd573dac2764353b82aedb12..4b5e11a50decc65957304af8715ab9b08b9e51bc 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: linkcfg.tcl,v 1.14.2.1 2007/05/07 08:20:09 ana Exp $ 
+# $Id: linkcfg.tcl,v 1.14.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -141,19 +141,19 @@ proc removeLink { link } {
 
     set pnodes [linkPeers $link]
     foreach node $pnodes {
-        global $node
-        set i [lsearch $pnodes $node]
-        set peer [lreplace $pnodes $i $i]
-        set ifc [ifcByPeer $node $peer]
-        netconfClearSection $node "interface $ifc"
-        set i [lsearch [set $node] "interface-peer {$ifc $peer}"]
-        set $node [lreplace [set $node] $i $i]
-        if { [[typemodel $node].layer] == "NETWORK" } {
-            set ifcs [ifcList $node]
-            foreach ifc $ifcs {
-                autoIPv4defaultroute $node $ifc
-            }
-        }
+       global $node
+       set i [lsearch $pnodes $node]
+       set peer [lreplace $pnodes $i $i]
+       set ifc [ifcByPeer $node $peer]
+       netconfClearSection $node "interface $ifc"
+       set i [lsearch [set $node] "interface-peer {$ifc $peer}"]
+       set $node [lreplace [set $node] $i $i]
+       if { [[typemodel $node].layer] == "NETWORK" } {
+           set ifcs [ifcList $node]
+           foreach ifc $ifcs {
+               autoIPv4defaultroute $node $ifc
+           }
+       }
     }
     set i [lsearch -exact $link_list $link]
     set link_list [lreplace $link_list $i $i]
@@ -323,10 +323,10 @@ proc getLinkDelayString { link } {
        } elseif { $delay >= 1000 } {
            set delstr "[expr {$delay * .001}] ms"
        } else {
-            set delstr "$delay us"
+           set delstr "$delay us"
        }
     } else {
-        set delstr ""
+       set delstr ""
     }
     return $delstr
 }
index 0e5316a6a0d58c9cb5fbecbaa9e9805632a67652..86bc1f7be4948a9ad21ae6340ff8809c6ee0a1b0 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: nodecfg.tcl,v 1.16.2.1 2007/05/07 08:20:10 ana Exp $ 
+# $Id: nodecfg.tcl,v 1.16.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2004, 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -383,7 +383,7 @@ proc getCustomConfig { node } {
        } else {
        set values [lsearch -all -inline [set $node] "custom-config *"]
        foreach val $values {
-               lappend customCfgList [lindex $val 1]
+               lappend customCfgList [lindex $val 1]
        }
        }
 
@@ -567,7 +567,7 @@ proc netconfInsertSection { node section } {
        lappend section "!"
     }
     foreach line $section {
-        set netconf [linsert $netconf $lnum_beg $line]
+       set netconf [linsert $netconf $lnum_beg $line]
        if { $lnum_beg != "end" } {
            incr lnum_beg
        }
@@ -618,10 +618,10 @@ proc setIfcOperState { node ifc state } {
        lappend ifcfg " shutdown"
     }
     foreach line [netconfFetchSection $node "interface $ifc"] {
-        if { [lindex $line 0] != "shutdown" && \
+       if { [lindex $line 0] != "shutdown" && \
            [lrange $line 0 1] != "no shutdown" } {
-            lappend ifcfg $line
-        }
+           lappend ifcfg $line
+       }
     }
     netconfInsertSection $node $ifcfg
 }
@@ -675,10 +675,10 @@ proc setIfcQDisc { node ifc qdisc } {
        lappend ifcfg " drr-queue"
     }
     foreach line [netconfFetchSection $node "interface $ifc"] {
-        if { [lindex $line 0] != "fair-queue" && \
+       if { [lindex $line 0] != "fair-queue" && \
            [lindex $line 0] != "drr-queue" } {
-            lappend ifcfg $line
-        }
+           lappend ifcfg $line
+       }
     }
     netconfInsertSection $node $ifcfg
 }
@@ -828,9 +828,9 @@ proc getIfcMTU { node ifc } {
 proc setIfcMTU { node ifc mtu } {
     set ifcfg [list "interface $ifc"]
     foreach line [netconfFetchSection $node "interface $ifc"] {
-        if { [lindex $line 0] != "mtu" } {
-            lappend ifcfg $line
-        }
+       if { [lindex $line 0] != "mtu" } {
+           lappend ifcfg $line
+       }
     }
     switch -exact [string range $ifc 0 2] {
        eth { set limit 1500 }
@@ -883,9 +883,9 @@ proc getIfcIPv4addr { node ifc } {
 proc setIfcIPv4addr { node ifc addr } {
     set ifcfg [list "interface $ifc"]
     foreach line [netconfFetchSection $node "interface $ifc"] {
-        if { [lrange $line 0 1] != "ip address" } {
-            lappend ifcfg $line
-        }
+       if { [lrange $line 0 1] != "ip address" } {
+           lappend ifcfg $line
+       }
     }
     if { $addr != "" } {
        lappend ifcfg " ip address $addr"
@@ -934,9 +934,9 @@ proc getIfcIPv6addr { node ifc } {
 proc setIfcIPv6addr { node ifc addr } {
     set ifcfg [list "interface $ifc"]
     foreach line [netconfFetchSection $node "interface $ifc"] {
-        if { [lrange $line 0 1] != "ipv6 address" } {
-            lappend ifcfg $line
-        }
+       if { [lrange $line 0 1] != "ipv6 address" } {
+           lappend ifcfg $line
+       }
     }
     if { $addr != "" } {
        lappend ifcfg " ipv6 address $addr"
@@ -1397,7 +1397,7 @@ proc ifcByLogicalPeer { node peer } {
        # Must search through pseudo peers
        #
        foreach ifc [ifcList $node] {
-            set t_peer [peerByIfc $node $ifc]
+           set t_peer [peerByIfc $node $ifc]
            if { [nodeType $t_peer] == "pseudo" } {
                set mirror [getNodeMirror $t_peer]
                if { [peerByIfc $mirror [ifcList $mirror]] == $peer } {
@@ -1473,9 +1473,9 @@ proc removeNode { node } {
     global node_list $node
 
     foreach ifc [ifcList $node] {
-        set peer [peerByIfc $node $ifc]
+       set peer [peerByIfc $node $ifc]
        set link [linkByPeers $node $peer]
-        removeLink $link
+       removeLink $link
     }
     set i [lsearch -exact $node_list $node]
     set node_list [lreplace $node_list $i $i]
diff --git a/pc.tcl b/pc.tcl
index d21921e39445db51c3298ef99e2d160be62d7592..7d4b3726a1560427480842cdd56e360ba9df55cd 100755 (executable)
--- a/pc.tcl
+++ b/pc.tcl
@@ -1,4 +1,4 @@
-# $Id: pc.tcl,v 1.13.2.1 2007/05/07 08:20:10 ana Exp $ 
+# $Id: pc.tcl,v 1.13.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -146,14 +146,14 @@ proc $MODULE.bootcmd { node } {
 proc $MODULE.shellcmd { node } {
     set ret [nexec whereis -b bash]
     if { [llength $ret] == 2 } {
-        return [lindex $ret 1]
+       return [lindex $ret 1]
     } else {
-        set ret [nexec whereis -b tcsh]
-        if { [llength $ret] == 2 } {
-            return [lindex $ret 1]
-        } else {
-            return "/bin/sh"
-        }
+       set ret [nexec whereis -b tcsh]
+       if { [llength $ret] == 2 } {
+           return [lindex $ret 1]
+       } else {
+           return "/bin/sh"
+       }
     }
 }
 
index d471592d6ff551e43216d642dac3895287ad18d9..78548a062e068db2ff7e7230499c2cc2b1c8c1b9 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: static.tcl,v 1.13.2.1 2007/05/07 08:20:10 ana Exp $ 
+# $Id: static.tcl,v 1.13.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -154,14 +154,14 @@ proc $MODULE.bootcmd { node } {
 proc $MODULE.shellcmd { node } {
     set ret [nexec whereis -b bash]
     if { [llength $ret] == 2 } {
-        return [lindex $ret 1]
+       return [lindex $ret 1]
     } else {
-        set ret [nexec whereis -b tcsh]
-        if { [llength $ret] == 2 } {
-            return [lindex $ret 1]
-        } else {
-            return "/bin/sh"
-        }
+       set ret [nexec whereis -b tcsh]
+       if { [llength $ret] == 2 } {
+           return [lindex $ret 1]
+       } else {
+           return "/bin/sh"
+       }
     }
 }
 
index 4a557a6fc848a2da19efe3a8e4d1075340bedead..f3128828e74f4ed5568b3a2a624bb39bb0997223 100755 (executable)
--- a/xorp.tcl
+++ b/xorp.tcl
@@ -1,4 +1,4 @@
-# $Id: xorp.tcl,v 1.19.2.1 2007/05/07 08:20:10 ana Exp $ 
+# $Id: xorp.tcl,v 1.19.2.2 2007/07/19 00:12:45 marko Exp $ 
 #
 # Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
 #
@@ -99,12 +99,12 @@ proc $MODULE.cfggen { node } {
        set ipv6mask "[lindex [split [getIfcIPv6addr $node $ifc] /] 1]"
        lappend cfg "    interface $ifc {"
        lappend cfg "   vif $ifc {"
-        if { $ipv4addr != "" } {
+       if { $ipv4addr != "" } {
            lappend cfg "           address $ipv4addr {"
            lappend cfg "               prefix-length: $ipv4mask"
            lappend cfg "           }"
        }
-        if { $ipv6addr != "" } {
+       if { $ipv6addr != "" } {
            lappend cfg "           address $ipv6addr {"
            lappend cfg "               prefix-length: $ipv6mask"
            lappend cfg "           }"
@@ -150,7 +150,7 @@ proc $MODULE.cfggen { node } {
        lappend cfg "   export: \"connected\""
        foreach ifc [ifcList $node] {
            set addr "[lindex [split [getIfcIPv4addr $node $ifc] /] 0]"
-            if { $addr != "" } {
+           if { $addr != "" } {
                lappend cfg "   interface $ifc {"
                lappend cfg "       vif $ifc {"
                lappend cfg "           address $addr {"
@@ -171,7 +171,7 @@ proc $MODULE.cfggen { node } {
        lappend cfg "   export: \"connected\""
        foreach ifc [ifcList $node] {
            set addr "[lindex [split [getIfcIPv6addr $node $ifc] /] 0]"
-            if { $addr != "" } {
+           if { $addr != "" } {
                lappend cfg "   interface $ifc {"
                lappend cfg "       vif $ifc {"
                lappend cfg "           address $addr {"