Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
| 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 4 | //import net.onrc.onos.ofcontroller.networkgraph.Port; |
| 5 | //import net.onrc.onos.ofcontroller.networkgraph.Switch; |
Brian O'Connor | 67c6e66 | 2014-02-17 15:20:44 -0800 | [diff] [blame] | 6 | import net.onrc.onos.ofcontroller.util.FlowEntryMatch; |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 7 | |
| 8 | /** |
Yuta HIGUCHI | e80664e | 2014-02-20 22:41:57 -0800 | [diff] [blame] | 9 | * |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 10 | * @author Brian O'Connor <bocon@onlab.us> |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | public class Match { |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 15 | protected long sw; |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 16 | protected MACAddress srcMac; |
| 17 | protected MACAddress dstMac; |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 18 | protected long srcPort; |
| 19 | |
| 20 | public Match(long sw, long srcPort, |
| 21 | MACAddress srcMac, MACAddress dstMac) { |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 22 | this.sw = sw; |
| 23 | this.srcPort = srcPort; |
| 24 | this.srcMac = srcMac; |
| 25 | this.dstMac = dstMac; |
| 26 | } |
Yuta HIGUCHI | e80664e | 2014-02-20 22:41:57 -0800 | [diff] [blame] | 27 | |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 28 | @Override |
| 29 | public boolean equals(Object obj) { |
| 30 | if(obj instanceof Match) { |
| 31 | Match other = (Match) obj; |
| 32 | return this.sw == other.sw && |
Yuta HIGUCHI | e80664e | 2014-02-20 22:41:57 -0800 | [diff] [blame] | 33 | this.srcMac.equals(other.srcMac) && |
| 34 | this.dstMac.equals(other.dstMac) && |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 35 | this.srcPort == other.srcPort; |
| 36 | } |
| 37 | else { |
| 38 | return false; |
| 39 | } |
| 40 | } |
Yuta HIGUCHI | e80664e | 2014-02-20 22:41:57 -0800 | [diff] [blame] | 41 | |
Brian O'Connor | 67c6e66 | 2014-02-17 15:20:44 -0800 | [diff] [blame] | 42 | public FlowEntryMatch getFlowEntryMatch(){ |
| 43 | FlowEntryMatch match = new FlowEntryMatch(); |
| 44 | match.enableSrcMac(srcMac); |
| 45 | match.enableDstMac(dstMac); |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 46 | match.enableInPort(new net.onrc.onos.ofcontroller.util.Port((short) srcPort)); |
Brian O'Connor | 67c6e66 | 2014-02-17 15:20:44 -0800 | [diff] [blame] | 47 | return match; |
| 48 | } |
Yuta HIGUCHI | e80664e | 2014-02-20 22:41:57 -0800 | [diff] [blame] | 49 | |
| 50 | @Override |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 51 | public String toString() { |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 52 | return "Sw:" + sw + " (" + srcPort + "," + srcMac + "," + dstMac + ")"; |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 53 | } |
| 54 | } |