summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-05-14 10:08:34 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-05-14 11:05:41 +0900
commit8761cba5e5b7594eb8b31c9f5d534de3bf5096a6 (patch)
tree62519f87149446f52fce3fb9bf3390b27cd13ca3
parent15951cd8ff4d60d646249a384f81d86bc227e20d (diff)
add Nicira Extension NXAST_REG_MOVE support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Reviewed-by: Simon Horman <horms@verge.net.au>
-rw-r--r--ryu/ofproto/ofproto_v1_0.py65
-rw-r--r--ryu/ofproto/ofproto_v1_0_parser.py26
2 files changed, 83 insertions, 8 deletions
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 2f5f649f..2abf89d9 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011, 2012 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -234,6 +234,7 @@ OFP_ACTION_PACK_STR = '!H'
# enum nx_action_subtype (truncated)
NXAST_RESUBMIT = 1
NXAST_SET_TUNNEL = 2
+NXAST_REG_MOVE = 6
NXAST_SET_TUNNEL64 = 9
NXAST_MULTIPATH = 10
NXAST_RESUBMIT_TABLE = 14
@@ -246,6 +247,10 @@ NX_ACTION_SET_TUNNEL_PACK_STR = '!HHIH2xI'
NX_ACTION_SET_TUNNEL_SIZE = 16
assert calcsize(NX_ACTION_SET_TUNNEL_PACK_STR) == NX_ACTION_SET_TUNNEL_SIZE
+NX_ACTION_REG_MOVE_PACK_STR = '!HHIHHHHII'
+NX_ACTION_REG_MOVE_SIZE = 24
+assert calcsize(NX_ACTION_REG_MOVE_PACK_STR) == NX_ACTION_REG_MOVE_SIZE
+
NX_ACTION_SET_TUNNEL64_PACK_STR = '!HHIH6xQ'
NX_ACTION_SET_TUNNEL64_SIZE = 24
assert calcsize(NX_ACTION_SET_TUNNEL64_PACK_STR) == NX_ACTION_SET_TUNNEL64_SIZE
@@ -555,18 +560,64 @@ 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_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_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_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_OF_ICMP_TYPE = nxm_header(0x0000, 13, 1)
+NXM_OF_ICMP_CODE = nxm_header(0x0000, 14, 1)
-NXM_OF_IP_TOS = nxm_header(0x0000, 5, 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_ARP_SHA = nxm_header(0x0001, 17, 6)
+NXM_NX_ARP_THA = nxm_header(0x0001, 18, 6)
+
+NXM_NX_ICMPV6_TYPE = nxm_header(0x0001, 21, 1)
+NXM_NX_ICMPV6_CODE = nxm_header(0x0001, 22, 1)
+
+NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6)
+
+NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)
+
+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_NX_IP_ECN = nxm_header(0x0001, 28, 1)
NXM_HEADER_PACK_STRING = '!I'
diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py
index 4b9b63db..daa7f010 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011, 2012 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -481,6 +481,30 @@ class NXActionSetTunnel(NXActionHeader):
ofproto_v1_0.NX_ACTION_SET_TUNNEL_PACK_STR, buf, offset)
return cls(tun_id)
+@NXActionHeader.register_nx_action_subtype(ofproto_v1_0.NXAST_REG_MOVE)
+class NXActionRegMove(NXActionHeader):
+ def __init__(self, n_bits, src_ofs, dst_ofs, src, dst):
+ super(NXActionRegMove, self).__init__(
+ ofproto_v1_0.NXAST_REG_MOVE,
+ ofproto_v1_0.NX_ACTION_REG_MOVE_SIZE)
+ self.n_bits = n_bits
+ self.src_ofs = src_ofs
+ self.dst_ofs = dst_ofs
+ self.src = src
+ self.dst = dst
+
+ def serialize(self, buf, offset):
+ msg_pack_into(ofproto_v1_0.NX_ACTION_REG_MOVE_PACK_STR, buf,
+ offset, self.type, self.len, self.vendor,
+ self.subtype, self.n_bits, self.src_ofs, self.dst_ofs,
+ self.src, self.dst)
+
+ @classmethod
+ def parser(cls, buf, offset):
+ type_, len_, vendor, subtype, n_bits, src_ofs, dst_ofs,
+ src, dst = struct.unpack_from(
+ ofprot_v1_0.NX_ACTION_REG_MOVE_PACK_STR, buf, offset)
+ return cls(n_bits, src_ofs, dst_ofs, src, dst)
@NXActionHeader.register_nx_action_subtype(ofproto_v1_0.NXAST_SET_TUNNEL64)
class NXActionSetTunnel64(NXActionHeader):