]> git.entuzijast.net Git - imunes.git/commitdiff
source code documentation
authorzrinka <zrinka>
Fri, 13 Jan 2006 20:37:33 +0000 (20:37 +0000)
committerzrinka <zrinka>
Fri, 13 Jan 2006 20:37:33 +0000 (20:37 +0000)
Bug found by:
Submitted by:
Requested by:
Reviewed by:
Approved by:
Obtained from:

editor.tcl
exec.tcl
filemgmt.tcl
help.tcl

index 47e6a4bcb9841d5c7a0381b9dc95efbd69e4c7df..1611811a9c9bf4f4e56afdf7259dc2107996dc5e 100755 (executable)
 # and Technology through the research contract #IP-2003-143.
 #
 
-
-proc animateCursor {} {
-    global cursorState
-    global clock_seconds
-
-    if { [clock seconds] == $clock_seconds } {
-       update
-       return
-    }
-    set clock_seconds [clock seconds]
-    if { $cursorState } {
-       .c config -cursor watch
-       set cursorState 0
-    } else {
-       .c config -cursor pirate
-       set cursorState 1
-    }
-    update
-    return
-}
-
+#****h* imunes/editor.tcl
+# NAME
+#  editor.tcl -- file used for defining functions that can be used in
+#  edit mode as well as all the functions which change the appearance 
+#  of the imunes GUI.
+# FUNCTION
+#  This module is used for defining all possible actions in imunes
+#  edit mode. It is also used for all the GUI related actions.
+#****
+
+
+#****f* editor.tcl/removeGUILink
+# NAME
+#   removeGUILink -- remove link from GUI
+# SYNOPSIS
+#   renoveGUILink $link_id $atomic
+# FUNCTION
+#   Removes link from GUI. It removes standard links as well as
+#   split links and links connecting nodes on different canvases.
+# INPUTS
+#   * link_id -- the link id
+#   * atomic -- defines if the remove was atomic action or a part 
+#     of a composed, non-atomic action (relevant for updating log 
+#     for undo).
+#****
 
 proc removeGUILink { link atomic } {
     global changed
@@ -84,6 +88,17 @@ proc removeGUILink { link atomic } {
     return
 }
 
+#****f* editor.tcl/removeGUINode
+# NAME
+#   removeGUINode -- remove node from GUI
+# SYNOPSIS
+#   renoveGUINode $node_id
+# FUNCTION
+#   Removes node from GUI. When removing a node from GUI the links
+#   connected to that node are also removed.
+# INPUTS
+#   * node_id -- node id
+#****
 
 proc removeGUINode { node } {
     set type [nodeType $node]
@@ -99,6 +114,15 @@ proc removeGUINode { node } {
     return
 }
 
+#****f* editor.tcl/updateUndoLog
+# NAME
+#   updateUndoLog -- update the undo log
+# SYNOPSIS
+#   updateUndoLog
+# FUNCTION
+#   Updates the undo log. Writes the current configuration to the 
+#   undolog array and updates the undolevel variable.
+#****
 
 proc updateUndoLog {} {
     global changed undolog undolevel redolevel
@@ -115,6 +139,15 @@ proc updateUndoLog {} {
     return
 }
 
+#****f* editor.tcl/undo
+# NAME
+#   undo -- undo function
+# SYNOPSIS
+#   undo 
+# FUNCTION
+#   Undo the change. Reads the undolog and updates the current
+#   configuration. Reduces the value of undolevel.
+#****
 
 proc undo {} {
     global undolevel undolog oper_mode
@@ -127,6 +160,17 @@ proc undo {} {
     return
 }
 
+#****f* editor.tcl/redo
+# NAME
+#   redo
+# SYNOPSIS
+#   redo
+# FUNCTION
+#   Redo the change if possible (redolevel is greater than 
+#   undolevel). Reads the configuration from undolog and
+#   updates the current configuration. Increases the value 
+#   of undolevel. 
+#****
 
 proc redo {} {
     global undolevel redolevel undolog oper_mode
@@ -139,6 +183,14 @@ proc redo {} {
     return
 }
 
+#****f* editor.tcl/redrawAll
+# NAME
+#   redrawAll
+# SYNOPSIS
+#   redrawAll
+# FUNCTION
+#   Redraws all the objects on the current canvas.
+#****
 
 proc redrawAll {} {
     global node_list link_list background sizex sizey
@@ -167,6 +219,20 @@ proc redrawAll {} {
     return
 }
 
+#****f* editor.tcl/drawNode
+# NAME
+#   drawNode
+# SYNOPSIS
+#   drawNode node_id
+# FUNCTION
+#   Draws the specified node. Draws node's image (router pc
+#   host lanswitch frswitch rj45 hub pseudo) and label.
+#   The visibility of the label depends on the showNodeLabels
+#   variable for all types of nodes and on invisible variable 
+#   for pseudo nodes.
+# INPUTS
+#   * node_id -- node id
+#****
 
 proc drawNode { node } {
     global showNodeLabels
@@ -205,12 +271,24 @@ proc drawNode { node } {
     }
     # XXX Invisible pseudo-node labels
     global invisible
-    if { $invisible == 1 && [getNodeMirror $node] != "" } {
+    if { $invisible == 1 && [nodeType $node] == "pseudo" } {
        .c itemconfigure $label -state hidden
     }
     return
 }
 
+#****f* editor.tcl/drawLink
+# NAME
+#   drawLink
+# SYNOPSIS
+#   drawLink link_id
+# FUNCTION
+#   Draws the specified link. An arrow is displayed for links 
+#   connected to pseudo nodes. If the variable invisible
+#   is specified link connecting a pseudo node stays hidden. 
+# INPUTS
+#   * link_id -- link id
+#****
 
 proc drawLink { link } {
     global defLinkWidth defLinkColor
@@ -246,6 +324,21 @@ proc drawLink { link } {
     return
 }
 
+#****f* editor.tcl/chooseIfName
+# NAME
+#   chooseIfName -- choose interface name
+# SYNOPSIS
+#   set ifcName [chooseIfName $lnode1 $lnode2]
+# FUNCTION
+#   Choose intreface name. The name can be:
+#   * eth -- for interface connecting pc, host and router  
+#   * e -- for interface connecting hub and lanswitch
+#   * f -- for interface connecting frswitch
+# INPUTS
+#   * link_id -- link id
+# RESULT
+#   * ifcName -- the name of the interface
+#****
 
 proc chooseIfName { lnode1 lnode2 } {
     global $lnode1 $lnode2
@@ -281,6 +374,21 @@ proc chooseIfName { lnode1 lnode2 } {
     }
 }
 
+#****f* editor.tcl/listLANNodes
+# NAME
+#   listLANNodes -- list LAN nodes
+# SYNOPSIS
+#   set l2peers [listLANNodes $l2node $l2peers]
+# FUNCTION
+#   Recursive function for finding all link layer nodes that are 
+#   connected to node l2node. Returns the list of all link layer 
+#   nodes that are on the same LAN as l2node.
+# INPUTS
+#   * l2node -- node id of a link layer node
+#   * l2peers -- old link layer nodes on the same LAN
+# RESULT
+#   * l2peers -- new link layer nodes on the same LAN
+#****
 
 proc listLANnodes { l2node l2peers } {
     lappend l2peers $l2node
@@ -296,6 +404,17 @@ proc listLANnodes { l2node l2peers } {
     return $l2peers
 }
 
+#****f* editor.tcl/calcDxDy
+# NAME
+#   calcDxDy lnode -- list LAN nodes
+# SYNOPSIS
+#   calcDxDy $lnode
+# FUNCTION
+#   Calculates dx and dy variables of the calling function.
+# INPUTS
+#   * lnode -- node id of a node whose dx and dy coordinates are 
+#   calculated
+#****
 
 proc calcDxDy { lnode } {
     global showIfIPaddrs showIfIPv6addrs
@@ -343,7 +462,20 @@ proc calcDxDy { lnode } {
     return
 }
 
-
+#****f* editor.tcl/updateIfcLabel
+# NAME
+#   updateIfcLabel -- update inetrface label
+# SYNOPSIS
+#   updateIfcLabel $lnode1 $lnode2
+# FUNCTION
+#   Updates the interface label, including interface name,
+#   interface state (* for interfaces that are down), IPv4
+#   address and IPv6 address.
+# INPUTS
+#   * lnode1 -- node id of a node where the interface resides
+#   * lnode2 -- node id of the node that is connected by this 
+#   interface. 
+#****
 proc updateIfcLabel { lnode1 lnode2 } {
     global showIfNames showIfIPaddrs showIfIPv6addrs
 
@@ -376,6 +508,17 @@ proc updateIfcLabel { lnode1 lnode2 } {
 }
 
 
+#****f* editor.tcl/updateLinkLabel
+# NAME
+#   updateLinkLabel -- update link label
+# SYNOPSIS
+#   updateLinkLabel $link
+# FUNCTION
+#   Updates the link label, including link bandwidth, link delay,
+#   BER and duplicate values.
+# INPUTS
+#   * link -- link id of the link whose labels are updated.
+#****
 proc updateLinkLabel { link } {
     global showLinkLabels
 
@@ -404,6 +547,14 @@ proc updateLinkLabel { link } {
 }
 
 
+#****f* editor.tcl/redrawAllLinks
+# NAME
+#   redrawAllLinks -- redraw all links
+# SYNOPSIS
+#   redrawAllLinks
+# FUNCTION
+#   Redraws all links on the current canvas.
+#****
 proc redrawAllLinks {} {
     global link_list curcanvas
 
@@ -419,6 +570,16 @@ proc redrawAllLinks {} {
 }
 
 
+#****f* editor.tcl/redrawLink
+# NAME
+#   redrawLink -- redraw a links
+# SYNOPSIS
+#   redrawLink $link
+# FUNCTION
+#   Redraws the specified link.
+# INPUTS
+#   * link -- link id
+#****
 proc redrawLink { link } {
     global $link
 
@@ -463,6 +624,17 @@ proc redrawLink { link } {
 }
 
 
+#****f* editor.tcl/splitGUILink
+# NAME
+#   splitGUILink -- splits a links 
+# SYNOPSIS
+#   splitGUILink $link
+# FUNCTION
+#   Splits the link and draws new links and new pseudo nodes 
+#   on the canvas.
+# INPUTS
+#   * link -- link id
+#****
 proc splitGUILink { link } {
     global changed
 
@@ -499,6 +671,18 @@ proc splitGUILink { link } {
 }
 
 
+#****f* editor.tcl/selectNode
+# NAME
+#   selectNode -- select node 
+# SYNOPSIS
+#   selectNode $c $obj
+# FUNCTION
+#   Crates the selecting box around the specified canvas
+#   object.
+# INPUTS
+#   * c -- tk canvas
+#   * obj -- tk canvas object tag id
+#****
 proc selectNode { c obj } {
     set node [lindex [$c gettags $obj] 1]
     $c addtag selected withtag "node && $node"
@@ -518,6 +702,26 @@ proc selectNode { c obj } {
 }
 
 
+#****f* editor.tcl/button3link
+# NAME
+#   button3link 
+# SYNOPSIS
+#   button3link $c $x $y
+# FUNCTION
+#   This procedure is called when a right mouse button is 
+#   clicked on the canvas. If there is a link on the place of
+#   mouse click this procedure creates and configures a popup
+#   menu. The options in the menu are:
+#   * Configure -- configure the link
+#   * Delete -- delete the link
+#   * Split -- split the link
+#   * Merge -- this option is active only if the link is previously
+#   been split, by this action the link is merged.
+# INPUTS
+#   * c -- tk canvas
+#   * x -- x coordinate for popup menu
+#   * y -- y coordinate for popup menu
+#****
 proc button3link { c x y } {
     global oper_mode env eid canvas_list node_list
     global curcanvas
@@ -581,6 +785,17 @@ proc button3link { c x y } {
 }
 
 
+#****f* editor.tcl/movetoCanvas
+# NAME
+#   movetoCanvas -- move to canvas 
+# SYNOPSIS
+#   movetoCanvas $canvas
+# FUNCTION
+#   This procedure moves all the nodes selected in the GUI to
+#   the specified canvas.
+# INPUTS
+#   * canvas -- canvas id.
+#****
 proc movetoCanvas { canvas } {
     global changed
 
@@ -625,6 +840,19 @@ proc movetoCanvas { canvas } {
 }
 
 
+#****f* editor.tcl/mergeGUINode
+# NAME
+#   mergeGUINode -- merge GUI node
+# SYNOPSIS
+#   mergeGUINode $node
+# FUNCTION
+#   This procedure removes the specified pseudo node as well
+#   as it's mirror copy. Also this procedure removes the
+#   pseudo links and reestablish the original link between
+#   the non-pseudo nodes.
+# INPUTS
+#   * node -- node id of a pseudo node.
+#****
 proc mergeGUINode { node } {
     set link [lindex [linkByIfc $node [ifcList $node]] 0]
     mergeLink $link
@@ -632,6 +860,35 @@ proc mergeGUINode { node } {
 }
 
 
+#****f* editor.tcl/button3node
+# NAME
+#   button3node
+# SYNOPSIS
+#   button3node $c $x $y
+# FUNCTION
+#   This procedure is called when a right mouse button is 
+#   clicked on the canvas. If there is a node on the place of
+#   mouse click this procedure creates and configures a popup
+#   menu. The options in the menu are:
+#   * Configure -- configure the node
+#   * Create link to -- create a link to any available node,
+#   it can be on the same canvas or on a different canvas.
+#   * Move to -- move to some other canvas
+#   * Merge -- this option is available only for pseudo nodes
+#   that have mirror nodes on the same canvas (Pseudo nodes
+#   created by splitting a link).
+#   * Delete -- delete the node
+#   * Shell window -- specifies the shell window to open in 
+#   exec mode. This option is available only to nodes on a 
+#   network layer
+#   * Ethereal -- opens a Ethereal program for the specified 
+#   node and the specified interface. This option is available 
+#   only for network layer nodes in exec mode.
+# INPUTS
+#   * c -- tk canvas
+#   * x -- x coordinate for popup menu
+#   * y -- y coordinate for popup menu
+#****
 proc button3node { c x y } {
     global oper_mode env eid canvas_list node_list curcanvas
 
@@ -795,6 +1052,19 @@ proc button3node { c x y } {
 }
 
 
+#****f* editor.tcl/spawnShell
+# NAME
+#   spawnShell -- spawn shell
+# SYNOPSIS
+#   spawnShell $node $cmd
+# FUNCTION
+#   This procedure spawns a new shell for a specified node.
+#   The shell is specified in cmd parameter.
+# INPUTS
+#   * node -- node id of the node for which the shell 
+#   is spawned.
+#   * cmd -- the path to the shell.
+#****
 proc spawnShell { node cmd } {
     global eid remote_exec exec_host gui_unix
 
@@ -817,6 +1087,18 @@ proc spawnShell { node cmd } {
 }
 
 
+#****f* editor.tcl/startethereal
+# NAME
+#   startethereal -- start ethereal
+# SYNOPSIS
+#   startethereal $node $iface
+# FUNCTION
+#   This procedure starts ethereal for the specified node
+#   and the specified interface.
+# INPUTS
+#   * node -- node id
+#   * iface -- interface name
+#****
 proc startethereal { node iface } {
     global eid
 
@@ -826,6 +1108,22 @@ proc startethereal { node iface } {
 }
 
 
+#****f* editor.tcl/button1
+# NAME
+#   button1
+# SYNOPSIS
+#   button1 $c $x $y $button
+# FUNCTION
+#   This procedure is called when a left mouse button is 
+#   clicked on the canvas. This procedure selects a new
+#   node or creates a new node, depending on the selected 
+#   tool.
+# INPUTS
+#   * c -- tk canvas
+#   * x -- x coordinate
+#   * y -- y coordinate
+#   * button -- the keyboard button that is pressed.
+#****
 proc button1 { c x y button } {
     global node_list curcanvas
     global activetool newlink curobj changed def_router_model
@@ -909,6 +1207,21 @@ proc button1 { c x y button } {
 }
 
 
+#****f* editor.tcl/button1-motion
+# NAME
+#   button1-motion
+# SYNOPSIS
+#   button1-motion $c $x $y 
+# FUNCTION
+#   This procedure is called when a left mouse button is 
+#   pressed and the mouse is moved around the canvas. 
+#   This procedure creates new select box, moves the 
+#   selected nodes or draws a new link.
+# INPUTS
+#   * c -- tk canvas
+#   * x -- x coordinate
+#   * y -- y coordinate
+#****
 proc button1-motion { c x y } {
     global activetool newlink changed grid
     global lastX lastY sizex sizey selectbox background
@@ -960,10 +1273,35 @@ proc button1-motion { c x y } {
 }
 
 
+#****f* editor.tcl/pseudo.layer
+# NAME
+#   pseudo.layer  
+# SYNOPSIS
+#   set layer [pseudo.layer]
+# FUNCTION
+#   Returns the layer on which the pseudo node operates
+#   i.e. returns no layer. 
+# RESULT
+#   * layer -- returns an empty string
+#****
 proc pseudo.layer {} {
 }
 
 
+#****f* editor.tcl/newGUILink
+# NAME
+#   newGUILink -- new GUI link
+# SYNOPSIS
+#   newGUILink $lnode1 $lnode2
+# FUNCTION
+#   This procedure is called to create a new link between 
+#   nodes lnode1 and lnode2. Nodes can be on the same canvas 
+#   or on different canvases. The result of this function
+#   is directly visible in GUI.
+# INPUTS
+#   * lnode1 -- node id of the first node
+#   * lnode2 -- node id of the second node
+#****
 proc newGUILink { lnode1 lnode2 } {
     global changed
 
@@ -994,6 +1332,21 @@ proc newGUILink { lnode1 lnode2 } {
 }
 
 
+#****f* editor.tcl/button1-release
+# NAME
+#   button1-release
+# SYNOPSIS
+#   button1-release $c $x $y 
+# FUNCTION
+#   This procedure is called when a left mouse button is 
+#   released. 
+#   The result of this function depends on the actions
+#   during the button1-motion procedure.
+# INPUTS
+#   * c -- tk canvas
+#   * x -- x coordinate
+#   * y -- y coordinate
+#****
 proc button1-release { c x y } {
     global node_list
     global activetool newlink curobj grid
@@ -1118,6 +1471,20 @@ proc button1-release { c x y } {
 }
 
 
+#****f* editor.tcl/nodeEnter
+# NAME
+#   nodeEnter
+# SYNOPSIS
+#   nodeEnter $c
+# FUNCTION
+#   This procedure prints the node id, node name and 
+#   node model (if exists), as well as all the interfaces
+#   of the node in the status line. 
+#   Information is presented for the node above which is
+#   the mouse pointer.  
+# INPUTS
+#   * c -- tk canvas
+#****
 proc nodeEnter { c } {
     global activetool
 
@@ -1140,6 +1507,19 @@ proc nodeEnter { c } {
 }
 
 
+#****f* editor.tcl/linkEnter
+# NAME
+#   linkEnter
+# SYNOPSIS
+#   linkEnter $c
+# FUNCTION
+#   This procedure prints the link id, link bandwidth
+#   and link delay in the status line.
+#   Information is presented for the link above which is
+#   the mouse pointer.  
+# INPUTS
+#   * c -- tk canvas
+#****
 proc linkEnter {c} {
     global activetool link_list
 
@@ -1153,6 +1533,16 @@ proc linkEnter {c} {
 }
 
 
+#****f* editor.tcl/anyLeave
+# NAME
+#   anyLeave
+# SYNOPSIS
+#   anyLeave $c
+# FUNCTION
+#   This procedure clears the status line.
+# INPUTS
+#   * c -- tk canvas
+#****
 proc anyLeave {c} {
     global activetool
 
@@ -1161,6 +1551,22 @@ proc anyLeave {c} {
 }
 
 
+#****f* editor.tcl/checkIntRange 
+# NAME
+#   checkIntRange -- check integer range
+# SYNOPSIS
+#   set check [checkIntRange $str $low $high]
+# FUNCTION
+#   This procedure checks the input string to see if it is 
+#   an integer between the low and high value.
+# INPUTS
+#   str -- string to check
+#   low -- the bottom value
+#   high -- the top value
+# RESULT
+#   * check -- set to 1 if the str is string between low and high
+#   value, 0 otherwise.
+#****
 proc checkIntRange { str low high } {
     if { $str == "" } {
        return 1
@@ -1179,6 +1585,20 @@ proc checkIntRange { str low high } {
 }
 
 
+#****f* editor.tcl/focusAndFlash 
+# NAME
+#   focusAndFlash -- focus and flash
+# SYNOPSIS
+#   focusAndFlash $W $count
+# FUNCTION
+#   This procedure sets the focus on the bad entry field
+#   and on this filed it provides an effect of flashing 
+#   for approximately 1 second.
+# INPUTS
+#   * W -- textbox field that caused the bed entry
+#   * count -- the parameter that causes flashes.
+#   It can be left blank.
+#****
 proc focusAndFlash {W {count 9}} {
     global badentry
 
@@ -1207,6 +1627,17 @@ proc focusAndFlash {W {count 9}} {
 }
 
 
+#****f* editor.tcl/popupConfigDialog
+# NAME
+#   popupConfigDialog -- popup Configuration Dialog Box
+# SYNOPSIS
+#   popupConfigDialog $c
+# FUNCTION
+#   Dynamically creates a popup dialog box for configuring 
+#   links or nodes in IMUNES.
+# INPUTS
+#   * c -- canvas id
+#****
 proc popupConfigDialog { c } {
     global activetool router_model supp_router_models oper_mode
     global badentry curcanvas
@@ -1537,7 +1968,7 @@ proc popupConfigDialog { c } {
 
     frame $wi.butt -borderwidth 6
     button $wi.butt.apply -text "Apply" -command \
-       "popupConfigApply $wi $object_type $target close 0"
+       "popupConfigApply $wi $object_type $target 0"
     focus $wi.butt.apply
     button $wi.butt.cancel -text "Cancel" -command \
        "set badentry -1 ; destroy $wi"
@@ -1550,12 +1981,34 @@ proc popupConfigDialog { c } {
 }
 
 
+#****f* editor.tcl/cfgGenerate
+# NAME
+#   cfgGenerate -- configuration generator
+# SYNOPSIS
+#   cfgGenerate $node_id
+# FUNCTION
+#   This procedure creates a boot time configuration for the 
+#   specified node. Uses cfggen and bootcmd functions that are 
+#   specific for every type and model of a node.
+# INPUTS
+#   * node_id -- node id
+#****
 proc cfgGenerate { node } {
     setCustomConfig $node [[typemodel $node].cfggen $node]
     setCustomCmd $node [[typemodel $node].bootcmd $node]
 }
 
 
+#****f* editor.tcl/editStartupCfg
+# NAME
+#   editStartupCfg -- edit startup configuration
+# SYNOPSIS
+#   editStartupCfg $node_id
+# FUNCTION
+#   Creates an edit startup configuration dialog box. 
+# INPUTS
+#   * node_id -- node id
+#****
 proc editStartupCfg { node } {
     set w .cfgeditor
     catch {destroy $w}
@@ -1596,6 +2049,19 @@ proc editStartupCfg { node } {
 }
 
 
+#****f* editor.tcl/customConfigApply
+# NAME
+#   customConfigApply -- custom configuration apply
+# SYNOPSIS
+#   customConfigApply $w $node
+# FUNCTION
+#   This procedure is called when the button aplly is pressed in 
+#   edit custom configuration dialog box. It reads the custom 
+#   configuration and a command that executes the configuration.
+# INPUTS
+#   * w -- widget
+#   * node_id -- node id
+#****
 proc customConfigApply { w node } {
     global changed
 
@@ -1615,7 +2081,27 @@ proc customConfigApply { w node } {
 }
 
 
-proc popupConfigApply { wi object_type target close phase } {
+#****f* editor.tcl/popupConfigApply
+# NAME
+#   popupConfigApply -- popup configuration apply
+# SYNOPSIS
+#   popupConfigApply $w $object_type $target $phase
+# FUNCTION
+#   This procedure is called when the button aplly is pressed in 
+#   popup configuration dialog box. It reads different
+#   configuration parameters depending on the object_type.
+# INPUTS
+#   * w -- widget
+#   * object_type -- describes the object type that is currently 
+#   configured. It can be either link or node.
+#   * target -- node id of the configured node or link id of the
+#   configured link
+#   * phase --  This pocedure is invoked in two diffenet phases 
+#   to enable validation of the entry that was the last made. 
+#   When calling this function always use the phase parameter 
+#   set to 0.
+#****
+proc popupConfigApply { wi object_type target phase } {
     global changed oper_mode router_model badentry customEnabled
     global eid
 
@@ -1624,7 +2110,7 @@ proc popupConfigApply { wi object_type target close phase } {
     if { $phase == 0 } {
        set badentry 0
        focus .
-       after 100 "popupConfigApply $wi $object_type $target $close 1"
+       after 100 "popupConfigApply $wi $object_type $target 1"
        return
     } elseif { $badentry } {
        $wi config -cursor left_ptr
@@ -1833,16 +2319,23 @@ proc popupConfigApply { wi object_type target close phase } {
     }
     if { $changed == 1 } {
        redrawAll
+        updateUndoLog
     }
-    updateUndoLog
-    if { $close == "close" } {
-       destroy $wi
-    } else {
-       $wi config -cursor left_ptr
-    }
+    destroy $wi
 }
 
 
+#****f* editor.tcl/printCanvas
+# NAME
+#   printCanvas -- print canvas
+# SYNOPSIS
+#   printCanvas $w
+# FUNCTION
+#   This procedure is called when the print button in
+#   print dialog box is pressed. 
+# INPUTS
+#   * w -- print dialog widget
+#****
 proc printCanvas { w } {
     global sizex sizey
 
@@ -1854,6 +2347,15 @@ proc printCanvas { w } {
 }
 
 
+#****f* editor.tcl/deleteSelection
+# NAME
+#   deleteSelection -- delete selection
+# SYNOPSIS
+#   deleteSelection
+# FUNCTION
+#   By calling this procedure all the selected nodes in imunes will 
+#   be deleted.
+#****
 proc deleteSelection { } {
     global changed
     global background 
@@ -1874,6 +2376,19 @@ proc deleteSelection { } {
 }
 
 
+#****f* editor.tcl/rearrange
+# NAME
+#   rearrange
+# SYNOPSIS
+#   rearrange $mode
+# FUNCTION
+#   This procedure rearranges the position of nodes in imunes.
+#   It can be used to rearrange all the nodes or only the selected
+#   nodes. 
+# INPUTS
+#   * mode -- when set to "selected" only the selected nodes will be
+#   rearranged.
+#****
 proc rearrange { mode } {
     global link_list autorearrange_enabled sizex sizey curcanvas
 
@@ -2027,6 +2542,18 @@ proc rearrange { mode } {
 }
 
 
+#****f* editor.tcl/switchCanvas 
+# NAME
+#   switchCanvas -- switch canvas
+# SYNOPSIS
+#   switchCanvas $direction
+# FUNCTION
+#   This procedure switches the canvas in one of the defined 
+#   directions (previous, next, first and last).
+# INPUTS
+#   * direction -- the direction of switching canvas. Can be: prev -- 
+#   previus, next -- next, first -- first, last -- last.
+#****
 proc switchCanvas { direction } {
     global canvas_list curcanvas
 
@@ -2095,6 +2622,14 @@ proc switchCanvas { direction } {
 }
 
 
+#****f* editor.tcl/renameCanvasPopup 
+# NAME
+#   renameCanvasPopup -- rename canvas popup
+# SYNOPSIS
+#   renameCanvasPopup
+# FUNCTION
+#   Tk widget for renaming the canvas. 
+#****
 proc renameCanvasPopup {} {
     global curcanvas
 
@@ -2121,6 +2656,17 @@ proc renameCanvasPopup {} {
 }
 
 
+#****f* editor.tcl/renameCanvasApply
+# NAME
+#   renameCanvasApply -- rename canvas apply
+# SYNOPSIS
+#   renameCanvasApply $w 
+# FUNCTION
+#   This procedure is called by clicking on apply button in rename 
+#   canvas popup dialog box. It renames the current canvas.
+# INPUTS
+#   * w -- tk widget (rename canvas popup dilog box)
+#****
 proc renameCanvasApply { w } {
     global curcanvas changed
 
@@ -2135,6 +2681,15 @@ proc renameCanvasApply { w } {
 }
 
 
+#****f* editor.tcl/animate
+# NAME
+#   animate
+# SYNOPSIS
+#   animate
+# FUNCTION
+#   This function animates the selectbox. The animation looks 
+#   different for edit and exec mode.
+#****
 proc animate {} {
     global animatephase oper_mode
 
@@ -2153,11 +2708,17 @@ proc animate {} {
 }
 
 
-proc toolOptions {} {
-    return
-}
 
 
+#****f* editor.tcl/configRemoteHosts
+# NAME
+#   configRemoteHosts -- configure remote hosts
+# SYNOPSIS
+#   configRemoteHosts
+# FUNCTION
+#   This function opens a remote host configuration dialog
+#   box.
+#****
 proc configRemoteHosts {} {
     global exec_hosts
     global remote_exec old_remote_exec editor_only
@@ -2259,6 +2820,15 @@ proc configRemoteHosts {} {
 }
 
 
+#****f* editor.tcl/configRemoteHostsApply
+# NAME
+#   configRemoteHostsApply -- configure remote hosts apply
+# SYNOPSIS
+#   configRemoteHostsApply $wi
+# FUNCTION
+#   This function is called when clicking on the apply button
+#   in remote hosts configuration dialog box.
+#****
 proc configRemoteHostsApply { wi } {
     global exec_hosts
     global active_host
@@ -2288,6 +2858,15 @@ proc configRemoteHostsApply { wi } {
 }
 
 
+#****f* editor.tcl/enable_disable
+# NAME
+#   enable_disable
+# SYNOPSIS
+#   enable_disable $wi
+# FUNCTION
+#   Enables or disables the hosts entries in the remote host 
+#   configuration dialog box.
+#****
 proc enable_disable { wi } {
     global exec_hosts
     global remote_exec editor_only
index b2549379f45c8c1130759ba179b83b0789e9ca35..35991bf49127f15c1070f531e60216e09af85ed2 100755 (executable)
--- a/exec.tcl
+++ b/exec.tcl
 # and Technology through the research contract #IP-2003-143.
 #
 
-
+#****h* imunes/exec.tcl
+# NAME
+#  exec.tcl -- file used for all the actions regarding 
+# FUNCTION
+#  This module is used for all actions that are executed during the 
+#  simulation, i.e.in the exec mode.
+#****
+
+
+#****f* exec.tcl/nexec_local
+# NAME
+#   nexec_local -- remove link from GUI
+# SYNOPSIS
+#   set result [nexec_local $args]
+# FUNCTION
+#   Locally executes the program passed by args. Returns the results 
+#   of the program.
+# INPUTS
+#   * args -- program name and arguments that are to be evaluated. 
+# RESULT
+#   * result -- the program standard output.
+#****
 proc nexec_local { args } {
     eval exec $args
 }
 
 
+#****f* exec.tcl/Read_exec_results
+# NAME
+#   Read_exec_results -- read exec results
+# SYNOPSIS
+#   Read_exec_results $sock
+# FUNCTION
+#   Reads one line from socket. If the socket is closed the line is not read.
+#   When the string Kraj is read, the exec_result_ready variable is set to 1,
+#   otherwise the line is appended to the exec_results list.
+# INPUTS
+#   * sock -- socket
+#****
 proc Read_exec_results {sock}  {
     global exec_results exec_results_ready
     if {[eof $sock] || [catch {gets $sock line}]} {
@@ -51,8 +84,24 @@ proc Read_exec_results {sock}  {
             append exec_results $line "\n"
         }
     }
+    return
 }
 
+#****f* exec.tcl/nexec
+# NAME
+#   nexec -- execute program
+# SYNOPSIS
+#   set result [nexec $args]
+# FUNCTION
+#   Executes the sting given in args variable. The sting is not executed 
+#   if IMUNES is running in editor only mode. Execution of a string can
+#   be local or remote. If socket can not be opened in try of a remote
+#   execution, mode is switched to editor only mode. 
+# INPUTS
+#   * args -- the string that should be executed localy or remotely.
+# RESULT
+#   * result -- the standard output of the executed string.
+#****
 proc nexec { args } {
     global remote_exec editor_only
     global exec_sock exec_results exec_results_ready
@@ -86,6 +135,19 @@ proc nexec { args } {
     }
 }
 
+
+#****f* exec.tcl/Read_monitor_results
+# NAME
+#   Read_monitor_results -- read monitor results
+# SYNOPSIS
+#   Read_monitor_results $sock
+# FUNCTION
+#   Reads one line from socket. If the socket is closed the line is not read.
+#   When the string Kraj is read, the monitor_result_ready variable is set 
+#   to 1, otherwise the line is appended to the monitor_results list.
+# INPUTS
+#   * sock -- socket
+#****
 # And now the same for monitor
 proc Read_monitor_results {sock}  {
     global monitor_results monitor_results_ready
@@ -103,6 +165,23 @@ proc Read_monitor_results {sock}  {
     }
 }
 
+
+#****f* exec.tcl/nexec_monitor
+# NAME
+#   nexec_monitor -- execute monitor
+# SYNOPSIS
+#   set result [nexec_monitor $args]
+# FUNCTION
+#   Executes the sting given in args variable. The sting is not executed 
+#   if IMUNES is running in editor only mode. Execution of a string can
+#   be local or remote. Opens an execute socket if it is not yet opened. 
+#   Sends the arguments to monitor_sock if the remote execution is 
+#   selected, otherwise executes arguments locally.
+# INPUTS
+#   * args -- the string that should be executed locally or remotely.
+# RESULT
+#   * result -- the standard output of the executed string.
+#****
 proc nexec_monitor { args } {
     global remote_exec editor_only
     global monitor_sock monitor_results monitor_results_ready
@@ -126,6 +205,18 @@ proc nexec_monitor { args } {
     }
 }
 
+
+#****f* exec.tcl/open_exec_sockets
+# NAME
+#   open_exec_sockets -- open execute socket
+# SYNOPSIS
+#   open_exec_sockets
+# FUNCTION
+#   Opens a socket for remote execution. Opens an exec socket and
+#   a monitor socket. The ip address and port numbers for sockets
+#   are defined in exec_hosts variable. The exec_host variable is
+#   also set.
+#****
 proc open_exec_sockets {} {
     global exec_hosts remote_exec exec_sockets_opened
     global exec_host exec_port monitor_port exec_sock monitor_sock
@@ -215,6 +306,28 @@ proc open_exec_sockets {} {
     set exec_sockets_opened true
 }
 
+
+#****f* exec.tcl/setOperMode
+# NAME
+#   setOperMode -- set operating mode
+# SYNOPSIS
+#   setOperMode $mode
+# FUNCTION
+#   Sets imunes operating mode to the value of the parameter mode.
+#   The mode can be set only to edit or exec.
+#   When changing the mode to exec all the emulation interfaces are
+#   checked (if they are nonexistent the message is displayed, and 
+#   mode is not changed), all the required buttons are disabled 
+#  (except the simulation/Terminate button, that is enabled) and
+#   procedure deployCfg is called.
+#   The mode can not be changed to exec if imunes operates only in 
+#   editor mode (editor_only variable is set). 
+#   When changing the mode to edit, all required buttons are enabled
+#   (except for simulation/Terminate button that is disabled) and
+#   procedure vimageCleanup is called.
+# INPUTS
+#   * mode -- the new operating mode. Can be edit or exec.
+#****
 proc setOperMode { mode } {
     global oper_mode activetool node_list
     global nmbufs nmbclusters
@@ -291,6 +404,17 @@ proc setOperMode { mode } {
 }
 
 
+#****f* exec.tcl/statline
+# NAME
+#   statline -- status line
+# SYNOPSIS
+#   statline $line
+# FUNCTION
+#   Sets the string of the status line. If the execution mode is 
+#   set to batch the line is just printed on the standard output.
+# INPUTS
+#   * line -- line to be displayed
+#****
 proc statline {line} {
     global execMode
 
@@ -298,11 +422,28 @@ proc statline {line} {
        puts $line
     } else {
        .bottom.textbox config -text "$line"
-       animateCursor
     }
 }
 
 
+#****f* exec.tcl/createIfc
+# NAME
+#   createIfc -- create interface
+# SYNOPSIS
+#   set name [createIfc $type $hook]
+# FUNCTION
+#   Creates a new netgraph interface, of the type $type. 
+#   Returns the name of the newly created interface.
+# INPUTS
+#   * type -- new interface type. In imunes are used only 
+#   eiface or iface types. Additional specification on this 
+#   types can be found in manual pages for netgraph nodes.
+#   * hook -- parameter specific for every netgraph node.
+#   For iface hook hook is inet, and for eiface type the
+#   hook is ether.
+# RESULT
+#   * name -- the name of the new interface
+#****
 proc createIfc {type hook} {
     catch {nexec ngctl mkpeer $type $hook $hook | tail -1} resp
     foreach elem [split [lindex [split $resp "\{\}"] 1]] {
@@ -314,6 +455,22 @@ proc createIfc {type hook} {
 }
 
 
+#****f* exec.tcl/l3node.instantiate 
+# NAME
+#   l3node.instantiate -- layer 3 node instantiate
+# SYNOPSIS
+#   l3node.instantiate $eid $node
+# FUNCTION
+#   Instantiates the specified node. This means that it creates
+#   a new vimage node, all the required interfaces (for serial 
+#   interface a new netgraph interface of type iface; for 
+#   ethernet of type eiface, using createIfc procedure) including
+#   loopback interface, cpu configuration and sets the kernel 
+#   variables.
+# INPUTS
+#   * eid -- experiment id
+#   * node -- node id
+#****
 proc l3node.instantiate { eid node } {
     global mac_byte4 mac_byte5
     set node_id "$eid\_$node"
@@ -367,6 +524,21 @@ proc l3node.instantiate { eid node } {
 }
 
 
+#****f* exec.tcl/l3node.nghook
+# NAME
+#   l3node.nghook -- layer 3 node netgraph hook
+# SYNOPSIS
+#   l3node.nghook $eid $node $ifc
+# FUNCTION
+#   Returns the netgraph node name and the hook name for
+#   a given experiment id, node id, and interface name.
+# INPUTS
+#   * eid -- experiment id
+#   * node -- node id
+#   * ifc -- interface name
+# RESULT
+#   * list -- list in the form of {netgraph_node_name hook}
+#****
 proc l3node.nghook { eid node ifc } {
     set ifnum [string range $ifc 3 end]
     set node_id "$eid\_$node"
@@ -381,6 +553,17 @@ proc l3node.nghook { eid node ifc } {
 }
 
 
+#****f* exec.tcl/deployCfg
+# NAME
+#   deployCfg -- deploy working configuration
+# SYNOPSIS
+#   deployCfg
+# FUNCTION
+#   Deploys a current working configuration. It creates all the 
+#   nodes and link as defined in configuration file of in GUI of
+#   imunes. Before deploying new configuration the old one is 
+#   removed (vimageCleanup procedure).
+#****
 proc deployCfg {} {
     global eid
     global node_list link_list supp_router_models
@@ -535,6 +718,15 @@ proc deployCfg {} {
 }
 
 
+#****f* exec.tcl/vimageCleanup
+# NAME
+#   vimageCleanup -- vimage cleanup
+# SYNOPSIS
+#   vimageCleanup
+# FUNCTION
+#   Called upon the termination of the simulation. If cleans all 
+#   the imunes objects created by the simulation that is terminated.
+#****
 proc vimageCleanup {} {
     global .c
 
@@ -569,6 +761,16 @@ proc vimageCleanup {} {
 }
 
 
+#****f* exec.tcl/monitor_loop
+# NAME
+#   monitor_loop -- monitor loop
+# SYNOPSIS
+#   monitor_loop
+# FUNCTION
+#   Calculates the usage of cpu, mbuffers and mbuf clusters.
+#   The results are displayed in status line and updated 
+#   every two seconds.
+#****
 proc monitor_loop {} {
     global oper_mode
     global nmbufs nmbclusters
@@ -594,6 +796,21 @@ proc monitor_loop {} {
 }
 
 
+#****f* exec.tcl/execSetIfcQDisc
+# NAME
+#   execSetIfcQDisc -- in exec mode set interface queuing discipline
+# SYNOPSIS
+#   execSetIfcQDisc $eid $node $ifc $qdisc
+# FUNCTION
+#   Sets the queuing discipline during the simulation. 
+#   New queuing discipline is defined in qdisc parameter. 
+#   Queueing discipline can be set to fifo, wfq or drr.
+# INPUTS
+#   eid -- experiment id
+#   node -- node id
+#   ifc -- interface name
+#   qdisc -- queuing discipline
+#****
 proc execSetIfcQDisc { eid node ifc qdisc } {
     set target [linkByIfc $node $ifc]
     set peers [linkPeers [lindex $target 0]]
@@ -617,6 +834,21 @@ proc execSetIfcQDisc { eid node ifc qdisc } {
 }
 
 
+#****f* exec.tcl/execSetIfcQDrop
+# NAME
+#   execSetIfcQDrop -- in exec mode set interface queue drop
+# SYNOPSIS
+#   execSetIfcQDrop $eid $node $ifc $qdrop
+# FUNCTION
+#   Sets the queue dropping policy during the simulation. 
+#   New queue dropping policy is defined in qdrop parameter. 
+#   Queue dropping policy can be set to drop-head or drop-tail.
+# INPUTS
+#   eid -- experiment id
+#   node -- node id
+#   ifc -- interface name
+#   qdrop -- queue dropping policy
+#****
 proc execSetIfcQDrop { eid node ifc qdrop } {
     set target [linkByIfc $node $ifc]
     set peers [linkPeers [lindex $target 0]]
@@ -640,6 +872,20 @@ proc execSetIfcQDrop { eid node ifc qdrop } {
 }
 
 
+#****f* exec.tcl/execSetIfcQLen
+# NAME
+#   execSetIfcQLen -- in exec mode set interface queue length
+# SYNOPSIS
+#   execSetIfcQDrop $eid $node $ifc $qlen
+# FUNCTION
+#   Sets the queue length during the simulation. 
+#   New queue length is defined in qlen parameter. 
+# INPUTS
+#   eid -- experiment id
+#   node -- node id
+#   ifc -- interface name
+#   qlen -- new queue's length
+#****
 proc execSetIfcQLen { eid node ifc qlen } {
     set target [linkByIfc $node $ifc]
     set peers [linkPeers [lindex $target 0]]
@@ -658,6 +904,18 @@ proc execSetIfcQLen { eid node ifc qlen } {
 }
 
 
+#****f* exec.tcl/execSetLinkParams
+# NAME
+#   execSetLinkParams -- in exec mode set link parameters
+# SYNOPSIS
+#   execSetLinkParams $eid $link
+# FUNCTION
+#   Sets the link parameters during the simulation. 
+#   All the parameters are set at the same time.
+# INPUTS
+#   eid -- experiment id
+#   link -- link id
+#****
 proc execSetLinkParams { eid link } {
     set lnode1 [lindex [linkPeers $link] 0]
     set lnode2 [lindex [linkPeers $link] 1]
index 725916048df9cb57197d0a8d37f21b5b4d894452..3e067726a1f5f80d9d07b5d715e16edf3a6c9b6d 100755 (executable)
 #
 
 
-#
+##****h* imunes/filemgmt.tcl
+# NAME
+#  filemgmt.tcl -- file used for manipulation with files
+# FUNCTION
+#  This module is used for all file manipulations. In this file 
+#  a file is read, a new file opened or existing file saved.
+# NOTES
+# variables:
+# 
 # currentFile
 #    relative or absolute path to the current configuration file
 # 
 # fileTypes
 #    types that will be displayed when opening new file 
 #
-# 
 # procedures used for loading and storing the configuration file:
 #
 # newFile 
 #
 # fileSaveAsDialogBox
 #   - opens dialog box for saving a file under new name  
-
+#****
 
 set currentFile ""
 
 set fileTypes {{"IMUNES network configuration" {.imn} }
            { "All files" {*}}}
 
-
+          
+#****f* filemgmt.tcl/newFile
+# NAME
+#   newFile -- new file
+# SYNOPSIS
+#   newFile
+# FUNCTION
+#   Loads an empty configuration, i.e. creates an empty project.
+#****
 proc newFile {} {
     global currentFile oper_mode
-    global canvas_list curcanvas
+    global canvas_list curcanvas undolevel redolevel
 
     if { $oper_mode == "exec" } {
        vimageCleanup
     }
     loadCfg ""
+    set undolevel 0
+    set redolevel 0
     set curcanvas [lindex $canvas_list 0]
     switchCanvas none
     redrawAll
@@ -93,6 +110,14 @@ proc newFile {} {
 }
 
 
+#****f* filemgmt.tcl/openFile
+# NAME
+#   openFile -- open file
+# SYNOPSIS
+#   openFile
+# FUNCTION
+#   Loads the configuration from the file named currentFile.
+#****
 proc openFile {} {
     global currentFile 
     global undolevel redolevel undolog activetool
@@ -117,6 +142,17 @@ proc openFile {} {
 }
 
 
+#****f* filemgmt.tcl/saveFile
+# NAME
+#   saveFile -- save file
+# SYNOPSIS
+#   saveFile $selectedFile
+# FUNCTION
+#   Loads the current configuration into the selectedFile file.
+# INPUTS
+#   * selectedFile -- the name of the file where current 
+#   configuration is saved.
+#****
 proc saveFile { selectedFile } {
     global currentFile 
     if { $selectedFile != ""} {
@@ -131,6 +167,15 @@ proc saveFile { selectedFile } {
 }
 
 
+#****f* filemgmt.tcl/fileOpenStartUp
+# NAME
+#   fileOpenStartUp -- file open in batch mode
+# SYNOPSIS
+#   fileOpenStartUp
+# FUNCTION
+#   Loads configuration from batch input file to the current 
+#   configuration.
+#****
 proc fileOpenStartUp {} {
     global argv
     global currentFile
@@ -142,6 +187,14 @@ proc fileOpenStartUp {} {
 }
 
 
+#****f* filemgmt.tcl/fileNewDialogBox
+# NAME
+#   fileNewDialogBox -- save changes dialog box
+# SYNOPSIS
+#   fileNewDialogBox
+# FUNCTION
+#   Opens message box to optionally save the changes.
+#****
 proc fileNewDialogBox {} {
     global currentFile
 
@@ -159,6 +212,14 @@ proc fileNewDialogBox {} {
 }
 
 
+#****f* filemgmt.tcl/fileOpenDialogBox
+# NAME
+#   fileOpenDialogBox -- open file dialog box
+# SYNOPSIS
+#   fileOpenDialogBox
+# FUNCTION
+#   Opens a open file dialog box.
+#****
 proc fileOpenDialogBox {} {
     global currentFile 
     global fileTypes
@@ -170,6 +231,15 @@ proc fileOpenDialogBox {} {
 }
 
 
+#****f* filemgmt.tcl/fileSaveDialogBox
+# NAME
+#   fileSaveDialogBox -- save file dialog box
+# SYNOPSIS
+#   fileSaveDialogBox
+# FUNCTION
+#   Opens dialog box for saving a file under new name if there is no
+#   current file.
+#****
 proc fileSaveDialogBox {} {
     global currentFile 
     global fileTypes
@@ -184,6 +254,14 @@ proc fileSaveDialogBox {} {
 }
 
 
+#****f* filemgmt.tcl/fileSaveAsDialogBox
+# NAME
+#   fileSaveAsDialogBox -- save as file dialog box
+# SYNOPSIS
+#   fileSaveAsDialogBox
+# FUNCTION
+#   Opens dialog box for saving a file under new name.
+#****
 proc fileSaveAsDialogBox {} {
     global currentFile 
     global fileTypes
@@ -194,16 +272,24 @@ proc fileSaveAsDialogBox {} {
 }
 
 
+#****f* filemgmt.tcl/readConfigFile
+# NAME
+#   readConfigFile -- read configuration file
+# SYNOPSIS
+#   readConfigFile
+# FUNCTION
+#   Read config files, the first one found: .imunesrc, $HOME/.imunesrc
 #
-# Read config files, the first one found: .imunesrc, $HOME/.imunesrc
-#
-# list of exec_hosts
-# Options / variables:
-# remote_exec
-#   0 - for local execution on FreeBSD, 
-#   1 - IMUNES GUI is on remote (even if exec_host=localhost)
-# editor_only
-#
+#   list of exec_hosts
+#   
+#   Options / variables:
+#   
+#   remote_exec
+#   * 0 - for local execution on FreeBSD, 
+#   * 1 - IMUNES GUI is on remote (even if exec_host=localhost)
+#   
+#   editor_only
+#***
 proc readConfigFile {} {
     global exec_hosts remote_exec editor_only
     global env
index 601749b9aa06fdf79cd522fd7ed0f25c61a3efaf..3e42dca2e827df8844ee8e25805c106bef24c9d1 100755 (executable)
--- a/help.tcl
+++ b/help.tcl
 # and Technology through the research contracts #IP-2003-143 and #IP-2004-154.
 #
 
+#****h* imunes/help.tcl
+# NAME
+#  help.tcl -- file used for help infromation
+# FUNCTION
+#  This file is considered to contain all the help information.
+#  Currently it contains only copyright information.
+#****
 
 set copyright {