Update OpenFlow API and events.

Events now generally carry the unique ID of the backend that is given
during initialization; there are a few more functions and other
bugfixes.

A few netcontrol tests are still broken (mostly due to a pcap update in
msater).
This commit is contained in:
Johanna Amann 2016-02-11 13:09:20 -08:00
parent 5e2ec25a38
commit 9f3c0c9bb4
19 changed files with 186 additions and 95 deletions

View file

@ -21,7 +21,7 @@ export {
## Broker port to connect to ## Broker port to connect to
acld_port: port; acld_port: port;
## Function that can decide weather to accept add request ## Function that can decide weather to accept add request
add_pred: function(p: PluginState, r: Rule, ar: AclRule): bool &optional &weaken; add_pred: function(p: PluginState, r: Rule, ar: AclRule): bool &optional;
}; };
## Instantiates the acld plugin. ## Instantiates the acld plugin.

View file

@ -11,9 +11,9 @@ export {
table_id: count &optional; 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 netcontrol 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; check_pred: function(p: PluginState, r: Rule): bool &optional;
match_pred: function(p: PluginState, e: Entity, m: vector of OpenFlow::ofp_match): vector of OpenFlow::ofp_match &optional &weaken; match_pred: function(p: PluginState, e: Entity, m: vector of OpenFlow::ofp_match): vector of OpenFlow::ofp_match &optional;
flow_mod_pred: function(p: PluginState, r: Rule, m: OpenFlow::ofp_flow_mod): OpenFlow::ofp_flow_mod &optional &weaken; flow_mod_pred: function(p: PluginState, r: Rule, m: OpenFlow::ofp_flow_mod): OpenFlow::ofp_flow_mod &optional;
}; };
redef record PluginState += { redef record PluginState += {
@ -318,7 +318,7 @@ function openflow_remove_rule(p: PluginState, r: Rule) : bool
return T; return T;
} }
event OpenFlow::flow_mod_success(match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) &priority=3 event OpenFlow::flow_mod_success(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) &priority=3
{ {
local id = OpenFlow::get_cookie_uid(flow_mod$cookie)/2; local id = OpenFlow::get_cookie_uid(flow_mod$cookie)/2;
if ( [id, flow_mod$command] !in of_messages ) if ( [id, flow_mod$command] !in of_messages )
@ -346,7 +346,7 @@ event OpenFlow::flow_mod_success(match: OpenFlow::ofp_match, flow_mod: OpenFlow:
event NetControl::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 event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) &priority=3
{ {
local id = OpenFlow::get_cookie_uid(flow_mod$cookie)/2; local id = OpenFlow::get_cookie_uid(flow_mod$cookie)/2;
if ( [id, flow_mod$command] !in of_messages ) if ( [id, flow_mod$command] !in of_messages )
@ -359,7 +359,7 @@ event OpenFlow::flow_mod_failure(match: OpenFlow::ofp_match, flow_mod: OpenFlow:
event NetControl::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) event OpenFlow::flow_removed(name: string, match: OpenFlow::ofp_match, cookie: count, priority: count, reason: count, duration_sec: count, idle_timeout: count, packet_count: count, byte_count: count)
{ {
local id = OpenFlow::get_cookie_uid(cookie)/2; local id = OpenFlow::get_cookie_uid(cookie)/2;
if ( id !in of_flows ) if ( id !in of_flows )

View file

@ -14,8 +14,6 @@ export {
## Workers need ability to forward commands to manager. ## Workers need ability to forward commands to manager.
redef Cluster::worker2manager_events += /OpenFlow::cluster_flow_(mod|clear)/; redef Cluster::worker2manager_events += /OpenFlow::cluster_flow_(mod|clear)/;
global name_to_controller: table[string] of Controller;
# the flow_mod function wrapper # the flow_mod function wrapper
function flow_mod(controller: Controller, match: ofp_match, flow_mod: ofp_flow_mod): bool function flow_mod(controller: Controller, match: ofp_match, flow_mod: ofp_flow_mod): bool
{ {
@ -81,14 +79,33 @@ function register_controller(tpe: OpenFlow::Plugin, name: string, controller: Co
if ( Cluster::local_node_type() != Cluster::MANAGER ) if ( Cluster::local_node_type() != Cluster::MANAGER )
return; return;
if ( controller$state$_name in name_to_controller ) register_controller_impl(tpe, name, controller);
}
function unregister_controller(controller: Controller)
{ {
Reporter::error("OpenFlow Controller %s was already registered. Ignored duplicate registration"); # we only run the on the manager.
if ( Cluster::local_node_type() != Cluster::MANAGER )
return; return;
unregister_controller_impl(controller);
} }
name_to_controller[controller$state$_name] = controller; function lookup_controller(name: string): vector of Controller
{
# we only run the on the manager. Otherwhise we don't have a mapping or state -> return empty
if ( Cluster::local_node_type() != Cluster::MANAGER )
return vector();
if ( controller?$init ) # I am not quite sure if we can actually get away with this - in the
controller$init(controller$state); # current state, this means that the individual nodes cannot lookup
# a controller by name.
#
# This means that there can be no reactions to things on the actual
# worker nodes - because they cannot look up a name. On the other hand -
# currently we also do not even send the events to the worker nodes (at least
# not if we are using broker). Because of that I am not really feeling that
# badly about it...
return lookup_controller_impl(name);
} }

View file

@ -34,26 +34,32 @@ export {
## Event confirming successful modification of a flow rule. ## Event confirming successful modification of a flow rule.
## ##
## name: The unique name of the OpenFlow controller from which this event originated.
##
## match: The ofp_match record which describes the flow to match. ## match: The ofp_match record which describes the flow to match.
## ##
## flow_mod: The openflow flow_mod record which describes the action to take. ## 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=""); global flow_mod_success: event(name: string, match: ofp_match, flow_mod: ofp_flow_mod, msg: string &default="");
## Reports an error while installing a flow Rule. ## Reports an error while installing a flow Rule.
## ##
## name: The unique name of the OpenFlow controller from which this event originated.
##
## match: The ofp_match record which describes the flow to match. ## match: The ofp_match record which describes the flow to match.
## ##
## flow_mod: The openflow flow_mod record which describes the action to take. ## flow_mod: The openflow flow_mod record which describes the action to take.
## ##
## msg: Message to describe the event. ## msg: Message to describe the event.
global flow_mod_failure: event(match: ofp_match, flow_mod: ofp_flow_mod, msg: string &default=""); global flow_mod_failure: event(name: string, match: ofp_match, flow_mod: ofp_flow_mod, msg: string &default="");
## Reports that a flow was removed by the switch because of either the hard or the idle timeout. ## Reports that a flow was removed by the switch because of either the hard or the idle timeout.
## This message is only generated by controllers that indicate that they support flow removal ## This message is only generated by controllers that indicate that they support flow removal
## in supports_flow_removed. ## in supports_flow_removed.
## ##
## name: The unique name of the OpenFlow controller from which this event originated.
##
## match: The ofp_match record which was used to create the flow. ## match: The ofp_match record which was used to create the flow.
## ##
## cookie: The cookie that was specified when creating the flow. ## cookie: The cookie that was specified when creating the flow.
@ -67,7 +73,7 @@ export {
## packet_count: packet count of the flow ## packet_count: packet count of the flow
## ##
## byte_count: byte count of the flow ## byte_count: byte count of the flow
global flow_removed: event(match: ofp_match, cookie: count, priority: count, reason: count, duration_sec: count, idle_timeout: count, packet_count: count, byte_count: count); global flow_removed: event(name: string, match: ofp_match, cookie: count, priority: count, reason: count, duration_sec: count, idle_timeout: count, packet_count: count, byte_count: count);
## Convert a conn_id record into an ofp_match record that can be used to ## Convert a conn_id record into an ofp_match record that can be used to
## create match objects for OpenFlow. ## create match objects for OpenFlow.
@ -113,8 +119,25 @@ export {
## ##
## controller: The controller to register ## controller: The controller to register
global register_controller: function(tpe: OpenFlow::Plugin, name: string, controller: Controller); global register_controller: function(tpe: OpenFlow::Plugin, name: string, controller: Controller);
## Function to unregister a controller instance. This function
## should be called when a specific controller should no longer
## be used.
##
## controller: The controller to unregister
global unregister_controller: function(controller: Controller);
## Function to lookup a controller instance by name
##
## name: unique name of the controller to look up
##
## Returns: one element vector with controller, if found. Empty vector otherwhise.
global lookup_controller: function(name: string): vector of Controller;
} }
global name_to_controller: table[string] of Controller;
function match_conn(id: conn_id, reverse: bool &default=F): ofp_match function match_conn(id: conn_id, reverse: bool &default=F): ofp_match
{ {
local dl_type = ETH_IPv4; local dl_type = ETH_IPv4;
@ -137,7 +160,7 @@ function match_conn(id: conn_id, reverse: bool &default=F): ofp_match
orig_h = id$resp_h; orig_h = id$resp_h;
orig_p = id$resp_p; orig_p = id$resp_p;
resp_h = id$orig_h; resp_h = id$orig_h;
resp_p = id$resp_p; resp_p = id$orig_p;
} }
if ( is_v6_addr(orig_h) ) if ( is_v6_addr(orig_h) )
@ -203,3 +226,38 @@ function get_cookie_gid(cookie: count): count
return INVALID_COOKIE; return INVALID_COOKIE;
} }
# Functions that are called from cluster.bro and non-cluster.bro
function register_controller_impl(tpe: OpenFlow::Plugin, name: string, controller: Controller)
{
if ( controller$state$_name in name_to_controller )
{
Reporter::error("OpenFlow Controller %s was already registered. Ignored duplicate registration");
return;
}
name_to_controller[controller$state$_name] = controller;
if ( controller?$init )
controller$init(controller$state);
}
function unregister_controller_impl(controller: Controller)
{
if ( controller$state$_name in name_to_controller )
delete name_to_controller[controller$state$_name];
else
Reporter::error("OpenFlow Controller %s was not registered in unregister.");
if ( controller?$destroy )
controller$destroy(controller$state);
}
function lookup_controller_impl(name: string): vector of Controller
{
if ( name in name_to_controller )
return vector(name_to_controller[name]);
else
return vector();
}

View file

@ -24,6 +24,15 @@ function register_controller(tpe: OpenFlow::Plugin, name: string, controller: Co
controller$state$_name = cat(tpe, name); controller$state$_name = cat(tpe, name);
controller$state$_plugin = tpe; controller$state$_plugin = tpe;
if ( controller?$init ) register_controller_impl(tpe, name, controller);
controller$init(controller$state); }
function unregister_controller(controller: Controller)
{
unregister_controller_impl(controller);
}
function lookup_controller(name: string): vector of Controller
{
return lookup_controller_impl(name);
} }

View file

@ -32,8 +32,8 @@ export {
broker_topic: string &optional; broker_topic: string &optional;
}; };
global broker_flow_mod: event(dpid: count, match: ofp_match, flow_mod: ofp_flow_mod); global broker_flow_mod: event(name: string, dpid: count, match: ofp_match, flow_mod: ofp_flow_mod);
global broker_flow_clear: event(dpid: count); global broker_flow_clear: event(name: string, dpid: count);
} }
function broker_describe(state: ControllerState): string function broker_describe(state: ControllerState): string
@ -43,14 +43,14 @@ function broker_describe(state: ControllerState): string
function broker_flow_mod_fun(state: ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool function broker_flow_mod_fun(state: ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool
{ {
BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_mod, state$broker_dpid, match, flow_mod)); BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_mod, state$_name, state$broker_dpid, match, flow_mod));
return T; return T;
} }
function broker_flow_clear_fun(state: OpenFlow::ControllerState): bool function broker_flow_clear_fun(state: OpenFlow::ControllerState): bool
{ {
BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_clear, state$broker_dpid)); BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_clear, state$_name, state$broker_dpid));
return T; return T;
} }

View file

@ -55,7 +55,7 @@ function log_flow_mod(state: ControllerState, match: ofp_match, flow_mod: OpenFl
{ {
Log::write(OpenFlow::LOG, [$ts=network_time(), $dpid=state$log_dpid, $match=match, $flow_mod=flow_mod]); Log::write(OpenFlow::LOG, [$ts=network_time(), $dpid=state$log_dpid, $match=match, $flow_mod=flow_mod]);
if ( state$log_success_event ) if ( state$log_success_event )
event OpenFlow::flow_mod_success(match, flow_mod); event OpenFlow::flow_mod_success(state$_name, match, flow_mod);
return T; return T;
} }

View file

@ -91,7 +91,7 @@ function ryu_flow_mod(state: OpenFlow::ControllerState, match: ofp_match, flow_m
# Generate our ryu_flow_mod record for the ReST API call. # Generate our ryu_flow_mod record for the ReST API call.
local mod: ryu_ofp_flow_mod = ryu_ofp_flow_mod( local mod: ryu_ofp_flow_mod = ryu_ofp_flow_mod(
$dpid=state$ryu_dpid, $dpid=state$ryu_dpid,
$cookie=OpenFlow::generate_cookie(flow_mod$cookie), $cookie=flow_mod$cookie,
$idle_timeout=flow_mod$idle_timeout, $idle_timeout=flow_mod$idle_timeout,
$hard_timeout=flow_mod$hard_timeout, $hard_timeout=flow_mod$hard_timeout,
$priority=flow_mod$priority, $priority=flow_mod$priority,
@ -122,7 +122,7 @@ function ryu_flow_mod(state: OpenFlow::ControllerState, match: ofp_match, flow_m
{ {
print url; print url;
print to_json(mod); print to_json(mod);
event OpenFlow::flow_mod_success(match, flow_mod); event OpenFlow::flow_mod_success(state$_name, match, flow_mod);
return T; return T;
} }
@ -137,11 +137,11 @@ function ryu_flow_mod(state: OpenFlow::ControllerState, match: ofp_match, flow_m
when ( local result = ActiveHTTP::request(request) ) when ( local result = ActiveHTTP::request(request) )
{ {
if(result$code == 200) if(result$code == 200)
event OpenFlow::flow_mod_success(match, flow_mod, result$body); event OpenFlow::flow_mod_success(state$_name, match, flow_mod, result$body);
else else
{ {
Reporter::warning(fmt("Flow modification failed with error: %s", result$body)); Reporter::warning(fmt("Flow modification failed with error: %s", result$body));
event OpenFlow::flow_mod_failure(match, flow_mod, result$body); event OpenFlow::flow_mod_failure(state$_name, match, flow_mod, result$body);
return F; return F;
} }
} }

View file

@ -108,35 +108,6 @@ export {
actions: ofp_flow_action &default=ofp_flow_action(); actions: ofp_flow_action &default=ofp_flow_action();
} &log; } &log;
# Functionality using this is currently not implemented. At all.
# ## Body of reply to OFPST_FLOW request.
# type ofp_flow_stats: record {
# ## ID of table flow came from.
# table_id: count;
# ## Description of fields.
# match: ofp_match;
# ## Time flow has been alive in seconds.
# duration_sec: count;
# ## Time flow has been alive in nanoseconds beyond
# ## duration_sec.
# duration_nsec: count;
# ## Priority of the entry. Only meaningful
# ## when this is not an exact-match entry.
# priority: count;
# ## Number of seconds idle before expiration.
# idle_timeout: count;
# ## Number of seconds before expiration.
# hard_timeout: count;
# ## Opaque controller-issued identifier.
# cookie: count;
# ## Number of packets in flow.
# packet_count: count;
# ## Number of bytes in flow.
# byte_count: count;
# ## Actions
# actions: vector of ofp_action_output;
# };
## Controller record representing an openflow controller ## Controller record representing an openflow controller
type Controller: record { type Controller: record {
## Controller related state. ## Controller related state.
@ -147,6 +118,8 @@ export {
describe: function(state: ControllerState): string; describe: function(state: ControllerState): string;
## one-time initialization function. ## one-time initialization function.
init: function (state: ControllerState) &optional; init: function (state: ControllerState) &optional;
## one-time destruction function
destroy: function (state: ControllerState) &optional;
## flow_mod function ## flow_mod function
flow_mod: function(state: ControllerState, match: ofp_match, flow_mod: ofp_flow_mod): bool &optional; flow_mod: function(state: ControllerState, match: ofp_match, flow_mod: ofp_flow_mod): bool &optional;
## flow_clear function ## flow_clear function

View file

@ -3,7 +3,7 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path netcontrol #path netcontrol
#open 2015-07-08-19-33-52 #open 2016-02-11-21-07-34
#fields ts category cmd state action target entity_type entity msg location plugin #fields ts category cmd state action target entity_type entity msg location plugin
#types time enum string enum string enum string string string string string #types time enum string enum string enum string string string string string
0.000000 NetControl::MESSAGE - - - - - - activated plugin with priority 0 - Openflow - OpenFlog Log Plugin - DPID 42 0.000000 NetControl::MESSAGE - - - - - - activated plugin with priority 0 - Openflow - OpenFlog Log Plugin - DPID 42
@ -11,4 +11,12 @@
1254722767.875996 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 10.10.1.4/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42 1254722767.875996 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 10.10.1.4/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1254722767.875996 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::MONITOR NetControl::FLOW 10.10.1.4/32/1470->74.53.140.153/32/25 - (empty) Openflow - OpenFlog Log Plugin - DPID 42 1254722767.875996 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::MONITOR NetControl::FLOW 10.10.1.4/32/1470->74.53.140.153/32/25 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1254722767.875996 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 10.10.1.4/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42 1254722767.875996 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 10.10.1.4/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
#close 2015-07-08-19-33-52 1437831787.861602 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::MONITOR NetControl::FLOW 192.168.133.100/32/49648->192.168.133.102/32/25 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831787.861602 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 192.168.133.100/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831787.861602 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::MONITOR NetControl::FLOW 192.168.133.100/32/49648->192.168.133.102/32/25 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831787.861602 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 192.168.133.100/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831799.610433 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::MONITOR NetControl::FLOW 192.168.133.100/32/49655->17.167.150.73/32/443 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831799.610433 NetControl::RULE ADD NetControl::REQUESTED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 192.168.133.100/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831799.610433 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::MONITOR NetControl::FLOW 192.168.133.100/32/49655->17.167.150.73/32/443 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
1437831799.610433 NetControl::RULE ADD NetControl::SUCCEEDED NetControl::DROP NetControl::FORWARD NetControl::ADDRESS 192.168.133.100/32 - (empty) Openflow - OpenFlog Log Plugin - DPID 42
#close 2016-02-11-21-07-34

View file

@ -3,10 +3,16 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path openflow #path openflow
#open 2015-06-01-17-45-48 #open 2016-02-11-21-07-34
#fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst #fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst
#types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count #types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count
1254722767.875996 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 4398046511108 - OpenFlow::OFPFC_ADD 0 30 0 - - 1 (empty) - - F - - - - - - - 1254722767.875996 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 4398046511108 - OpenFlow::OFPFC_ADD 0 30 0 - - 1 (empty) - - F - - - - - - -
1254722767.875996 42 - - - - - 2048 - - 10.10.1.4/32 - - - 4398046511110 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - - 1254722767.875996 42 - - - - - 2048 - - 10.10.1.4/32 - - - 4398046511110 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
1254722767.875996 42 - - - - - 2048 - - - 10.10.1.4/32 - - 4398046511111 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - - 1254722767.875996 42 - - - - - 2048 - - - 10.10.1.4/32 - - 4398046511111 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
#close 2015-06-01-17-45-48 1437831787.861602 42 - - - - - 2048 - 6 192.168.133.100/32 192.168.133.102/32 49648 25 4398046511112 - OpenFlow::OFPFC_ADD 0 30 0 - - 1 (empty) - - F - - - - - - -
1437831787.861602 42 - - - - - 2048 - - 192.168.133.100/32 - - - 4398046511114 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
1437831787.861602 42 - - - - - 2048 - - - 192.168.133.100/32 - - 4398046511115 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
1437831799.610433 42 - - - - - 2048 - 6 192.168.133.100/32 17.167.150.73/32 49655 443 4398046511116 - OpenFlow::OFPFC_ADD 0 30 0 - - 1 (empty) - - F - - - - - - -
1437831799.610433 42 - - - - - 2048 - - 192.168.133.100/32 - - - 4398046511118 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
1437831799.610433 42 - - - - - 2048 - - - 192.168.133.100/32 - - 4398046511119 - OpenFlow::OFPFC_ADD 0 15 0 - - 1 (empty) - - F - - - - - - -
#close 2016-02-11-21-07-34

View file

@ -1,5 +1,5 @@
BrokerComm::incoming_connection_established BrokerComm::incoming_connection_established
flow_clear, 42 flow_clear, 42
got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=<uninitialized>, nw_tos=<uninitialized>, nw_proto=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>], [cookie=1, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=0, hard_timeout=0, priority=0, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[3, 7], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]] got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=<uninitialized>, nw_tos=<uninitialized>, nw_proto=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>], [cookie=4398046511105, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=0, hard_timeout=0, priority=0, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[3, 7], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]]
got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=2048, nw_tos=<uninitialized>, nw_proto=6, nw_src=10.10.1.4/32, nw_dst=74.53.140.153/32, tp_src=1470, tp_dst=25], [cookie=42, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=30, hard_timeout=0, priority=5, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]] got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=2048, nw_tos=<uninitialized>, nw_proto=6, nw_src=10.10.1.4/32, nw_dst=74.53.140.153/32, tp_src=1470, tp_dst=25], [cookie=4398046511146, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=30, hard_timeout=0, priority=5, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]]
got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=2048, nw_tos=<uninitialized>, nw_proto=6, nw_src=74.53.140.153/32, nw_dst=10.10.1.4/32, tp_src=25, tp_dst=25], [cookie=42, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=30, hard_timeout=0, priority=5, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]] got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=2048, nw_tos=<uninitialized>, nw_proto=6, nw_src=74.53.140.153/32, nw_dst=10.10.1.4/32, tp_src=25, tp_dst=1470], [cookie=4398046511146, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=30, hard_timeout=0, priority=5, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]]

View file

@ -3,10 +3,14 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path openflow #path openflow
#open 2015-05-22-20-37-23 #open 2016-02-11-20-32-05
#fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst #fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst
#types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count #types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count
0.000000 42 - - - - - - - - - - - - 1 - OpenFlow::OFPFC_ADD 0 0 0 - - 0 3,7 - - F - - - - - - - 0.000000 42 - - - - - - - - - - - - 4398046511105 - OpenFlow::OFPFC_ADD 0 0 0 - - 0 3,7 - - F - - - - - - -
1254722767.875996 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 42 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - - 1254722767.875996 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 4398046511147 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
1254722767.875996 42 - - - - - 2048 - 6 74.53.140.153/32 10.10.1.4/32 25 25 42 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - - 1254722767.875996 42 - - - - - 2048 - 6 74.53.140.153/32 10.10.1.4/32 25 1470 4398046511147 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
#close 2015-05-22-20-37-23 1437831787.861602 42 - - - - - 2048 - 6 192.168.133.100/32 192.168.133.102/32 49648 25 4398046511148 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
1437831787.861602 42 - - - - - 2048 - 6 192.168.133.102/32 192.168.133.100/32 25 49648 4398046511148 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
1437831799.610433 42 - - - - - 2048 - 6 192.168.133.100/32 17.167.150.73/32 49655 443 4398046511149 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
1437831799.610433 42 - - - - - 2048 - 6 17.167.150.73/32 192.168.133.100/32 443 49655 4398046511149 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
#close 2016-02-11-20-32-05

View file

@ -3,9 +3,9 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path openflow #path openflow
#open 2015-05-26-20-51-55 #open 2016-02-11-21-06-45
#fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst #fields ts dpid match.in_port match.dl_src match.dl_dst match.dl_vlan match.dl_vlan_pcp match.dl_type match.nw_tos match.nw_proto match.nw_src match.nw_dst match.tp_src match.tp_dst flow_mod.cookie flow_mod.table_id flow_mod.command flow_mod.idle_timeout flow_mod.hard_timeout flow_mod.priority flow_mod.out_port flow_mod.out_group flow_mod.flags flow_mod.actions.out_ports flow_mod.actions.vlan_vid flow_mod.actions.vlan_pcp flow_mod.actions.vlan_strip flow_mod.actions.dl_src flow_mod.actions.dl_dst flow_mod.actions.nw_tos flow_mod.actions.nw_src flow_mod.actions.nw_dst flow_mod.actions.tp_src flow_mod.actions.tp_dst
#types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count #types time count count string string count count count count count subnet subnet count count count count enum count count count count count count vector[count] count count bool string string count addr addr count count
1432673515.912626 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 42 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - - 1455224805.349129 42 - - - - - 2048 - 6 10.10.1.4/32 74.53.140.153/32 1470 25 4398046511146 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
1432673515.912626 42 - - - - - 2048 - 6 74.53.140.153/32 10.10.1.4/32 25 25 42 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - - 1455224805.349129 42 - - - - - 2048 - 6 74.53.140.153/32 10.10.1.4/32 25 1470 4398046511146 - OpenFlow::OFPFC_ADD 30 0 5 - - 0 (empty) - - F - - - - - - -
#close 2015-05-26-20-52-05 #close 2016-02-11-21-06-46

View file

@ -5,6 +5,18 @@ Flow_mod_success
http://127.0.0.1:8080/stats/flowentry/add http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 25, "nw_dst": "74.53.140.153/32", "nw_src": "10.10.1.4/32", "dl_type": 2048, "tp_src": 1470, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30} {"match": {"tp_dst": 25, "nw_dst": "74.53.140.153/32", "nw_src": "10.10.1.4/32", "dl_type": 2048, "tp_src": 1470, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
http://127.0.0.1:8080/stats/flowentry/add http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 25, "nw_dst": "10.10.1.4/32", "nw_src": "74.53.140.153/32", "dl_type": 2048, "tp_src": 25, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30} {"match": {"tp_dst": 1470, "nw_dst": "10.10.1.4/32", "nw_src": "74.53.140.153/32", "dl_type": 2048, "tp_src": 25, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
Flow_mod_success
Flow_mod_success
http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 25, "nw_dst": "192.168.133.102/32", "nw_src": "192.168.133.100/32", "dl_type": 2048, "tp_src": 49648, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 49648, "nw_dst": "192.168.133.100/32", "nw_src": "192.168.133.102/32", "dl_type": 2048, "tp_src": 25, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
Flow_mod_success
Flow_mod_success
http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 443, "nw_dst": "17.167.150.73/32", "nw_src": "192.168.133.100/32", "dl_type": 2048, "tp_src": 49655, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
http://127.0.0.1:8080/stats/flowentry/add
{"match": {"tp_dst": 49655, "nw_dst": "192.168.133.100/32", "nw_src": "17.167.150.73/32", "dl_type": 2048, "tp_src": 443, "nw_proto": 6}, "dpid": 42, "flags": 0, "hard_timeout": 0, "priority": 5, "actions": [], "cookie": 4398046511146, "idle_timeout": 30}
Flow_mod_success Flow_mod_success
Flow_mod_success Flow_mod_success

View file

@ -30,7 +30,7 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
print "BrokerComm::outgoing_connection_established", peer_address, peer_port; print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
continue_processing(); continue_processing();
OpenFlow::flow_clear(of_controller); OpenFlow::flow_clear(of_controller);
OpenFlow::flow_mod(of_controller, [], [$cookie=1, $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]); OpenFlow::flow_mod(of_controller, [], [$cookie=OpenFlow::generate_cookie(1), $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]);
} }
event BrokerComm::outgoing_connection_broken(peer_address: string, event BrokerComm::outgoing_connection_broken(peer_address: string,
@ -46,7 +46,7 @@ event connection_established(c: connection)
local match_rev = OpenFlow::match_conn(c$id, T); local match_rev = OpenFlow::match_conn(c$id, T);
local flow_mod: OpenFlow::ofp_flow_mod = [ local flow_mod: OpenFlow::ofp_flow_mod = [
$cookie=42, $cookie=OpenFlow::generate_cookie(42),
$command=OpenFlow::OFPFC_ADD, $command=OpenFlow::OFPFC_ADD,
$idle_timeout=30, $idle_timeout=30,
$priority=5 $priority=5
@ -56,12 +56,12 @@ event connection_established(c: connection)
OpenFlow::flow_mod(of_controller, match_rev, flow_mod); OpenFlow::flow_mod(of_controller, match_rev, flow_mod);
} }
event OpenFlow::flow_mod_success(match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) event OpenFlow::flow_mod_success(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string)
{ {
print "Flow_mod_success"; print "Flow_mod_success";
} }
event OpenFlow::flow_mod_failure(match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string)
{ {
print "Flow_mod_failure"; print "Flow_mod_failure";
} }
@ -97,15 +97,15 @@ function got_message()
terminate(); terminate();
} }
event OpenFlow::broker_flow_mod(dpid: count, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod) event OpenFlow::broker_flow_mod(name: string, dpid: count, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod)
{ {
print "got flow_mod", dpid, match, flow_mod; print "got flow_mod", dpid, match, flow_mod;
BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_success, match, flow_mod, "")); BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_success, name, match, flow_mod, ""));
BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_failure, match, flow_mod, "")); BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_failure, name, match, flow_mod, ""));
got_message(); got_message();
} }
event OpenFlow::broker_flow_clear(dpid: count) event OpenFlow::broker_flow_clear(name: string, dpid: count)
{ {
print "flow_clear", dpid; print "flow_clear", dpid;
got_message(); got_message();

View file

@ -6,11 +6,13 @@
global of_controller: OpenFlow::Controller; global of_controller: OpenFlow::Controller;
global cookie_id: count = 42;
event bro_init() event bro_init()
{ {
of_controller = OpenFlow::log_new(42); of_controller = OpenFlow::log_new(42);
OpenFlow::flow_mod(of_controller, [], [$cookie=1, $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]); OpenFlow::flow_mod(of_controller, [], [$cookie=OpenFlow::generate_cookie(1), $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]);
} }
event connection_established(c: connection) event connection_established(c: connection)
@ -19,7 +21,7 @@ event connection_established(c: connection)
local match_rev = OpenFlow::match_conn(c$id, T); local match_rev = OpenFlow::match_conn(c$id, T);
local flow_mod: OpenFlow::ofp_flow_mod = [ local flow_mod: OpenFlow::ofp_flow_mod = [
$cookie=42, $cookie=OpenFlow::generate_cookie(++cookie_id),
$command=OpenFlow::OFPFC_ADD, $command=OpenFlow::OFPFC_ADD,
$idle_timeout=30, $idle_timeout=30,
$priority=5 $priority=5

View file

@ -33,7 +33,7 @@ event connection_established(c: connection)
local match_rev = OpenFlow::match_conn(c$id, T); local match_rev = OpenFlow::match_conn(c$id, T);
local flow_mod: OpenFlow::ofp_flow_mod = [ local flow_mod: OpenFlow::ofp_flow_mod = [
$cookie=42, $cookie=OpenFlow::generate_cookie(42),
$command=OpenFlow::OFPFC_ADD, $command=OpenFlow::OFPFC_ADD,
$idle_timeout=30, $idle_timeout=30,
$priority=5 $priority=5
@ -41,6 +41,8 @@ event connection_established(c: connection)
OpenFlow::flow_mod(of_controller, match, flow_mod); OpenFlow::flow_mod(of_controller, match, flow_mod);
OpenFlow::flow_mod(of_controller, match_rev, flow_mod); OpenFlow::flow_mod(of_controller, match_rev, flow_mod);
terminate();
} }
event terminate_me() { event terminate_me() {

View file

@ -12,7 +12,7 @@ event bro_init()
of_controller$state$ryu_debug=T; of_controller$state$ryu_debug=T;
OpenFlow::flow_clear(of_controller); OpenFlow::flow_clear(of_controller);
OpenFlow::flow_mod(of_controller, [], [$cookie=1, $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]); OpenFlow::flow_mod(of_controller, [], [$cookie=OpenFlow::generate_cookie(1), $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]);
} }
event connection_established(c: connection) event connection_established(c: connection)
@ -21,7 +21,7 @@ event connection_established(c: connection)
local match_rev = OpenFlow::match_conn(c$id, T); local match_rev = OpenFlow::match_conn(c$id, T);
local flow_mod: OpenFlow::ofp_flow_mod = [ local flow_mod: OpenFlow::ofp_flow_mod = [
$cookie=42, $cookie=OpenFlow::generate_cookie(42),
$command=OpenFlow::OFPFC_ADD, $command=OpenFlow::OFPFC_ADD,
$idle_timeout=30, $idle_timeout=30,
$priority=5 $priority=5
@ -31,7 +31,7 @@ event connection_established(c: connection)
OpenFlow::flow_mod(of_controller, match_rev, flow_mod); OpenFlow::flow_mod(of_controller, match_rev, flow_mod);
} }
event OpenFlow::flow_mod_success(match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) event OpenFlow::flow_mod_success(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string)
{ {
print "Flow_mod_success"; print "Flow_mod_success";
} }