Signed-off-by: FUJITA Tomonori <fujita.tomon...@lab.ntt.co.jp>
---
 ryu/ofproto/nx_match.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 14b7428..9ccad8e 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -34,6 +34,7 @@ FWW_IN_PORT = 1 << 0
 FWW_DL_SRC = 1 << 2
 FWW_DL_DST = 1 << 3
 FWW_DL_TYPE = 1 << 4
+FWW_NW_PROTO = 1 << 5
 # No corresponding OFPFW_* bits
 FWW_ETH_MCAST = 1 << 1
 FWW_NW_DSCP = 1 << 6
@@ -68,6 +69,7 @@ class Flow(object):
         self.nw_tos = 0
         self.vlan_tci = 0
         self.nw_ttl = 0
+        self.nw_proto = 0
 
 
 class FlowWildcards(object):
@@ -150,6 +152,10 @@ class ClsRule(object):
         self.wc.vlan_tci_mask = mask
         self.flow.vlan_tci = tci
 
+    def set_nw_proto(self, nw_proto):
+        self.wc.wildcards &= ~FWW_NW_PROTO
+        self.flow.nw_proto = nw_proto
+
     def set_nw_dscp(self, nw_dscp):
         self.wc.wildcards &= ~FWW_NW_DSCP
         self.flow.nw_tos &= ~IP_DSCP_MASK
@@ -376,6 +382,17 @@ class MFIPTTL(MFField):
         return self._put(buf, offset, rule.flow.nw_ttl)
 
 
+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_OF_IP_PROTO])
+class MFIPProto(MFField):
+    @classmethod
+    def make(cls):
+        return cls(MF_PACK_STRING_8)
+
+    def put(self, buf, offset, rule):
+        return self._put(buf, offset, rule.flow.nw_proto)
+
+
 def serialize_nxm_match(rule, buf, offset):
     old_offset = offset
 
@@ -404,6 +421,8 @@ def serialize_nxm_match(rule, buf, offset):
         offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_ECN, rule)
     if not rule.wc.wildcards & FWW_NW_TTL:
         offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_TTL, rule)
+    if not rule.wc.wildcards & FWW_NW_PROTO:
+        offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_IP_PROTO, rule)
     # XXX: IP Source and Destination
     # XXX: IPv6
     # XXX: ARP
-- 
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
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to