From 7168ba32f5b42f48af7c3504609882d254aba9cb Mon Sep 17 00:00:00 2001 From: zrinka Date: Fri, 2 Dec 2005 09:15:51 +0000 Subject: [PATCH] Source file documentation Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- nodecfg.tcl | 701 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 691 insertions(+), 10 deletions(-) diff --git a/nodecfg.tcl b/nodecfg.tcl index b378bca..96b4715 100755 --- a/nodecfg.tcl +++ b/nodecfg.tcl @@ -16,6 +16,7 @@ # 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 @@ -60,6 +61,7 @@ # * lanswitch # * hub # * rj45 +# * pseudo # # The following node types are to be implemented in the future: # * frswitch @@ -91,7 +93,7 @@ # 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". @@ -157,10 +159,10 @@ # 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. @@ -172,13 +174,13 @@ # 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 }. @@ -192,14 +194,31 @@ # 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 @@ -221,14 +240,14 @@ # 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 } { @@ -241,6 +260,19 @@ 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 @@ -252,6 +284,17 @@ proc getCustomEnabled { 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 @@ -266,6 +309,18 @@ proc setCustomEnabled { node enabled } { 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 @@ -273,6 +328,17 @@ proc getCustomCmd { 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 @@ -285,6 +351,18 @@ proc setCustomCmd { node cmd } { 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 @@ -292,6 +370,17 @@ proc getCustomConfig { 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 @@ -306,6 +395,21 @@ proc setCustomConfig { node cfg } { 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 @@ -327,6 +431,18 @@ proc netconfFetchSection { node sectionhead } { } } +#****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 @@ -349,6 +465,20 @@ proc netconfClearSection { node sectionhead } { } } +#****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 @@ -379,16 +509,42 @@ proc netconfInsertSection { node section } { 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"] @@ -405,6 +561,20 @@ proc setIfcOperState { node ifc state } { 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"] { @@ -418,6 +588,18 @@ proc getIfcQDisc { node 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"] @@ -437,6 +619,20 @@ proc setIfcQDisc { node ifc qdisc } { 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"] { @@ -447,11 +643,25 @@ proc getIfcQDrop { node 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" && \ @@ -463,6 +673,19 @@ proc setIfcQDrop { node ifc qdrop } { 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"] { @@ -473,6 +696,18 @@ proc getIfcQLen { node 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"] @@ -488,6 +723,19 @@ proc setIfcQLen { node ifc len } { 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"] { @@ -502,6 +750,18 @@ proc getIfcMTU { node 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"] @@ -521,6 +781,19 @@ proc setIfcMTU { node ifc mtu } { 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 {} @@ -532,6 +805,19 @@ proc getIfcIPv4addr { node ifc } { 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"] @@ -547,6 +833,19 @@ proc setIfcIPv4addr { node ifc addr } { 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 {} @@ -558,6 +857,19 @@ proc getIfcIPv6addr { node ifc } { 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"] @@ -573,6 +885,19 @@ proc setIfcIPv6addr { node ifc addr } { 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 @@ -585,6 +910,18 @@ proc getStatIPv4routes { 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]" @@ -596,6 +933,19 @@ proc setStatIPv4routes { node routes } { 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 @@ -608,17 +958,42 @@ proc getStatIPv6routes { 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 @@ -627,6 +1002,17 @@ proc getNodeName { 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]" @@ -634,6 +1020,18 @@ proc setNodeName { node name } { 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 @@ -641,6 +1039,19 @@ proc nodeType { 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 @@ -648,6 +1059,18 @@ proc getNodeModel { 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 @@ -661,6 +1084,18 @@ proc setNodeModel { node model } { 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 @@ -668,6 +1103,18 @@ proc getNodeCoords { 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 @@ -681,6 +1128,18 @@ proc setNodeCoords { node coords } { 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 @@ -688,6 +1147,17 @@ proc getNodeLabelCoords { 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 @@ -701,6 +1171,18 @@ proc setNodeLabelCoords { node coords } { 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 @@ -708,6 +1190,17 @@ proc getNodeCPUConf { 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 @@ -727,6 +1220,18 @@ proc setNodeCPUConf { node param_list } { 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 @@ -738,6 +1243,21 @@ proc ifcList { 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 @@ -746,6 +1266,22 @@ proc peerByIfc { node ifc } { 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 @@ -753,6 +1289,7 @@ proc logicalPeerByIfc { node ifc } { set peer [peerByIfc $node $ifc] if { [nodeType $peer] != "pseudo" } { return $peer + } else { set mirror_node [getNodeMirror $peer] set mirror_ifc [ifcList $mirror_node] @@ -760,6 +1297,21 @@ proc logicalPeerByIfc { node ifc } { } } +#****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 @@ -768,6 +1320,21 @@ proc ifcByPeer { node peer } { 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 @@ -792,6 +1359,19 @@ proc ifcByLogicalPeer { node peer } { } } +#****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] { @@ -802,6 +1382,19 @@ proc hasIPv4Addr { 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] { @@ -812,6 +1405,17 @@ proc hasIPv6Addr { 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 @@ -826,6 +1430,18 @@ proc removeNode { 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 @@ -833,6 +1449,17 @@ proc getNodeCanvas { 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 @@ -846,6 +1473,19 @@ proc setNodeCanvas { node canvas } { 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] @@ -853,6 +1493,18 @@ proc newIfc { type 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 @@ -890,6 +1542,21 @@ proc newNode { type } { 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 @@ -897,6 +1564,20 @@ proc getNodeMirror { 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 -- 2.39.5