diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-26 15:58:27 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-26 19:41:08 +0900 |
commit | 696639de4ed0c64accae105720f7007de8861446 (patch) | |
tree | a8331bde20a44a8c365fae7269f69b1d1b99e80f | |
parent | 2bf07c065a62fba8eca9fcfee94f31288504d63b (diff) |
of1.2: fix IPv6 match parsers
Fix the folloing problem in MTIPv6Src, MTIPv6Src, MTIPv6Dst, and
MTIPv6NdTarget's parsers:
File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1705, in parser
field = OFPMatchField.parser(buf, offset)
File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1934, in parser
field = cls_.field_parser(header, buf, offset)
File "/home/openflow/ryu/ryu/ofproto/ofproto_v1_2_parser.py", line 1949, in field_parser
(value,) = struct.unpack_from(cls.pack_str, buf, offset + 4)
ValueError: too many values to unpack
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index b18bc842..32a7313d 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -2252,9 +2252,25 @@ class MTArpTha(OFPMatchField): self.mask = mask +class MTIPv6(object): + @classmethod + def field_parser(cls, header, buf, offset): + hasmask = (header >> 8) & 1 + if hasmask: + pack_str = '!' + cls.pack_str[1:] * 2 + value = struct.unpack_from(pack_str, buf, offset + 4) + return cls(header, list(value[:8]), list(value[8:])) + else: + value = struct.unpack_from(cls.pack_str, buf, offset + 4) + return cls(header, list(value)) + + def serialize(self, buf, offset): + self.putv6(buf, offset, self.value, self.mask) + + @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IPV6_SRC, ofproto_v1_2.OXM_OF_IPV6_SRC_W]) -class MTIPv6Src(OFPMatchField): +class MTIPv6Src(MTIPv6, OFPMatchField): pack_str = '!8H' def __init__(self, header, value, mask=None): @@ -2262,13 +2278,10 @@ class MTIPv6Src(OFPMatchField): self.value = value self.mask = mask - def serialize(self, buf, offset): - self.putv6(buf, offset, self.value, self.mask) - @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IPV6_DST, ofproto_v1_2.OXM_OF_IPV6_DST_W]) -class MTIPv6Dst(OFPMatchField): +class MTIPv6Dst(MTIPv6, OFPMatchField): pack_str = '!8H' def __init__(self, header, value, mask=None): @@ -2276,9 +2289,6 @@ class MTIPv6Dst(OFPMatchField): self.value = value self.mask = mask - def serialize(self, buf, offset): - self.putv6(buf, offset, self.value, self.mask) - @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IPV6_FLABEL, ofproto_v1_2.OXM_OF_IPV6_FLABEL_W]) @@ -2319,7 +2329,7 @@ class MTICMPV6Code(OFPMatchField): @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IPV6_ND_TARGET]) -class MTIPv6NdTarget(OFPMatchField): +class MTIPv6NdTarget(MTIPv6, OFPMatchField): pack_str = '!8H' def __init__(self, header, value, mask=None): |