diff options
author | Simon Horman <horms@verge.net.au> | 2012-03-13 09:06:19 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-03-13 21:41:33 -0700 |
commit | 3d780e2ce8e18792572c0a0c4fa2be36e1f50024 (patch) | |
tree | b13e587f41d1697f02bf4ef78e3a6e640217ae0b | |
parent | eb3fbc5d460b6c335df822e12688a70e6b8c6180 (diff) |
NXM: Add MFEthType class
This is to handle ETH_TYPE NXM fields.
This will used when sending NXM_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.py | 27 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_0.py | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py index a147e3f9..cb402f1e 100644 --- a/ryu/ofproto/nx_match.py +++ b/ryu/ofproto/nx_match.py @@ -30,10 +30,19 @@ UINT64_MAX = (1 << 64) - 1 FWW_IN_PORT = 1 << 0 FWW_DL_SRC = 1 << 2 FWW_DL_DST = 1 << 3 +FWW_DL_TYPE = 1 << 4 # No corresponding OFPFW_* bits FWW_ETH_MCAST = 1 << 1 FWW_ALL = (1 << 13) - 1 +# Ethernet types, for set_dl_type() +ETH_TYPE_IP = 0x0800 +ETH_TYPE_ARP = 0x0806 +ETH_TYPE_VLAN = 0x8100 +ETH_TYPE_IPV6 = 0x86dd +ETH_TYPE_LACP = 0x8809 + + MF_PACK_STRING_BE64 = '!Q' MF_PACK_STRING_BE16 = '!H' MF_PACK_STRING_MAC = '!6s' @@ -113,6 +122,10 @@ class ClsRule(object): self.wc.wildcards &= ~FWW_DL_SRC self.flow.dl_src = dl_src + def set_dl_type(self, dl_type): + self.wc.wildcards &= ~FWW_DL_TYPE + self.flow.dl_type = dl_type + def set_tun_id(self, tun_id): self.set_tun_id_masked(tun_id, UINT64_MAX) @@ -215,6 +228,17 @@ class MFEthSrc(MFField): @_register_make +@_set_nxm_headers([ofproto_v1_0.NXM_OF_ETH_TYPE]) +class MFEthType(MFField): + @classmethod + def make(cls): + return cls(MF_PACK_STRING_BE16) + + def put(self, buf, offset, rule): + return self._put(buf, offset, rule.flow.dl_type) + + +@_register_make @_set_nxm_headers([ofproto_v1_0.NXM_NX_TUN_ID, ofproto_v1_0.NXM_NX_TUN_ID_W]) class MFTunId(MFField): @classmethod @@ -235,7 +259,8 @@ def serialize_nxm_match(rule, buf, offset): offset += nxm_put_eth_dst(buf, offset, rule) if not rule.wc.wildcards & FWW_DL_SRC: offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_ETH_SRC, rule) - # XXX: Ethernet Type + if not rule.wc.wildcards & FWW_DL_TYPE: + offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_ETH_TYPE, rule) # XXX: 802.1Q # XXX: L3 diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py index a29e8373..ad051d56 100644 --- a/ryu/ofproto/ofproto_v1_0.py +++ b/ryu/ofproto/ofproto_v1_0.py @@ -520,6 +520,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_OF_ETH_TYPE = nxm_header(0x0000, 3, 2) NXM_NX_TUN_ID = nxm_header(0x0001, 16, 8) NXM_NX_TUN_ID_W = nxm_header_w(0x0001, 16, 8) |