summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristopher Scherb <christopher.scherb@stud.unibas.ch>2013-03-24 14:11:28 -0700
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-03-24 14:15:35 -0700
commit322e0cfc9ed1e9e84a89d0ffe2ea1c7d876923b0 (patch)
tree8540516a2dcccb8b96b945116c5db38991c8d81b
parent7d5a68cdc20c657bef192c82c1dab2746efb2bf3 (diff)
nx_match: add vlan and vlan_pop
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/nx_match.py50
1 files changed, 45 insertions, 5 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 58636d27..63d35ec1 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -66,6 +66,8 @@ FLOW_N_REGS = 8 # ovs 1.5
class Flow(object):
def __init__(self):
self.in_port = 0
+ self.dl_vlan = 0
+ self.dl_vlan_pcp = 0
self.dl_src = mac.DONTCARE
self.dl_dst = mac.DONTCARE
self.dl_type = 0
@@ -108,7 +110,7 @@ class FlowWildcards(object):
self.nw_frag_mask = 0
self.regs_bits = 0
self.regs_mask = [0] * FLOW_N_REGS
- self.wildcards = FWW_ALL
+ self.wildcards = ofproto_v1_0.OFPFW_ALL
class ClsRule(object):
@@ -120,6 +122,14 @@ class ClsRule(object):
self.wc.wildcards &= ~FWW_IN_PORT
self.flow.in_port = port
+ def set_dl_vlan(self, dl_vlan):
+ self.wc.wildcards &= ~ofproto_v1_0.OFPFW_DL_VLAN
+ self.flow.dl_vlan = dl_vlan
+
+ def set_dl_vlan_pcp(self, dl_vlan_pcp):
+ self.wc.wildcards &= ~ofproto_v1_0.OFPFW_DL_VLAN_PCP
+ self.flow.dl_vlan_pcp = dl_vlan_pcp
+
def set_dl_dst(self, dl_dst):
self.flow.dl_dst = dl_dst
@@ -314,11 +324,41 @@ class ClsRule(object):
if not self.wc.wildcards & FWW_DL_TYPE:
wildcards &= ~ofproto_v1_0.OFPFW_DL_TYPE
- # FIXME: Add support for dl_vlan, fl_vlan_pcp, nw_tos, nw_proto,
- # nw_src, nw_dst, tp_src and dp_dst to self
+ if self.flow.dl_vlan != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_DL_VLAN
+
+ if self.flow.dl_vlan_pcp != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_DL_VLAN_PCP
+
+ if self.flow.nw_tos != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_NW_TOS
+
+ if self.flow.nw_proto != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_NW_PROTO
+
+ if self.flow.nw_src != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_NW_SRC_MASK
+ # maximum size of 32 to prevent changes on other bits
+ wildcards |= (self.wc.nw_src_mask % 32) << 8
+
+ if self.flow.nw_dst != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_NW_DST_MASK
+ # maximum size of 32 to prevent changes on other bits
+ wildcards |= (self.wc.nw_dst_mask % 32) << 14
+
+ if self.flow.tp_src != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_TP_SRC
+
+ if self.flow.tp_dst != 0:
+ wildcards &= ~ofproto_v1_0.OFPFW_TP_DST
+
+ #FIXME: add support for arp, icmp, etc
+
return (wildcards, self.flow.in_port, self.flow.dl_src,
- self.flow.dl_dst, 0, 0, self.flow.dl_type,
- self.flow.nw_tos & IP_DSCP_MASK, 0, 0, 0, 0, 0)
+ self.flow.dl_dst, self.flow.dl_vlan, self.flow.dl_vlan_pcp,
+ self.flow.dl_type, self.flow.nw_tos & IP_DSCP_MASK,
+ self.flow.nw_proto, self.flow.nw_src, self.flow.nw_dst,
+ self.flow.tp_src, self.flow.tp_dst)
def _set_nxm_headers(nxm_headers):