@@ -2379,27 +2379,6 @@ module Action = struct
2379
2379
| SetQueue _ -> sizeof_ofp_action_set_queue
2380
2380
| Experimenter _ -> sizeof_ofp_action_experimenter
2381
2381
2382
- let to_type t : actionTyp =
2383
- match (int_to_ofp_action_type t) with
2384
- | Some OFPAT_OUTPUT -> Output
2385
- | Some OFPAT_COPY_TTL_OUT -> CopyTTLOut
2386
- | Some OFPAT_COPY_TTL_IN -> CopyTTLIn
2387
- | Some OFPAT_SET_MPLS_TTL -> SetMPLSTTL
2388
- | Some OFPAT_DEC_MPLS_TTL -> DecMPLSTTL
2389
- | Some OFPAT_PUSH_VLAN -> PushVLAN
2390
- | Some OFPAT_POP_VLAN -> PopVLAN
2391
- | Some OFPAT_PUSH_MPLS -> PushMPLS
2392
- | Some OFPAT_POP_MPLS -> PopMPLS
2393
- | Some OFPAT_SET_QUEUE -> SetQueue
2394
- | Some OFPAT_GROUP -> Group
2395
- | Some OFPAT_SET_NW_TTL -> SetNWTTL
2396
- | Some OFPAT_DEC_NW_TTL -> DecNWTTL
2397
- | Some OFPAT_SET_FIELD -> SetField
2398
- | Some OFPAT_PUSH_PBB -> PushPBB
2399
- | Some OFPAT_POP_PBB -> PopPBB
2400
- | Some OFPAT_EXPERIMENTER -> Experimenter
2401
- | None -> failwith " None type"
2402
-
2403
2382
let marshal (buf : Cstruct.t ) (act : action ) : int =
2404
2383
let size = sizeof act in
2405
2384
match act with
@@ -2528,27 +2507,27 @@ module Action = struct
2528
2507
size
2529
2508
2530
2509
let parse (bits : Cstruct.t ) : action =
2531
- match to_type (get_ofp_action_header_typ bits) with
2532
- | Output -> Output (PseudoPort. make (get_ofp_action_output_port bits)
2533
- (get_ofp_action_output_max_len bits))
2534
- | Group -> Group (get_ofp_action_group_group_id bits)
2535
- | PushVLAN -> PushVlan
2536
- | PopVLAN -> PopVlan
2537
- | PushMPLS -> PushMpls
2538
- | PopMPLS -> PopMpls
2539
- | SetField -> let field,_ = Oxm. parse (
2540
- Cstruct. shift bits 4 ) in (* TEST BECAUSE OF WRONG OFFSET?? *)
2541
- SetField (field )
2542
- | CopyTTLOut -> CopyTtlOut
2543
- | CopyTTLIn -> CopyTtlIn
2544
- | SetMPLSTTL -> SetMplsTtl (get_ofp_action_mpls_ttl_mpls_ttl bits)
2545
- | DecMPLSTTL -> DecMplsTtl
2546
- | SetQueue -> SetQueue (get_ofp_action_set_queue_queue_id bits)
2547
- | SetNWTTL -> SetNwTtl (get_ofp_action_nw_ttl_nw_ttl bits )
2548
- | DecNWTTL -> DecNwTtl
2549
- | PushPBB -> PushPbb
2550
- | PopPBB -> PopPbb
2551
- | Experimenter -> Experimenter (get_ofp_action_experimenter_experimenter bits)
2510
+ match int_to_ofp_action_type (get_ofp_action_header_typ bits) with
2511
+ | Some OFPAT_OUTPUT -> Output (PseudoPort. make (get_ofp_action_output_port bits) (get_ofp_action_output_max_len bits))
2512
+ | Some OFPAT_COPY_TTL_OUT -> CopyTtlOut
2513
+ | Some OFPAT_COPY_TTL_IN -> CopyTtlIn
2514
+ | Some OFPAT_SET_MPLS_TTL -> SetMplsTtl (get_ofp_action_mpls_ttl_mpls_ttl bits)
2515
+ | Some OFPAT_DEC_MPLS_TTL -> DecMplsTtl
2516
+ | Some OFPAT_PUSH_VLAN -> PushVlan
2517
+ | Some OFPAT_POP_VLAN -> PopVlan
2518
+ | Some OFPAT_PUSH_MPLS -> PushMpls
2519
+ | Some OFPAT_POP_MPLS -> PopMpls
2520
+ | Some OFPAT_SET_QUEUE -> SetQueue (get_ofp_action_set_queue_queue_id bits )
2521
+ | Some OFPAT_GROUP -> Group (get_ofp_action_group_group_id bits)
2522
+ | Some OFPAT_SET_NW_TTL -> SetNwTtl (get_ofp_action_nw_ttl_nw_ttl bits)
2523
+ | Some OFPAT_DEC_NW_TTL -> DecNwTtl
2524
+ | Some OFPAT_SET_FIELD -> let field,_ = Oxm. parse (
2525
+ Cstruct. shift bits 4 ) in
2526
+ SetField (field )
2527
+ | Some OFPAT_PUSH_PBB -> PushPbb
2528
+ | Some OFPAT_POP_PBB -> PopPbb
2529
+ | Some OFPAT_EXPERIMENTER -> Experimenter (get_ofp_action_experimenter_experimenter bits)
2530
+ | None -> failwith " None type "
2552
2531
2553
2532
let rec parse_fields (bits : Cstruct.t ) : sequence * Cstruct.t =
2554
2533
if Cstruct. len bits < sizeof_ofp_action_header then ([] , bits)
@@ -3907,6 +3886,146 @@ module InstructionTyp = struct
3907
3886
3908
3887
end
3909
3888
3889
+ module ActionTyp = struct
3890
+
3891
+ let sizeof (act : actionTyp ) =
3892
+ match act with
3893
+ | OutputAct
3894
+ | CopyTTLOut
3895
+ | CopyTTLIn
3896
+ | SetMPLSTTL
3897
+ | DecMPLSTTL
3898
+ | PushVLAN
3899
+ | PopVLAN
3900
+ | PushMPLS
3901
+ | PopMPLS
3902
+ | SetQueueAct
3903
+ | GroupAct
3904
+ | SetNWTTL
3905
+ | DecNWTTL
3906
+ | SetFieldAct
3907
+ | PushPBB
3908
+ | PopPBB -> 4
3909
+ | ExperimenterAct _ -> 8
3910
+
3911
+ let to_string (act : actionTyp ) =
3912
+ match act with
3913
+ | OutputAct -> " Output"
3914
+ | CopyTTLOut -> " CopyTTLOut"
3915
+ | CopyTTLIn -> " CopyTTLIn"
3916
+ | SetMPLSTTL -> " SetMplsTtl"
3917
+ | DecMPLSTTL -> " DecMplsTtl"
3918
+ | PushVLAN -> " PushVlan"
3919
+ | PopVLAN -> " PopVlan"
3920
+ | PushMPLS -> " PushMpls"
3921
+ | PopMPLS -> " PopMpls"
3922
+ | SetQueueAct -> " SetQueue"
3923
+ | GroupAct -> " Group"
3924
+ | SetNWTTL -> " SetNwTtl"
3925
+ | DecNWTTL -> " DecMplsTtl"
3926
+ | SetFieldAct -> " SetField"
3927
+ | PushPBB -> " PushPBB"
3928
+ | PopPBB -> " PopPBB"
3929
+ | ExperimenterAct e -> Format. sprintf " Experimenter = %lu" e
3930
+
3931
+ let marshal (buf : Cstruct.t ) (act : actionTyp ) : int =
3932
+ match act with
3933
+ | OutputAct ->
3934
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_OUTPUT );
3935
+ set_ofp_action_header_len buf 4 ;
3936
+ 4 (* ofp_action_header without the padding *)
3937
+ | CopyTTLOut ->
3938
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_COPY_TTL_OUT );
3939
+ set_ofp_action_header_len buf 4 ;
3940
+ 4
3941
+ | CopyTTLIn ->
3942
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_COPY_TTL_IN );
3943
+ set_ofp_action_header_len buf 4 ;
3944
+ 4
3945
+ | SetMPLSTTL ->
3946
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_SET_MPLS_TTL );
3947
+ set_ofp_action_header_len buf 4 ;
3948
+ 4
3949
+ | DecMPLSTTL ->
3950
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_DEC_MPLS_TTL );
3951
+ set_ofp_action_header_len buf 4 ;
3952
+ 4
3953
+ | PushVLAN ->
3954
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_PUSH_VLAN );
3955
+ set_ofp_action_header_len buf 4 ;
3956
+ 4
3957
+ | PopVLAN ->
3958
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_POP_VLAN );
3959
+ set_ofp_action_header_len buf 4 ;
3960
+ 4
3961
+ | PushMPLS ->
3962
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_PUSH_MPLS );
3963
+ set_ofp_action_header_len buf 4 ;
3964
+ 4
3965
+ | PopMPLS ->
3966
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_POP_MPLS );
3967
+ set_ofp_action_header_len buf 4 ;
3968
+ 4
3969
+ | SetQueueAct ->
3970
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_SET_QUEUE );
3971
+ set_ofp_action_header_len buf 4 ;
3972
+ 4
3973
+ | GroupAct ->
3974
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_GROUP );
3975
+ set_ofp_action_header_len buf 4 ;
3976
+ 4
3977
+ | SetNWTTL ->
3978
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_SET_NW_TTL );
3979
+ set_ofp_action_header_len buf 4 ;
3980
+ 4
3981
+ | DecNWTTL ->
3982
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_DEC_NW_TTL );
3983
+ set_ofp_action_header_len buf 4 ;
3984
+ 4
3985
+ | SetFieldAct ->
3986
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_SET_FIELD );
3987
+ set_ofp_action_header_len buf 4 ;
3988
+ 4
3989
+ | PushPBB ->
3990
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_PUSH_PBB );
3991
+ set_ofp_action_header_len buf 4 ;
3992
+ 4
3993
+ | PopPBB ->
3994
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_POP_PBB );
3995
+ set_ofp_action_header_len buf 4 ;
3996
+ 4
3997
+ | ExperimenterAct e ->
3998
+ set_ofp_action_header_typ buf (ofp_action_type_to_int OFPAT_EXPERIMENTER );
3999
+ set_ofp_action_header_len buf 8 ;
4000
+ set_ofp_action_experimenter_experimenter buf e;
4001
+ sizeof_ofp_action_experimenter
4002
+
4003
+ let parse (bits : Cstruct.t ) : actionTyp =
4004
+ match (int_to_ofp_action_type (get_ofp_action_header_typ bits)) with
4005
+ | Some OFPAT_OUTPUT -> OutputAct
4006
+ | Some OFPAT_COPY_TTL_OUT -> CopyTTLOut
4007
+ | Some OFPAT_COPY_TTL_IN -> CopyTTLIn
4008
+ | Some OFPAT_SET_MPLS_TTL -> SetMPLSTTL
4009
+ | Some OFPAT_DEC_MPLS_TTL -> DecMPLSTTL
4010
+ | Some OFPAT_PUSH_VLAN -> PushVLAN
4011
+ | Some OFPAT_POP_VLAN -> PopVLAN
4012
+ | Some OFPAT_PUSH_MPLS -> PushMPLS
4013
+ | Some OFPAT_POP_MPLS -> PopMPLS
4014
+ | Some OFPAT_SET_QUEUE -> SetQueueAct
4015
+ | Some OFPAT_GROUP -> GroupAct
4016
+ | Some OFPAT_SET_NW_TTL -> SetNWTTL
4017
+ | Some OFPAT_DEC_NW_TTL -> DecNWTTL
4018
+ | Some OFPAT_SET_FIELD -> SetFieldAct
4019
+ | Some OFPAT_PUSH_PBB -> PushPBB
4020
+ | Some OFPAT_POP_PBB -> PopPBB
4021
+ | Some OFPAT_EXPERIMENTER -> ExperimenterAct (get_ofp_action_experimenter_experimenter bits)
4022
+ | None -> failwith " None type"
4023
+
4024
+ let length_func (buf : Cstruct.t ) : int option =
4025
+ if Cstruct. len buf < 4 (* ofp_action_header without padding *) then None
4026
+ else Some (get_ofp_action_header_len buf)
4027
+
4028
+ end
3910
4029
3911
4030
module TableFeatureProp = struct
3912
4031
@@ -3934,13 +4053,13 @@ module TableFeatureProp = struct
3934
4053
| TfpNextTableMiss t ->
3935
4054
List. length t
3936
4055
| TfpWriteAction act ->
3937
- sum (map Action . sizeof act)
4056
+ sum (map ActionTyp . sizeof act)
3938
4057
| TfpWriteActionMiss act ->
3939
- sum (map Action . sizeof act)
4058
+ sum (map ActionTyp . sizeof act)
3940
4059
| TfpApplyAction act ->
3941
- sum (map Action . sizeof act)
4060
+ sum (map ActionTyp . sizeof act)
3942
4061
| TfpApplyActionMiss act ->
3943
- sum (map Action . sizeof act)
4062
+ sum (map ActionTyp . sizeof act)
3944
4063
| TfpMatch ox ->
3945
4064
Oxm. sizeof_header ox
3946
4065
| TfpWildcard ox ->
@@ -3984,16 +4103,16 @@ module TableFeatureProp = struct
3984
4103
marshal_fields buf_payload t marsh
3985
4104
| TfpWriteAction act ->
3986
4105
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_WRITE_ACTIONS );
3987
- marshal_fields buf_payload act Action . marshal
4106
+ marshal_fields buf_payload act ActionTyp . marshal
3988
4107
| TfpWriteActionMiss act ->
3989
4108
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_WRITE_ACTIONS_MISS );
3990
- marshal_fields buf_payload act Action . marshal
4109
+ marshal_fields buf_payload act ActionTyp . marshal
3991
4110
| TfpApplyAction act ->
3992
4111
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_APPLY_ACTIONS );
3993
- marshal_fields buf_payload act Action . marshal
4112
+ marshal_fields buf_payload act ActionTyp . marshal
3994
4113
| TfpApplyActionMiss act ->
3995
4114
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_APPLY_ACTIONS_MISS );
3996
- marshal_fields buf_payload act Action . marshal
4115
+ marshal_fields buf_payload act ActionTyp . marshal
3997
4116
| TfpMatch ox ->
3998
4117
set_ofp_table_feature_prop_header_typ buf (ofp_table_feature_prop_type_to_int OFPTFPT_MATCH );
3999
4118
marshal_fields buf_payload ox Oxm. marshal_header
@@ -4045,13 +4164,13 @@ module TableFeatureProp = struct
4045
4164
let ids,_ = parse_tables tfpPayBits (tfpLength - sizeof_ofp_table_feature_prop_header) in
4046
4165
TfpNextTableMiss ids
4047
4166
| Some OFPTFPT_WRITE_ACTIONS ->
4048
- TfpWriteAction (Action. parse_sequence tfpPayBits)
4167
+ TfpWriteAction (parse_fields tfpPayBits ActionTyp. parse ActionTyp. length_func )
4049
4168
| Some OFPTFPT_WRITE_ACTIONS_MISS ->
4050
- TfpWriteActionMiss (Action. parse_sequence tfpPayBits)
4169
+ TfpWriteActionMiss (parse_fields tfpPayBits ActionTyp. parse ActionTyp. length_func )
4051
4170
| Some OFPTFPT_APPLY_ACTIONS ->
4052
- TfpApplyAction (Action. parse_sequence tfpPayBits)
4171
+ TfpApplyAction (parse_fields tfpPayBits ActionTyp. parse ActionTyp. length_func )
4053
4172
| Some OFPTFPT_APPLY_ACTIONS_MISS ->
4054
- TfpApplyActionMiss (Action. parse_sequence tfpPayBits)
4173
+ TfpApplyActionMiss (parse_fields tfpPayBits ActionTyp. parse ActionTyp. length_func )
4055
4174
| Some OFPTFPT_MATCH ->
4056
4175
let fields,_ = Oxm. parse_headers tfpPayBits in
4057
4176
TfpMatch fields
@@ -4095,16 +4214,16 @@ module TableFeatureProp = struct
4095
4214
(String. concat " ; " (map string_of_int n)))
4096
4215
| TfpWriteAction a ->
4097
4216
(Format. sprintf " WriteAction [ %s ]"
4098
- (String. concat " ; " (map Action . to_string a)))
4217
+ (String. concat " ; " (map ActionTyp . to_string a)))
4099
4218
| TfpWriteActionMiss a ->
4100
4219
(Format. sprintf " WriteActionMiss [ %s ]"
4101
- (String. concat " ; " (map Action . to_string a)))
4220
+ (String. concat " ; " (map ActionTyp . to_string a)))
4102
4221
| TfpApplyAction a ->
4103
4222
(Format. sprintf " ApplyActions [ %s ]"
4104
- (String. concat " ; " (map Action . to_string a)))
4223
+ (String. concat " ; " (map ActionTyp . to_string a)))
4105
4224
| TfpApplyActionMiss a ->
4106
4225
(Format. sprintf " ApplyActionsMiss [ %s ]"
4107
- (String. concat " ; " (map Action . to_string a)))
4226
+ (String. concat " ; " (map ActionTyp . to_string a)))
4108
4227
| TfpMatch s ->
4109
4228
(Format. sprintf " Match [ %s ]"
4110
4229
(String. concat " ; " (map Oxm. field_name s)))
0 commit comments