tb_compat.tcl.in 15.5 KB
Newer Older
1
# -*- tcl -*-
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6 7
# All rights reserved.
#

8 9 10
# This is the tb_compact.tcl that deals with all the TB specific commands.
# It should be loaded at the beginning of any ns script using the TB commands.

Leigh B. Stoller's avatar
Leigh B. Stoller committed
11 12 13 14 15 16 17 18 19 20 21 22 23
# We set up some helper stuff in a separate namespace to avoid any conflicts.
namespace eval TBCOMPAT {
    var_import ::GLOBALS::DB
    var_import ::GLOBALS::pid
    var_import ::GLOBALS::eid

    # This is regular expression that matches slightly more than valid
    # IP addresses.  The only thing it doesn't check is that IP 
    # addresses are in range (i.e. 0-255).
    variable IP {^([0-9]{1,3}\.){3,3}[0-9]{1,3}$}

    # This is an RE to match a floating point number.
    variable FLOAT {(^[0-9]+(\.[0-9]+)?$)|(^\.[0-9]+$)}
24 25 26 27 28 29 30

    # This is the default weight for a soft vtype.
    variable default_soft_vtype_weight 0.5

    # This is the default weight for a hard vtype.
    variable default_hard_vtype_weight 1.0

Leigh B. Stoller's avatar
Leigh B. Stoller committed
31 32 33 34 35 36 37 38 39
    # This is a general procedure that takes a node, an object (lan or link)
    # it is connected to, and an IP address, and sets the IP address
    # for the node on that object.  It checks both the validity of the
    # IP addresses and the fact that the node is actually a member of the
    # lan/link.
    proc set-ip {node obj ip} {
	variable IP
	set caller [lindex [info level -1] 0]
	if {[regexp $IP $ip] == 0} {
40
	    perror "$caller - $ip is not a valid IP address."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
41 42 43 44
	    return
	}
	set port [$node find_port $obj]
	if {$port == -1} {
45
	    perror "$caller - $node is not connected to $obj."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
46 47 48 49 50 51 52
	    return
	}
	$node ip $port $ip
    }

    # Let's set up a hwtypes table that contains all valid hardware types.
    variable hwtypes
53
    variable isremote
54 55
    variable isvirt
    sql query $DB "select type,isremotenode,isvirtnode from node_types"
Leigh B. Stoller's avatar
Leigh B. Stoller committed
56
    while {[set row [sql fetchrow $DB]] != ""} {
57 58
	set type  [lindex $row 0]
	set isrem [lindex $row 1]
59
	set isv   [lindex $row 2]
60 61 62

	set hwtypes($type) 1
	set isremote($type) $isrem
63
	set isvirt($type) $isv
Leigh B. Stoller's avatar
Leigh B. Stoller committed
64 65
    }
    sql endquery $DB
66
    sql query $DB "select class,isremotenode,isvirtnode from node_types"
67
    while {[set row [sql fetchrow $DB]] != ""} {
68 69
	set type  [lindex $row 0]
	set isrem [lindex $row 1]
70
	set isv   [lindex $row 2]
71 72 73

	set hwtypes($type) 1
	set isremote($type) $isrem
74
	set isvirt($type) $isv
75 76
    }
    sql endquery $DB
Leigh B. Stoller's avatar
Leigh B. Stoller committed
77

Shashi Guruprasad's avatar
Shashi Guruprasad committed
78 79 80
    # NSE hack: sim type is not in DB. Just adding it now
    set hwtypes(sim) 1
    set isremote(sim) 0
81
    set isvirt(sim) 0
Shashi Guruprasad's avatar
Shashi Guruprasad committed
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    # The permissions table. Entries in this table indicate who is allowed
    # to use nodes of a particular type. No entries means anyone can use it.
    #
    # We omit this check in anonymous mode.
    #
    if {!${GLOBALS::anonymous}} {
	variable nodetypeXpid_permissions
    
	sql query $DB "select type,pid from nodetypeXpid_permissions"
	while {[set row [sql fetchrow $DB]] != ""} {
	    set type  [lindex $row 0]
	    set allow [lindex $row 1]

	    if {([info exists nodetypeXpid_permissions($type)])} {
		lappend nodetypeXpid_permissions($type) $allow
	    } else {
		set nodetypeXpid_permissions($type) [list $allow]
	    }
	}
	sql endquery $DB
    }

105 106 107 108
    # And a os table with valid OS Descriptor names. While we still call
    # them "osids", we are using the user level name not the internal,
    # globally unique name. We leave it to a later phase to deal with it.
    #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
109 110 111 112
    # We omit this check in anonymous mode.
    if {!${GLOBALS::anonymous}} {
	variable osids
	sql query $DB \
113
	    "select osname from os_info where shared=1 or pid='$pid'"
Leigh B. Stoller's avatar
Leigh B. Stoller committed
114 115 116 117 118
	while {[set row [sql fetchrow $DB]] != ""} {
	    set osids($row) 1
	}
	sql endquery $DB
    }
119 120
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
121 122
# IP addresses routines.  These all do some checks and convert into set-ip
# calls.
123
proc tb-set-ip {node ip} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
124 125
    $node instvar portlist
    if {[llength $portlist] != 1} {
126
	perror "\[tb-set-ip] $node does not have a single connection."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
127 128 129
	return
    }
    ::TBCOMPAT::set-ip $node [lindex $portlist 0] $ip
130 131
}
proc tb-set-ip-interface {src dst ip} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
132 133 134 135
    set sim [$src set sim]
    set reallink [$sim find_link $src $dst]
    if {$reallink == {}} {
	perror \
136
	    "\[tb-set-ip-interface] No connection between $src and $dst."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
137
	return
138
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
139
    ::TBCOMPAT::set-ip $src $reallink $ip
140 141
}
proc tb-set-ip-lan {src lan ip} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
142
    if {[$lan info class] != "Lan"} {
143
	perror "\[tb-set-ip-lan] $lan is not a LAN."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
144 145 146
	return
    }
    ::TBCOMPAT::set-ip $src $lan $ip
147 148
}
proc tb-set-ip-link {src link ip} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
149
    if {[$link info class] != "Link"} {
150
	perror "\[tb-set-ip-link] $link is not a link."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
151 152 153
	return
    }
    ::TBCOMPAT::set-ip $src $link $ip
154
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
155 156

# Node state routines.
157
proc tb-set-hardware {node type args} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
158
    var_import ::TBCOMPAT::hwtypes
159
    var_import ::TBCOMPAT::isremote
160
    var_import ::TBCOMPAT::isvirt
161 162 163
    var_import ::GLOBALS::vtypes
    if {(! [info exists hwtypes($type)]) &&
	(! [info exists vtypes($type)])} {
164
	perror "\[tb-set-hardware] Invalid hardware type $type."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
165 166
	return
    }
167 168 169
    if {! ${GLOBALS::anonymous}} {
	var_import ::TBCOMPAT::nodetypeXpid_permissions
	var_import ::GLOBALS::pid
Leigh B. Stoller's avatar
Leigh B. Stoller committed
170
	set allowed 1
171 172
	
	if {[info exists nodetypeXpid_permissions($type)]} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
173
	    set allowed 0
174 175 176 177 178 179 180 181 182 183 184
	    foreach allowedpid $nodetypeXpid_permissions($type) {
		if {$allowedpid == $pid} {
		    set allowed 1
		}
	    }
	}
	if {! $allowed} {
	    perror "\[tb-set-hardware] No permission to use type $type."
	    return
	}
    }
185 186 187 188
    set remote 0
    if {[info exists isremote($type)]} {
	set remote $isremote($type)
    }
189 190 191 192 193
    set isv 0
    if {[info exists isvirt($type)]} {
	set isv $isvirt($type)
    }
    $node set_hwtype $type $remote $isv
194
}
195

196
proc tb-set-node-os {node os} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
197 198 199
    if {! ${GLOBALS::anonymous}} {
	var_import ::TBCOMPAT::osids
	if {! [info exists osids($os)]} {
200
	    perror "\[tb-set-node-os] Invalid osid $os."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
201 202 203 204 205 206 207 208 209 210
	    return
	}
    }
    $node set osid $os
}
proc tb-set-node-cmdline {node cmdline} {
    $node set cmdline $cmdline
}
proc tb-set-node-rpms {node args} {
    if {$args == {}} {
211
	perror "\[tb-set-node-rpms] No rpms given."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
212 213
	return
    }
214
    $node set rpms [join $args :]
215
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
216 217 218 219 220
proc tb-set-node-startup {node cmd} {
    $node set startup $cmd
}
proc tb-set-node-tarfiles {node args} {
    if {$args == {}} {
221
	perror "\[tb-set-node-tarfiles] tb-set-node-tarfiles <node> (<dir> <tar>)+"
Leigh B. Stoller's avatar
Leigh B. Stoller committed
222 223 224
	return
    }
    if {[expr [llength $args] % 2] != 0} {
225
	perror "\[tb-set-node-tarfiles] Arguments should be node and series of pairs."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
226 227
	return
    }
228 229 230 231 232 233
    set tarfiles {}
    while {$args != {}} {
	lappend tarfiles [join [lrange $args 0 1]]
	set args [lrange $args 2 end]
    }
    $node set tarfiles [join $tarfiles :]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
234 235 236
}
proc tb-set-node-deltas {node args} {
    if {$args == {}} {
237
	perror "\[tb-set-node-deltas] No deltas given."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
238 239
	return
    }
240
    $node set deltas [join $args :]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
241
}
242 243 244
proc tb-set-ip-routing {type} {
    var_import ::GLOBALS::default_ip_routing_type

245
    if {$type == {}} {
246
	perror "\[tb-set-ip-routing] No type given."
247 248 249
	return
    }
    if {($type != "none") &&
250 251
	($type != "ospf")} {
	perror "\[tb-set-ip-routing] Type is not one of none|ospf"
252 253
	return
    }
254
    set default_ip_routing_type $type
255
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
256 257 258 259 260 261

# Lan/Link state routines.

# This takes two possible formats:
# tb-set-link-loss <link> <loss>
# tb-set-link-loss <src> <dst> <loss>
262
proc tb-set-link-loss {srclink args} {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
263
    var_import ::TBCOMPAT::FLOAT
264 265
    if {[llength $args] == 2} {
	set dst [lindex $args 0]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
266 267 268 269
	set lossrate [lindex $args 1]
	set sim [$srclink set sim]
	set reallink [$sim find_link $srclink $dst]
	if {$reallink == {}} {
270
	    perror "\[tb-set-link-loss] No link between $srclink and $dst."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
271
	    return
272 273
	}
    } else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
274
	set reallink $srclink
275
	set lossrate [lindex $args 0]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
276 277 278
    }
    if {([regexp $FLOAT $lossrate] == 0) ||
	($lossrate > 1.0)} {
279
	perror "\[tb-set-link-loss] $lossrate is not a valid loss rate."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
280
    }
281 282
    $reallink instvar loss
    $reallink instvar rloss
Leigh B. Stoller's avatar
Leigh B. Stoller committed
283 284 285
    set adjloss [expr 1-sqrt(1-$lossrate)]
    foreach pair [array names loss] {
	set loss($pair) $adjloss
286
	set rloss($pair) $adjloss
287
    }
288
}
289

Leigh B. Stoller's avatar
Leigh B. Stoller committed
290 291 292
proc tb-set-lan-loss {lan lossrate} {
    var_import ::TBCOMPAT::FLOAT
    if {[$lan info class] != "Lan"} {
293
	perror "\[tb-set-lan-loss] $lan is not a lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
294 295 296 297
	return
    }
    if {([regexp $FLOAT $lossrate] == 0) ||
	($lossrate > 1.0)} {
298
	perror "\[tb-set-lan-loss] $lossrate is not a valid loss rate."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
299 300
    }
    $lan instvar loss
301
    $lan instvar rloss
Leigh B. Stoller's avatar
Leigh B. Stoller committed
302 303 304
    set adjloss [expr 1-sqrt(1-$lossrate)]
    foreach pair [array names loss] {
	set loss($pair) $adjloss
305
	set rloss($pair) $adjloss
Leigh B. Stoller's avatar
Leigh B. Stoller committed
306
    }
Christopher Alfeld's avatar
Added:  
Christopher Alfeld committed
307
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
308 309 310

proc tb-set-node-lan-delay {node lan delay} {
    if {[$node info class] != "Node"} {
311
	perror "\[tb-set-node-lan-delay] $node is not a node."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
312 313 314
	return
    }
    if {[$lan info class] != "Lan"} {
315
	perror "\[tb-set-node-lan-delay] $lan is not a lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
316 317 318 319
	return
    }
    set port [$lan get_port $node]
    if {$port == {}} {
320
	perror "\[tb-set-node-lan-delay] $node is not in $lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
321 322 323
	return
    }
    $lan set delay([list $node $port]) [parse_delay $delay]
324
    $lan set rdelay([list $node $port]) [parse_delay $delay]
Christopher Alfeld's avatar
Added:  
Christopher Alfeld committed
325
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
326 327
proc tb-set-node-lan-bandwidth {node lan bw} {
    if {[$node info class] != "Node"} {
328
	perror "\[tb-set-node-lan-delay] $node is not a node."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
329 330 331
	return
    }
    if {[$lan info class] != "Lan"} {
332
	perror "\[tb-set-node-lan-delay] $lan is not a lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
333 334 335 336
	return
    }
    set port [$lan get_port $node]
    if {$port == {}} {
337
	perror "\[tb-set-node-lan-delay] $node is not in $lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
338 339 340
	return
    }
    $lan set bandwidth([list $node $port]) [parse_bw $bw]
341
    $lan set rbandwidth([list $node $port]) [parse_bw $bw]
342
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
343 344 345
proc tb-set-node-lan-loss {node lan loss} {
    var_import ::TBCOMPAT::FLOAT
    if {[$node info class] != "Node"} {
346
	perror "\[tb-set-node-lan-delay] $node is not a node."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
347 348 349
	return
    }
    if {[$lan info class] != "Lan"} {
350
	perror "\[tb-set-node-lan-delay] $lan is not a lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
351 352 353 354
	return
    }
    set port [$lan get_port $node]
    if {$port == {}} {
355
	perror "\[tb-set-node-lan-delay] $node is not in $lan."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
356 357 358 359
	return
    }
    if {([regexp $FLOAT $loss] == 0) ||
	($loss > 1.0)} {
360
	perror "\[tb-set-link-loss] $loss is not a valid loss rate."
Leigh B. Stoller's avatar
Leigh B. Stoller committed
361 362
    }
    $lan set loss([list $node $port]) $loss
363
    $lan set rloss([list $node $port]) $loss
Christopher Alfeld's avatar
Added:  
Christopher Alfeld committed
364
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
365 366 367 368
proc tb-set-node-lan-params {node lan delay bw loss} {
    tb-set-node-lan-delay $node $lan $delay
    tb-set-node-lan-bandwidth $node $lan $bw
    tb-set-node-lan-loss $node $lan $loss
369
}
370 371 372 373 374 375 376 377 378 379 380

proc tb-set-node-failure-action {node type} {
    if {[$node info class] != "Node"} {
	perror "\[tb-set-node-failure-action] $node is not a node."
	return
    }
    if {[lsearch -exact {fatal nonfatal ignore} $type] == -1} {
	perror "\[tb-set-node-failure-action] type must be one of fatal|nonfatal|ignore."
	return
    }
    $node set failureaction $type
381 382 383 384
}

proc tb-fix-node {vnode pnode} {
    if {[$vnode info class] != "Node"} {
385
	perror "\[tb-fix-node] $vnode is not a node."
386 387
	return
    }
388
    $vnode set_fixed $pnode
389 390
}

391 392
proc tb-make-soft-vtype {name types} {
    var_import ::TBCOMPAT::hwtypes
393
    var_import ::TBCOMPAT::isremote
394 395 396 397 398 399 400
    var_import ::GLOBALS::vtypes
    var_import ::TBCOMPAT::default_soft_vtype_weight

    foreach type $types {
	if {! [info exists hwtypes($type)]} {
	    perror "\[tb-make-soft-vtype] Invalid hardware type $type."
	}
401 402 403
	if {$isremote($type)} {
	    perror "\[tb-make-soft-vtype] Remote type $type not allowed."
	}
404 405 406 407 408 409
    }
    set vtypes($name) [Vtype $name $default_soft_vtype_weight $types]
}

proc tb-make-hard-vtype {name types} {
    var_import ::TBCOMPAT::hwtypes
410
    var_import ::TBCOMPAT::isremote
411 412 413 414 415 416 417
    var_import ::GLOBALS::vtypes
    var_import ::TBCOMPAT::default_hard_vtype_weight

    foreach type $types {
	if {! [info exists hwtypes($type)]} {
	    perror "\[tb-make-hard-vtype] Invalid hardware type $type."
	}
418 419 420
	if {$isremote($type)} {
	    perror "\[tb-make-hard-vtype] Remote type $type not allowed."
	}
421 422 423 424 425 426
    }
    set vtypes($name) [Vtype $name $default_hard_vtype_weight $types]
}

proc tb-make-weighted-vtype {name weight types} {
    var_import ::TBCOMPAT::hwtypes
427
    var_import ::TBCOMPAT::isremote
428 429 430 431 432
    var_import ::GLOBALS::vtypes
    var_import ::TBCOMPAT::FLOAT

    foreach type $types {
	if {! [info exists hwtypes($type)]} {
433 434 435 436
	    perror "\[tb-make-weighted-vtype] Invalid hardware type $type."
	}
	if {$isremote($type)} {
	    perror "\[tb-make-weighted-vtype] Remote type $type not allowed."
437 438 439 440 441 442 443
	}
    }
    if {([regexp $FLOAT $weight] == 0) ||
	($weight <= 0) || ($weight >= 1.0)} {
	perror "\[tb-make-weighted-vtype] $weight is not a valid weight. (0 < weight < 1)."
    }
    set vtypes($name) [Vtype $name $weight $types]
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
}

proc tb-set-link-simplex-params {link src delay bw loss} {
    var_import ::TBCOMPAT::FLOAT
    if {[$link info class] != "Link"} {
	perror "\[tb-set-link-simplex-params] $link is not a link."
	return
    }
    if {[$src info class] != "Node"} {
	perror "\[tb-set-link-simplex-params] $src is not a link."
	return
    }
    set port [$link get_port $src]
    if {$port == {}} {
	perror "\[tb-set-link-simplex-params] $src is not in $link."
	return
    }
    if {([regexp $FLOAT $loss] == 0) || ($loss > 1.0)} {
	perror "\[tb-set-link-simplex-params] $loss is not a valid loss rate."
	return
    }
    set adjloss [expr 1-sqrt(1-$loss)]
    set np [list $src $port]
    foreach nodeport [$link set nodelist] {
	if {$nodeport != $np} {
	    set onp $nodeport
	}
    }

    set realdelay [parse_delay $delay]
    set realbw [parse_bw $bw]
    $link set delay($np) [expr $realdelay / 2.0]
    $link set rdelay($onp) [expr $realdelay / 2.0]
    $link set bandwidth($np) $realbw
    $link set rbandwidth($onp) $realbw
    $link set loss($np) [expr $adjloss]
    $link set rloss($onp) [expr $adjloss]
}

proc tb-set-lan-simplex-params {lan node todelay tobw toloss fromdelay frombw fromloss} {
    var_import ::TBCOMPAT::FLOAT
    if {[$node info class] != "Node"} {
	perror "\[tb-set-node-lan-delay] $node is not a node."
	return
    }
    if {[$lan info class] != "Lan"} {
	perror "\[tb-set-node-lan-delay] $lan is not a lan."
	return
    }
    set port [$lan get_port $node]
    if {$port == {}} {
	perror "\[tb-set-node-lan-delay] $node is not in $lan."
	return
    }
    if {([regexp $FLOAT $toloss] == 0) || ($toloss > 1.0)} {
	perror "\[tb-set-link-loss] $toloss is not a valid loss rate."
    }
    if {([regexp $FLOAT $fromloss] == 0) || ($fromloss > 1.0)} {
	perror "\[tb-set-link-loss] $fromloss is not a valid loss rate."
    }

    set realtodelay [parse_delay $todelay]
    set realfromdelay [parse_delay $fromdelay]
    set realtobw [parse_bw $tobw]
    set realfrombw [parse_bw $frombw]

    $lan set delay([list $node $port]) $realtodelay
    $lan set rdelay([list $node $port]) $realfromdelay
    $lan set loss([list $node $port]) $toloss
    $lan set rloss([list $node $port]) $fromloss
    $lan set bandwidth([list $node $port]) $realtobw
    $lan set rbandwidth([list $node $port]) $realfrombw
516 517 518
}

proc tb-set-uselatestwadata {onoff} {
519
    var_import ::GLOBALS::uselatestwadata
520 521 522 523 524 525 526 527

    if {$onoff != 0 && $onoff != 1} {
	perror "\[tb-set-uselatestwadata] $onoff must be 0/1"
	return
    }

    set uselatestwadata $onoff
}
528

529 530 531 532 533 534 535 536 537 538 539
proc tb-set-usewatunnels {onoff} {
    var_import ::GLOBALS::usewatunnels

    if {$onoff != 0 && $onoff != 1} {
	perror "\[tb-set-usewatunnels] $onoff must be 0/1"
	return
    }

    set usewatunnels $onoff
}

540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
proc tb-set-wasolver-weights {delay bw plr} {
    var_import ::GLOBALS::wa_delay_solverweight
    var_import ::GLOBALS::wa_bw_solverweight
    var_import ::GLOBALS::wa_plr_solverweight

    if {($delay < 0) || ($bw < 0) || ($plr < 0)} {
	perror "\[tb-set-wasolver-weights] Weights must be postive integers."
	return
    }
    if {($delay == {}) || ($bw == {}) || ($plr == {})} {
	perror "\[tb-set-wasolver-weights] Must provide delay, bw, and plr."
	return
    }

    set wa_delay_solverweight $delay
    set wa_bw_solverweight $bw
    set wa_plr_solverweight $plr
}