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