This is to handle TUN_ID and TUN_ID_W NXM fields.
This will be used when sending NXT_FLOW_MOD messages.

Signed-off-by: Simon Horman <[email protected]>
---
 ryu/ofproto/nx_match.py     |   20 ++++++++++++++++++++
 ryu/ofproto/ofproto_v1_0.py |    3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index b368c8e..2b753ba 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -41,6 +41,7 @@ class Flow(object):
 
 class FlowWildcards(object):
     def __init__(self):
+        self.tun_id_mask = 0
         self.wildcards = FWW_ALL
 
 
@@ -53,6 +54,14 @@ class ClsRule(object):
         self.wc.wildcards &= ~FWW_IN_PORT
         self.flow.in_port = port
 
+    def set_tun_id(self, tun_id):
+        self.set_tun_id_masked(tun_id, UINT64_MAX)
+
+    def set_tun_id_masked(self, tun_id, mask):
+        self.wc.tun_id_mask = mask
+        self.flow.tun_id = tun_id & mask
+
+
 def _set_nxm_headers(nxm_headers):
     '''Annotate corresponding NXM header'''
     def _set_nxm_headers(self):
@@ -116,6 +125,17 @@ class MFInPort(MFField):
         return self._put(buf, offset, rule.flow.in_port)
 
 
+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_TUN_ID, ofproto_v1_0.NXM_NX_TUN_ID_W])
+class MFTunId(MFField):
+    @classmethod
+    def make(cls):
+        return cls(MF_PACK_STRING_BE64)
+
+    def put(self, buf, offset, rule):
+        return self.putm(buf, offset, rule.flow.tun_id, rule.wc.tun_id_mask)
+
+
 def serialize_nxm_match(rule, buf, offset):
     old_offset = offset
 
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 92f03af..0d6a36c 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -517,4 +517,7 @@ def nxm_header_w(vendor, field, length):
 
 NXM_OF_IN_PORT = nxm_header(0x0000,  0, 2)
 
+NXM_NX_TUN_ID = nxm_header(0x0001, 16, 8)
+NXM_NX_TUN_ID_W = nxm_header_w(0x0001, 16, 8)
+
 NXM_HEADER_PACK_STRING = '!I'
-- 
1.7.6.3


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to