OpenFlow Controller In Elixir
Find a file
2018-04-17 15:01:37 +09:00
bin Merge pull request #3 from shun159/refactoring_enum_macro 2018-03-24 02:08:21 +09:00
config Refactored Enum macro 2018-03-23 21:28:37 +09:00
examples Add patch_panel example 2018-02-25 23:44:58 +09:00
images Add architecture image 2018-02-17 22:58:48 +09:00
lib tres/secure_channel: Fix a bug which interpolating error when logging 2018-04-17 15:01:37 +09:00
src secure_channel: Fix transact_db to contains original xid in the error_msg 2018-03-17 22:54:47 +09:00
test Fix to handler start_link fail 2018-02-08 22:39:11 +09:00
.formatter.exs Formatted 2018-01-30 22:47:31 +09:00
.gitignore Fix .gitignore 2017-11-27 00:43:10 +09:00
CHANGELOG.md tres/secure_channel: Fix a bug which interpolating error when logging 2018-04-17 15:01:37 +09:00
LICENSE Licensed 2018-02-18 00:32:37 +09:00
mix.exs Merge pull request #3 from shun159/refactoring_enum_macro 2018-03-24 02:08:21 +09:00
mix.lock Add dependencies 2017-11-26 19:11:24 +09:00
README.md Add patch_panel example 2018-02-25 23:45:51 +09:00

Tres - an Elixir OpenFlow development platform

Overview

Tres is a framework and set of helper libraries to develop OpenFlow controllers in Elixir.

How to build your own controller application

Installation

def deps do
  [
    {:tres, github: "shun159/tres", branch: "develop"}
  ]
end

callbacks

config :tres,
  callback_module: Tres.ExampleHandler,
  callback_args:   []

To use Tres.Controller with your code, set the handler callback_module to your callback module. This module must implement the Module.start_link/2 that returns on_start.

Set the callback_args to the terms you want pass to the start_link/2 callback function.

% cat lib/sample.ex
defmodule Sample do
  use GenServer
  use Tres.Controller

  def start_link(datapath_id, _start_args) do
    GenServer.start_link(__MODULE__, [datapath_id])
  end
  
  def init([datapath_id]) do
    # As an example create a flow to receive all packet_ins from port 1
    redirect_action = Output.new(:controller)
    apply_ins = ApplyActions.new(redirect_action)
    match = Match.new(in_port: 1)
    :ok = send_flow_mod_add(datapath_id, 
                            priority: 1,
                            match: match,
                            instructions: [apply_ins])
    {:ok, datapath_id}
  end
  
  def handle_info(%PacketIn{} = packet_in, datapath_id) do
    # print the packet_in message struct
    IO.inspect(packet_in)
    {:noreply, datapath_id}
  end
end

To run the controller

$ iex -S mix

Examples

  • learning-switch: Simple Layer2 switch
  • leader-example: Simple election based multiple controller using Ulf Wiger's Locks Leader
  • patch_panel: inteligent patch_panel example

License

Tres is released under the Apache license Version 2.0: