Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.flowmanager; |
| 2 | |
| 3 | import net.onrc.onos.core.util.Dpid; |
| 4 | import net.onrc.onos.core.util.PortNumber; |
| 5 | import net.onrc.onos.core.util.SwitchPort; |
| 6 | |
| 7 | /** |
| 8 | * A link representation used by IFlow objects. |
| 9 | * <p> |
| 10 | * TODO: Should lambda, bandwidth, tag, etc. be defined in this FlowLink, Path, |
| 11 | * Tree or IFlow? We have to define it. |
| 12 | */ |
| 13 | public class FlowLink { |
| 14 | protected SwitchPort srcSwitchPort; |
| 15 | protected SwitchPort dstSwitchPort; |
| 16 | |
| 17 | /** |
| 18 | * Creates new FlowLink object using source/destination switch port pair. |
| 19 | * |
| 20 | * @param src The source switch port. |
| 21 | * @param dst The destination switch port. |
| 22 | */ |
| 23 | public FlowLink(SwitchPort src, SwitchPort dst) { |
| 24 | this.srcSwitchPort = src; |
| 25 | this.dstSwitchPort = dst; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Creates new FlowLink object using DPID and port number pairs at |
| 30 | * source/destination switches. |
| 31 | * |
| 32 | * @param srcDpid The source switch DPID. |
| 33 | * @param srcPortNumber The source port number at the source switch. |
| 34 | * @param dstDpid The destination switch DPID. |
| 35 | * @param dstPortNumber The destination port number at the destination |
| 36 | * switch. |
| 37 | */ |
| 38 | public FlowLink(Dpid srcDpid, PortNumber srcPortNumber, |
| 39 | Dpid dstDpid, PortNumber dstPortNumber) { |
| 40 | this.srcSwitchPort = new SwitchPort(srcDpid, srcPortNumber); |
| 41 | this.dstSwitchPort = new SwitchPort(dstDpid, dstPortNumber); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Gets the source switch port. |
| 46 | * |
| 47 | * @return The source switch port. |
| 48 | */ |
| 49 | public SwitchPort getSrcSwitchPort() { |
| 50 | return srcSwitchPort; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Gets the source switch DPID. |
| 55 | * |
| 56 | * @return The source switch DPID. |
| 57 | */ |
| 58 | public Dpid getSrcDpid() { |
| 59 | return srcSwitchPort.dpid(); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Gets the source port number at the source switch. |
| 64 | * |
| 65 | * @return The source port number at the source switch. |
| 66 | */ |
| 67 | public PortNumber getSrcPortNumber() { |
| 68 | return srcSwitchPort.port(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets the destination switch port. |
| 73 | * |
| 74 | * @return The destination switch port. |
| 75 | */ |
| 76 | public SwitchPort getDstSwitchPort() { |
| 77 | return dstSwitchPort; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Gets the destination switch DPID. |
| 82 | * |
| 83 | * @return The destination switch DPID. |
| 84 | */ |
| 85 | public Dpid getDstDpid() { |
| 86 | return dstSwitchPort.dpid(); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Gets the destination port number at the destination switch. |
| 91 | * |
| 92 | * @return The destination port number at the destination switch. |
| 93 | */ |
| 94 | public PortNumber getDstPortNumber() { |
| 95 | return dstSwitchPort.port(); |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | public String toString() { |
| 100 | return srcSwitchPort + "-->" + dstSwitchPort; |
| 101 | } |
| 102 | } |