summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2012-03-13 09:06:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-03-13 21:41:30 -0700
commitbb7d3e8dd21c4494701101b1af112a58ba1ff87c (patch)
treeddfacbec2448cefe6854fb3d96edec819a36a200
parentcda7026742335baef3ae5a5f20cdc649de1bd263 (diff)
NXM: Add MFTunId class
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 <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/nx_match.py20
-rw-r--r--ryu/ofproto/ofproto_v1_0.py3
2 files changed, 23 insertions, 0 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index b368c8e9..2b753bad 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 92f03af3..0d6a36c9 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'