Update README
This commit is contained in:
parent
fa2c0c5bbc
commit
2fb0be0348
1 changed files with 47 additions and 4 deletions
51
README.md
51
README.md
|
|
@ -1,10 +1,12 @@
|
|||
# Tres - a Elixir OpenFlow development platform
|
||||
# Tres - an Elixir OpenFlow development platform
|
||||
|
||||
## Overview
|
||||
|
||||
Tres is a framework and set of helper libraries to develop OpenFlow controllers in Elixir.
|
||||
|
||||
## Installation
|
||||
## How to build your own controller application
|
||||
|
||||
### Installation
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
|
|
@ -14,7 +16,7 @@ def deps do
|
|||
end
|
||||
```
|
||||
|
||||
## callbacks
|
||||
### callbacks
|
||||
|
||||
```elixir
|
||||
config :tres,
|
||||
|
|
@ -27,8 +29,49 @@ 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
|
||||
|
||||
```bash
|
||||
$ iex -S mix
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
- learning-switch: Simple Layer2 switch
|
||||
- leader-example: Simple Leader election based multiple controller
|
||||
- leader-example: Simple election based multiple controller using Ulf Wiger's Locks Leader
|
||||
|
||||
License
|
||||
-------
|
||||
Tres is released under the Apache license Version 2.0:
|
||||
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue