Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/nx_match.py |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 3100eba..a3f73eb 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -50,6 +50,7 @@ ETH_TYPE_IPV6 = 0x86dd
 ETH_TYPE_LACP = 0x8809
 
 IPPROTO_ICMP = 1
+IPPROTO_ICMPV6 = 58
 
 IP_ECN_MASK = 0x03
 IP_DSCP_MASK = 0xfc
@@ -197,6 +198,12 @@ class ClsRule(object):
         self.wc.wildcards &= ~FWW_ARP_THA
         self.flow.arp_tha = tha
 
+    def set_icmpv6_type(self, icmp_type):
+        self.set_tp_src(icmp_type)
+
+    def set_icmpv6_code(self, icmp_code):
+        self.set_tp_dst(icmp_code)
+
     def flow_format(self):
         # Tunnel ID is only supported by NXM
         if self.wc.tun_id_mask != 0:
@@ -487,6 +494,28 @@ class MFICMPCode(MFField):
         return self._put(buf, offset, rule.flow.nw_dst)
 
 
+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_ICMPV6_TYPE])
+class MFICMPV6Type(MFField):
+    @classmethod
+    def make(cls):
+        return cls(MF_PACK_STRING_8)
+
+    def put(self, buf, offset, rule):
+        return self._put(buf, offset, rule.flow.tp_src)
+
+
+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_ICMPV6_CODE])
+class MFICMPV6Code(MFField):
+    @classmethod
+    def make(cls):
+        return cls(MF_PACK_STRING_8)
+
+    def put(self, buf, offset, rule):
+        return self._put(buf, offset, rule.flow.tp_dst)
+
+
 def serialize_nxm_match(rule, buf, offset):
     old_offset = offset
 
@@ -586,6 +615,17 @@ def serialize_nxm_match(rule, buf, offset):
         offset += nxm_put(buf, offset, header, rule)
 
     # XXX: IPv6
+    if not rule.wc.wildcards & FWW_NW_PROTO and (rule.flow.nw_proto
+                                                 == IPPROTO_ICMPV6):
+        if rule.wc.tp_src_mask != 0:
+            offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_ICMPV6_TYPE,
+                              rule)
+        elif rule.wc.tp_dst_mask != 0:
+            offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_ICMPV6_CODE,
+                              rule)
+        else:
+            pass
+
     # ARP
     if not rule.wc.wildcards & FWW_ARP_SHA:
         offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_ARP_SHA, rule)
-- 
1.7.4.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to