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