Skip to content

Commit fadfbcb

Browse files
committed
table features properties should be a list
1 parent c4a8236 commit fadfbcb

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

lib/OpenFlow0x04.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,6 +3846,10 @@ module TableFeatureProp = struct
38463846

38473847
type t = tableFeatureProp
38483848

3849+
let length_func (buf : Cstruct.t) : int option =
3850+
if Cstruct.len buf < sizeof_ofp_table_feature_prop_header then None
3851+
else Some (pad_to_64bits (get_ofp_table_feature_prop_header_length buf))
3852+
38493853
let sizeof tfp : int =
38503854
let size = sizeof_ofp_table_feature_prop_header + (match tfp with
38513855
| TfpInstruction ins ->
@@ -4083,7 +4087,7 @@ module TableFeature = struct
40834087

40844088
let sizeof (tf : tableFeatures) =
40854089
(* should be equal to tf.length *)
4086-
pad_to_64bits (sizeof_ofp_table_features + (TableFeatureProp.sizeof tf.feature_prop))
4090+
pad_to_64bits (sizeof_ofp_table_features + sum (map TableFeatureProp.sizeof tf.feature_prop))
40874091

40884092
let marshal (buf : Cstruct.t) (tf : tableFeatures) : int =
40894093
set_ofp_table_features_length buf tf.length;
@@ -4095,7 +4099,7 @@ module TableFeature = struct
40954099
set_ofp_table_features_config buf (TableConfig.marshal tf.config);
40964100
set_ofp_table_features_max_entries buf tf.max_entries;
40974101
sizeof_ofp_table_features + (
4098-
TableFeatureProp.marshal (Cstruct.shift buf sizeof_ofp_table_features) tf.feature_prop)
4102+
marshal_fields (Cstruct.shift buf sizeof_ofp_table_features) tf.feature_prop TableFeatureProp.marshal)
40994103

41004104
let parse (bits : Cstruct.t) : tableFeatures*Cstruct.t =
41014105
let length = get_ofp_table_features_length bits in
@@ -4105,7 +4109,7 @@ module TableFeature = struct
41054109
let metadataWrite = get_ofp_table_features_metadata_write bits in
41064110
let config = TableConfig.parse (get_ofp_table_features_config bits) in
41074111
let maxEntries = get_ofp_table_features_max_entries bits in
4108-
let featureProp = TableFeatureProp.parse (Cstruct.sub bits sizeof_ofp_table_features (length-sizeof_ofp_table_features)) in
4112+
let featureProp = parse_fields (Cstruct.sub bits sizeof_ofp_table_features (length-sizeof_ofp_table_features)) TableFeatureProp.parse TableFeatureProp.length_func in
41094113
{ length = length;
41104114
table_id = tableId;
41114115
name = name;
@@ -4125,7 +4129,7 @@ module TableFeature = struct
41254129
tf.metadata_write
41264130
(TableConfig.to_string tf.config)
41274131
tf.max_entries
4128-
(TableFeatureProp.to_string tf.feature_prop)
4132+
("[ " ^ (String.concat "; " (map TableFeatureProp.to_string tf.feature_prop)) ^ " ]")
41294133

41304134
end
41314135

lib/OpenFlow0x04_Core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ type tableConfig = Deprecated
508508
type tableFeatures = {length : int16;table_id : tableId; name : string;
509509
metadata_match : int64; metadata_write : int64;
510510
config : tableConfig; max_entries: int32;
511-
feature_prop : tableFeatureProp}
511+
feature_prop : tableFeatureProp list}
512512

513513
type multipartType =
514514
| SwitchDescReq

lib/OpenFlow0x04_Core.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ type tableConfig = Deprecated
477477
type tableFeatures = {length : int16; table_id : tableId; name : string;
478478
metadata_match : int64; metadata_write : int64;
479479
config : tableConfig; max_entries: int32;
480-
feature_prop : tableFeatureProp}
480+
feature_prop : tableFeatureProp list}
481481

482482
type multipartType =
483483
| SwitchDescReq

quickcheck/Arbitrary_OpenFlow0x04.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ module MultipartReq = struct
801801

802802
let calc_length tfp =
803803
(* sizeof_ofp_table_feature = 64*)
804-
ret_gen (64+(TableFeatureProp.size_of tfp))
804+
ret_gen (64+sum (List.map TableFeatureProp.size_of tfp))
805805

806806
let arbitrary =
807807
arbitrary_uint8 >>= fun table_id ->
@@ -810,7 +810,7 @@ module MultipartReq = struct
810810
arbitrary_uint64 >>= fun metadata_write ->
811811
arbitrary_config >>= fun config ->
812812
arbitrary_uint32 >>= fun max_entries ->
813-
TableFeatureProp.arbitrary >>= fun feature_prop ->
813+
list1 TableFeatureProp.arbitrary >>= fun feature_prop ->
814814
calc_length feature_prop>>= fun length ->
815815
ret_gen {
816816
length;

0 commit comments

Comments
 (0)