On Wed, Feb 20, 2013 at 12:51:02PM +0900, KONDOH Tasuku wrote:
> - add action's size to offset of bucket.
> 
> Signed-off-by: KONDOH Tasuku <[email protected]>

The ofproto_v1_2_parser portion appears to be compliant
with the Open Flow 1.2 specification.

Reviewed-by: Simon Horman <[email protected]>

> ---
>  ryu/ofproto/ofproto_v1_2_parser.py        |    7 ++---
>  ryu/tests/unit/ofproto/test_parser_v12.py |   40 
> +++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+), 3 deletions(-)
> 
> diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
> b/ryu/ofproto/ofproto_v1_2_parser.py
> index 989a494..21c36a3 100644
> --- a/ryu/ofproto/ofproto_v1_2_parser.py
> +++ b/ryu/ofproto/ofproto_v1_2_parser.py
> @@ -1220,9 +1220,10 @@ class OFPGroupDescStats(object):
>          offset += ofproto_v1_2.OFP_GROUP_DESC_STATS_SIZE
>          buckets = []
>          while bucket_len > 0:
> -            buckets.append(OFPBucket.parser(buf, offset))
> -            offset += ofproto_v1_2.OFP_BUCKET_SIZE
> -            bucket_len -= ofproto_v1_2.OFP_BUCKET_SIZE
> +            bucket = OFPBucket.parser(buf, offset)
> +            buckets.append(bucket)
> +            offset += bucket.len
> +            bucket_len -= bucket.len
>  
>          return cls(length, type_, group_id, buckets)
>  
> diff --git a/ryu/tests/unit/ofproto/test_parser_v12.py 
> b/ryu/tests/unit/ofproto/test_parser_v12.py
> index 75e2208..ee69d22 100644
> --- a/ryu/tests/unit/ofproto/test_parser_v12.py
> +++ b/ryu/tests/unit/ofproto/test_parser_v12.py
> @@ -2993,6 +2993,46 @@ class TestOFPGroupDescStats(unittest.TestCase):
>          eq_(self.port, res.buckets[0].actions[0].port)
>          eq_(self.max_len, res.buckets[0].actions[0].max_len)
>  
> +    def test_parser_loop(self):
> +        bucket_cnt = 2
> +        # OFP_GROUP_DESC_STATS_PACK_STR = '!HBxI'
> +        length = ofproto_v1_2.OFP_GROUP_DESC_STATS_SIZE \
> +            + (ofproto_v1_2.OFP_BUCKET_SIZE
> +            + ofproto_v1_2.OFP_ACTION_OUTPUT_SIZE) * bucket_cnt
> +        type_ = ofproto_v1_2.OFPGT_ALL
> +        group_id = 6606
> +
> +        fmt = ofproto_v1_2.OFP_GROUP_DESC_STATS_PACK_STR
> +        buf = pack(fmt, length, type_, group_id)
> +
> +        buckets = []
> +        for b in range(bucket_cnt):
> +            # OFP_BUCKET
> +            weight = watch_port = watch_group = b
> +            bucket = OFPBucket(self.len_, weight,
> +                               watch_port, watch_group,
> +                               self.actions)
> +            buckets.append(bucket)
> +            buf_buckets = bytearray()
> +            buckets[b].serialize(buf_buckets, 0)
> +            buf += str(buf_buckets)
> +
> +        res = OFPGroupDescStats.parser(buf, 0)
> +
> +        eq_(type_, res.type)
> +        eq_(length, res.length)
> +        eq_(group_id, res.group_id)
> +
> +        for b in range(bucket_cnt):
> +            eq_(buckets[b].len, res.buckets[b].len)
> +            eq_(buckets[b].weight, res.buckets[b].weight)
> +            eq_(buckets[b].watch_port, res.buckets[b].watch_port)
> +            eq_(buckets[b].watch_group, res.buckets[b].watch_group)
> +            eq_(buckets[b].actions[0].port,
> +                res.buckets[b].actions[0].port)
> +            eq_(buckets[b].actions[0].max_len,
> +                res.buckets[b].actions[0].max_len)
> +
>  
>  class TestOFPGroupFeaturesStatsRequest(unittest.TestCase):
>      """ Test case for ofproto_v1_2_parser.OFPGroupFeaturesStatsRequest
> -- 
> 1.7.9.5
> 
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to