blob: 70edfeef52d236c6e02cd3596830a68ce4a53d5b [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003
4import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08005
6/**
7 * The class representing the Data Path Endpoints.
8 */
9public class DataPathEndpoints {
Ray Milkey269ffb92014-04-03 14:43:30 -070010 private SwitchPort srcPort; // The source port
11 private SwitchPort dstPort; // The destination port
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080012
13 /**
14 * Default constructor.
15 */
16 public DataPathEndpoints() {
17 }
18
19 /**
20 * Constructor for given source and destination ports.
21 *
22 * @param srcPort the source port to use.
23 * @param dstPort the destination port to use.
24 */
25 public DataPathEndpoints(SwitchPort srcPort, SwitchPort dstPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -070026 this.srcPort = srcPort;
27 this.dstPort = dstPort;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080028 }
29
30 /**
31 * Get the data path source port.
32 *
33 * @return the data path source port.
34 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080035 @JsonProperty("srcPort")
Ray Milkey269ffb92014-04-03 14:43:30 -070036 public SwitchPort srcPort() {
37 return srcPort;
38 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080039
40 /**
41 * Set the data path source port.
42 *
43 * @param srcPort the data path source port to set.
44 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080045 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080046 public void setSrcPort(SwitchPort srcPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -070047 this.srcPort = srcPort;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080048 }
49
50 /**
51 * Get the data path destination port.
52 *
53 * @return the data path destination port.
54 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080055 @JsonProperty("dstPort")
Ray Milkey269ffb92014-04-03 14:43:30 -070056 public SwitchPort dstPort() {
57 return dstPort;
58 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080059
60 /**
61 * Set the data path destination port.
62 *
63 * @param dstPort the data path destination port to set.
64 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080065 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080066 public void setDstPort(SwitchPort dstPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -070067 this.dstPort = dstPort;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080068 }
69
70 /**
71 * Convert the data path endpoints to a string.
Ray Milkey269ffb92014-04-03 14:43:30 -070072 * <p/>
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080073 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080074 * [src=01:01:01:01:01:01:01:01/1111 dst=02:02:02:02:02:02:02:02/2222]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080075 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080076 * @return the data path endpoints as a string.
77 */
78 @Override
79 public String toString() {
Ray Milkey269ffb92014-04-03 14:43:30 -070080 String ret = "[src=" + this.srcPort.toString() +
81 " dst=" + this.dstPort.toString() + "]";
82 return ret;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080083 }
84}