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; |
| 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 | /** |
| 9 | * |
| 10 | * @author Brian O'Connor <bocon@onlab.us> |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | public 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'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); |
| 46 | match.enableInPort(new net.onrc.onos.ofcontroller.util.Port(srcPort.getNumber().shortValue())); |
| 47 | return match; |
| 48 | } |
| 49 | |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 50 | public String toString() { |
| 51 | return "(" + srcPort + "," + srcMac + "," + dstMac + ")"; |
| 52 | } |
| 53 | } |