base/frameworks/openflow/main.zeek

OpenFlow

Zeek’s OpenFlow control framework.

This plugin-based framework allows to control OpenFlow capable switches by implementing communication to an OpenFlow controller via plugins. The framework has to be instantiated via the new function in one of the plugins. This framework only offers very low-level functionality; if you want to use OpenFlow capable switches, e.g., for shunting, please look at the NetControl framework, which provides higher level functions and can use the OpenFlow framework as a backend.

Namespace

OpenFlow

Imports

base/frameworks/openflow/consts.zeek, base/frameworks/openflow/types.zeek

Summary

Events

OpenFlow::controller_activated: event

Event that is raised once a controller finishes initialization and is completely activated.

OpenFlow::flow_mod_failure: event

Reports an error while installing a flow Rule.

OpenFlow::flow_mod_success: event

Event confirming successful modification of a flow rule.

OpenFlow::flow_removed: event

Reports that a flow was removed by the switch because of either the hard or the idle timeout.

Functions

OpenFlow::controller_init_done: function

Function to signal that a controller finished activation and is ready to use.

OpenFlow::flow_clear: function

Clear the current flow table of the controller.

OpenFlow::flow_mod: function

Global flow_mod function.

OpenFlow::generate_cookie: function

Function to generate a new cookie using our group id.

OpenFlow::get_cookie_gid: function

Function to get the group id out of a given cookie.

OpenFlow::get_cookie_uid: function

Function to get the unique id out of a given cookie.

OpenFlow::lookup_controller: function

Function to lookup a controller instance by name.

OpenFlow::match_conn: function

Convert a conn_id record into an ofp_match record that can be used to create match objects for OpenFlow.

OpenFlow::register_controller: function

Function to register a controller instance.

OpenFlow::unregister_controller: function

Function to unregister a controller instance.

Detailed Interface

Events

OpenFlow::controller_activated
Type

event (name: string, controller: OpenFlow::Controller)

Event that is raised once a controller finishes initialization and is completely activated.

Parameters
  • name – Unique name of this controller instance.

  • controller – The controller that finished activation.

OpenFlow::flow_mod_failure
Type

event (name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string &default = "" &optional)

Reports an error while installing a flow Rule.

Parameters
  • name – The unique name of the OpenFlow controller from which this event originated.

  • match – The ofp_match record which describes the flow to match.

  • flow_mod – The openflow flow_mod record which describes the action to take.

  • msg – Message to describe the event.

OpenFlow::flow_mod_success
Type

event (name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string &default = "" &optional)

Event confirming successful modification of a flow rule.

Parameters
  • name – The unique name of the OpenFlow controller from which this event originated.

  • match – The ofp_match record which describes the flow to match.

  • flow_mod – The openflow flow_mod record which describes the action to take.

  • msg – An optional informational message by the plugin.

OpenFlow::flow_removed
Type

event (name: string, match: OpenFlow::ofp_match, cookie: count, priority: count, reason: count, duration_sec: count, idle_timeout: count, packet_count: count, byte_count: count)

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 in supports_flow_removed.

Parameters
  • 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.

  • cookie – The cookie that was specified when creating the flow.

  • priority – The priority that was specified when creating the flow.

  • reason – The reason for flow removal (OFPRR_*).

  • duration_sec – Duration of the flow in seconds.

  • packet_count – Packet count of the flow.

  • byte_count – Byte count of the flow.

Functions

OpenFlow::controller_init_done
Type

function (controller: OpenFlow::Controller) : void

Function to signal that a controller finished activation and is ready to use. Will throw the OpenFlow::controller_activated event.

OpenFlow::flow_clear
Type

function (controller: OpenFlow::Controller) : bool

Clear the current flow table of the controller.

Parameters

controller – The controller which should execute the flow modification.

Returns

F on error or if the plugin does not support the operation, T when the operation was queued.

OpenFlow::flow_mod
Type

function (controller: OpenFlow::Controller, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod) : bool

Global flow_mod function.

Parameters
  • controller – The controller which should execute the flow modification.

  • match – The ofp_match record which describes the flow to match.

  • flow_mod – The openflow flow_mod record which describes the action to take.

Returns

F on error or if the plugin does not support the operation, T when the operation was queued.

Type

function (cookie: count &default = 0 &optional) : count

Function to generate a new cookie using our group id.

Parameters

cookie – The openflow match cookie.

Returns

The cookie group id.

Type

function (cookie: count) : count

Function to get the group id out of a given cookie.

Parameters

cookie – The openflow match cookie.

Returns

The cookie group id.

Type

function (cookie: count) : count

Function to get the unique id out of a given cookie.

Parameters

cookie – The openflow match cookie.

Returns

The cookie unique id.

OpenFlow::lookup_controller
Type

function (name: string) : vector of OpenFlow::Controller

Function to lookup a controller instance by name.

Parameters

name – Unique name of the controller to look up.

Returns

One element vector with controller, if found. Empty vector otherwise.

OpenFlow::match_conn
Type

function (id: conn_id, reverse: bool &default = F &optional) : OpenFlow::ofp_match

Convert a conn_id record into an ofp_match record that can be used to create match objects for OpenFlow.

Parameters
  • id – The conn_id record that describes the record.

  • reverse – Reverse the sources and destinations when creating the match record (default F).

Returns

ofp_match object for the conn_id record.

OpenFlow::register_controller
Type

function (tpe: OpenFlow::Plugin, name: string, controller: OpenFlow::Controller) : void

Function to register a controller instance. This function is called automatically by the plugin _new functions.

Parameters
  • tpe – Type of this plugin.

  • name – Unique name of this controller instance.

  • controller – The controller to register.

OpenFlow::unregister_controller
Type

function (controller: OpenFlow::Controller) : void

Function to unregister a controller instance. This function should be called when a specific controller should no longer be used.

Parameters

controller – The controller to unregister.