@@ -3835,6 +3835,79 @@ module QueueRequest = struct
3835
3835
3836
3836
end
3837
3837
3838
+ module InstructionTyp = struct
3839
+
3840
+ let sizeof (ins : instructionTyp ) =
3841
+ match ins with
3842
+ | GotoTableTyp
3843
+ | ApplyActionsTyp
3844
+ | WriteActionsTyp
3845
+ | WriteMetadataTyp
3846
+ | ClearTyp
3847
+ | MeterTyp -> 4
3848
+ | ExperimenterTyp _ -> 8
3849
+
3850
+ let to_string (ins : instructionTyp ) =
3851
+ match ins with
3852
+ | GotoTableTyp -> " Go to Table"
3853
+ | ApplyActionsTyp -> " Apply Actions"
3854
+ | WriteActionsTyp -> " Write Actions"
3855
+ | WriteMetadataTyp -> " WriteMeta"
3856
+ | ClearTyp -> " Clear"
3857
+ | MeterTyp -> " Meter"
3858
+ | ExperimenterTyp e -> Format. sprintf " Experimenter = %lu" e
3859
+
3860
+ let marshal (buf : Cstruct.t ) (ins : instructionTyp ) : int =
3861
+ match ins with
3862
+ | GotoTableTyp ->
3863
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_GOTO_TABLE );
3864
+ set_ofp_instruction_len buf 4 ;
3865
+ sizeof_ofp_instruction
3866
+ | ApplyActionsTyp ->
3867
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_APPLY_ACTIONS );
3868
+ set_ofp_instruction_len buf 4 ;
3869
+ sizeof_ofp_instruction
3870
+ | WriteActionsTyp ->
3871
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_WRITE_ACTIONS );
3872
+ set_ofp_instruction_len buf 4 ;
3873
+ sizeof_ofp_instruction
3874
+ | WriteMetadataTyp ->
3875
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_WRITE_METADATA );
3876
+ set_ofp_instruction_len buf 4 ;
3877
+ sizeof_ofp_instruction
3878
+ | ClearTyp ->
3879
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_CLEAR_ACTIONS );
3880
+ set_ofp_instruction_len buf 4 ;
3881
+ sizeof_ofp_instruction
3882
+ | MeterTyp ->
3883
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_METER );
3884
+ set_ofp_instruction_len buf 4 ;
3885
+ sizeof_ofp_instruction
3886
+ | ExperimenterTyp e ->
3887
+ set_ofp_instruction_typ buf (ofp_instruction_type_to_int OFPIT_EXPERIMENTER );
3888
+ set_ofp_instruction_len buf 8 ;
3889
+ set_ofp_instruction_experimenter_experimenter buf e;
3890
+ sizeof_ofp_instruction_experimenter
3891
+
3892
+ let parse (bits : Cstruct.t ) : instructionTyp =
3893
+ let typ = int_to_ofp_instruction_type (get_ofp_instruction_typ bits) in
3894
+ match typ with
3895
+ | Some OFPIT_GOTO_TABLE -> GotoTableTyp
3896
+ | Some OFPIT_APPLY_ACTIONS -> ApplyActionsTyp
3897
+ | Some OFPIT_WRITE_ACTIONS -> WriteActionsTyp
3898
+ | Some OFPIT_WRITE_METADATA -> WriteMetadataTyp
3899
+ | Some OFPIT_CLEAR_ACTIONS -> ClearTyp
3900
+ | Some OFPIT_METER -> MeterTyp
3901
+ | Some OFPIT_EXPERIMENTER -> ExperimenterTyp (get_ofp_instruction_experimenter_experimenter bits)
3902
+ | None -> raise (Unparsable (sprintf " malfomed typ" ))
3903
+
3904
+ let length_func (buf : Cstruct.t ) : int option =
3905
+ if Cstruct. len buf < sizeof_ofp_instruction then None
3906
+ else Some (get_ofp_instruction_len buf)
3907
+
3908
+ end
3909
+
3910
+
3838
3911
module TableFeatureProp = struct
3839
3912
3840
3913
cstruct ofp_table_feature_prop_experimenter {
@@ -3853,9 +3926,9 @@ module TableFeatureProp = struct
3853
3926
let sizeof tfp : int =
3854
3927
let size = sizeof_ofp_table_feature_prop_header + (match tfp with
3855
3928
| TfpInstruction ins ->
3856
- Instructions . sizeof ins
3929
+ sum (map InstructionTyp . sizeof ins)
3857
3930
| TfpInstructionMiss ins ->
3858
- Instructions . sizeof ins
3931
+ sum (map InstructionTyp . sizeof ins)
3859
3932
| TfpNextTable t ->
3860
3933
List. length t
3861
3934
| TfpNextTableMiss t ->
@@ -3893,10 +3966,10 @@ module TableFeatureProp = struct
3893
3966
(match tfp with
3894
3967
| TfpInstruction ins ->
3895
3968
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_INSTRUCTIONS );
3896
- Instructions. marshal buf_payload ins
3969
+ marshal_fields buf_payload ins InstructionTyp. marshal
3897
3970
| TfpInstructionMiss ins ->
3898
3971
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_INSTRUCTIONS_MISS );
3899
- Instructions. marshal buf_payload ins
3972
+ marshal_fields buf_payload ins InstructionTyp. marshal
3900
3973
| TfpNextTable t ->
3901
3974
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_NEXT_TABLES );
3902
3975
let marsh (buf : Cstruct.t ) (id : uint8 ) : int =
@@ -3962,9 +4035,9 @@ module TableFeatureProp = struct
3962
4035
let tfpPayBits = Cstruct. sub bits sizeof_ofp_table_feature_prop_header (tfpLength - sizeof_ofp_table_feature_prop_header) in
3963
4036
match int_to_ofp_table_feature_prop_type tfpType with
3964
4037
| Some OFPTFPT_INSTRUCTIONS ->
3965
- TfpInstruction (Instructions . parse tfpPayBits )
4038
+ TfpInstruction (parse_fields tfpPayBits InstructionTyp . parse InstructionTyp. length_func )
3966
4039
| Some OFPTFPT_INSTRUCTIONS_MISS ->
3967
- TfpInstructionMiss (Instructions . parse tfpPayBits )
4040
+ TfpInstructionMiss (parse_fields tfpPayBits InstructionTyp . parse InstructionTyp. length_func )
3968
4041
| Some OFPTFPT_NEXT_TABLES ->
3969
4042
let ids,_ = parse_tables tfpPayBits (tfpLength - sizeof_ofp_table_feature_prop_header) in
3970
4043
TfpNextTable ids
@@ -4011,9 +4084,9 @@ module TableFeatureProp = struct
4011
4084
Format. sprintf " { type = %s; len:%u }"
4012
4085
(match tfp with
4013
4086
| TfpInstruction i ->
4014
- (Format. sprintf " Instructions %s " (Instructions. to_string i))
4087
+ (Format. sprintf " Instructions [ %s ] " (String. concat " ; " (map InstructionTyp. to_string i) ))
4015
4088
| TfpInstructionMiss i ->
4016
- (Format. sprintf " InstructionMiss %s " (Instructions. to_string i))
4089
+ (Format. sprintf " InstructionMiss [ %s ] " (String. concat " ; " (map InstructionTyp. to_string i) ))
4017
4090
| TfpNextTable n ->
4018
4091
(Format. sprintf " NextTable [ %s ]"
4019
4092
(String. concat " ; " (map string_of_int n)))
0 commit comments