From: Yuichi Sudo <[email protected]>

an example:
   match = OFPMatch(
          dl_type = 0x0800,
          nw_src = ipv4_bytes_to_int(ipv4_to_bin("192.168.0.1")),
                 nw_src_mask = 24
          )

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/ofproto_v1_0_parser.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index 7ed33c1..d8d8aef 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -109,7 +109,7 @@ class OFPMatch(StringifyMixin):
     def __init__(self, wildcards=None, in_port=None, dl_src=None, dl_dst=None,
                  dl_vlan=None, dl_vlan_pcp=None, dl_type=None, nw_tos=None,
                  nw_proto=None, nw_src=None, nw_dst=None,
-                 tp_src=None, tp_dst=None):
+                 tp_src=None, tp_dst=None, nw_src_mask=32, nw_dst_mask=32):
         super(OFPMatch, self).__init__()
         wc = ofproto_v1_0.OFPFW_ALL
         if in_port is None:
@@ -169,14 +169,15 @@ class OFPMatch(StringifyMixin):
         if nw_src is None:
             self.nw_src = 0
         else:
-            # mask is not supported
-            wc &= ~ofproto_v1_0.OFPFW_NW_SRC_MASK
+            wc &= (32 - nw_src_mask) << ofproto_v1_0.OFPFW_NW_SRC_SHIFT \
+                | ~ofproto_v1_0.OFPFW_NW_SRC_MASK
             self.nw_src = nw_src
 
         if nw_dst is None:
             self.nw_dst = 0
         else:
-            wc &= ~ofproto_v1_0.OFPFW_NW_DST_MASK
+            wc &= (32 - nw_dst_mask) << ofproto_v1_0.OFPFW_NW_DST_SHIFT \
+                | ~ofproto_v1_0.OFPFW_NW_DST_MASK
             self.nw_dst = nw_dst
 
         if tp_src is None:
-- 
1.7.12.4 (Apple Git-37)


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to