mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
handle the notification events correctly.
Now if a rule is inserted correctly (or fails to be inserted) into openflow, we actually get the corresponding Pacf events that everything worked.
This commit is contained in:
parent
8c292ddd49
commit
6014b395b8
10 changed files with 105 additions and 15 deletions
|
@ -38,7 +38,7 @@ export {
|
|||
##
|
||||
## flow_mod: The openflow flow_mod record which describes the action to take.
|
||||
##
|
||||
## msg: An optional informational message by the plugin..
|
||||
## msg: An optional informational message by the plugin.
|
||||
global flow_mod_success: event(match: ofp_match, flow_mod: ofp_flow_mod, msg: string &default="");
|
||||
|
||||
## Reports an error while installing a flow Rule.
|
||||
|
|
|
@ -60,6 +60,7 @@ function broker_new(host: addr, host_port: port, topic: string, dpid: count): Op
|
|||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect(cat(host), host_port, 1sec);
|
||||
BrokerComm::subscribe_to_events(topic); # openflow success and failure events are directly sent back via the other plugin via broker.
|
||||
|
||||
return [$state=[$broker_host=host, $broker_port=host_port, $broker_dpid=dpid, $broker_topic=topic, $_plugin=OpenFlow::BROKER],
|
||||
$flow_mod=broker_flow_mod_fun, $flow_clear=broker_flow_clear_fun, $describe=broker_describe];
|
||||
|
|
|
@ -17,12 +17,16 @@ export {
|
|||
##
|
||||
## dpid: OpenFlow switch datapath id.
|
||||
##
|
||||
## success_event: If true, flow_mod_success is raised for each logged line.
|
||||
##
|
||||
## Returns: OpenFlow::Controller record
|
||||
global log_new: function(dpid: count): OpenFlow::Controller;
|
||||
global log_new: function(dpid: count, success_event: bool &default=T): OpenFlow::Controller;
|
||||
|
||||
redef record ControllerState += {
|
||||
## OpenFlow switch datapath id.
|
||||
log_dpid: count &optional;
|
||||
## Raise or do not raise success event
|
||||
log_success_event: bool &optional;
|
||||
};
|
||||
|
||||
## The record type which contains column fields of the OpenFlow log.
|
||||
|
@ -50,6 +54,8 @@ event bro_init() &priority=5
|
|||
function log_flow_mod(state: ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool
|
||||
{
|
||||
Log::write(OpenFlow::LOG, [$ts=network_time(), $dpid=state$log_dpid, $match=match, $flow_mod=flow_mod]);
|
||||
if ( state$log_success_event )
|
||||
event OpenFlow::flow_mod_success(match, flow_mod);
|
||||
|
||||
return T;
|
||||
}
|
||||
|
@ -59,8 +65,8 @@ function log_describe(state: ControllerState): string
|
|||
return fmt("OpenFlog Log Plugin - DPID %d", state$log_dpid);
|
||||
}
|
||||
|
||||
function log_new(dpid: count): OpenFlow::Controller
|
||||
function log_new(dpid: count, success_event: bool &default=T): OpenFlow::Controller
|
||||
{
|
||||
return [$state=[$log_dpid=dpid, $_plugin=OpenFlow::LOG],
|
||||
return [$state=[$log_dpid=dpid, $log_success_event=success_event, $_plugin=OpenFlow::LOG],
|
||||
$flow_mod=log_flow_mod, $flow_clear=ryu_flow_clear, $describe=log_describe];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue