Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
| 3 | import net.floodlightcontroller.util.SwitchPort; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 4 | |
| 5 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 6 | |
| 7 | /** |
| 8 | * The class representing the Data Path Endpoints. |
| 9 | */ |
| 10 | public class DataPathEndpoints { |
| 11 | private SwitchPort srcPort; // The source port |
| 12 | private SwitchPort dstPort; // The destination port |
| 13 | |
| 14 | /** |
| 15 | * Default constructor. |
| 16 | */ |
| 17 | public DataPathEndpoints() { |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Constructor for given source and destination ports. |
| 22 | * |
| 23 | * @param srcPort the source port to use. |
| 24 | * @param dstPort the destination port to use. |
| 25 | */ |
| 26 | public DataPathEndpoints(SwitchPort srcPort, SwitchPort dstPort) { |
| 27 | this.srcPort = srcPort; |
| 28 | this.dstPort = dstPort; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the data path source port. |
| 33 | * |
| 34 | * @return the data path source port. |
| 35 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 36 | @JsonProperty("srcPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 37 | public SwitchPort srcPort() { return srcPort; } |
| 38 | |
| 39 | /** |
| 40 | * Set the data path source port. |
| 41 | * |
| 42 | * @param srcPort the data path source port to set. |
| 43 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 44 | @JsonProperty("srcPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 45 | public void setSrcPort(SwitchPort srcPort) { |
| 46 | this.srcPort = srcPort; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get the data path destination port. |
| 51 | * |
| 52 | * @return the data path destination port. |
| 53 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 54 | @JsonProperty("dstPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 55 | public SwitchPort dstPort() { return dstPort; } |
| 56 | |
| 57 | /** |
| 58 | * Set the data path destination port. |
| 59 | * |
| 60 | * @param dstPort the data path destination port to set. |
| 61 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 62 | @JsonProperty("dstPort") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 63 | public void setDstPort(SwitchPort dstPort) { |
| 64 | this.dstPort = dstPort; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Convert the data path endpoints to a string. |
| 69 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 70 | * The string has the following form: |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 71 | * [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] | 72 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 73 | * @return the data path endpoints as a string. |
| 74 | */ |
| 75 | @Override |
| 76 | public String toString() { |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 77 | String ret = "[src=" + this.srcPort.toString() + |
| 78 | " dst=" + this.dstPort.toString() + "]"; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 79 | return ret; |
| 80 | } |
| 81 | } |