Skip to content

Commit

Permalink
Porting Ox to new version of Frenetic
Browse files Browse the repository at this point in the history
  • Loading branch information
jnfoster committed Jun 24, 2016
1 parent ae8e3ce commit 08790ec
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 70 deletions.
5 changes: 2 additions & 3 deletions INSTALL.txt
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: e4ae9e88b0cee5cb9aef1898181ef22f) *)
(* DO NOT EDIT (digest: 35200b916d368e4d386e9e1449f146fd) *)

This is the INSTALL file for the ox distribution.

Expand All @@ -15,8 +15,7 @@ In order to compile this package, you will need:
* findlib
* core
* async
* packet
* openflow
* frenetic

Installing
==========
Expand Down
5 changes: 2 additions & 3 deletions _oasis
Expand Up @@ -17,9 +17,8 @@ Library ox
BuildDepends:
core,
async,
packet,
openflow,
openflow.async,
frenetic,
frenetic.async,
threads
InternalModules:
OxShared
Expand Down
7 changes: 3 additions & 4 deletions _tags
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: e34aa0ffc9f1beb9d8a2c71f6dc4ec01)
# DO NOT EDIT (digest: be6f5fd087e4c9140e58480195f1c16d)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand All @@ -18,8 +18,7 @@ true: annot, bin_annot
"lib/ox.cmxs": use_ox
<lib/*.ml{,i,y}>: pkg_async
<lib/*.ml{,i,y}>: pkg_core
<lib/*.ml{,i,y}>: pkg_openflow
<lib/*.ml{,i,y}>: pkg_openflow.async
<lib/*.ml{,i,y}>: pkg_packet
<lib/*.ml{,i,y}>: pkg_frenetic
<lib/*.ml{,i,y}>: pkg_frenetic.async
<lib/*.ml{,i,y}>: pkg_threads
# OASIS_STOP
4 changes: 2 additions & 2 deletions lib/META
@@ -1,8 +1,8 @@
# OASIS_START
# DO NOT EDIT (digest: 9d36368bbed2bf00c465d0675c615221)
# DO NOT EDIT (digest: e17cb1c19adcec895aed2b17343b25db)
version = "1.1.1"
description = "A platform for writing OpenFlow controllers"
requires = "core async packet openflow openflow.async threads"
requires = "core async frenetic frenetic.async threads"
archive(byte) = "ox.cma"
archive(byte, plugin) = "ox.cma"
archive(native) = "ox.cmxa"
Expand Down
4 changes: 2 additions & 2 deletions lib/OxPlatform.ml
@@ -1,8 +1,8 @@
open Async.Std

open Printf
open Packet
open OpenFlow0x01
open Frenetic_Packet
open Frenetic_OpenFlow0x01
open Message
open OxShared

Expand Down
2 changes: 1 addition & 1 deletion lib/OxPlatform.mli
@@ -1,5 +1,5 @@
(** Functions that an Ox controller can use to send OpenFlow messages. *)
open OpenFlow0x01
open Frenetic_OpenFlow0x01

(** [send_packet_out sw xid pkt] sends a [packetOut] message with
transaction ID [xid] to switch [sw]. *)
Expand Down
10 changes: 5 additions & 5 deletions lib/OxShared.ml
@@ -1,8 +1,8 @@
open Core.Std
open Async.Std

open Packet
open OpenFlow0x01
open Frenetic_Packet
open Frenetic_OpenFlow0x01

type to_sw = switchId * xid * Message.t

Expand All @@ -19,6 +19,6 @@ let munge_exns thk =
| Ok () ->
()
| Error exn ->
Printf.eprintf
"unhandled exception raised by a callback\n%s"
(Exn.to_string exn)
eprintf
"unhandled exception raised by a callback\n%s"
(Exn.to_string exn)
30 changes: 16 additions & 14 deletions lib/OxStart.ml
@@ -1,13 +1,13 @@
open Printf
open Packet
open OpenFlow0x01
open Frenetic_Packet
open Frenetic_OpenFlow0x01
open OxShared
open OpenFlow_Header
open Frenetic_OpenFlow_Header

module Controller = Async_OpenFlow0x01_Controller
module Controller = Frenetic_OpenFlow0x01_Controller

module type OXMODULE = sig
val switch_connected : switchId -> OpenFlow0x01.SwitchFeatures.t -> unit
val switch_connected : switchId -> SwitchFeatures.t -> unit
val switch_disconnected : switchId -> unit
val packet_in : switchId -> xid -> packetIn -> unit
val barrier_reply : switchId -> xid -> unit
Expand Down Expand Up @@ -37,7 +37,7 @@ module Make (Handlers:OXMODULE) = struct
open Core.Std

let send_pkt_out ((sw, xid, msg) : switchId * xid * Message.t) : unit Deferred.t =
match Controller.send sw xid msg with
Controller.send sw xid msg >>= function
| `Ok ->
return ()
| `Eof ->
Expand All @@ -48,14 +48,16 @@ module Make (Handlers:OXMODULE) = struct
match event with
| `Connect (sw, feats) ->
begin
match
Controller.send sw 0l (FlowModMsg delete_all_flows),
Controller.send sw 1l BarrierRequest
with
| `Ok, `Ok ->
return (Handlers.switch_connected sw feats)
| _ ->
return ()
Controller.send sw 0l (FlowModMsg delete_all_flows) >>= function
| `Ok ->
begin Controller.send sw 1l BarrierRequest >>= function
| `Ok ->
return (Handlers.switch_connected sw feats)
| `Eof ->
return ()
end
| `Eof ->
return ()
end
| `Message (sw, hdr, msg) ->
let xid = hdr.xid in
Expand Down
6 changes: 3 additions & 3 deletions lib/OxStart.mli
@@ -1,13 +1,13 @@
(** Launches an Ox application. *)
open OpenFlow0x01
open Frenetic_OpenFlow0x01

(** Provides default implementations for some advanced event handlers,
reducing clutter in simple controllers.
These event handlers simply ignore the messages they receive. *)
module DefaultTutorialHandlers : sig

val switch_connected : switchId -> OpenFlow0x01.SwitchFeatures.t -> unit
val switch_connected : switchId -> SwitchFeatures.t -> unit
val switch_disconnected : switchId -> unit
val barrier_reply : switchId -> xid -> unit
val stats_reply : switchId -> xid -> reply -> unit
Expand All @@ -22,7 +22,7 @@ module type OXMODULE = sig

(** [switch_connected sw] is a callback invoked with [sw] when a switch with
identifer [sw] connects to the controller. *)
val switch_connected : switchId -> OpenFlow0x01.SwitchFeatures.t -> unit
val switch_connected : switchId -> SwitchFeatures.t -> unit

(** [switch_disconnected sw] is a callback invoked with [sw] when a switch
with identifer [sw] disconnects from the controller. *)
Expand Down

0 comments on commit 08790ec

Please sign in to comment.