blob: 14d1038c961f12b4969db3c0fcacadb8cb2f2a8f [file] [log] [blame]
Brian O'Connor7f8e3012014-02-15 23:59:29 -08001package net.onrc.onos.intent;
2
3import java.util.HashSet;
4import java.util.Set;
5
6import net.floodlightcontroller.util.MACAddress;
7import net.onrc.onos.ofcontroller.networkgraph.Port;
8import net.onrc.onos.ofcontroller.networkgraph.Switch;
Brian O'Connor67c6e662014-02-17 15:20:44 -08009import net.onrc.onos.ofcontroller.util.Dpid;
10import net.onrc.onos.ofcontroller.util.FlowEntryActions;
11import net.onrc.onos.ofcontroller.util.FlowEntryId;
Brian O'Connor7f8e3012014-02-15 23:59:29 -080012
13/**
14 *
15 * @author Brian O'Connor <bocon@onlab.us>
16 *
17 */
18
19public class FlowEntry {
20 protected Switch sw;
21 protected Match match;
22 protected Set<Action> actions;
23
24 public FlowEntry(Switch sw, Port srcPort, Port dstPort,
25 MACAddress srcMac, MACAddress dstMac) {
26 this.sw = sw;
27 this.match = new Match(sw, srcPort, srcMac, dstMac);
28 this.actions = new HashSet<Action>();
29 this.actions.add(new ForwardAction(dstPort));
30 }
31
32 public String toString() {
33 return match + "->" + actions;
34 }
Brian O'Connor67c6e662014-02-17 15:20:44 -080035
36 public Switch getSwitch() {
37 return sw;
38 }
39
40 public net.onrc.onos.ofcontroller.util.FlowEntry getFlowEntry() {
41 net.onrc.onos.ofcontroller.util.FlowEntry entry = new net.onrc.onos.ofcontroller.util.FlowEntry();
42 entry.setDpid(new Dpid(sw.getDpid()));
43 entry.setFlowEntryId(new FlowEntryId(0)); // all zero for now
44 entry.setFlowEntryMatch(match.getFlowEntryMatch());
45 FlowEntryActions flowEntryActions = new FlowEntryActions();
46 for(Action action : actions) {
47 flowEntryActions.addAction(action.getFlowEntryAction());
48 }
49 entry.setFlowEntryActions(flowEntryActions);
50 return entry;
51 }
Brian O'Connor7f8e3012014-02-15 23:59:29 -080052}