Then how about this:
----
>From 3e29f270b921ed871d9cbc8b80d275c9fe19e96f Mon Sep 17 00:00:00 2001
From: Can Zhang <[email protected]>
Date: Tue, 2 Apr 2013 11:45:20 +0800
Subject: [PATCH] Changed pack string of IPv6 address in NXM from former
'!4I'
to '!8H'. Registered IPv6 src/dst field header so we could
parse IPv6 addresses now.
Signed-off-by: Can Zhang <[email protected]>
---
ryu/ofproto/nx_match.py | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 715129c..70cb316 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -57,6 +57,7 @@ MF_PACK_STRING_BE32 = '!I'
MF_PACK_STRING_BE16 = '!H'
MF_PACK_STRING_8 = '!B'
MF_PACK_STRING_MAC = '!6s'
+MF_PACK_STRING_IPV6 = '!8H'
_MF_FIELDS = {}
@@ -722,13 +723,35 @@ class MFArpSha(MFField):
return self._put(buf, offset, rule.flow.arp_sha)
+class MFIPV6(object):
+ pack_str = MF_PACK_STRING_IPV6
+
+ @classmethod
+ def field_parser(cls, header, buf, offset):
+ hasmask = (header >> 8) & 1
+ if hasmask:
+ pack_string = '!' + cls.pack_str[1:] * 2
+ value = struct.unpack_from(pack_string, 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))
+
+
@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_IPV6_SRC,
ofproto_v1_0.NXM_NX_IPV6_SRC_W])
-class MFIPV6Src(MFField):
[email protected]_field_header([ofproto_v1_0.NXM_NX_IPV6_SRC,
+ ofproto_v1_0.NXM_NX_IPV6_SRC_W])
+class MFIPV6Src(MFIPV6, MFField):
+ def __init__(self, header, value, mask = None):
+ super(MFIPV6Src, self).__init__(header, MFIPV6Src.pack_str)
+ self.value = value
+ self.mask = mask
+
@classmethod
def make(cls, header):
- return cls(header, '!4I')
+ return cls(header, cls.pack_str)
def put(self, buf, offset, rule):
return self.putv6(buf, offset,
@@ -739,10 +762,17 @@ class MFIPV6Src(MFField):
@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_IPV6_DST,
ofproto_v1_0.NXM_NX_IPV6_DST_W])
-class MFIPV6Dst(MFField):
[email protected]_field_header([ofproto_v1_0.NXM_NX_IPV6_DST,
+ ofproto_v1_0.NXM_NX_IPV6_DST_W])
+class MFIPV6Dst(MFIPV6, MFField):
+ def __init__(self, header, value, mask = None):
+ super(MFIPV6Dst, self).__init__(header, MFIPV6Dst.pack_str)
+ self.value = value
+ self.mask = mask
+
@classmethod
def make(cls, header):
- return cls(header, '!4I')
+ return cls(header, cls.pack_str)
def put(self, buf, offset, rule):
return self.putv6(buf, offset,
--
1.7.11.1
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel