Andreas Wundsam | e1de1f6 | 2013-10-04 15:57:54 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.util; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 6 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 7 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
| 8 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 9 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 10 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 11 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; |
| 12 | |
| 13 | import com.google.common.collect.ImmutableList; |
| 14 | |
| 15 | public class ActionUtils { |
| 16 | private ActionUtils() {} |
| 17 | |
| 18 | public static List<OFAction> getActions(OFFlowStatsEntry e) { |
| 19 | if(e.getVersion() == OFVersion.OF_10) { |
| 20 | return e.getActions(); |
| 21 | } else { |
| 22 | for(OFInstruction i: e.getInstructions()) { |
| 23 | if(i.getType() == OFInstructionType.APPLY_ACTIONS) { |
| 24 | return ((OFInstructionApplyActions) i).getActions(); |
| 25 | } |
| 26 | } |
| 27 | return ImmutableList.of(); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public static List<OFAction> getActions(OFFlowMod e) { |
| 32 | if(e.getVersion() == OFVersion.OF_10) { |
| 33 | return e.getActions(); |
| 34 | } else { |
| 35 | for(OFInstruction i: e.getInstructions()) { |
| 36 | if(i.getType() == OFInstructionType.APPLY_ACTIONS) { |
| 37 | return ((OFInstructionApplyActions) i).getActions(); |
| 38 | } |
| 39 | } |
| 40 | return ImmutableList.of(); |
| 41 | } |
| 42 | } |
| 43 | } |