accton/accton_util.py
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 1c26766..26e7c6c 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -600,7 +600,7 @@
 
     return request        
     
-def add_termination_flow(ctrl, in_port, eth_type, dst_mac, vlanid, send_barrier=False):
+def add_termination_flow(ctrl, in_port, eth_type, dst_mac, vlanid, goto_table=None, send_barrier=False):
     match = ofp.match()
     match.oxm_list.append(ofp.oxm.eth_type(eth_type))
     if dst_mac[0]&0x01 == 0x01:
@@ -611,7 +611,8 @@
            match.oxm_list.append(ofp.oxm.in_port(in_port))
        match.oxm_list.append(ofp.oxm.eth_dst(dst_mac))
        match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlanid))
-       goto_table=30
+       if goto_table == None:
+           goto_table=30
 
     request = ofp.message.flow_add(
             table_id=20,
@@ -693,7 +694,32 @@
         do_barrier(ctrl)   
 
     return request            
-       
+
+#dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60
+def add_nat_flow(ctrl, eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id):
+    match = ofp.match()
+    match.oxm_list.append(ofp.oxm.eth_type(eth_type))
+    match.oxm_list.append(ofp.oxm.ipv4_dst(ip_dst))
+    match.oxm_list.append(ofp.oxm.ip_proto(ip_proto))
+    match.oxm_list.append(ofp.oxm.tcp_dst(tcp_dst))
+    
+    request = ofp.message.flow_add(
+            table_id=28,
+            cookie=42,
+            match=match,
+            instructions=[
+                    ofp.instruction.write_actions(
+                        actions=[ofp.action.set_field(ofp.oxm.ipv4_dst(set_ip_dst)),
+                                 ofp.action.set_field(ofp.oxm.tcp_dst(set_tcp_dst)),
+                                 ofp.action.group(action_group_id)]),
+                    ofp.instruction.goto_table(60)
+                ],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1) 
+    logging.info("Inserting DNAT flow eth_type %lx, dip %lx, ip_proto %ld, tcp_dst %ld, SetFeild: Dip %lx, tcp_dst %ld, action_gorup=%lx",eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id)
+    ctrl.message_send(request)
+    return request
+    
 def get_vtap_lport_config_xml(dp_id, lport, phy_port, vlan, vnid, operation='merge'):  
     """
     Command Example: