Skip to content

Commit 5987278

Browse files
committed
export t type for every module
use t in messages
1 parent 1c73bb8 commit 5987278

File tree

2 files changed

+48
-34
lines changed

2 files changed

+48
-34
lines changed

lib/OpenFlow0x04.ml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,22 @@ end
235235

236236
module PortState = struct
237237

238-
let state_to_int (state : portState) : int32 =
238+
type t = portState
239+
240+
let state_to_int (state : t) : int32 =
239241
Int32.logor (if state.link_down then (Int32.shift_left 1l 0) else 0l)
240242
(Int32.logor (if state.blocked then (Int32.shift_left 1l 1) else 0l)
241243
(if state.live then (Int32.shift_left 1l 2) else 0l))
242244

243-
let marshal (ps : portState) : int32 = state_to_int ps
245+
let marshal (ps : t) : int32 = state_to_int ps
244246

245-
let parse bits : portState =
247+
let parse bits : t =
246248
{ link_down = Bits.test_bit 0 bits;
247249
blocked = Bits.test_bit 1 bits;
248250
live = Bits.test_bit 2 bits
249251
}
250252

251-
let to_string (state : portState) =
253+
let to_string (state : t) =
252254
Format.sprintf "{ link_down = %B; blocked = %B; live = %B }"
253255
state.link_down
254256
state.blocked
@@ -372,8 +374,6 @@ cstruct ofp_table_feature_prop_header {
372374
uint16_t length
373375
} as big_endian
374376

375-
(* MISSING: ofp_ queues *)
376-
377377
cenum ofp_flow_mod_command {
378378
OFPFC_ADD = 0; (* New flow. *)
379379
OFPFC_MODIFY = 1; (* Modify all matching flows. *)
@@ -6715,14 +6715,14 @@ module Message = struct
67156715
| EchoReply of bytes
67166716
| FeaturesRequest
67176717
| FeaturesReply of SwitchFeatures.t
6718-
| FlowModMsg of flowMod
6718+
| FlowModMsg of FlowMod.t
67196719
| GroupModMsg of GroupMod.t
6720-
| PortModMsg of portMod
6721-
| MeterModMsg of meterMod
6722-
| PacketInMsg of packetIn
6723-
| FlowRemoved of flowRemoved
6724-
| PacketOutMsg of packetOut
6725-
| PortStatusMsg of portStatus
6720+
| PortModMsg of PortMod.t
6721+
| MeterModMsg of MeterMod.t
6722+
| PacketInMsg of PacketIn.t
6723+
| FlowRemoved of FlowRemoved.t
6724+
| PacketOutMsg of PacketOut.t
6725+
| PortStatusMsg of PortStatus.t
67266726
| MultipartReq of MultipartReq.t
67276727
| MultipartReply of MultipartReply.t
67286728
| BarrierRequest
@@ -6734,10 +6734,10 @@ module Message = struct
67346734
| GetConfigRequestMsg
67356735
| GetConfigReplyMsg of SwitchConfig.t
67366736
| SetConfigMsg of SwitchConfig.t
6737-
| TableModMsg of tableMod
6737+
| TableModMsg of TableMod.t
67386738
| GetAsyncRequest
6739-
| GetAsyncReply of asyncConfig
6740-
| SetAsync of asyncConfig
6739+
| GetAsyncReply of AsyncConfig.t
6740+
| SetAsync of AsyncConfig.t
67416741
| Error of Error.t
67426742

67436743

lib/OpenFlow0x04.mli

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ module Instruction : sig
230230
val sizeof : t -> int
231231

232232
val marshal : Cstruct.t -> t -> int
233+
233234
val parse : Cstruct.t -> t
234235

235236
val to_string : t -> string
@@ -243,6 +244,7 @@ module Instructions : sig
243244
val sizeof : t -> int
244245

245246
val marshal : Cstruct.t -> t -> int
247+
246248
val parse : Cstruct.t -> t
247249

248250
val to_string : t -> string
@@ -292,6 +294,8 @@ end
292294

293295
module PortState : sig
294296

297+
type t = portState
298+
295299
val marshal : portState -> int32
296300

297301
val parse : int32 -> portState
@@ -302,24 +306,29 @@ end
302306

303307
module PortDesc : sig
304308

305-
val sizeof : portDesc -> int
309+
type t = portDesc
310+
311+
val sizeof : t -> int
312+
313+
val marshal : Cstruct.t -> t -> int
306314

307-
val marshal : Cstruct.t -> portDesc -> int
315+
val parse : Cstruct.t -> t
308316

309-
val parse : Cstruct.t -> portDesc
317+
val to_string : t -> string
310318

311-
val to_string : portDesc -> string
312319
end
313320

314321
module PortStatus : sig
315322

316-
val sizeof : portStatus -> int
323+
type t = portStatus
317324

318-
val marshal : Cstruct.t -> portStatus -> int
325+
val sizeof : t -> int
319326

320-
val parse : Cstruct.t -> portStatus
327+
val marshal : Cstruct.t -> t -> int
321328

322-
val to_string : portStatus -> string
329+
val parse : Cstruct.t -> t
330+
331+
val to_string : t -> string
323332

324333
end
325334

@@ -342,9 +351,11 @@ module PacketOut : sig
342351
type t = packetOut
343352

344353
val sizeof : t -> int
354+
345355
val to_string : t -> string
346356

347357
val marshal : Cstruct.t -> t -> int
358+
348359
val parse : Cstruct.t -> t
349360

350361
end
@@ -709,8 +720,11 @@ module Error : sig
709720
}
710721

711722
val marshal : Cstruct.t -> t -> int
723+
712724
val parse : Cstruct.t -> t
725+
713726
val sizeof : t -> int
727+
714728
val to_string : t -> string
715729

716730
end
@@ -793,14 +807,14 @@ module Message : sig
793807
| EchoReply of bytes
794808
| FeaturesRequest
795809
| FeaturesReply of SwitchFeatures.t
796-
| FlowModMsg of flowMod
810+
| FlowModMsg of FlowMod.t
797811
| GroupModMsg of GroupMod.t
798-
| PortModMsg of portMod
799-
| MeterModMsg of meterMod
800-
| PacketInMsg of packetIn
801-
| FlowRemoved of flowRemoved
802-
| PacketOutMsg of packetOut
803-
| PortStatusMsg of portStatus
812+
| PortModMsg of PortMod.t
813+
| MeterModMsg of MeterMod.t
814+
| PacketInMsg of PacketIn.t
815+
| FlowRemoved of FlowRemoved.t
816+
| PacketOutMsg of PacketOut.t
817+
| PortStatusMsg of PortStatus.t
804818
| MultipartReq of MultipartReq.t
805819
| MultipartReply of MultipartReply.t
806820
| BarrierRequest
@@ -812,10 +826,10 @@ module Message : sig
812826
| GetConfigRequestMsg
813827
| GetConfigReplyMsg of SwitchConfig.t
814828
| SetConfigMsg of SwitchConfig.t
815-
| TableModMsg of tableMod
829+
| TableModMsg of TableMod.t
816830
| GetAsyncRequest
817-
| GetAsyncReply of asyncConfig
818-
| SetAsync of asyncConfig
831+
| GetAsyncReply of AsyncConfig.t
832+
| SetAsync of AsyncConfig.t
819833
| Error of Error.t
820834

821835
val sizeof : t -> int

0 commit comments

Comments
 (0)