blob: e0553a905709938d55ad398d7049a77e7a4e4a6c [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001package org.projectfloodlight.openflow.util;
2
3import java.util.List;
4
5import org.projectfloodlight.openflow.protocol.OFFlowMod;
6import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
7import org.projectfloodlight.openflow.protocol.OFInstructionType;
8import org.projectfloodlight.openflow.protocol.OFVersion;
9import org.projectfloodlight.openflow.protocol.action.OFAction;
10import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
11import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
12
13import com.google.common.collect.ImmutableList;
14
15public 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}