Skip to content

Commit 1da0db2

Browse files
committed
multi: expose aggregate and individual stats APIs for 0x01
1 parent 6761813 commit 1da0db2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

async/Async_OpenFlow.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ module OpenFlow0x01 : sig
204204

205205
val send_pkt_out : t -> Client_id.t -> packetOut -> (unit, exn) Deferred.Result.t
206206
val barrier : t -> Client_id.t -> (unit, exn) Result.t Deferred.t
207-
val stats : t -> Client_id.t -> pattern -> (aggregateStats, exn) Deferred.Result.t
207+
val aggregate_stats : t -> Client_id.t -> pattern -> (aggregateStats, exn) Deferred.Result.t
208+
val individual_stats : t -> Client_id.t -> pattern -> (individualStats list, exn) Deferred.Result.t
208209
end
209210

210211
end

async/Async_OpenFlow0x01.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ module Controller = struct
111111
let c_id = client_id_of_switch_exn t sw_id in
112112
ChunkController.send_ignore_errors t.sub c_id (Message.marshal' msg)
113113

114-
let send_to_all t msg = ChunkController.send_to_all t.sub (Message.marshal' msg)
114+
let send_to_all t msg =
115+
ChunkController.send_to_all t.sub (Message.marshal' msg)
115116

116117
let client_addr_port t sw_id =
117118
let c_id = client_id_of_switch_exn t sw_id in
@@ -222,7 +223,7 @@ module Controller = struct
222223
| M.BarrierReply -> Result.Ok ()
223224
| _ -> assert false)
224225

225-
let stats t sw_id pattern =
226+
let aggregate_stats t sw_id pattern =
226227
let open OpenFlow0x01_Stats in
227228
let msg = AggregateRequest
228229
{ as_of_match = pattern
@@ -232,4 +233,15 @@ module Controller = struct
232233
send_txn_with t sw_id (M.StatsRequestMsg msg) (function
233234
| M.StatsReplyMsg (AggregateFlowRep r) -> Result.Ok r
234235
| _ -> assert false)
236+
237+
let individual_stats t sw_id pattern =
238+
let open OpenFlow0x01_Stats in
239+
let msg = IndividualRequest
240+
{ is_of_match = pattern
241+
; is_table_id = 0xff
242+
; is_out_port = None }
243+
in
244+
send_txn_with t sw_id (M.StatsRequestMsg msg) (function
245+
| M.StatsReplyMsg (IndividualFlowRep r) -> Result.Ok r
246+
| _ -> assert false)
235247
end

0 commit comments

Comments
 (0)