@@ -4300,11 +4300,11 @@ module TableFeature = struct
4300
4300
4301
4301
type t = tableFeatures
4302
4302
4303
- let sizeof (tf : tableFeatures ) =
4303
+ let sizeof (tf : t ) =
4304
4304
(* should be equal to tf.length *)
4305
4305
pad_to_64bits (sizeof_ofp_table_features + sum (map TableFeatureProp. sizeof tf.feature_prop))
4306
4306
4307
- let marshal (buf : Cstruct.t ) (tf : tableFeatures ) : int =
4307
+ let marshal (buf : Cstruct.t ) (tf : t ) : int =
4308
4308
set_ofp_table_features_length buf tf.length;
4309
4309
set_ofp_table_features_table_id buf tf.table_id;
4310
4310
set_ofp_table_features_pad (Cstruct. to_string (Cstruct. create 5 )) 0 buf;
@@ -4316,7 +4316,7 @@ module TableFeature = struct
4316
4316
sizeof_ofp_table_features + (
4317
4317
marshal_fields (Cstruct. shift buf sizeof_ofp_table_features) tf.feature_prop TableFeatureProp. marshal)
4318
4318
4319
- let parse (bits : Cstruct.t ) : tableFeatures*Cstruct. t =
4319
+ let parse (bits : Cstruct.t ) : t =
4320
4320
let length = get_ofp_table_features_length bits in
4321
4321
let tableId = get_ofp_table_features_table_id bits in
4322
4322
let name = Cstruct. to_string (get_ofp_table_features_name bits) in
@@ -4332,9 +4332,9 @@ module TableFeature = struct
4332
4332
metadata_write = metadataWrite;
4333
4333
config = config;
4334
4334
max_entries = maxEntries;
4335
- feature_prop = featureProp},( Cstruct. shift bits length)
4335
+ feature_prop = featureProp}
4336
4336
4337
- let to_string (tf : tableFeatures ) =
4337
+ let to_string (tf : t ) =
4338
4338
Format. sprintf " { table_id = %u; name = %s; metadata_match = %Lu; \
4339
4339
metadata_write = %Lu; config = %s; max_entries = %lu;
4340
4340
feature_prop = %s }"
@@ -4346,35 +4346,9 @@ module TableFeature = struct
4346
4346
tf.max_entries
4347
4347
(" [ " ^ (String. concat " ; " (map TableFeatureProp. to_string tf.feature_prop)) ^ " ]" )
4348
4348
4349
- end
4350
-
4351
- module TableFeatures = struct
4352
-
4353
- type t = tableFeatures list
4354
-
4355
- let sizeof (tfr : tableFeatures list ) =
4356
- sum (map TableFeature. sizeof tfr)
4357
-
4358
- let marshal (buf : Cstruct.t ) (tfr : tableFeatures list ) =
4359
- marshal_fields buf tfr TableFeature. marshal
4360
-
4361
-
4362
- let rec parse_fields (bits : Cstruct.t ) len cumul : tableFeatures list*Cstruct.t =
4363
- if len = cumul then [] ,bits
4364
- else (
4365
- let field,nextBits = TableFeature. parse bits in
4366
- let fields,bits3 = parse_fields nextBits len (cumul + (TableFeature. sizeof field)) in
4367
- (List. append [field] fields,bits3)
4368
- )
4369
-
4370
- let parse (bits : Cstruct.t ) : tableFeatures list =
4371
- let length = Cstruct. len bits in
4372
- let body,_ = parse_fields bits length 0 in
4373
- body
4374
-
4375
- let to_string tfr =
4376
- " [ " ^ (String. concat " \n " (map TableFeature. to_string tfr)) ^ " ]"
4377
-
4349
+ let length_func (buf : Cstruct.t ) : int option =
4350
+ if Cstruct. len buf < sizeof_ofp_table_features then None
4351
+ else Some (get_ofp_table_features_length buf)
4378
4352
end
4379
4353
4380
4354
module MultipartReq = struct
@@ -4425,7 +4399,7 @@ module MultipartReq = struct
4425
4399
| MeterStatsReq _ | MeterConfReq _ -> sizeof_ofp_meter_multipart_request
4426
4400
| TableFeatReq tfr -> (match tfr with
4427
4401
| None -> 0
4428
- | Some t -> TableFeatures . sizeof t)
4402
+ | Some t -> sum (map TableFeature . sizeof t) )
4429
4403
| ExperimentReq _ -> sizeof_ofp_experimenter_multipart_header)
4430
4404
4431
4405
let to_string (mpr : multipartRequest ) : string =
@@ -4450,7 +4424,7 @@ module MultipartReq = struct
4450
4424
| MeterConfReq m -> Format. sprintf " MeterConf Req %lu" m
4451
4425
| MeterFeatReq -> " MeterFeat Req"
4452
4426
| TableFeatReq t -> Format. sprintf " TableFeat Req %s" (match t with
4453
- | Some v -> TableFeatures. to_string v
4427
+ | Some v -> " [ " ^ ( String. concat " ; " (map TableFeature. to_string v)) ^ " ] "
4454
4428
| None -> " None" )
4455
4429
| ExperimentReq e -> Format. sprintf " Experimenter Req: id: %lu; type: %lu" e.exp_id e.exp_type)
4456
4430
@@ -4487,7 +4461,7 @@ module MultipartReq = struct
4487
4461
| TableFeatReq t ->
4488
4462
(match t with
4489
4463
| None -> 0
4490
- | Some v -> size + ( TableFeatures. marshal pay_buf v) )
4464
+ | Some v -> size + marshal_fields pay_buf v TableFeature. marshal )
4491
4465
| ExperimentReq _ -> size
4492
4466
4493
4467
let parse (bits : Cstruct.t ) : multipartRequest =
@@ -4520,7 +4494,7 @@ module MultipartReq = struct
4520
4494
| Some OFPMP_TABLE_FEATURES -> TableFeatReq (
4521
4495
if Cstruct. len bits < = sizeof_ofp_multipart_request then None
4522
4496
else Some (
4523
- TableFeatures. parse (Cstruct. shift bits sizeof_ofp_multipart_request)
4497
+ parse_fields (Cstruct. shift bits sizeof_ofp_multipart_request) TableFeature. parse TableFeature. length_func
4524
4498
))
4525
4499
| Some OFPMP_EXPERIMENTER -> ExperimentReq (
4526
4500
let exp_bits = Cstruct. shift bits sizeof_ofp_multipart_request in
@@ -5383,7 +5357,7 @@ module MultipartReply = struct
5383
5357
| FlowStatsReply fsr -> sum (map FlowStats. sizeof fsr)
5384
5358
| AggregateReply ag -> AggregateStats. sizeof ag
5385
5359
| TableReply tr -> sum (map TableStats. sizeof tr)
5386
- | TableFeaturesReply tf -> TableFeatures . sizeof tf
5360
+ | TableFeaturesReply tf -> sum (map TableFeature . sizeof tf)
5387
5361
| PortStatsReply psr -> sum (map PortStats. sizeof psr)
5388
5362
| QueueStatsReply qsr -> sum (map QueueStats. sizeof qsr)
5389
5363
| GroupStatsReply gs -> sum (map GroupStats. sizeof gs)
@@ -5400,7 +5374,7 @@ module MultipartReply = struct
5400
5374
| FlowStatsReply fsr -> Format. sprintf " Flow { %s }" (String. concat " ; " (map FlowStats. to_string fsr))
5401
5375
| AggregateReply ag -> Format. sprintf " Aggregate Flow %s" (AggregateStats. to_string ag)
5402
5376
| TableReply tr -> Format. sprintf " TableReply { %s }" (String. concat " ; " (map TableStats. to_string tr))
5403
- | TableFeaturesReply tf -> Format. sprintf " TableFeaturesReply %s " (TableFeatures. to_string tf)
5377
+ | TableFeaturesReply tf -> Format. sprintf " TableFeaturesReply { %s } " (String. concat " ; " (map TableFeature. to_string tf) )
5404
5378
| PortStatsReply psr -> Format. sprintf " PortStatsReply { %s }" (String. concat " ; " (map PortStats. to_string psr))
5405
5379
| QueueStatsReply qsr -> Format. sprintf " QueueStats { %s }" (String. concat " ; " (map QueueStats. to_string qsr))
5406
5380
| GroupStatsReply gs -> Format. sprintf " GroupStats { %s }" (String. concat " ; " (map GroupStats. to_string gs))
@@ -5434,7 +5408,7 @@ module MultipartReply = struct
5434
5408
marshal_fields ofp_body_bits tr TableStats. marshal
5435
5409
| TableFeaturesReply tf ->
5436
5410
set_ofp_multipart_reply_typ buf (ofp_multipart_types_to_int OFPMP_TABLE_FEATURES );
5437
- TableFeatures. marshal ofp_body_bits tf
5411
+ marshal_fields ofp_body_bits tf TableFeature. marshal
5438
5412
| PortStatsReply psr ->
5439
5413
set_ofp_multipart_reply_typ buf (ofp_multipart_types_to_int OFPMP_PORT_STATS );
5440
5414
marshal_fields ofp_body_bits psr PortStats. marshal
@@ -5475,7 +5449,7 @@ module MultipartReply = struct
5475
5449
| Some OFPMP_TABLE ->
5476
5450
TableReply (parse_fields ofp_body_bits TableStats. parse TableStats. length_func)
5477
5451
| Some OFPMP_TABLE_FEATURES ->
5478
- TableFeaturesReply (TableFeatures . parse ofp_body_bits )
5452
+ TableFeaturesReply (parse_fields ofp_body_bits TableFeature . parse TableFeature. length_func )
5479
5453
| Some OFPMP_PORT_STATS ->
5480
5454
PortStatsReply (parse_fields ofp_body_bits PortStats. parse PortStats. length_func)
5481
5455
| Some OFPMP_QUEUE ->
0 commit comments