summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorShinpei Muraoka <shinpei.muraoka@gmail.com>2016-06-06 09:48:14 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-09 13:07:47 +0900
commit7ca8690557656c030e79e45f8303e97b2cd202da (patch)
tree527ed56ae7170cffb5afe7af9a5498bdf4b3faf6
parent5ebf0fa5c4781e73020ebc853bb4ff8f9168bac3 (diff)
ofproto/nicira_ext: Move the variable and method for Nicira Extension
Move variable and method that exist in the ofproto_v1_0.py to the nicira_ext.py. Move the oxm_types that exists in the nx_match.py to the nicira_ext.py. Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--doc/source/nicira_ext_ref.rst2
-rw-r--r--ryu/ofproto/nicira_ext.py207
-rw-r--r--ryu/ofproto/nx_match.py105
-rw-r--r--ryu/ofproto/ofproto_v1_0.py117
-rw-r--r--ryu/ofproto/ofproto_v1_2.py4
-rw-r--r--ryu/ofproto/ofproto_v1_3.py4
-rw-r--r--ryu/ofproto/ofproto_v1_4.py4
-rw-r--r--ryu/ofproto/ofproto_v1_5.py4
8 files changed, 237 insertions, 210 deletions
diff --git a/doc/source/nicira_ext_ref.rst b/doc/source/nicira_ext_ref.rst
index dc7d5424..562e12aa 100644
--- a/doc/source/nicira_ext_ref.rst
+++ b/doc/source/nicira_ext_ref.rst
@@ -27,5 +27,5 @@ but also available in OF1.2+.
Nicira Extended Match Structures
================================
-.. automodule:: ryu.ofproto.nx_match
+.. automodule:: ryu.ofproto.nicira_ext
diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py
index 86ebe1f9..aae3383e 100644
--- a/ryu/ofproto/nicira_ext.py
+++ b/ryu/ofproto/nicira_ext.py
@@ -17,9 +17,11 @@
# Nicira extensions
# Many of these definitions are common among OpenFlow versions.
+import sys
from struct import calcsize
-
+from ryu.lib import type_desc
from ryu.ofproto.ofproto_common import OFP_HEADER_SIZE
+from ryu.ofproto import oxm_fields
# Action subtypes
NXAST_RESUBMIT = 1
@@ -252,3 +254,206 @@ NX_NAT_RANGE_IPV6_MIN = 1 << 2
NX_NAT_RANGE_IPV6_MAX = 1 << 3
NX_NAT_RANGE_PROTO_MIN = 1 << 4
NX_NAT_RANGE_PROTO_MAX = 1 << 5
+
+
+def nxm_header__(vendor, field, hasmask, length):
+ return (vendor << 16) | (field << 9) | (hasmask << 8) | length
+
+
+def nxm_header(vendor, field, length):
+ return nxm_header__(vendor, field, 0, length)
+
+
+def nxm_header_w(vendor, field, length):
+ return nxm_header__(vendor, field, 1, (length) * 2)
+
+
+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_SRC_W = nxm_header_w(0x0000, 2, 6)
+NXM_OF_ETH_TYPE = nxm_header(0x0000, 3, 2)
+
+NXM_OF_VLAN_TCI = nxm_header(0x0000, 4, 2)
+NXM_OF_VLAN_TCI_W = nxm_header_w(0x0000, 4, 2)
+
+NXM_OF_IP_TOS = nxm_header(0x0000, 5, 1)
+
+NXM_OF_IP_PROTO = nxm_header(0x0000, 6, 1)
+
+NXM_OF_IP_SRC = nxm_header(0x0000, 7, 4)
+NXM_OF_IP_SRC_W = nxm_header_w(0x0000, 7, 4)
+NXM_OF_IP_DST = nxm_header(0x0000, 8, 4)
+NXM_OF_IP_DST_W = nxm_header_w(0x0000, 8, 4)
+
+NXM_OF_TCP_SRC = nxm_header(0x0000, 9, 2)
+NXM_OF_TCP_SRC_W = nxm_header_w(0x0000, 9, 2)
+NXM_OF_TCP_DST = nxm_header(0x0000, 10, 2)
+NXM_OF_TCP_DST_W = nxm_header_w(0x0000, 10, 2)
+
+NXM_OF_UDP_SRC = nxm_header(0x0000, 11, 2)
+NXM_OF_UDP_SRC_W = nxm_header_w(0x0000, 11, 2)
+NXM_OF_UDP_DST = nxm_header(0x0000, 12, 2)
+NXM_OF_UDP_DST_W = nxm_header_w(0x0000, 12, 2)
+
+NXM_OF_ICMP_TYPE = nxm_header(0x0000, 13, 1)
+NXM_OF_ICMP_CODE = nxm_header(0x0000, 14, 1)
+
+NXM_OF_ARP_OP = nxm_header(0x0000, 15, 2)
+
+NXM_OF_ARP_SPA = nxm_header(0x0000, 16, 4)
+NXM_OF_ARP_SPA_W = nxm_header_w(0x0000, 16, 4)
+NXM_OF_ARP_TPA = nxm_header(0x0000, 17, 4)
+NXM_OF_ARP_TPA_W = nxm_header_w(0x0000, 17, 4)
+
+NXM_NX_TUN_ID = nxm_header(0x0001, 16, 8)
+NXM_NX_TUN_ID_W = nxm_header_w(0x0001, 16, 8)
+NXM_NX_TUN_IPV4_SRC = nxm_header(0x0001, 31, 4)
+NXM_NX_TUN_IPV4_SRC_W = nxm_header_w(0x0001, 31, 4)
+NXM_NX_TUN_IPV4_DST = nxm_header(0x0001, 32, 4)
+NXM_NX_TUN_IPV4_DST_W = nxm_header_w(0x0001, 32, 4)
+
+NXM_NX_ARP_SHA = nxm_header(0x0001, 17, 6)
+NXM_NX_ARP_THA = nxm_header(0x0001, 18, 6)
+
+NXM_NX_IPV6_SRC = nxm_header(0x0001, 19, 16)
+NXM_NX_IPV6_SRC_W = nxm_header_w(0x0001, 19, 16)
+NXM_NX_IPV6_DST = nxm_header(0x0001, 20, 16)
+NXM_NX_IPV6_DST_W = nxm_header_w(0x0001, 20, 16)
+
+NXM_NX_ICMPV6_TYPE = nxm_header(0x0001, 21, 1)
+NXM_NX_ICMPV6_CODE = nxm_header(0x0001, 22, 1)
+
+NXM_NX_ND_TARGET = nxm_header(0x0001, 23, 16)
+NXM_NX_ND_TARGET_W = nxm_header_w(0x0001, 23, 16)
+
+NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6)
+
+NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)
+
+NXM_NX_IP_FRAG = nxm_header(0x0001, 26, 1)
+NXM_NX_IP_FRAG_W = nxm_header_w(0x0001, 26, 1)
+
+NXM_NX_IPV6_LABEL = nxm_header(0x0001, 27, 4)
+
+NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
+
+NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)
+
+NXM_NX_PKT_MARK = nxm_header(0x0001, 33, 4)
+NXM_NX_PKT_MARK_W = nxm_header_w(0x0001, 33, 4)
+
+NXM_NX_TCP_FLAGS = nxm_header(0x0001, 34, 2)
+NXM_NX_TCP_FLAGS_W = nxm_header_w(0x0001, 34, 2)
+
+
+def nxm_nx_reg(idx):
+ return nxm_header(0x0001, idx, 4)
+
+
+def nxm_nx_reg_w(idx):
+ return nxm_header_w(0x0001, idx, 4)
+
+NXM_HEADER_PACK_STRING = '!I'
+
+#
+# The followings are implementations for OpenFlow 1.2+
+#
+
+sys.modules[__name__].__doc__ = """
+The API of this class is the same as ``OFPMatch``.
+
+You can define the flow match by the keyword arguments.
+The following arguments are available.
+
+================ =============== ==============================================
+Argument Value Description
+================ =============== ==============================================
+eth_dst_nxm MAC address Ethernet destination address.
+eth_src_nxm MAC address Ethernet source address.
+eth_type_nxm Integer 16bit Ethernet type. Needed to support Nicira
+ extensions that require the eth_type to
+ be set. (i.e. tcp_flags_nxm)
+ip_proto_nxm Integer 8bit IP protocol. Needed to support Nicira
+ extensions that require the ip_proto to
+ be set. (i.e. tcp_flags_nxm)
+tunnel_id_nxm Integer 64bit Tunnel identifier.
+tun_ipv4_src IPv4 address Tunnel IPv4 source address.
+tun_ipv4_dst IPv4 address Tunnel IPv4 destination address.
+pkt_mark Integer 32bit Packet metadata mark.
+tcp_flags_nxm Integer 16bit TCP Flags. Requires setting fields:
+ eth_type_nxm = [0x0800 (IP)|0x86dd (IPv6)] and
+ ip_proto_nxm = 6 (TCP)
+conj_id Integer 32bit Conjunction ID used only with
+ the conjunction action
+ct_state Integer 32bit Conntrack state.
+ct_zone Integer 16bit Conntrack zone.
+ct_mark Integer 32bit Conntrack mark.
+ct_label Integer 128bit Conntrack label.
+tun_ipv6_src IPv6 address Tunnel IPv6 source address.
+tun_ipv6_dst IPv6 address Tunnel IPv6 destination address.
+_dp_hash Integer 32bit Flow hash computed in Datapath.
+reg<idx> Integer 32bit Packet register.
+ <idx> is register number 0-7.
+================ =============== ==============================================
+
+.. Note::
+
+ Setting the TCP flags via the nicira extensions.
+ This is required when using OVS version < 2.4.
+ When using the nxm fields, you need to use any nxm prereq
+ fields as well or you will receive a OFPBMC_BAD_PREREQ error
+
+ Example::
+
+ # WILL NOT work
+ flag = tcp.TCP_ACK
+ match = parser.OFPMatch(
+ tcp_flags_nxm=(flag, flag),
+ ip_proto=inet.IPPROTO_TCP,
+ eth_type=eth_type)
+
+ # Works
+ flag = tcp.TCP_ACK
+ match = parser.OFPMatch(
+ tcp_flags_nxm=(flag, flag),
+ ip_proto_nxm=inet.IPPROTO_TCP,
+ eth_type_nxm=eth_type)
+"""
+
+oxm_types = [
+ oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr),
+ oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr),
+ oxm_fields.NiciraExtended0('eth_type_nxm', 3, type_desc.Int2),
+ oxm_fields.NiciraExtended0('ip_proto_nxm', 6, type_desc.Int1),
+ oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8),
+ oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
+ oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+ oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
+ oxm_fields.NiciraExtended1('tcp_flags_nxm', 34, type_desc.Int2),
+ oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
+ oxm_fields.NiciraExtended1('ct_state', 105, type_desc.Int4),
+ oxm_fields.NiciraExtended1('ct_zone', 106, type_desc.Int2),
+ oxm_fields.NiciraExtended1('ct_mark', 107, type_desc.Int4),
+ oxm_fields.NiciraExtended1('ct_label', 108, type_desc.Int16),
+ oxm_fields.NiciraExtended1('tun_ipv6_src', 109, type_desc.IPv6Addr),
+ oxm_fields.NiciraExtended1('tun_ipv6_dst', 110, type_desc.IPv6Addr),
+
+ # The following definition is merely for testing 64-bit experimenter OXMs.
+ # Following Open vSwitch, we use dp_hash for this purpose.
+ # Prefix the name with '_' to indicate this is not intended to be used
+ # in wild.
+ oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4),
+
+ # Support for matching/setting NX registers 0-7
+ oxm_fields.NiciraExtended1('reg0', 0, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg1', 1, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg2', 2, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg3', 3, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg4', 4, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg5', 5, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg6', 6, type_desc.Int4),
+ oxm_fields.NiciraExtended1('reg7', 7, type_desc.Int4),
+]
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 49989276..77803ccf 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -16,17 +16,15 @@
# limitations under the License.
import struct
-import sys
from ryu import exception
from ryu.lib import mac
-from ryu.lib import type_desc
from ryu.lib.pack_utils import msg_pack_into
from ryu.ofproto import ether
from ryu.ofproto import ofproto_parser
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import inet
-from ryu.ofproto import oxm_fields
+
import logging
LOG = logging.getLogger('ryu.ofproto.nx_match')
@@ -1228,104 +1226,3 @@ class NXMatch(object):
msg_pack_into(ofproto_v1_0.NXM_HEADER_PACK_STRING,
buf, offset, self.header)
return struct.calcsize(ofproto_v1_0.NXM_HEADER_PACK_STRING)
-
-
-#
-# The followings are implementations for OpenFlow 1.2+
-#
-
-sys.modules[__name__].__doc__ = """
-The API of this class is the same as ``OFPMatch``.
-
-You can define the flow match by the keyword arguments.
-The following arguments are available.
-
-================ =============== ==============================================
-Argument Value Description
-================ =============== ==============================================
-eth_dst_nxm MAC address Ethernet destination address.
-eth_src_nxm MAC address Ethernet source address.
-eth_type_nxm Integer 16bit Ethernet type. Needed to support Nicira
- extensions that require the eth_type to
- be set. (i.e. tcp_flags_nxm)
-ip_proto_nxm Integer 8bit IP protocol. Needed to support Nicira
- extensions that require the ip_proto to
- be set. (i.e. tcp_flags_nxm)
-tunnel_id_nxm Integer 64bit Tunnel identifier.
-tun_ipv4_src IPv4 address Tunnel IPv4 source address.
-tun_ipv4_dst IPv4 address Tunnel IPv4 destination address.
-pkt_mark Integer 32bit Packet metadata mark.
-tcp_flags_nxm Integer 16bit TCP Flags. Requires setting fields:
- eth_type_nxm = [0x0800 (IP)|0x86dd (IPv6)] and
- ip_proto_nxm = 6 (TCP)
-conj_id Integer 32bit Conjunction ID used only with
- the conjunction action
-ct_state Integer 32bit Conntrack state.
-ct_zone Integer 16bit Conntrack zone.
-ct_mark Integer 32bit Conntrack mark.
-ct_label Integer 128bit Conntrack label.
-tun_ipv6_src IPv6 address Tunnel IPv6 source address.
-tun_ipv6_dst IPv6 address Tunnel IPv6 destination address.
-_dp_hash Integer 32bit Flow hash computed in Datapath.
-reg<idx> Integer 32bit Packet register.
- <idx> is register number 0-7.
-================ =============== ==============================================
-
-.. Note::
-
- Setting the TCP flags via the nicira extensions.
- This is required when using OVS version < 2.4.
- When using the nxm fields, you need to use any nxm prereq
- fields as well or you will receive a OFPBMC_BAD_PREREQ error
-
- Example::
-
- # WILL NOT work
- flag = tcp.TCP_ACK
- match = parser.OFPMatch(
- tcp_flags_nxm=(flag, flag),
- ip_proto=inet.IPPROTO_TCP,
- eth_type=eth_type)
-
- # Works
- flag = tcp.TCP_ACK
- match = parser.OFPMatch(
- tcp_flags_nxm=(flag, flag),
- ip_proto_nxm=inet.IPPROTO_TCP,
- eth_type_nxm=eth_type)
-"""
-
-oxm_types = [
- oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr),
- oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr),
- oxm_fields.NiciraExtended0('eth_type_nxm', 3, type_desc.Int2),
- oxm_fields.NiciraExtended0('ip_proto_nxm', 6, type_desc.Int1),
- oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8),
- oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
- oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
- oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
- oxm_fields.NiciraExtended1('tcp_flags_nxm', 34, type_desc.Int2),
- oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
- oxm_fields.NiciraExtended1('ct_state', 105, type_desc.Int4),
- oxm_fields.NiciraExtended1('ct_zone', 106, type_desc.Int2),
- oxm_fields.NiciraExtended1('ct_mark', 107, type_desc.Int4),
- oxm_fields.NiciraExtended1('ct_label', 108, type_desc.Int16),
- oxm_fields.NiciraExtended1('tun_ipv6_src', 109, type_desc.IPv6Addr),
- oxm_fields.NiciraExtended1('tun_ipv6_dst', 110, type_desc.IPv6Addr),
-
- # The following definition is merely for testing 64-bit experimenter OXMs.
- # Following Open vSwitch, we use dp_hash for this purpose.
- # Prefix the name with '_' to indicate this is not intended to be used
- # in wild.
- oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4),
-
- # Support for matching/setting NX registers 0-7
- oxm_fields.NiciraExtended1('reg0', 0, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg1', 1, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg2', 2, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg3', 3, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg4', 4, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg5', 5, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg6', 6, type_desc.Int4),
- oxm_fields.NiciraExtended1('reg7', 7, type_desc.Int4),
-]
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 0ba06201..52d1b746 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -18,10 +18,8 @@
OpenFlow 1.0 definitions.
"""
-from struct import calcsize
-
from ryu.ofproto import ofproto_utils
-
+from ryu.ofproto.nicira_ext import * # For API compat
MAX_XID = 0xffffffff
@@ -498,110 +496,37 @@ OFP_QUEUE_PROP_MIN_RATE_SIZE = 16
assert (calcsize(OFP_QUEUE_PROP_MIN_RATE_PACK_STR) +
OFP_QUEUE_PROP_HEADER_SIZE == OFP_QUEUE_PROP_MIN_RATE_SIZE)
-# generate utility methods
-ofproto_utils.generate(__name__)
-
-
-def nxm_header__(vendor, field, hasmask, length):
- return (vendor << 16) | (field << 9) | (hasmask << 8) | length
-
-
-def nxm_header(vendor, field, length):
- return nxm_header__(vendor, field, 0, length)
-
-
-def nxm_header_w(vendor, field, length):
- return nxm_header__(vendor, field, 1, (length) * 2)
-
-
-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_SRC_W = nxm_header_w(0x0000, 2, 6)
-NXM_OF_ETH_TYPE = nxm_header(0x0000, 3, 2)
-
-NXM_OF_VLAN_TCI = nxm_header(0x0000, 4, 2)
-NXM_OF_VLAN_TCI_W = nxm_header_w(0x0000, 4, 2)
-
-NXM_OF_IP_TOS = nxm_header(0x0000, 5, 1)
+# OXM
-NXM_OF_IP_PROTO = nxm_header(0x0000, 6, 1)
+# enum ofp_oxm_class
+OFPXMC_OPENFLOW_BASIC = 0x8000 # Basic class for OpenFlow
-NXM_OF_IP_SRC = nxm_header(0x0000, 7, 4)
-NXM_OF_IP_SRC_W = nxm_header_w(0x0000, 7, 4)
-NXM_OF_IP_DST = nxm_header(0x0000, 8, 4)
-NXM_OF_IP_DST_W = nxm_header_w(0x0000, 8, 4)
-NXM_OF_TCP_SRC = nxm_header(0x0000, 9, 2)
-NXM_OF_TCP_SRC_W = nxm_header_w(0x0000, 9, 2)
-NXM_OF_TCP_DST = nxm_header(0x0000, 10, 2)
-NXM_OF_TCP_DST_W = nxm_header_w(0x0000, 10, 2)
+def _oxm_tlv_header(class_, field, hasmask, length):
+ return (class_ << 16) | (field << 9) | (hasmask << 8) | length
-NXM_OF_UDP_SRC = nxm_header(0x0000, 11, 2)
-NXM_OF_UDP_SRC_W = nxm_header_w(0x0000, 11, 2)
-NXM_OF_UDP_DST = nxm_header(0x0000, 12, 2)
-NXM_OF_UDP_DST_W = nxm_header_w(0x0000, 12, 2)
-NXM_OF_ICMP_TYPE = nxm_header(0x0000, 13, 1)
-NXM_OF_ICMP_CODE = nxm_header(0x0000, 14, 1)
+def oxm_tlv_header(field, length):
+ return _oxm_tlv_header(OFPXMC_OPENFLOW_BASIC, field, 0, length)
-NXM_OF_ARP_OP = nxm_header(0x0000, 15, 2)
-NXM_OF_ARP_SPA = nxm_header(0x0000, 16, 4)
-NXM_OF_ARP_SPA_W = nxm_header_w(0x0000, 16, 4)
-NXM_OF_ARP_TPA = nxm_header(0x0000, 17, 4)
-NXM_OF_ARP_TPA_W = nxm_header_w(0x0000, 17, 4)
+def oxm_tlv_header_w(field, length):
+ return _oxm_tlv_header(OFPXMC_OPENFLOW_BASIC, field, 1, length * 2)
-NXM_NX_TUN_ID = nxm_header(0x0001, 16, 8)
-NXM_NX_TUN_ID_W = nxm_header_w(0x0001, 16, 8)
-NXM_NX_TUN_IPV4_SRC = nxm_header(0x0001, 31, 4)
-NXM_NX_TUN_IPV4_SRC_W = nxm_header_w(0x0001, 31, 4)
-NXM_NX_TUN_IPV4_DST = nxm_header(0x0001, 32, 4)
-NXM_NX_TUN_IPV4_DST_W = nxm_header_w(0x0001, 32, 4)
-NXM_NX_ARP_SHA = nxm_header(0x0001, 17, 6)
-NXM_NX_ARP_THA = nxm_header(0x0001, 18, 6)
+def oxm_tlv_header_extract_hasmask(header):
+ return (header >> 8) & 1
-NXM_NX_IPV6_SRC = nxm_header(0x0001, 19, 16)
-NXM_NX_IPV6_SRC_W = nxm_header_w(0x0001, 19, 16)
-NXM_NX_IPV6_DST = nxm_header(0x0001, 20, 16)
-NXM_NX_IPV6_DST_W = nxm_header_w(0x0001, 20, 16)
-NXM_NX_ICMPV6_TYPE = nxm_header(0x0001, 21, 1)
-NXM_NX_ICMPV6_CODE = nxm_header(0x0001, 22, 1)
+def oxm_tlv_header_extract_length(header):
+ if oxm_tlv_header_extract_hasmask(header):
+ length = (header & 0xff) // 2
+ else:
+ length = header & 0xff
+ return length
-NXM_NX_ND_TARGET = nxm_header(0x0001, 23, 16)
-NXM_NX_ND_TARGET_W = nxm_header_w(0x0001, 23, 16)
-NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6)
+oxm_fields.generate(__name__)
-NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)
-
-NXM_NX_IP_FRAG = nxm_header(0x0001, 26, 1)
-NXM_NX_IP_FRAG_W = nxm_header_w(0x0001, 26, 1)
-
-NXM_NX_IPV6_LABEL = nxm_header(0x0001, 27, 4)
-
-NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
-
-NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)
-
-NXM_NX_PKT_MARK = nxm_header(0x0001, 33, 4)
-NXM_NX_PKT_MARK_W = nxm_header_w(0x0001, 33, 4)
-
-NXM_NX_TCP_FLAGS = nxm_header(0x0001, 34, 2)
-NXM_NX_TCP_FLAGS_W = nxm_header_w(0x0001, 34, 2)
-
-
-def nxm_nx_reg(idx):
- return nxm_header(0x0001, idx, 4)
-
-
-def nxm_nx_reg_w(idx):
- return nxm_header_w(0x0001, idx, 4)
-
-NXM_HEADER_PACK_STRING = '!I'
-
-from ryu.ofproto.nicira_ext import * # For API compat
+# generate utility methods
+ofproto_utils.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_2.py b/ryu/ofproto/ofproto_v1_2.py
index adf131cf..9c8aa906 100644
--- a/ryu/ofproto/ofproto_v1_2.py
+++ b/ryu/ofproto/ofproto_v1_2.py
@@ -19,7 +19,7 @@ OpenFlow 1.2 definitions.
"""
from ryu.lib import type_desc
-from ryu.ofproto import nx_match
+from ryu.ofproto import nicira_ext
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@@ -836,7 +836,7 @@ oxm_types = [
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
-] + nx_match.oxm_types
+] + nicira_ext.oxm_types
oxm_fields.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index 6b31ec2a..8a562a8d 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -19,7 +19,7 @@ OpenFlow 1.3 definitions.
"""
from ryu.lib import type_desc
-from ryu.ofproto import nx_match
+from ryu.ofproto import nicira_ext
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@@ -1195,7 +1195,7 @@ oxm_types = [
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
-] + nx_match.oxm_types
+] + nicira_ext.oxm_types
oxm_fields.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 02b07b1b..d1c48225 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -19,7 +19,7 @@ OpenFlow 1.4 definitions.
"""
from ryu.lib import type_desc
-from ryu.ofproto import nx_match
+from ryu.ofproto import nicira_ext
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@@ -396,7 +396,7 @@ oxm_types = [
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
-] + nx_match.oxm_types
+] + nicira_ext.oxm_types
oxm_fields.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index 45191dd8..83531845 100644
--- a/ryu/ofproto/ofproto_v1_5.py
+++ b/ryu/ofproto/ofproto_v1_5.py
@@ -19,7 +19,7 @@ OpenFlow 1.5 definitions.
"""
from ryu.lib import type_desc
-from ryu.ofproto import nx_match
+from ryu.ofproto import nicira_ext
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
from ryu.ofproto import oxs_fields
@@ -431,7 +431,7 @@ oxm_types = [
oxm_fields.OpenFlowBasic('tcp_flags', 42, type_desc.Int2),
oxm_fields.OpenFlowBasic('actset_output', 43, type_desc.Int4),
oxm_fields.OpenFlowBasic('packet_type', 44, type_desc.Int4),
-] + nx_match.oxm_types
+] + nicira_ext.oxm_types
oxm_fields.generate(__name__)