blob: 3f95ce443555541152d0d87b0d9227a7cd925455 [file] [log] [blame]
Brian O'Connor7f8e3012014-02-15 23:59:29 -08001package net.onrc.onos.intent;
2
3import net.floodlightcontroller.util.MACAddress;
4import net.onrc.onos.ofcontroller.networkgraph.Port;
5import net.onrc.onos.ofcontroller.networkgraph.Switch;
Brian O'Connor67c6e662014-02-17 15:20:44 -08006import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
Brian O'Connor7f8e3012014-02-15 23:59:29 -08007
8/**
9 *
10 * @author Brian O'Connor <bocon@onlab.us>
11 *
12 */
13
14public class Match {
15 protected Switch sw;
16 protected MACAddress srcMac;
17 protected MACAddress dstMac;
18 protected Port srcPort;
19
20 public Match(Switch sw, Port srcPort,
21 MACAddress srcMac, MACAddress dstMac) {
22 this.sw = sw;
23 this.srcPort = srcPort;
24 this.srcMac = srcMac;
25 this.dstMac = dstMac;
26 }
27
28 @Override
29 public boolean equals(Object obj) {
30 if(obj instanceof Match) {
31 Match other = (Match) obj;
32 return this.sw == other.sw &&
33 this.srcMac == other.srcMac &&
34 this.dstMac == other.dstMac &&
35 this.srcPort == other.srcPort;
36 }
37 else {
38 return false;
39 }
40 }
41
Brian O'Connor67c6e662014-02-17 15:20:44 -080042 public FlowEntryMatch getFlowEntryMatch(){
43 FlowEntryMatch match = new FlowEntryMatch();
44 match.enableSrcMac(srcMac);
45 match.enableDstMac(dstMac);
46 match.enableInPort(new net.onrc.onos.ofcontroller.util.Port(srcPort.getNumber().shortValue()));
47 return match;
48 }
49
Brian O'Connor7f8e3012014-02-15 23:59:29 -080050 public String toString() {
51 return "(" + srcPort + "," + srcMac + "," + dstMac + ")";
52 }
53}