ofp-msgs: Split OFPRAW_OFPST_AGGREGATE_REQUEST
authorSimon Horman <horms@verge.net.au>
Tue, 21 Aug 2012 04:55:35 +0000 (13:55 +0900)
committerBen Pfaff <blp@nicira.com>
Wed, 29 Aug 2012 16:56:35 +0000 (09:56 -0700)
Split OFPRAW_OFPST_AGGREGATE_REQUEST into OpenFlow 1.0 and 1.1+
versions.

This should be sufficient to allow adding encoding and decoding of
Open Flow 1.1 and 1.2 Aggregate Stats Request messages.

Encoding and decoding of Open Flow 1.1 and 1.2 Aggregate Stats Response
messages works using the existing code without modification.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-msgs.h
lib/ofp-util.c
tests/ofp-print.at

index b8bc122..7ef7c5a 100644 (file)
@@ -194,11 +194,13 @@ enum ofpraw {
     OFPRAW_NXST_FLOW_REPLY,
 
     /* OFPST 1.0 (2): struct ofp10_flow_stats_request. */
-    OFPRAW_OFPST_AGGREGATE_REQUEST,
+    OFPRAW_OFPST10_AGGREGATE_REQUEST,
+    /* OFPST 1.1+ (2): struct ofp11_flow_stats_request, uint8_t[8][]. */
+    OFPRAW_OFPST11_AGGREGATE_REQUEST,
     /* NXST 1.0 (1): struct nx_flow_stats_request, uint8_t[8][]. */
     OFPRAW_NXST_AGGREGATE_REQUEST,
 
-    /* OFPST 1.0 (2): struct ofp_aggregate_stats_reply. */
+    /* OFPST 1.0+ (2): struct ofp_aggregate_stats_reply. */
     OFPRAW_OFPST_AGGREGATE_REPLY,
     /* NXST 1.0 (1): struct ofp_aggregate_stats_reply. */
     OFPRAW_NXST_AGGREGATE_REPLY,
@@ -371,7 +373,8 @@ enum ofptype {
     OFPTYPE_FLOW_STATS_REPLY,        /* OFPRAW_OFPST10_FLOW_REPLY.
                                       * OFPRAW_OFPST11_FLOW_REPLY.
                                       * OFPRAW_NXST_FLOW_REPLY. */
-    OFPTYPE_AGGREGATE_STATS_REQUEST, /* OFPRAW_OFPST_AGGREGATE_REQUEST.
+    OFPTYPE_AGGREGATE_STATS_REQUEST, /* OFPRAW_OFPST10_AGGREGATE_REQUEST.
+                                      * OFPRAW_OFPST11_AGGREGATE_REQUEST.
                                       * OFPRAW_NXST_AGGREGATE_REQUEST. */
     OFPTYPE_AGGREGATE_STATS_REPLY,   /* OFPRAW_OFPST_AGGREGATE_REPLY.
                                       * OFPRAW_NXST_AGGREGATE_REPLY. */
index a2e9501..ce9bb74 100644 (file)
@@ -1476,12 +1476,15 @@ ofputil_decode_flow_stats_request(struct ofputil_flow_stats_request *fsr,
     case OFPRAW_OFPST10_FLOW_REQUEST:
         return ofputil_decode_ofpst10_flow_request(fsr, b.data, false);
 
-    case OFPRAW_OFPST_AGGREGATE_REQUEST:
+    case OFPRAW_OFPST10_AGGREGATE_REQUEST:
         return ofputil_decode_ofpst10_flow_request(fsr, b.data, true);
 
     case OFPRAW_OFPST11_FLOW_REQUEST:
         return ofputil_decode_ofpst11_flow_request(fsr, &b, false);
 
+    case OFPRAW_OFPST11_AGGREGATE_REQUEST:
+        return ofputil_decode_ofpst11_flow_request(fsr, &b, true);
+
     case OFPRAW_NXST_FLOW_REQUEST:
         return ofputil_decode_nxst_flow_request(fsr, &b, false);
 
@@ -1509,7 +1512,7 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
         struct ofp11_flow_stats_request *ofsr;
 
         raw = (fsr->aggregate
-               ? OFPRAW_OFPST_AGGREGATE_REQUEST
+               ? OFPRAW_OFPST11_AGGREGATE_REQUEST
                : OFPRAW_OFPST11_FLOW_REQUEST);
         msg = ofpraw_alloc(raw, OFP12_VERSION, NXM_TYPICAL_LEN);
         ofsr = ofpbuf_put_zeros(msg, sizeof *ofsr);
@@ -1527,7 +1530,7 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
         struct ofp10_flow_stats_request *ofsr;
 
         raw = (fsr->aggregate
-               ? OFPRAW_OFPST_AGGREGATE_REQUEST
+               ? OFPRAW_OFPST10_AGGREGATE_REQUEST
                : OFPRAW_OFPST10_FLOW_REQUEST);
         msg = ofpraw_alloc(raw, OFP10_VERSION, 0);
         ofsr = ofpbuf_put_zeros(msg, sizeof *ofsr);
@@ -1863,7 +1866,7 @@ ofputil_encode_aggregate_stats_reply(
     enum ofpraw raw;
 
     ofpraw_decode(&raw, request);
-    if (raw == OFPRAW_OFPST_AGGREGATE_REQUEST) {
+    if (raw == OFPRAW_OFPST10_AGGREGATE_REQUEST) {
         packet_count = unknown_to_zero(stats->packet_count);
         byte_count = unknown_to_zero(stats->byte_count);
     } else {
index e01419f..aca502a 100644 (file)
@@ -748,7 +748,7 @@ OFPST_FLOW reply (OF1.2) (xid=0x2):
 ])
 AT_CLEANUP
 
-AT_SETUP([OFPST_AGGREGATE request])
+AT_SETUP([OFPST_AGGREGATE request - OF1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 10 00 38 00 00 00 04 00 02 00 00 00 38 20 ff \
@@ -760,7 +760,19 @@ OFPST_AGGREGATE request (xid=0x4): @&t@
 ])
 AT_CLEANUP
 
-AT_SETUP([OFPST_AGGREGATE reply])
+AT_SETUP([OFPST_AGGREGATE request - OF1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 12 00 38 00 00 00 02 00 02 00 00 00 00 00 00 \
+ff 00 00 00 ff ff ff ff ff ff ff ff 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 01 00 04 00 00 00 00 \
+"], [0], [dnl
+OFPST_AGGREGATE request (OF1.2) (xid=0x2): @&t@
+])
+AT_CLEANUP
+
+AT_SETUP([OFPST_AGGREGATE reply - OF1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 11 00 24 00 00 00 04 00 02 00 00 00 00 00 00 \
@@ -771,6 +783,17 @@ OFPST_AGGREGATE reply (xid=0x4): packet_count=386 byte_count=37752 flow_count=4
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPST_AGGREGATE reply - OF1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 13 00 28 00 00 00 02 00 02 00 00 00 00 00 00 \
+00 00 00 00 00 00 00 79 00 00 00 00 00 00 4b 4f \
+00 00 00 03 00 00 00 00 \
+"], [0], [dnl
+OFPST_AGGREGATE reply (OF1.2) (xid=0x2): packet_count=121 byte_count=19279 flow_count=3
+])
+AT_CLEANUP
+
 AT_SETUP([OFPST_TABLE request])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "0110000c0000000100030000"], [0], [dnl