blob: 71e0a2f3c996810df3ddfaf63e25dc5fec76738f [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
3import java.util.ArrayList;
4
5import net.floodlightcontroller.util.SwitchPort;
6import net.floodlightcontroller.util.FlowEntry;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08007
8import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08009
10/**
11 * The class representing the Data Path.
12 */
13public 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 Radoslavovf83aa442013-02-26 14:09:01 -080022 flowEntries = new ArrayList<FlowEntry>();
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080023 }
24
25 /**
26 * Get the data path source port.
27 *
28 * @return the data path source port.
29 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080030 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080031 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 Radoslavov2013cbb2013-02-26 10:15:18 -080038 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080039 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 Radoslavov2013cbb2013-02-26 10:15:18 -080048 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080049 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 Radoslavov2013cbb2013-02-26 10:15:18 -080056 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080057 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 Radoslavov2013cbb2013-02-26 10:15:18 -080066 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080067 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 Radoslavov2013cbb2013-02-26 10:15:18 -080074 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080075 public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
76 this.flowEntries = flowEntries;
77 }
78
79 /**
80 * Convert the data path to a string.
81 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080082 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080083 * [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 Radoslavovad008e02013-02-21 18:42:42 -080084 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080085 * @return the data path as a string.
86 */
87 @Override
88 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080089 String ret = "[src=" + this.srcPort.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080090
91 for (FlowEntry fe : flowEntries) {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080092 ret += " flowEntry=" + fe.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080093 }
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080094 ret += " dst=" + this.dstPort.toString() + "]";
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080095
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080096 return ret;
97 }
98}