diff options
author | Shinpei Muraoka <shinpei.muraoka@gmail.com> | 2016-07-11 10:44:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-12 13:21:05 +0900 |
commit | 3b1a314bd019cc466d79342d98120f7c62c97ede (patch) | |
tree | ecee2318db55704f626fa3caa922d8e5b2eea4d1 | |
parent | 8cb23e19a7e4cbad78e2b9ae261e9eec39f685bd (diff) |
ofproto/nx_actions: Add NXAction used only in OpenFlow1.0
There is NXAction to be used only in OpenFlow1.0.
These actions are supported by default in OpenFlow1.2 or later.
Therefore, it becomes unnecessary as the NXAction.
But, to add the NXAction in order to be able to use in OpenFlow1.0.
Actions to be added are as following.
- NXActionSetQueue
- NXActionDecTtl
- NXActionPushMpls
- NXActionPopMpls
- NXActionSetMplsTtl
- NXActionDecMplsTtl
- NXActionSetMplsLabel
- NXActionSetMplsTc
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/nicira_ext.py | 6 | ||||
-rw-r--r-- | ryu/ofproto/nx_actions.py | 175 |
2 files changed, 181 insertions, 0 deletions
diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py index aae3383e..c5af140d 100644 --- a/ryu/ofproto/nicira_ext.py +++ b/ryu/ofproto/nicira_ext.py @@ -44,6 +44,12 @@ NXAST_EXIT = 17 NXAST_DEC_TTL = 18 NXAST_FIN_TIMEOUT = 19 NXAST_CONTROLLER = 20 +NXAST_PUSH_MPLS = 23 +NXAST_POP_MPLS = 24 +NXAST_SET_MPLS_TTL = 25 +NXAST_DEC_MPLS_TTL = 26 +NXAST_SET_MPLS_LABEL = 30 +NXAST_SET_MPLS_TC = 31 NXAST_CONJUNCTION = 34 NXAST_CT = 35 NXAST_NAT = 36 diff --git a/ryu/ofproto/nx_actions.py b/ryu/ofproto/nx_actions.py index 14bc4796..e0605d35 100644 --- a/ryu/ofproto/nx_actions.py +++ b/ryu/ofproto/nx_actions.py @@ -201,6 +201,28 @@ def generate(ofp_name, ofpp_name): # fixup return bytearray() if self.data is None else self.data + # For OpenFlow1.0 only + class NXActionSetQueue(NXAction): + _subtype = nicira_ext.NXAST_SET_QUEUE + + # queue_id + _fmt_str = '!2xI' + + def __init__(self, queue_id, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionSetQueue, self).__init__() + self.queue_id = queue_id + + @classmethod + def parser(cls, buf): + (queue_id,) = struct.unpack_from(cls._fmt_str, buf, 0) + return cls(queue_id) + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0, self.queue_id) + return data + class NXActionPopQueue(NXAction): _subtype = nicira_ext.NXAST_POP_QUEUE @@ -558,6 +580,25 @@ def generate(ofp_name, ofpp_name): msg_pack_into(self._fmt_str, data, 0) return data + # For OpenFlow1.0 only + class NXActionDecTtl(NXAction): + _subtype = nicira_ext.NXAST_DEC_TTL + + _fmt_str = '!6x' + + def __init__(self, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionDecTtl, self).__init__() + + @classmethod + def parser(cls, buf): + return cls() + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0) + return data + class NXActionController(NXAction): _subtype = nicira_ext.NXAST_CONTROLLER @@ -592,6 +633,132 @@ def generate(ofp_name, ofpp_name): self.reason) return data + # For OpenFlow1.0 only + class NXActionMplsBase(NXAction): + # ethertype + _fmt_str = '!H4x' + + def __init__(self, + ethertype, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionMplsBase, self).__init__() + self.ethertype = ethertype + + @classmethod + def parser(cls, buf): + (ethertype,) = struct.unpack_from( + cls._fmt_str, buf) + return cls(ethertype) + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0, + self.ethertype) + return data + + # For OpenFlow1.0 only + class NXActionPushMpls(NXActionMplsBase): + _subtype = nicira_ext.NXAST_PUSH_MPLS + + # For OpenFlow1.0 only + class NXActionPopMpls(NXActionMplsBase): + _subtype = nicira_ext.NXAST_POP_MPLS + + # For OpenFlow1.0 only + class NXActionSetMplsTtl(NXAction): + _subtype = nicira_ext.NXAST_SET_MPLS_TTL + + # ethertype + _fmt_str = '!B5x' + + def __init__(self, + ttl, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionSetMplsTtl, self).__init__() + self.ttl = ttl + + @classmethod + def parser(cls, buf): + (ttl,) = struct.unpack_from( + cls._fmt_str, buf) + return cls(ttl) + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0, + self.ttl) + return data + + # For OpenFlow1.0 only + class NXActionDecMplsTtl(NXAction): + _subtype = nicira_ext.NXAST_DEC_MPLS_TTL + + # ethertype + _fmt_str = '!6x' + + def __init__(self, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionDecMplsTtl, self).__init__() + + @classmethod + def parser(cls, buf): + return cls() + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0) + return data + + # For OpenFlow1.0 only + class NXActionSetMplsLabel(NXAction): + _subtype = nicira_ext.NXAST_SET_MPLS_LABEL + + # ethertype + _fmt_str = '!2xI' + + def __init__(self, + label, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionSetMplsLabel, self).__init__() + self.label = label + + @classmethod + def parser(cls, buf): + (label,) = struct.unpack_from( + cls._fmt_str, buf) + return cls(label) + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0, + self.label) + return data + + # For OpenFlow1.0 only + class NXActionSetMplsTc(NXAction): + _subtype = nicira_ext.NXAST_SET_MPLS_TC + + # ethertype + _fmt_str = '!B5x' + + def __init__(self, + tc, + type_=None, len_=None, vendor=None, subtype=None): + super(NXActionSetMplsTc, self).__init__() + self.tc = tc + + @classmethod + def parser(cls, buf): + (tc,) = struct.unpack_from( + cls._fmt_str, buf) + return cls(tc) + + def serialize_body(self): + data = bytearray() + msg_pack_into(self._fmt_str, data, 0, + self.tc) + return data + class NXActionFinTimeout(NXAction): _subtype = nicira_ext.NXAST_FIN_TIMEOUT @@ -972,6 +1139,7 @@ def generate(ofp_name, ofpp_name): add_attr('NXActionUnknown', NXActionUnknown) classes = [ + 'NXActionSetQueue', 'NXActionPopQueue', 'NXActionRegLoad', 'NXActionNote', @@ -983,7 +1151,14 @@ def generate(ofp_name, ofpp_name): 'NXActionOutputReg', 'NXActionLearn', 'NXActionExit', + 'NXActionDecTtl', 'NXActionController', + 'NXActionPushMpls', + 'NXActionPopMpls', + 'NXActionSetMplsTtl', + 'NXActionDecMplsTtl', + 'NXActionSetMplsLabel', + 'NXActionSetMplsTc', 'NXActionFinTimeout', 'NXActionConjunction', 'NXActionMultipath', |