# 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
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]
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
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
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
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
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
}
# 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
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
}
}
+#****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
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
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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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"
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
}
+#****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
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"
}
+#****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}
}
+#****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
}
-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
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
}
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
}
+#****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
}
+#****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
}
+#****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
}
+#****f* editor.tcl/renameCanvasPopup
+# NAME
+# renameCanvasPopup -- rename canvas popup
+# SYNOPSIS
+# renameCanvasPopup
+# FUNCTION
+# Tk widget for renaming the canvas.
+#****
proc renameCanvasPopup {} {
global curcanvas
}
+#****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
}
+#****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
}
-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
}
+#****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
}
+#****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
# 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}]} {
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
}
}
+
+#****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
}
}
+
+#****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
}
}
+
+#****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
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
}
+#****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
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]] {
}
+#****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"
}
+#****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"
}
+#****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
}
+#****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
}
+#****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
}
+#****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]]
}
+#****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]]
}
+#****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]]
}
+#****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]