Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.util; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 3 | |
| 4 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 5 | |
| 6 | /** |
| 7 | * The class representing the Data Path Endpoints. |
| 8 | */ |
| 9 | public class DataPathEndpoints { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 10 | private SwitchPort srcPort; // The source port |
| 11 | private SwitchPort dstPort; // The destination port |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 12 | |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 26 | this.srcPort = srcPort; |
| 27 | this.dstPort = dstPort; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Get the data path source port. |
| 32 | * |
| 33 | * @return the data path source port. |
| 34 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 35 | @JsonProperty("srcPort") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 36 | public SwitchPort srcPort() { |
| 37 | return srcPort; |
| 38 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Set the data path source port. |
| 42 | * |
| 43 | * @param srcPort the data path source port to set. |
| 44 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 45 | @JsonProperty("srcPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 46 | public void setSrcPort(SwitchPort srcPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 47 | this.srcPort = srcPort; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get the data path destination port. |
| 52 | * |
| 53 | * @return the data path destination port. |
| 54 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 55 | @JsonProperty("dstPort") |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 56 | public SwitchPort dstPort() { |
| 57 | return dstPort; |
| 58 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Set the data path destination port. |
| 62 | * |
| 63 | * @param dstPort the data path destination port to set. |
| 64 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 65 | @JsonProperty("dstPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 66 | public void setDstPort(SwitchPort dstPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 67 | this.dstPort = dstPort; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Convert the data path endpoints to a string. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 72 | * <p/> |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 73 | * The string has the following form: |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 74 | * [src=01:01:01:01:01:01:01:01/1111 dst=02:02:02:02:02:02:02:02/2222] |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 75 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 76 | * @return the data path endpoints as a string. |
| 77 | */ |
| 78 | @Override |
| 79 | public String toString() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 80 | String ret = "[src=" + this.srcPort.toString() + |
| 81 | " dst=" + this.dstPort.toString() + "]"; |
| 82 | return ret; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 83 | } |
| 84 | } |