<commit_before># -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2010 University of Utah and the Flux Group.
# All rights reserved.
#

######################################################################
#
# Firewall support.
#
######################################################################

Class Firewall -superclass NSObject

namespace eval GLOBALS {
    set new_classes(Firewall) {}
}

Firewall instproc init {s} {
    global ::GLOBALS::last_class
    var_import ::GLOBALS::explicit_firewall
    var_import ::GLOBALS::security_level

    $self set sim $s

    $self set type    "ipfw2-vlan"
    $self set style   "basic"
    $self set osid    "FW-IPFW2"
    $self set cmdline ""
    $self set parent  ""

    $self set next_rule 100
    $self instvar rules
    array set rules {}

    # Link simulator to this new object.
    if {[$s add_firewall $self] == 0} {
	set ::GLOBALS::last_class $self
    }

    if {$security_level} {
	perror "\[add_firewall] cannot combine firewall with security-level"
    }

    # avoid conflicts with security_level
    set explicit_firewall 1
}

Firewall instproc rename {old new} {
    $self instvar sim

    $sim rename_firewall $old $new
}

#
# Set the type of the firewall
# 
Firewall instproc set-type {targ} {
    $self instvar type
    $self instvar osid
    $self instvar cmdline

    switch -- $targ {
	"ipfw" {
	    set type $targ
	    set osid "FW-IPFW"
	}
	"ipfw2-vlan" {
	    set type $targ
	    set osid "FW-IPFW2"
	    set cmdline "/kernel.fw"
	}
	"ipfw2" -
	"ipchains" {
	    perror "\[set-type] firewall type $targ not yet implemented"
	}
	default {
	    perror "\[set-type] unknown firewall type: $targ"
	}
    }
}

#
# Set the style of the firewall
# 
Firewall instproc set-style {starg} {<commit_msg>Add support for iptables firewall type<commit_after># -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2010 University of Utah and the Flux Group.
# All rights reserved.
#

######################################################################
#
# Firewall support.
#
######################################################################

Class Firewall -superclass NSObject

namespace eval GLOBALS {
    set new_classes(Firewall) {}
}

Firewall instproc init {s} {
    global ::GLOBALS::last_class
    var_import ::GLOBALS::explicit_firewall
    var_import ::GLOBALS::security_level

    $self set sim $s

    $self set type    "ipfw2-vlan"
    $self set style   "basic"
    $self set osid    "FW-IPFW2"
    $self set cmdline ""
    $self set parent  ""

    $self set next_rule 100
    $self instvar rules
    array set rules {}

    # Link simulator to this new object.
    if {[$s add_firewall $self] == 0} {
	set ::GLOBALS::last_class $self
    }

    if {$security_level} {
	perror "\[add_firewall] cannot combine firewall with security-level"
    }

    # avoid conflicts with security_level
    set explicit_firewall 1
}

Firewall instproc rename {old new} {
    $self instvar sim

    $sim rename_firewall $old $new
}

#
# Set the type of the firewall
# 
Firewall instproc set-type {targ} {
    $self instvar type
    $self instvar osid
    $self instvar cmdline

    switch -- $targ {
	"ipfw" {
	    set type $targ
	    set osid "FW-IPFW"
	}
	"ipfw2-vlan" {
	    set type $targ
	    set osid "FW-IPFW2"
	    set cmdline "/kernel.fw"
	}
	"iptables" -
	"iptables-vlan" {
	    set type $targ
	    set osid "FW-IPTABLES"
	}
	"ipfw2"	{
	    perror "\[set-type] firewall type $targ not yet implemented"
	}
	default {
	    perror "\[set-type] unknown firewall type: $targ"
	}
    }
}

#
# Set the style of the firewall
# 
Firewall instproc set-style {starg} {
{'fraction_non_alphanumeric': 0.1760505355671519, 'fraction_numerical': 0.009887393573194177, 'mean_word_length': 3.060200668896321, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2854499', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1202, 'n_words': 366}