# 4. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
+
#
# THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# * lanswitch
# * hub
# * rj45
+# * pseudo
#
# The following node types are to be implemented in the future:
# * frswitch
# Returns "up" or "down".
#
# setIfcOperState { node_id ifc state }
-# Sets the new interface state.
+# Sets the new interface state. Implicit default is "up".
#
# getIfcQDisc { node_id ifc }
# Returns "FIFO", "WFQ" or "DRR".
# Returns node's type.
#
# getNodeModel { node_id }
-# Returns node's optional model identifyer.
+# Returns node's optional model identifier.
#
# setNodeModel { node_id model }
-# Sets the node's optional model identifyer.
+# Sets the node's optional model identifier.
#
# getNodeCanvas { node_id }
# Returns node's canvas affinity.
# Return icon coords.
#
# setNodeCoords { node_id coords }
-# Sets the coords.
+# Sets the coordinates.
#
# getNodeLabelCoords { node_id }
-# Return node label coords.
+# Return node label coordinates.
#
# setNodeLabelCoords { node_id coords }
-# Sets the label coords.
+# Sets the label coordinates.
#
# getNodeCPUConf { node_id }
# Returns node's CPU scheduling parameters { minp maxp weight }.
# peerByIfc { node_id ifc }
# Returns id of the node on the other side of the interface
#
+# logicalPeerByIfc { node_id ifc }
+# Returns id of the logical node on the other side of the interface.
+#
# ifcByPeer { local_node_id peer_node_id }
+# Returns the name of the interface connected to the specified peer
+# if the peer is on the same canvas, otherwise returns an empty string.
+#
+# ifcByLogicalPeer { local_node_id peer_node_id }
# Returns the name of the interface connected to the specified peer.
+# Returns the right interface even if the peer node is on the other
+# canvas.
#
# hasIPv4Addr { node_id }
# hasIPv6Addr { node_id }
-# Retruns true if at least one interface has an IPv{4|6} address
+# Returns true if at least one interface has an IPv{4|6} address
# configured, otherwise returns false.
#
+# removeNode { node_id }
+# Removes the specified node as well as all the links that bind
+# that node to any other node.
+#
+# newIfc { ifc_type node_id }
+# Returns the first available name for a new interface of the
+# specified type.
+#
# All of the above functions are independent to any Tk objects. This means
# they can be used for implementing tasks external to GUI, so inside the
# GUI any updating of related Tk objects (such as text labels etc.) will
# NAME
# typemodel -- find node's type and routing model
# SYNOPSIS
-# set typemod [typemodel $node]
+# set typemod [typemodel $node_id]
# FUNCTION
# For input node this procedure returns the node's
# type and routing model (if exists)
# INPUTS
-# * node -- the node whose type and routing model we search
+# * node_id -- node id
# RESULT
-# * typemod -- returns the free IPv4 network address in the form 10.a.b
+# * typemod -- returns node's type and routing model in form type.model
#****
proc typemodel { node } {
}
}
+#****f* nodecfg.tcl/getCustomEnabled
+# NAME
+# getCustomEnabled -- get custom configuration enabled state
+# SYNOPSIS
+# set enabled [getCustomEnabled $node_id]
+# FUNCTION
+# For input node this procedure returns true if custom configuration
+# is enabled for the specified node.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * enabled -- returns true if custom configuration is enabled
+#****
proc getCustomEnabled { node } {
global $node
}
}
+#****f* nodecfg.tcl/setCustomEnabled
+# NAME
+# setCustomEnabled -- set custom configuration enabled state
+# SYNOPSIS
+# setCustomEnabled $node_id $enabled
+# FUNCTION
+# For input node this procedure enables or disables custom configuration.
+# INPUTS
+# * node_id -- node id
+# * enabled -- true if enabling custom configuration, false if disabling
+#****
proc setCustomEnabled { node enabled } {
global $node
return
}
+#****f* nodecfg.tcl/getCustomCmd
+# NAME
+# getCustomCmd -- get custom configuration command
+# SYNOPSIS
+# set command [getCustomCmd $node_id]
+# FUNCTION
+# For input node this procedure returns custom command.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * command -- custom configuration command
+#****
proc getCustomCmd { node } {
global $node
return [lindex [lsearch -inline [set $node] "custom-command *"] 1]
}
+#****f* nodecfg.tcl/setCustomCmd
+# NAME
+# setCustomEnabled -- set custom configuration command
+# SYNOPSIS
+# setCustomCmd $node_id $command
+# FUNCTION
+# For input node this procedure sets custom command.
+# INPUTS
+# * node_id -- node id
+# * command -- custom configuration command
+#****
proc setCustomCmd { node cmd } {
global $node
return
}
+#****f* nodecfg.tcl/getCustomConfig
+# NAME
+# getCustomConfig -- get custom configuration section
+# SYNOPSIS
+# set cfg [getCustomConfig $node_id]
+# FUNCTION
+# For input node this procedure returns custom configuration section.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * cfg -- returns custom configuration section
+#****
proc getCustomConfig { node } {
global $node
return [lindex [lsearch -inline [set $node] "custom-config *"] 1]
}
+#****f* nodecfg.tcl/setCustomConfig
+# NAME
+# setCustomConfig -- set custom configuration command
+# SYNOPSIS
+# setCustomConfig $node_id $cfg
+# FUNCTION
+# For input node this procedure sets custom configuration section.
+# INPUTS
+# * node_id -- node id
+# * cfg -- custom configuration section
+#****
proc setCustomConfig { node cfg } {
global $node
return
}
+#****f* nodecfg.tcl/netconfFetchSection
+# NAME
+# netconfFetchSection -- fetch the network configuration section
+# SYNOPSIS
+# set section [netconfFetchSection $node_id $sectionhead]
+# FUNCTION
+# Returns a section of a network part of a configuration file starting with the $sectionhead
+# line, and ending with the first occurrence of the "!" sign.
+# INPUTS
+# * node_id -- node id
+# * sectionhead -- represents the first line of the section in network-config part of
+# the configuration file
+# RESULT
+# * section -- returns a part of the configuration file between sectionhead and "!"
+#****
proc netconfFetchSection { node sectionhead } {
global $node
}
}
+#****f* nodecfg.tcl/netconfClearSection
+# NAME
+# netconfClearSection -- clear the section from a network-config part
+# SYNOPSIS
+# netconfClearSection $node_id $sectionhead
+# FUNCTION
+# Removes the appropriate section from the network part of the configuration.
+# INPUTS
+# * node_id -- node id
+# * sectionhead -- represents the first line of the section that is to be removed from network-config
+# part of the configuration.
+#****
proc netconfClearSection { node sectionhead } {
global $node
}
}
+#****f* nodecfg.tcl/netconfInsertSection
+# NAME
+# netconfInsertSection -- Insert the section to a network-config part of configuration
+# SYNOPSIS
+# netconfInsertSection $node_id $section
+# FUNCTION
+# Inserts a section in the configuration. Sections beginning with the
+# "interface" keyword are inserted at the head of the configuration, and
+# all other sequences are simply appended to the configuration tail.
+# INPUTS
+# * node_id -- the node id of the node whose config section is inserted
+# * section -- represents the section that is being inserted. If there
+# was a section in network config with the same section head, it is lost.
+#****
proc netconfInsertSection { node section } {
global $node
return
}
+#****f* nodecfg.tcl/getIfcOperState
+# NAME
+# getIfcOperState -- get interface operating state
+# SYNOPSIS
+# set state [getIfcOperState $node_id $ifc]
+# FUNCTION
+# Returns the operating state of the specified interface. It can be "up" or "down".
+# INPUTS
+# * node_id -- node id
+# * ifc -- The interface that is up or down
+# RESULT
+# * state -- the operating state of the interface, can either "up" or "down".
+#****
proc getIfcOperState { node ifc } {
foreach line [netconfFetchSection $node "interface $ifc"] {
if { [lindex $line 0] == "shutdown" } {
return "down"
+
}
}
return "up"
}
+#****f* nodecfg.tcl/setIfcOperState
+# NAME
+# setIfcOperState -- set interface operating state
+# SYNOPSIS
+# setIfcOperState $node_id $ifc
+# FUNCTION
+# Sets the operating state of the specified interface. It can be set to "up" or "down".
+# INPUTS
+# * node_id -- node id
+# * ifc -- interface
+# * state -- new operating state of the interface, can be either "up" or "down"
+#****
proc setIfcOperState { node ifc state } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getIfcQDisc
+# NAME
+# getIfcQDisc -- get interface queuing discipline
+# SYNOPSIS
+# set qdisc [getIfcQDisc $node_id $ifc]
+# FUNCTION
+# Returns one of the supported queuing discipline ("FIFO", "WFQ" or "DRR") that is activ
+# for the specified interface.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queuing discipline is checked.
+# * ifc -- The interface name.
+# RESULT
+# * qdisc -- returns queuing discipline of the interface, can be "FIFO", "WFQ" or "DRR".
+#****
proc getIfcQDisc { node ifc } {
foreach line [netconfFetchSection $node "interface $ifc"] {
return FIFO
}
+#****f* nodecfg.tcl/setIfcQDisc
+# NAME
+# setIfcQDisc -- set interface queueing discipline
+# SYNOPSIS
+# setIfcQDisc $node_id $ifc $qdisc
+# FUNCTION
+# Sets the new queuing discipline for the interface. Implicit default is FIFO.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queuing discipline is set.
+# * ifc -- interface name.
+# * qdisc -- queuing discipline of the interface, can be "FIFO", "WFQ" or "DRR".
+#****
proc setIfcQDisc { node ifc qdisc } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getIfcQDrop
+# NAME
+# getIfcQDrop -- get interface queue dropping policy
+# SYNOPSIS
+# set qdrop [getIfcQDrop $node_id $ifc]
+# FUNCTION
+# Returns one of the supported queue dropping policies ("drop-tail" or "drop-head") that is active
+# for the specified interface.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queue dropping policy is checked.
+# * ifc -- The interface name.
+# RESULT
+# * qdrop -- returns queue dropping policy of the interface, can be "drop-tail" or "drop-head".
+#****
proc getIfcQDrop { node ifc } {
foreach line [netconfFetchSection $node "interface $ifc"] {
return drop-tail
}
+#****f* nodecfg.tcl/setIfcQDrop
+# NAME
+# setIfcQDrop -- set interface queue dropping policy
+
+# SYNOPSIS
+# setIfcQDrop $node_id $ifc $qdrop
+# FUNCTION
+# Sets the new queuing discipline. Implicit default is "drop-tail".
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queue droping policie is set.
+# * ifc -- interface name.
+# * qdrop -- new queue dropping policy of the interface, can be "drop-tail" or "drop-head".
+#****
proc setIfcQDrop { node ifc qdrop } {
set ifcfg [list "interface $ifc"]
if { $qdrop == "drop-head" } {
lappend ifcfg " drop-head"
+
}
foreach line [netconfFetchSection $node "interface $ifc"] {
if { [lindex $line 0] != "drop-head" && \
return
}
+#****f* nodecfg.tcl/getIfcQLen
+# NAME
+# getIfcQLen -- get interface queue length
+# SYNOPSIS
+# set qlen [getIfcQLen $node_id $ifc]
+# FUNCTION
+# Returns the queue length limit in number of packets.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queue length is checked.
+# * ifc -- interface name.
+# RESULT
+# * qlen -- queue length limit represented in number of packets.
+#****
proc getIfcQLen { node ifc } {
foreach line [netconfFetchSection $node "interface $ifc"] {
return 50
}
+#****f* nodecfg.tcl/setIfcQLen
+# NAME
+# setIfcQLen -- set interface queue length
+# SYNOPSIS
+# setIfcQLen $node_id $ifc $len
+# FUNCTION
+# Sets the queue length limit.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's queue length is set.
+# * ifc -- interface name.
+# * qlen -- queue length limit represented in number of packets.
+#****
proc setIfcQLen { node ifc len } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getIfcMTU
+# NAME
+# getIfcMTU -- get interface MTU size.
+# SYNOPSIS
+# set mtu [getIfcMTU $node_id $ifc]
+# FUNCTION
+# Returns the configured MTU, or a default MTU.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's MTU is checked.
+# * ifc -- interface name.
+# RESULT
+# * mtu -- maximum transmission unit of the packet, represented in bytes.
+#****
proc getIfcMTU { node ifc } {
foreach line [netconfFetchSection $node "interface $ifc"] {
}
}
+#****f* nodecfg.tcl/setIfcMTU
+# NAME
+# setIfcMTU -- set interface MTU size.
+# SYNOPSIS
+# setIfcMTU $node_id $ifc $mtu
+# FUNCTION
+# Sets the new MTU. Zero MTU value denotes the default MTU.
+# INPUTS
+# * node_id -- represents the node id of the node whose interface's MTU is set.
+# * ifc -- interface name.
+# * mtu -- maximum transmission unit of a packet, represented in bytes.
+#****
proc setIfcMTU { node ifc mtu } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getIfcIPv4addr
+# NAME
+# getIfcIPv4addr -- get interface IPv4 address.
+# SYNOPSIS
+# set addr [getIfcIPv4addr $node_id $ifc]
+# FUNCTION
+# Returns the list of IPv4 addresses assigned to the specified interface.
+# INPUTS
+# * node_id -- node id
+# * ifc -- interface name.
+# RESULT
+# * addr -- A list of all the IPv4 addresses assigned to the specified interface.
+#****
proc getIfcIPv4addr { node ifc } {
set addrlist {}
return $addrlist
}
+#****f* nodecfg.tcl/setIfcIPv4addr
+# NAME
+# setIfcIPv4addr -- set interface IPv4 address.
+# SYNOPSIS
+# setIfcIPv4addr $node_id $ifc $addr
+# FUNCTION
+# Sets a new IPv4 address(es) on an interface. The correctness of the
+# IP address format is not checked / enforced.
+# INPUTS
+# * node_id -- the node id of the node whose interface's IPv4 address is set.
+# * ifc -- interface name.
+# * addr -- new IPv4 address.
+#****
proc setIfcIPv4addr { node ifc addr } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getIfcIPv6addr
+# NAME
+# getIfcIPv6addr -- get interface IPv6 address.
+# SYNOPSIS
+# set addr [getIfcIPv6addr $node_id $ifc]
+# FUNCTION
+# Returns the list of IPv6 addresses assigned to the specified interface.
+# INPUTS
+# * node_id -- the node id of the node whose interface's IPv6 addresses are returned.
+# * ifc -- interface name.
+# RESULT
+# * addr -- A list of all the IPv6 addresses assigned to the specified interface.
+#****
proc getIfcIPv6addr { node ifc } {
set addrlist {}
return $addrlist
}
+#****f* nodecfg.tcl/setIfcIPv6addr
+# NAME
+# setIfcIPv6addr -- set interface IPv6 address.
+# SYNOPSIS
+# setIfcIPv6addr $node_id $ifc $addr
+# FUNCTION
+# Sets a new IPv6 address(es) on an interface. The correctness of the
+# IP address format is not checked / enforced.
+# INPUTS
+# * node_id -- the node id of the node whose interface's IPv4 address is set.
+# * ifc -- interface name.
+# * addr -- new IPv6 address.
+#****
proc setIfcIPv6addr { node ifc addr } {
set ifcfg [list "interface $ifc"]
return
}
+#****f* nodecfg.tcl/getStatIPv4routes
+# NAME
+# getStatIPv4routes -- get static IPv4 routes.
+# SYNOPSIS
+# set routes [getStatIPv4routes $node_id]
+# FUNCTION
+# Returns a list of all static IPv4 routes as a list of
+# {destination gateway {metric}} pairs.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * routes -- the list of all static routes defined for the specified node
+#****
proc getStatIPv4routes { node } {
global $node
return $routes
}
+#****f* nodecfg.tcl/setStatIPv4routes
+# NAME
+# setStatIPv4routes -- set static IPv4 routes.
+# SYNOPSIS
+# setStatIPv4routes $node_id $routes
+# FUNCTION
+# Replace all current static route entries with a new one, in form of
+# a list of {destination gateway {metric}} pairs.
+# INPUTS
+# * node_id -- the node id of the node whose static routes are set.
+# * routes -- the list of all static routes defined for the specified node
+#****
proc setStatIPv4routes { node routes } {
netconfClearSection $node "ip route [lindex [getStatIPv4routes $node] 0]"
return
}
+#****f* nodecfg.tcl/getStatIPv6routes
+# NAME
+# getStatIPv6routes -- get static IPv6 routes.
+# SYNOPSIS
+# set routes [getStatIPv6routes $node_id]
+# FUNCTION
+# Returns a list of all static IPv6 routes as a list of
+# {destination gateway {metric}} pairs.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * routes -- the list of all static routes defined for the specified node
+#****
proc getStatIPv6routes { node } {
global $node
return $routes
}
+#****f* nodecfg.tcl/setStatIPv6routes
+# NAME
+# setStatIPv4routes -- set static IPv6 routes.
+# SYNOPSIS
+# setStatIPv6routes $node_id $routes
+# FUNCTION
+# Replace all current static route entries with a new one, in form of
+# a list of {destination gateway {metric}} pairs.
+# INPUTS
+# * node_id -- node id
+# * routes -- the list of all static routes defined for the specified node
+#****
proc setStatIPv6routes { node routes } {
netconfClearSection $node "ipv6 route [lindex [getStatIPv6routes $node] 0]"
set section {}
foreach route $routes {
lappend section "ipv6 route $route"
+
}
netconfInsertSection $node $section
return
}
+#****f* nodecfg.tcl/getNodeName
+# NAME
+# getNodeName -- get node name.
+# SYNOPSIS
+# set name [getNodeName $node_id]
+# FUNCTION
+# Returns node's logical name.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * name -- logical name of the node
+#****
proc getNodeName { node } {
global $node
return [lrange [lsearch -inline $netconf "hostname *"] 1 end]
}
+#****f* nodecfg.tcl/setNodeName
+# NAME
+# setNodeName -- set node name.
+# SYNOPSIS
+# setNodeName $node_id $name
+# FUNCTION
+# Sets node's logical name.
+# INPUTS
+# * node_id -- node id
+# * name -- logical name of the node
+#****
proc setNodeName { node name } {
netconfClearSection $node "hostname [getNodeName $node]"
return
}
+#****f* nodecfg.tcl/getNodeType
+# NAME
+# getNodeType -- get node type.
+# SYNOPSIS
+# set type [getNodeType $node_id]
+# FUNCTION
+# Returns node's type.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * type -- type of the node
+#****
proc nodeType { node } {
global $node
return [lindex [lsearch -inline [set $node] "type *"] 1]
}
+#****f* nodecfg.tcl/getNodeModel
+# NAME
+# getNodeModel -- get node routing model.
+# SYNOPSIS
+# set model [getNodeModel $node_id]
+# FUNCTION
+# Returns node's optional routing model. Currently supported models are
+# quagga, xorp and static and only nodes of type router have a defined model.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * model -- routing model of the specified node
+#****
proc getNodeModel { node } {
global $node
return [lindex [lsearch -inline [set $node] "model *"] 1]
}
+#****f* nodecfg.tcl/setNodeModel
+# NAME
+# setNodeModel -- set node routing model.
+# SYNOPSIS
+# setNodeModel $node_id $model
+# FUNCTION
+# Sets a optional routing model to the node. Currently supported models are
+# quagga, xorp and static and only nodes of type router have a defined model.
+# INPUTS
+# * node_id -- node id
+# * model -- routing model of the specified node
+#****
proc setNodeModel { node model } {
global $node
return
}
+#****f* nodecfg.tcl/getNodeCoords
+# NAME
+# getNodeCoords -- get node icon coordinates.
+# SYNOPSIS
+# set coords [getNodeCoords $node_id]
+# FUNCTION
+# Returns node's icon coordinates.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * coords -- coordinates of the node's icon a list in form of {Xcoord Ycoord}
+#****
proc getNodeCoords { node } {
global $node
return [lindex [lsearch -inline [set $node] "iconcoords *"] 1]
}
+#****f* nodecfg.tcl/setNodeCoords
+# NAME
+# setNodeCoords -- set node's icon coordinates.
+# SYNOPSIS
+
+# setNodeCoords $node_id $coords
+# FUNCTION
+# Sets node's icon coordinates.
+# INPUTS
+# * node_id -- node id
+# * coords -- coordinates of the node's icon in form of Xcoord Ycoord
+#****
proc setNodeCoords { node coords } {
global $node
return
}
+#****f* nodecfg.tcl/getNodeLabelCoords
+# NAME
+# getNodeLabelCoords -- get node's label coordinates.
+# SYNOPSIS
+# set coords [getNodeLabelCoords $node_id]
+# FUNCTION
+# Returns node's label coordinates.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * coords -- coordinates of the node's label a list in form of {Xcoord Ycoord}
+#****
proc getNodeLabelCoords { node } {
global $node
return [lindex [lsearch -inline [set $node] "labelcoords *"] 1]
}
+#****f* nodecfg.tcl/setNodeLabelCoords
+# NAME
+# setNodeLabelCoords -- set node's label coordinates.
+# SYNOPSIS
+# setNodeLabelCoords $node_id $coords
+# FUNCTION
+# Sets node's label coordinates.
+# INPUTS
+# * node_id -- node id
+# * coords -- coordinates of the node's label in form of Xcoord Ycoord
+#****
proc setNodeLabelCoords { node coords } {
global $node
return
}
+#****f* nodecfg.tcl/getNodeCPUConf
+# NAME
+# getNodeCPUConf -- get node's CPU configuration
+# SYNOPSIS
+# set conf [getNodeCPUConf $node_id]
+# FUNCTION
+# Returns node's CPU scheduling parameters { minp maxp weight }.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * conf -- node's CPU scheduling parameters { minp maxp weight }.
+#****
proc getNodeCPUConf { node } {
global $node
return [join [lrange [lsearch -inline [set $node] "cpu *"] 1 3]]
}
+#****f* nodecfg.tcl/setNodeCPUConf
+# NAME
+# setNodeCPUConf -- set node's CPU configuration
+# SYNOPSIS
+# setNodeCPUConf $node_id $param_list
+# FUNCTION
+# Sets the node's CPU scheduling parameters.
+# INPUTS
+# * node_id -- node id
+# * param_list -- node's CPU scheduling parameters { minp maxp weight }.
+#****
proc setNodeCPUConf { node param_list } {
global $node
return
}
+#****f* nodecfg.tcl/ifcList
+# NAME
+# ifcList -- get list of all interfaces
+# SYNOPSIS
+# set ifcs [ifcList $node_id]
+# FUNCTION
+# Returns a list of all interfaces present in a node.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * ifcs -- list of all node's interfaces.
+#****
proc ifcList { node } {
global $node
return $interfaces
}
+#****f* nodecfg.tcl/peerByIfc
+# NAME
+# peerByIfc -- get node's peer by interface.
+# SYNOPSIS
+# set peer [peerByIfc $node_id $ifc]
+# FUNCTION
+# Returns id of the node on the other side of the interface. If the node
+# on the other side of the interface is situated on the other canvas or connected
+# via split link, this function returns a pseudo node.
+# INPUTS
+# * node_id -- node id
+# * ifc -- interface name
+# RESULT
+# * peer -- node id of the node on the other side of the interface
+#****
proc peerByIfc { node ifc } {
global $node
return [lindex [lindex $entry 1] 1]
}
+#****f* nodecfg.tcl/logicalPeerByIfc
+# NAME
+# logicalPeerByIfc -- get node's peer by interface.
+# SYNOPSIS
+# set peer [logicalPeerByIfc $node_id $ifc]
+# FUNCTION
+# Returns id of the node on the other side of the interface. If the node on the other
+# side of the interface is connected via normal link (not split) this function acts the same
+# as the function peerByIfc, but if the nodes are connected via split links or situated on different
+# canvases this function returns the logical peer node.
+# INPUTS
+# * node_id -- node id
+# * ifc -- interface name
+# RESULT
+# * peer -- node id of the node on the other side of the interface
+#****
proc logicalPeerByIfc { node ifc } {
global $node
set peer [peerByIfc $node $ifc]
if { [nodeType $peer] != "pseudo" } {
return $peer
+
} else {
set mirror_node [getNodeMirror $peer]
set mirror_ifc [ifcList $mirror_node]
}
}
+#****f* nodecfg.tcl/ifcByPeer
+# NAME
+# ifcByPeer -- get node interface by peer.
+# SYNOPSIS
+# set ifc [peerByIfc $node_id $peer_id]
+# FUNCTION
+# Returns the name of the interface connected to the specified peer.
+# If the peer node is on different canvas or connected via split link
+# to the specified node this function returns an empty string.
+# INPUTS
+# * node_id -- node id
+# * peer_id -- id of the peer node
+# RESULT
+# * ifc -- interface name
+#****
proc ifcByPeer { node peer } {
global $node
return [lindex [lindex $entry 1] 0]
}
+#****f* nodecfg.tcl/ifcByLogicalPeer
+# NAME
+# ifcByPeer -- get node interface by peer.
+# SYNOPSIS
+# set ifc [peerByIfc $node_id $peer_id]
+# FUNCTION
+# Returns the name of the interface connected to the specified peer.
+# Returns the right interface even if the peer node is on the other
+# canvas or connected via split link.
+# INPUTS
+# * node_id -- node id
+# * peer_id -- id of the peer node
+# RESULT
+# * ifc -- interface name
+#****
proc ifcByLogicalPeer { node peer } {
global $node
}
}
+#****f* nodecfg.tcl/hasIPv4Addr
+# NAME
+# hasIPv4Addr -- has IPv4 address.
+# SYNOPSIS
+# set check [hasIPv4Addr $node_id]
+# FUNCTION
+# Returns true if at least one interface has an IPv4 address
+# configured, otherwise returns false.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * check -- true if at least one interface has IPv4 address, otherwise false.
+#****
proc hasIPv4Addr { node } {
foreach ifc [ifcList $node] {
return false
}
+#****f* nodecfg.tcl/hasIPv6Addr
+# NAME
+# hasIPv4Addr -- has IPv6 address.
+# SYNOPSIS
+# set check [hasIPv6Addr $node_id]
+# FUNCTION
+# Retruns true if at least one interface has an IPv6 address
+# configured, otherwise returns false.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * check -- true if at least one interface has IPv6 address, otherwise false.
+#****
proc hasIPv6Addr { node } {
foreach ifc [ifcList $node] {
return false
}
+#****f* nodecfg.tcl/removeNode
+# NAME
+# removeNode -- removes the node
+# SYNOPSIS
+# removeNode $node_id
+# FUNCTION
+# Removes the specified node as well as all the links binding that node to
+# the other nodes.
+# INPUTS
+# * node_id -- node id
+#****
proc removeNode { node } {
global node_list $node
return
}
+#****f* nodecfg.tcl/getNodeCanvas
+# NAME
+# getNodeCanvas -- get node canvas id
+# SYNOPSIS
+# set canvas [getNodeCanvas $node_id]
+# FUNCTION
+# Returns node's canvas affinity.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * canvas -- canvas id
+#****
proc getNodeCanvas { node } {
global $node
return [lindex [lsearch -inline [set $node] "canvas *"] 1]
}
+#****f* nodecfg.tcl/setNodeCanvas
+# NAME
+# setNodeCanvas -- set node canvas
+# SYNOPSIS
+# setNodeCanvas $node_id $canvas
+# FUNCTION
+# Sets node's canvas affinity.
+# INPUTS
+# * node_id -- node id
+# * canvas -- canvas id
+#****
proc setNodeCanvas { node canvas } {
global $node
return
}
+#****f* nodecfg.tcl/newIfc
+# NAME
+# newIfc -- new interface
+# SYNOPSIS
+# set ifc [newIfc $type $node_id]
+# FUNCTION
+# Returns the first available name for a new interface of the specified type.
+# INPUTS
+# * node_id -- node id
+# * type -- type
+# RESULT
+# * ifc -- the first available name for a interface of the specified type
+#****
proc newIfc { type node } {
set interfaces [ifcList $node]
return $type$id
}
+#****f* nodecfg.tcl/newNode
+# NAME
+# newNode -- new node
+# SYNOPSIS
+# set node_id [newNode $type]
+# FUNCTION
+# Returns the node id of a new node of the specified type.
+# INPUTS
+# * type -- node type
+# RESULT
+# * node_id -- node id of a new node of the specified type
+#****
proc newNode { type } {
global node_list def_router_model
return $node
}
+#****f* nodecfg.tcl/getNodeMirror
+# NAME
+# getNodeMirror -- get node mirror
+# SYNOPSIS
+# set mirror_node_id [getNodeMirror $node_id]
+# FUNCTION
+# Returns the node id of a mirror pseudo node of the node. Mirror node is the
+# corresponding pseudo node. The pair of pseudo nodes, node and his mirror node, are
+# introduced to form a split in a link. This split can be used for avoiding crossed
+# links or for displaying a link between the nodes on a different canvas.
+# INPUTS
+# * node_id -- node id
+# RESULT
+# * mirror_node_id -- node id of a mirror node
+#****
proc getNodeMirror { node } {
global $node
return [lindex [lsearch -inline [set $node] "mirror *"] 1]
}
+#****f* nodecfg.tcl/setNodeMirror
+# NAME
+# setNodeMirror -- set node mirror
+# SYNOPSIS
+# setNodeMirror $node_id $mirror_node_id
+# FUNCTION
+# Sets the node id of a mirror pseudo node of the specified node. Mirror node is the
+# corresponding pseudo node. The pair of pseudo nodes, node and his mirror node, are
+# introduced to form a split in a link. This split can be used for avoiding crossed
+# links or for displaying a link between the nodes on a different canvas.
+# INPUTS
+# * node_id -- node id
+# * mirror_node_id -- node id of a mirror node
+#****
proc setNodeMirror { node value } {
global $node