blob: 42b778881faecb39e6fbe345c55f33c3c6873f05 [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.api.flowmanager;
2
3import net.onrc.onos.core.util.Dpid;
4import net.onrc.onos.core.util.PortNumber;
5import net.onrc.onos.core.util.SwitchPort;
6
7/**
Toshio Koide7894ca02014-08-15 14:30:13 -07008 * A link representation used by Flow objects.
Toshio Koidea03915e2014-07-01 18:39:52 -07009 * <p>
10 * TODO: Should lambda, bandwidth, tag, etc. be defined in this FlowLink, Path,
Toshio Koide7894ca02014-08-15 14:30:13 -070011 * Tree or Flow? We have to define it.
Toshio Koidea03915e2014-07-01 18:39:52 -070012 */
13public 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() {
Pavlin Radoslavov3d322f42014-08-18 14:58:55 -070059 return srcSwitchPort.getDpid();
Toshio Koidea03915e2014-07-01 18:39:52 -070060 }
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() {
Pavlin Radoslavov3d322f42014-08-18 14:58:55 -070068 return srcSwitchPort.getPortNumber();
Toshio Koidea03915e2014-07-01 18:39:52 -070069 }
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() {
Pavlin Radoslavov3d322f42014-08-18 14:58:55 -070086 return dstSwitchPort.getDpid();
Toshio Koidea03915e2014-07-01 18:39:52 -070087 }
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() {
Pavlin Radoslavov3d322f42014-08-18 14:58:55 -070095 return dstSwitchPort.getPortNumber();
Toshio Koidea03915e2014-07-01 18:39:52 -070096 }
97
98 @Override
99 public String toString() {
100 return srcSwitchPort + "-->" + dstSwitchPort;
101 }
102}