This is to handle ETH_SRC NXM fields.
This will be used when sending NXM_FLOW_MOD messages.

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

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 77abcb6..a147e3f 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -109,6 +109,10 @@ class ClsRule(object):
                                   map(lambda x: chr(ord(x[0]) & ord(x[1])),
                                       zip(dl_dst, mask)))
 
+    def set_dl_src(self, dl_src):
+        self.wc.wildcards &= ~FWW_DL_SRC
+        self.flow.dl_src = dl_src
+
     def set_tun_id(self, tun_id):
         self.set_tun_id_masked(tun_id, UINT64_MAX)
 
@@ -200,6 +204,17 @@ class MFEthDst(MFField):
 
 
 @_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_OF_ETH_SRC])
+class MFEthSrc(MFField):
+    @classmethod
+    def make(cls):
+        return cls(MF_PACK_STRING_MAC)
+
+    def put(self, buf, offset, rule):
+        return self._put(buf, offset, rule.flow.dl_src)
+
+
+@_register_make
 @_set_nxm_headers([ofproto_v1_0.NXM_NX_TUN_ID, ofproto_v1_0.NXM_NX_TUN_ID_W])
 class MFTunId(MFField):
     @classmethod
@@ -218,7 +233,9 @@ def serialize_nxm_match(rule, buf, offset):
 
     # Ethernet.
     offset += nxm_put_eth_dst(buf, offset, rule)
-    # XXX: Ethernet Source and Type
+    if not rule.wc.wildcards & FWW_DL_SRC:
+        offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_ETH_SRC, rule)
+    # XXX: Ethernet Type
 
     # XXX: 802.1Q
     # XXX: L3
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index b322d3e..a29e837 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -519,6 +519,7 @@ NXM_OF_IN_PORT = nxm_header(0x0000,  0, 2)
 
 NXM_OF_ETH_DST = nxm_header(0x0000,  1, 6)
 NXM_OF_ETH_DST_W = nxm_header_w(0x0000,  1, 6)
+NXM_OF_ETH_SRC = nxm_header(0x0000,  2, 6)
 
 NXM_NX_TUN_ID = nxm_header(0x0001, 16, 8)
 NXM_NX_TUN_ID_W = nxm_header_w(0x0001, 16, 8)
-- 
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