reactoring code for OFDPA ga2.0
diff --git a/accton/accton_util.py b/accton/accton_util.py
index d38bb78..e12cc63 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -276,7 +276,7 @@
 
     action=[]
     action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac)))
-    action.append(ofp.action.set_field(ofp.oxm.vlan_vid(vlanid)))       
+    action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid)))       
     action.append(ofp.action.group(group_id))
     
     buckets = [ofp.bucket(actions=action)]
@@ -779,32 +779,30 @@
 
     return request        
 
-def add_mpls(ctrl, action_group_id, label=100 ,ethertype=0x0800, bos=1, vrf=1, send_barrier=False):
+def add_mpls_flow(ctrl, action_group_id=0x0, label=100 ,ethertype=0x0800, bos=1, vrf=1, goto_table=27, send_barrier=False):
     match = ofp.match()
     match.oxm_list.append(ofp.oxm.eth_type(0x8847))
     match.oxm_list.append(ofp.oxm.mpls_label(label))
     match.oxm_list.append(ofp.oxm.mpls_bos(bos))
     actions = [ofp.action.dec_mpls_ttl(),
-               #ofp.action.copy_ttl_in(),
-               ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)),
-               ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=23, value=32)),
-               ofp.action.group(action_group_id)]
-               #ofp.action.pop_mpls(ethertype)]
-
+               ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))]
+    if (goto_table == 29):
+            actions.append(ofp.action.set_field(
+                            ofp.oxm.exp2ByteValue(exp_type=23, value=32)))
+            actions.append(ofp.action.group(action_group_id))
+    else:
+            actions.append(ofp.action.copy_ttl_in())
+            
     request = ofp.message.flow_add(
             table_id=24,
             cookie=43,
             match=match,
             instructions=[
-                    ofp.instruction.apply_actions(
-                        actions=actions
-                    ),
-                    #ofp.instruction.write_actions(
-                    ofp.instruction.goto_table(29)
+                    ofp.instruction.apply_actions(actions=actions),
+                    ofp.instruction.goto_table(goto_table)
                 ],
             buffer_id=ofp.OFP_NO_BUFFER,
             priority=1)
-
     logging.info("Inserting MPLS flow , label %ld", label)
     ctrl.message_send(request)
 
@@ -813,44 +811,6 @@
 
     return request
 
-
-
-def add_mpls_flow(ctrl, action_group_id=0x0, label=100 ,ethertype=0x0800, bos=1, vrf=1, send_barrier=False):
-    match = ofp.match()
-    match.oxm_list.append(ofp.oxm.eth_type(0x8847))
-    match.oxm_list.append(ofp.oxm.mpls_label(label))
-    match.oxm_list.append(ofp.oxm.mpls_bos(bos))
-    actions = [ofp.action.dec_mpls_ttl(),
-               ofp.action.copy_ttl_in(),
-               ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)),
-               ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=23, value=32))]
-               #ofp.action.group(action_group_id)]
-               #ofp.action.pop_mpls(ethertype)]
-   
-    request = ofp.message.flow_add(
-            table_id=24,
-            cookie=43,
-            match=match,
-            instructions=[
-                    ofp.instruction.apply_actions(
-                        actions=actions
-                    ),
-                    #ofp.instruction.write_actions(
-                    #    actions=[ofp.action.group(action_group_id)]),
-                    ofp.instruction.goto_table(27)
-                ],
-            buffer_id=ofp.OFP_NO_BUFFER,
-            priority=1)
-
-    logging.info("Inserting MPLS flow , label %ld", label)
-    ctrl.message_send(request)
-
-    if send_barrier:
-        do_barrier(ctrl)
-
-    return request
-
-
 def add_mcast4_routing_flow(ctrl, vlan_id, src_ip, src_ip_mask, dst_ip, action_group_id, send_barrier=False):
     match = ofp.match()
     match.oxm_list.append(ofp.oxm.eth_type(0x0800))