This patch implements the NXAST_REG_MOVE action subtype.

Signed-off-by: Saul St. John <[email protected]>
---
 pox/openflow/nicira.py |   51 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/pox/openflow/nicira.py b/pox/openflow/nicira.py
index 8c86206..eb5bf18 100644
--- a/pox/openflow/nicira.py
+++ b/pox/openflow/nicira.py
@@ -485,6 +485,57 @@ class nx_packet_in_format (nicira_base):
       s += str(self.format)
     return s + "\n"
 
+class nx_reg_move(of.ofp_action_vendor_base):
+  def _init(self, kw):
+    self.vendor = NX_VENDOR_ID
+    self.subtype = NXAST_REG_MOVE
+    self.nbits = 0
+    self.src_ofs = 0
+    self.src = None
+    self.dst_ofs = 0
+    self.dst = None # an nxm_entry class
+
+  def _eq (self, other):
+    if self.subtype != other.subtype: return False
+    return True
+
+  def _pack_body (self):
+    o = self.dst()
+    o._force_mask = False
+    dst = o.pack(omittable=False)[:4]
+
+    o = self.src()
+    o._force_mask = False
+    src = o.pack(omittable=False)[:4]
+
+    p = struct.pack('!HHHH4s4s', self.subtype, self.nbits, self.src_ofs,
+            self.dst_ofs, src, dst)
+    return p
+
+  def _unpack_body (self, raw, offset, avail):
+    offset,(self.subtype, self.nbits, self.src_ofs, self.dst_ofs, src, dst) = \
+        of._unpack('!HHHH4s4s', raw, offset)
+
+    _,dst = nxm_entry.unpack_new(dst, 0)
+    self.dst = dst.__class__
+
+    _,src = nxm_entry.unpack_new(src, 0)
+    self.src = src.__class__
+
+    return offset
+
+  def _body_length (self):
+    return 16
+
+  def _show (self, prefix):
+    s = ''
+    s += prefix + ('subtype: %s\n' % (self.subtype,))
+    s += prefix + ('nbits: %s\n' % (self.nbits,))
+    s += prefix + ('src: %s\n' % (self.src,))
+    s += prefix + ('src_ofs: %s\n' % (self.src_ofs,))
+    s += prefix + ('dst: %s\n' % (self.dst,))
+    s += prefix + ('dst_ofs: %s\n' % (self.dst_ofs,))
+    return s
 
 class nx_reg_load (of.ofp_action_vendor_base):
   def _init (self, kw):
-- 
1.7.10.4

Reply via email to