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