Signed-off-by: FUJITA Tomonori <[email protected]>
---
ryu/ofproto/nx_match.py | 32 +++++++++++++++++++++++++++++++-
ryu/ofproto/ofproto_v1_0.py | 3 +++
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 56527d9..5ca27ca 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -94,6 +94,7 @@ class Flow(object):
self.nd_target = []
self.nw_frag = 0
self.ipv6_label = 0
+ self.cookie = 0
class FlowWildcards(object):
@@ -112,6 +113,7 @@ class FlowWildcards(object):
self.ipv6_dst_mask = []
self.nd_target_mask = []
self.nw_frag_mask = 0
+ self.cookie_mask = 0
self.wildcards = FWW_ALL
@@ -275,6 +277,13 @@ class ClsRule(object):
def set_nd_target(self, target):
self.flow.nd_target = target
+ def set_cookie(self, cookie):
+ self.flow.cookie = cookie
+
+ def set_cookie_masked(self, cookie, mask):
+ self.flow.cookie = cookie & mask
+ self.wc.cookie_mask = mask
+
def flow_format(self):
# Tunnel ID is only supported by NXM
if self.wc.tun_id_mask != 0:
@@ -689,6 +698,21 @@ class MFICMPV6Label(MFField):
return self._put(buf, offset, rule.flow.ipv6_label)
+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_COOKIE, ofproto_v1_0.NXM_NX_COOKIE_W])
+class MFCookie(MFField):
+ @classmethod
+ def make(cls):
+ return cls(MF_PACK_STRING_BE64)
+
+ def put(self, buf, offset, rule):
+ if rule.wc.cookie_mask:
+ return self.putw(buf, offset, rule.flow.cookie,
+ rule.wc.cookie_mask)
+ else:
+ return self._put(buf, offset, rule.flow.cookie)
+
+
def serialize_nxm_match(rule, buf, offset):
old_offset = offset
@@ -854,7 +878,13 @@ def serialize_nxm_match(rule, buf, offset):
header = ofproto_v1_0.NXM_NX_TUN_ID_W
offset += nxm_put(buf, offset, header, rule)
- # XXX: Cookie
+ # Cookie
+ if rule.flow.cookie:
+ if rule.wc.cookie_mask:
+ header = ofproto_v1_0.NXM_NX_COOKIE_W
+ else:
+ header = ofproto_v1_0.NXM_NX_COOKIE
+ offset += nxm_put(buf, offset, header, rule)
# Pad
pad_len = round_up(offset) - offset
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index ec37caf..6d90e52 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -731,6 +731,9 @@ NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)
+NXM_NX_COOKIE = nxm_header(0x0001, 30, 8)
+NXM_NX_COOKIE_W = nxm_header_w(0x0001, 30, 8)
+
def nxm_nx_reg(idx):
return nxm_header(0x0001, idx, 4)
--
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