Add basic OpenFlow plugin for Pacf.

This also changes a few types in pacf and adds a few needed bits and
pieces to the OpenFlow framework.

And - it even has a testcase...
This commit is contained in:
Johanna Amann 2015-04-14 15:22:19 -07:00
parent aad988d2f2
commit 7d7578146f
12 changed files with 258 additions and 33 deletions

View file

@ -45,15 +45,20 @@ event bro_init() &priority=5
Log::create_stream(LOG, [$columns=Info, $ev=log_openflow, $path="openflow"]);
}
function log_flow_mod(state: OpenFlow::ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool
function log_flow_mod(state: ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool
{
Log::write(LOG, [$ts=network_time(), $dpid=state$log_dpid, $match=match, $flow_mod=flow_mod]);
return T;
}
function log_describe(state: ControllerState): string
{
return fmt("OpenFlog Log Plugin - DPID %d", state$log_dpid);
}
function log_new(dpid: count): OpenFlow::Controller
{
return [$state=[$log_dpid=dpid, $_plugin=OpenFlow::LOG],
$flow_mod=log_flow_mod, $flow_clear=ryu_flow_clear];
$flow_mod=log_flow_mod, $flow_clear=ryu_flow_clear, $describe=log_describe];
}

View file

@ -164,9 +164,14 @@ function ryu_flow_clear(state: OpenFlow::ControllerState): bool
return T;
}
function ryu_describe(state: ControllerState): string
{
return fmt("Ryu Plugin - http://%s:%d - DPID: %d", state$ryu_host, state$ryu_port, state$ryu_dpid);
}
# Ryu controller constructor
function ryu_new(host: addr, host_port: count, dpid: count): OpenFlow::Controller
{
return [$state=[$ryu_host=host, $ryu_port=host_port, $ryu_dpid=dpid, $_plugin=OpenFlow::RYU],
$flow_mod=ryu_flow_mod, $flow_clear=ryu_flow_clear];
$flow_mod=ryu_flow_mod, $flow_clear=ryu_flow_clear, $describe=ryu_describe];
}

View file

@ -111,6 +111,8 @@ export {
type Controller: record {
## Controller related state.
state: ControllerState;
## function that describes the controller. Has to be implemented.
describe: function(state: ControllerState): string;
## flow_mod function
flow_mod: function(state: ControllerState, match: ofp_match, flow_mod: ofp_flow_mod): bool &optional;
## flow_clear function