blob: 5adb598a98e24c6aef9e78b6cfed6a3405f3c9dc [file] [log] [blame]
Brian O'Connor7f8e3012014-02-15 23:59:29 -08001package net.onrc.onos.intent;
2
3import net.floodlightcontroller.util.MACAddress;
Brian O'Connor488e5ed2014-02-20 19:50:01 -08004//import net.onrc.onos.ofcontroller.networkgraph.Port;
5//import 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/**
Yuta HIGUCHIe80664e2014-02-20 22:41:57 -08009 *
Brian O'Connor7f8e3012014-02-15 23:59:29 -080010 * @author Brian O'Connor <bocon@onlab.us>
11 *
12 */
13
14public class Match {
Brian O'Connor488e5ed2014-02-20 19:50:01 -080015 protected long sw;
Brian O'Connor7f8e3012014-02-15 23:59:29 -080016 protected MACAddress srcMac;
17 protected MACAddress dstMac;
Brian O'Connor488e5ed2014-02-20 19:50:01 -080018 protected long srcPort;
19
20 public Match(long sw, long srcPort,
21 MACAddress srcMac, MACAddress dstMac) {
Brian O'Connor7f8e3012014-02-15 23:59:29 -080022 this.sw = sw;
23 this.srcPort = srcPort;
24 this.srcMac = srcMac;
25 this.dstMac = dstMac;
26 }
Yuta HIGUCHIe80664e2014-02-20 22:41:57 -080027
Brian O'Connor7f8e3012014-02-15 23:59:29 -080028 @Override
29 public boolean equals(Object obj) {
30 if(obj instanceof Match) {
31 Match other = (Match) obj;
32 return this.sw == other.sw &&
Yuta HIGUCHIe80664e2014-02-20 22:41:57 -080033 this.srcMac.equals(other.srcMac) &&
34 this.dstMac.equals(other.dstMac) &&
Brian O'Connor7f8e3012014-02-15 23:59:29 -080035 this.srcPort == other.srcPort;
36 }
37 else {
38 return false;
39 }
40 }
Yuta HIGUCHIe80664e2014-02-20 22:41:57 -080041
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);
Brian O'Connor488e5ed2014-02-20 19:50:01 -080046 match.enableInPort(new net.onrc.onos.ofcontroller.util.Port((short) srcPort));
Brian O'Connor67c6e662014-02-17 15:20:44 -080047 return match;
48 }
Yuta HIGUCHIe80664e2014-02-20 22:41:57 -080049
50 @Override
Brian O'Connor7f8e3012014-02-15 23:59:29 -080051 public String toString() {
Brian O'Connor488e5ed2014-02-20 19:50:01 -080052 return "Sw:" + sw + " (" + srcPort + "," + srcMac + "," + dstMac + ")";
Brian O'Connor7f8e3012014-02-15 23:59:29 -080053 }
54}