Commit 5a38a137 authored by Leigh Stoller's avatar Leigh Stoller

Add the little bits for specifying security level:

	tb-set-security-level Green|Yellow|Orange:Red

Also add a template elabinelab.ns file.
parent d44cb5a0
......@@ -150,7 +150,8 @@ my %experiment_fields = ("multiplex_factor" => 1,
"usemodelnet" => 1,
"modelnet_cores" => 1,
"modelnet_edges" => 1,
"elab_in_elab" => 1);
"elab_in_elab" => 1,
"security_level" => 1);
# New parsing code state machine control.
my $PARSING_NOTYET = 0;
......
......@@ -16,7 +16,8 @@ include $(OBJDIR)/Makeconf
LIB_STUFF = lanlink.tcl node.tcl sim.tcl tb_compat.tcl null.tcl \
nsobject.tcl traffic.tcl vtype.tcl parse.tcl program.tcl \
nsenode.tcl nstb_compat.tcl event.tcl firewall.tcl
nsenode.tcl nstb_compat.tcl event.tcl firewall.tcl \
elabinelab.ns
BOSSLIBEXEC = parse-ns
USERLIBEXEC = parse.proxy
......
source tb_compat.tcl
set ns [new Simulator]
set maxpcs @MAXPCS@
set security_level @SECURITY_LEVEL@
set myboss [$ns node]
set myops [$ns node]
tb-set-hardware $myboss pc2000
tb-set-hardware $myops pc2000
tb-elab-in-elab 1
tb-set-node-inner-elab-role $myboss boss
tb-set-node-inner-elab-role $myops ops
set lanstr "myboss myops "
for {set i 1} {$i <= $maxpcs} {incr i} {
set name "mypc${i}"
set $name [$ns node]
append lanstr "[set $name] "
tb-set-node-os [set $name] FBSD-STD
tb-set-node-inner-elab-role [set $name] node
tb-set-hardware [set $name] pc600
}
set publiclan [$ns make-lan $lanstr 100Mb 0ms]
tb-set-ip-lan $myboss $publiclan 10.200.1.70
tb-set-ip-lan $myops $publiclan 10.200.1.74
for {set i 1} {$i <= $maxpcs} {incr i} {
set name "mypc${i}"
tb-set-ip-lan [set $name] $publiclan 10.200.1.$i
}
tb-set-node-os $myboss FBSD410-UPDATE
tb-set-node-cmdline $myboss /kernel.linkdelay
tb-set-node-os $myops FBSD410-UPDATE
if {$security_level >= 2} {
# Set up a firewall
set fw [new Firewall $ns]
$fw set-type ipfw2-vlan
$fw set-style closed
# allow tracroute as well
$fw add-rule "allow udp from 155.98.36.0/22 to any 33434-33524"
$fw add-rule "allow udp from any 33434-33524 to 155.98.36.0/22"
}
# No routing!
$ns run
......@@ -256,6 +256,9 @@ namespace eval GLOBALS {
# Is an inner elab experiment.
variable elab_in_elab 0
# Security level. Defaults to green
variable security_level 0
}
# Load all our classes
......
......@@ -270,6 +270,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::modelnet_cores
var_import ::GLOBALS::modelnet_edges
var_import ::GLOBALS::elab_in_elab
var_import ::GLOBALS::security_level
if {$ran == 1} {
perror "The Simulator 'run' statement can only be run once."
......@@ -453,6 +454,11 @@ Simulator instproc run {} {
lappend values 1
}
if {$security_level} {
lappend fields "security_level"
lappend values $security_level
}
$self spitxml_data "experiments" $fields $values
# This could probably be elsewhere.
......
......@@ -1454,3 +1454,29 @@ proc tb-set-node-inner-elab-role {node role} {
$node set inner_elab_role $role
}
#
# Set security level.
#
proc tb-set-security-level {level} {
var_import ::GLOBALS::security_level
switch -- $level {
"Green" {
set level 0
}
"Yellow" {
set level 1
}
"Orange" {
set level 2
}
"Red" {
set level 3
}
unknown {
perror "\[tb-set-security-level] $level is not a valid level"
return
}
}
set security_level $level
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment