Rename Pacf to NetControl

This commit is contained in:
Johanna Amann 2015-07-08 12:34:42 -07:00
parent eb9fbd1258
commit 0e213352d7
61 changed files with 498 additions and 498 deletions

View file

@ -1,6 +1,6 @@
##! Implementation of catch-and-release functionality for Pacf
##! Implementation of catch-and-release functionality for NetControl
module Pacf;
module NetControl;
export {
## Stops all packets involving an IP address from being forwarded. This function

View file

@ -1,20 +1,20 @@
@load ./main
@load base/frameworks/cluster
module Pacf;
module NetControl;
export {
## This is the event used to transport add_rule calls to the manager.
global cluster_pacf_add_rule: event(r: Rule);
global cluster_netcontrol_add_rule: event(r: Rule);
## This is the event used to transport remove_rule calls to the manager.
global cluster_pacf_remove_rule: event(id: string);
global cluster_netcontrol_remove_rule: event(id: string);
}
## Workers need ability to forward commands to manager.
redef Cluster::worker2manager_events += /Pacf::cluster_pacf_(add|remove)_rule/;
redef Cluster::worker2manager_events += /NetControl::cluster_netcontrol_(add|remove)_rule/;
## Workers need to see the result events from the manager.
redef Cluster::manager2worker_events += /Pacf::rule_(added|removed|timeout|error)/;
redef Cluster::manager2worker_events += /NetControl::rule_(added|removed|timeout|error)/;
function activate(p: PluginState, priority: int)
@ -37,7 +37,7 @@ function add_rule(r: Rule) : string
if ( r$id == "" )
r$id = cat(Cluster::node, ":", ++local_rule_count);
event Pacf::cluster_pacf_add_rule(r);
event NetControl::cluster_netcontrol_add_rule(r);
return r$id;
}
}
@ -48,18 +48,18 @@ function remove_rule(id: string) : bool
return remove_rule_impl(id);
else
{
event Pacf::cluster_pacf_remove_rule(id);
event NetControl::cluster_netcontrol_remove_rule(id);
return T; # well, we can't know here. So - just hope...
}
}
@if ( Cluster::local_node_type() == Cluster::MANAGER )
event Pacf::cluster_pacf_add_rule(r: Rule)
event NetControl::cluster_netcontrol_add_rule(r: Rule)
{
add_rule_impl(r);
}
event Pacf::cluster_pacf_remove_rule(id: string)
event NetControl::cluster_netcontrol_remove_rule(id: string)
{
remove_rule_impl(id);
}

View file

@ -10,7 +10,7 @@
##! provides convinience functions for a set of common operations. The
##! low-level API provides full flexibility.
module Pacf;
module NetControl;
@load ./plugin
@load ./types
@ -195,7 +195,7 @@ export {
## ignored and not passed on to any plugin.
##
## r: The rule to be added
global Pacf::rule_policy: hook(r: Rule);
global NetControl::rule_policy: hook(r: Rule);
## Type of an entry in the PACF log.
type InfoCategory: enum {
@ -242,9 +242,9 @@ export {
plugin: string &log &optional;
};
## Event that can be handled to access the :bro:type:`Pacf::Info`
## Event that can be handled to access the :bro:type:`NetControl::Info`
## record as it is sent on to the logging framework.
global log_pacf: event(rec: Info);
global log_netcontrol: event(rec: Info);
}
redef record Rule += {
@ -261,7 +261,7 @@ global id_to_cids: table[string] of set[count]; # id to cid
event bro_init() &priority=5
{
Log::create_stream(Pacf::LOG, [$columns=Info, $ev=log_pacf, $path="pacf"]);
Log::create_stream(NetControl::LOG, [$columns=Info, $ev=log_netcontrol, $path="netcontrol"]);
}
function entity_to_info(info: Info, e: Entity)
@ -394,7 +394,7 @@ function whitelist_subnet(s: subnet, t: interval, location: string &default="")
function shunt_flow(f: flow_id, t: interval, location: string &default="") : string
{
local flow = Pacf::Flow(
local flow = NetControl::Flow(
$src_h=addr_to_subnet(f$src_h),
$src_p=f$src_p,
$dst_h=addr_to_subnet(f$dst_h),
@ -408,7 +408,7 @@ function shunt_flow(f: flow_id, t: interval, location: string &default="") : str
function redirect_flow(f: flow_id, out_port: count, t: interval, location: string &default="") : string
{
local flow = Pacf::Flow(
local flow = NetControl::Flow(
$src_h=addr_to_subnet(f$src_h),
$src_p=f$src_p,
$dst_h=addr_to_subnet(f$dst_h),
@ -469,7 +469,7 @@ function add_rule_impl(rule: Rule) : string
if ( ! rule?$id || rule$id == "" )
rule$id = cat(rule$cid);
if ( ! hook Pacf::rule_policy(rule) )
if ( ! hook NetControl::rule_policy(rule) )
return "";
local accepted = F;
@ -514,7 +514,7 @@ function remove_single_rule(id: string, cid: count) : bool
{
if ( [id,cid] !in rules )
{
Reporter::error(fmt("Rule %s -- %d does not exist in Pacf::remove_single_rule", id, cid));
Reporter::error(fmt("Rule %s -- %d does not exist in NetControl::remove_single_rule", id, cid));
return F;
}
@ -536,7 +536,7 @@ function remove_rule_impl(id: string) : bool
{
if ( id !in id_to_cids )
{
Reporter::error(fmt("Rule %s does not exist in Pacf::remove_rule", id));
Reporter::error(fmt("Rule %s does not exist in NetControl::remove_rule", id));
return F;
}
@ -547,7 +547,7 @@ function remove_rule_impl(id: string) : bool
{
if ( [id,cid] !in rules )
{
Reporter::error(fmt("Internal error in pacf::remove_rule - cid %d does not belong to rule %s", cid, id));
Reporter::error(fmt("Internal error in netcontrol::remove_rule - cid %d does not belong to rule %s", cid, id));
delete cids[cid];
next;
}

View file

@ -1,4 +1,4 @@
module Pacf;
module NetControl;
@load ./main

View file

@ -1,5 +1,5 @@
module Pacf;
module NetControl;
@load ./types

View file

@ -1,6 +1,6 @@
# Acld plugin for the pacf framework.
# Acld plugin for the netcontrol framework.
module Pacf;
module NetControl;
@load ../plugin
@load base/frameworks/broker
@ -41,9 +41,9 @@ export {
global acld_rule_error: event(id: count, r: Rule, msg: string);
}
global pacf_acld_topics: set[string] = set();
global pacf_acld_id: table[count] of PluginState = table();
global pacf_acld_current_id: count = 0;
global netcontrol_acld_topics: set[string] = set();
global netcontrol_acld_id: table[count] of PluginState = table();
global netcontrol_acld_current_id: count = 0;
const acld_add_to_remove: table[string] of string = {
["drop"] = "restore",
@ -58,43 +58,43 @@ const acld_add_to_remove: table[string] of string = {
["nullzero "] ="nonullzero"
};
event Pacf::acld_rule_added(id: count, r: Rule, msg: string)
event NetControl::acld_rule_added(id: count, r: Rule, msg: string)
{
if ( id !in pacf_acld_id )
if ( id !in netcontrol_acld_id )
{
Reporter::error(fmt("Pacf acld plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl acld plugin with id %d not found, aborting", id));
return;
}
local p = pacf_acld_id[id];
local p = netcontrol_acld_id[id];
event Pacf::rule_added(r, p, msg);
event NetControl::rule_added(r, p, msg);
}
event Pacf::acld_rule_removed(id: count, r: Rule, msg: string)
event NetControl::acld_rule_removed(id: count, r: Rule, msg: string)
{
if ( id !in pacf_acld_id )
if ( id !in netcontrol_acld_id )
{
Reporter::error(fmt("Pacf acld plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl acld plugin with id %d not found, aborting", id));
return;
}
local p = pacf_acld_id[id];
local p = netcontrol_acld_id[id];
event Pacf::rule_removed(r, p, msg);
event NetControl::rule_removed(r, p, msg);
}
event Pacf::acld_rule_error(id: count, r: Rule, msg: string)
event NetControl::acld_rule_error(id: count, r: Rule, msg: string)
{
if ( id !in pacf_acld_id )
if ( id !in netcontrol_acld_id )
{
Reporter::error(fmt("Pacf acld plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl acld plugin with id %d not found, aborting", id));
return;
}
local p = pacf_acld_id[id];
local p = netcontrol_acld_id[id];
event Pacf::rule_error(r, p, msg);
event NetControl::rule_error(r, p, msg);
}
function acld_name(p: PluginState) : string
@ -215,15 +215,15 @@ global acld_plugin = Plugin(
function create_acld(config: AcldConfig) : PluginState
{
if ( config$acld_topic in pacf_acld_topics )
Reporter::warning(fmt("Topic %s was added to Pacf acld plugin twice. Possible duplication of commands", config$acld_topic));
if ( config$acld_topic in netcontrol_acld_topics )
Reporter::warning(fmt("Topic %s was added to NetControl acld plugin twice. Possible duplication of commands", config$acld_topic));
else
add pacf_acld_topics[config$acld_topic];
add netcontrol_acld_topics[config$acld_topic];
local p: PluginState = [$acld_config=config, $plugin=acld_plugin, $acld_id=pacf_acld_current_id];
local p: PluginState = [$acld_config=config, $plugin=acld_plugin, $acld_id=netcontrol_acld_current_id];
pacf_acld_id[pacf_acld_current_id] = p;
++pacf_acld_current_id;
netcontrol_acld_id[netcontrol_acld_current_id] = p;
++netcontrol_acld_current_id;
return p;
}

View file

@ -1,8 +1,8 @@
# Broker plugin for the pacf framework. Sends the raw data structures
# used in pacf on to Broker to allow for easy handling, e.g., of
# Broker plugin for the netcontrol framework. Sends the raw data structures
# used in netcontrol on to Broker to allow for easy handling, e.g., of
# command-line scripts.
module Pacf;
module NetControl;
@load ../plugin
@load base/frameworks/broker
@ -31,60 +31,60 @@ export {
global broker_rule_timeout: event(id: count, r: Rule, i: FlowInfo);
}
global pacf_broker_topics: set[string] = set();
global pacf_broker_id: table[count] of PluginState = table();
global pacf_broker_current_id: count = 0;
global netcontrol_broker_topics: set[string] = set();
global netcontrol_broker_id: table[count] of PluginState = table();
global netcontrol_broker_current_id: count = 0;
event Pacf::broker_rule_added(id: count, r: Rule, msg: string)
event NetControl::broker_rule_added(id: count, r: Rule, msg: string)
{
if ( id !in pacf_broker_id )
if ( id !in netcontrol_broker_id )
{
Reporter::error(fmt("Pacf broker plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl broker plugin with id %d not found, aborting", id));
return;
}
local p = pacf_broker_id[id];
local p = netcontrol_broker_id[id];
event Pacf::rule_added(r, p, msg);
event NetControl::rule_added(r, p, msg);
}
event Pacf::broker_rule_removed(id: count, r: Rule, msg: string)
event NetControl::broker_rule_removed(id: count, r: Rule, msg: string)
{
if ( id !in pacf_broker_id )
if ( id !in netcontrol_broker_id )
{
Reporter::error(fmt("Pacf broker plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl broker plugin with id %d not found, aborting", id));
return;
}
local p = pacf_broker_id[id];
local p = netcontrol_broker_id[id];
event Pacf::rule_removed(r, p, msg);
event NetControl::rule_removed(r, p, msg);
}
event Pacf::broker_rule_error(id: count, r: Rule, msg: string)
event NetControl::broker_rule_error(id: count, r: Rule, msg: string)
{
if ( id !in pacf_broker_id )
if ( id !in netcontrol_broker_id )
{
Reporter::error(fmt("Pacf broker plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl broker plugin with id %d not found, aborting", id));
return;
}
local p = pacf_broker_id[id];
local p = netcontrol_broker_id[id];
event Pacf::rule_error(r, p, msg);
event NetControl::rule_error(r, p, msg);
}
event Pacf::broker_rule_timeout(id: count, r: Rule, i: FlowInfo)
event NetControl::broker_rule_timeout(id: count, r: Rule, i: FlowInfo)
{
if ( id !in pacf_broker_id )
if ( id !in netcontrol_broker_id )
{
Reporter::error(fmt("Pacf broker plugin with id %d not found, aborting", id));
Reporter::error(fmt("NetControl broker plugin with id %d not found, aborting", id));
return;
}
local p = pacf_broker_id[id];
local p = netcontrol_broker_id[id];
event Pacf::rule_timeout(r, i, p);
event NetControl::rule_timeout(r, i, p);
}
function broker_name(p: PluginState) : string
@ -129,19 +129,19 @@ global broker_plugin_can_expire = Plugin(
function create_broker(host: addr, host_port: port, topic: string, can_expire: bool &default=F) : PluginState
{
if ( topic in pacf_broker_topics )
Reporter::warning(fmt("Topic %s was added to Pacf broker plugin twice. Possible duplication of commands", topic));
if ( topic in netcontrol_broker_topics )
Reporter::warning(fmt("Topic %s was added to NetControl broker plugin twice. Possible duplication of commands", topic));
else
add pacf_broker_topics[topic];
add netcontrol_broker_topics[topic];
local plugin = broker_plugin;
if ( can_expire )
plugin = broker_plugin_can_expire;
local p: PluginState = [$broker_host=host, $broker_port=host_port, $plugin=plugin, $broker_topic=topic, $broker_id=pacf_broker_current_id];
local p: PluginState = [$broker_host=host, $broker_port=host_port, $plugin=plugin, $broker_topic=topic, $broker_id=netcontrol_broker_current_id];
pacf_broker_id[pacf_broker_current_id] = p;
++pacf_broker_current_id;
netcontrol_broker_id[netcontrol_broker_current_id] = p;
++netcontrol_broker_current_id;
return p;
}

View file

@ -1,7 +1,7 @@
@load ../plugin
module Pacf;
module NetControl;
export {
## Instantiates a debug plugin for the PACF framework. The debug
@ -24,7 +24,7 @@ function debug_name(p: PluginState) : string
function debug_log(p: PluginState, msg: string)
{
print fmt("pacf debug (%s): %s", debug_name(p), msg);
print fmt("netcontrol debug (%s): %s", debug_name(p), msg);
}
function debug_init(p: PluginState)
@ -44,7 +44,7 @@ function debug_add_rule(p: PluginState, r: Rule) : bool
if ( do_something(p) )
{
event Pacf::rule_added(r, p);
event NetControl::rule_added(r, p);
return T;
}
@ -56,7 +56,7 @@ function debug_remove_rule(p: PluginState, r: Rule) : bool
local s = fmt("remove_rule: %s", r);
debug_log(p, s);
event Pacf::rule_removed(r, p);
event NetControl::rule_removed(r, p);
return T;
}

View file

@ -1,7 +1,7 @@
@load ../plugin
@load base/frameworks/openflow
module Pacf;
module NetControl;
export {
type OfConfig: record {
@ -9,7 +9,7 @@ export {
forward: bool &default=T;
idle_timeout: count &default=0;
table_id: count &optional;
priority_offset: int &default=+0; ##< add this to all rule priorities. Can be useful if you want the openflow priorities be offset from the pacf priorities without having to write a filter function.
priority_offset: int &default=+0; ##< add this to all rule priorities. Can be useful if you want the openflow priorities be offset from the netcontrol priorities without having to write a filter function.
check_pred: function(p: PluginState, r: Rule): bool &optional &weaken;
match_pred: function(p: PluginState, e: Entity, m: vector of OpenFlow::ofp_match): vector of OpenFlow::ofp_match &optional &weaken;
@ -17,7 +17,7 @@ export {
};
redef record PluginState += {
## OpenFlow controller for Pacf OpenFlow plugin
## OpenFlow controller for NetControl OpenFlow plugin
of_controller: OpenFlow::Controller &optional;
## OpenFlow configuration record that is passed on initialization
of_config: OfConfig &optional;
@ -54,7 +54,7 @@ global of_messages: table[count, OpenFlow::ofp_flow_mod_command] of OfTable &cre
local p = t[rid, command]$p;
local r = t[rid, command]$r;
event Pacf::rule_error(r, p, "Timeout during rule insertion/removal");
event NetControl::rule_error(r, p, "Timeout during rule insertion/removal");
return 0secs;
};
@ -341,9 +341,9 @@ event OpenFlow::flow_mod_success(match: OpenFlow::ofp_match, flow_mod: OpenFlow:
of_flows[id] = OfTable($p=p, $r=r);
if ( flow_mod$command == OpenFlow::OFPFC_ADD )
event Pacf::rule_added(r, p, msg);
event NetControl::rule_added(r, p, msg);
else if ( flow_mod$command == OpenFlow::OFPFC_DELETE || flow_mod$command == OpenFlow::OFPFC_DELETE_STRICT )
event Pacf::rule_removed(r, p, msg);
event NetControl::rule_removed(r, p, msg);
}
event OpenFlow::flow_mod_failure(match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) &priority=3
@ -356,7 +356,7 @@ event OpenFlow::flow_mod_failure(match: OpenFlow::ofp_match, flow_mod: OpenFlow:
local p = of_messages[id,flow_mod$command]$p;
delete of_messages[id,flow_mod$command];
event Pacf::rule_error(r, p, msg);
event NetControl::rule_error(r, p, msg);
}
event OpenFlow::flow_removed(match: OpenFlow::ofp_match, cookie: count, priority: count, reason: count, duration_sec: count, idle_timeout: count, packet_count: count, byte_count: count)
@ -375,12 +375,12 @@ event OpenFlow::flow_removed(match: OpenFlow::ofp_match, cookie: count, priority
if ( of_flows[id]$c < 2 )
return; # will do stuff once the second part arrives...
else
event Pacf::rule_timeout(r, FlowInfo($duration=double_to_interval((rec$duration_sec+duration_sec)/2), $packet_count=packet_count+rec$packet_count, $byte_count=byte_count+rec$byte_count), p);
event NetControl::rule_timeout(r, FlowInfo($duration=double_to_interval((rec$duration_sec+duration_sec)/2), $packet_count=packet_count+rec$packet_count, $byte_count=byte_count+rec$byte_count), p);
return;
}
event Pacf::rule_timeout(r, FlowInfo($duration=double_to_interval(duration_sec+0.0), $packet_count=packet_count, $byte_count=byte_count), p);
event NetControl::rule_timeout(r, FlowInfo($duration=double_to_interval(duration_sec+0.0), $packet_count=packet_count, $byte_count=byte_count), p);
}
global openflow_plugin = Plugin(

View file

@ -3,7 +3,7 @@
# and can only add/remove filters for addresses, this is quite
# limited in scope at the moment.
module Pacf;
module NetControl;
@load ../plugin

View file

@ -1,5 +1,5 @@
module Pacf;
module NetControl;
export {
const default_priority: int = +0 &redef;