Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | |
| 5 | import net.floodlightcontroller.util.SwitchPort; |
| 6 | import net.floodlightcontroller.util.FlowEntry; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 7 | import net.floodlightcontroller.util.serializers.DataPathSerializer; |
| 8 | |
| 9 | import org.codehaus.jackson.annotate.JsonProperty; |
| 10 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 11 | |
| 12 | /** |
| 13 | * The class representing the Data Path. |
| 14 | */ |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 15 | @JsonSerialize(using=DataPathSerializer.class) |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 16 | public class DataPath { |
| 17 | private SwitchPort srcPort; // The source port |
| 18 | private SwitchPort dstPort; // The destination port |
| 19 | private ArrayList<FlowEntry> flowEntries; // The Flow Entries |
| 20 | |
| 21 | /** |
| 22 | * Default constructor. |
| 23 | */ |
| 24 | public DataPath() { |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Get the data path source port. |
| 29 | * |
| 30 | * @return the data path source port. |
| 31 | */ |
| 32 | public SwitchPort srcPort() { return srcPort; } |
| 33 | |
| 34 | /** |
| 35 | * Set the data path source port. |
| 36 | * |
| 37 | * @param srcPort the data path source port to set. |
| 38 | */ |
| 39 | public void setSrcPort(SwitchPort srcPort) { |
| 40 | this.srcPort = srcPort; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Get the data path destination port. |
| 45 | * |
| 46 | * @return the data path destination port. |
| 47 | */ |
| 48 | public SwitchPort dstPort() { return dstPort; } |
| 49 | |
| 50 | /** |
| 51 | * Set the data path destination port. |
| 52 | * |
| 53 | * @param dstPort the data path destination port to set. |
| 54 | */ |
| 55 | public void setDstPort(SwitchPort dstPort) { |
| 56 | this.dstPort = dstPort; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the data path flow entries. |
| 61 | * |
| 62 | * @return the data path flow entries. |
| 63 | */ |
| 64 | public ArrayList<FlowEntry> flowEntries() { return flowEntries; } |
| 65 | |
| 66 | /** |
| 67 | * Set the data path flow entries. |
| 68 | * |
| 69 | * @param flowEntries the data path flow entries to set. |
| 70 | */ |
| 71 | public void setFlowEntries(ArrayList<FlowEntry> flowEntries) { |
| 72 | this.flowEntries = flowEntries; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Convert the data path to a string. |
| 77 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 78 | * The string has the following form: |
| 79 | * [src:01:01:01:01:01:01:01:01/1111 flowEntry:<entry1> flowEntry:<entry2> flowEntry:<entry3> dst:02:02:02:02:02:02:02:02/2222] |
| 80 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 81 | * @return the data path as a string. |
| 82 | */ |
| 83 | @Override |
| 84 | public String toString() { |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 85 | String ret = "[src:" + this.srcPort.toString(); |
| 86 | |
| 87 | for (FlowEntry fe : flowEntries) { |
| 88 | ret += " flowEntry:" + fe.toString(); |
| 89 | } |
| 90 | ret += " dst:" + this.dstPort.toString() + "]"; |
| 91 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 92 | return ret; |
| 93 | } |
| 94 | } |