blob: 9ec938028312087693f7696ee413f9822230a5a0 [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() {
22 }
23
24 /**
25 * Get the data path source port.
26 *
27 * @return the data path source port.
28 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080029 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080030 public SwitchPort srcPort() { return srcPort; }
31
32 /**
33 * Set the data path source port.
34 *
35 * @param srcPort the data path source port to set.
36 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080037 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080038 public void setSrcPort(SwitchPort srcPort) {
39 this.srcPort = srcPort;
40 }
41
42 /**
43 * Get the data path destination port.
44 *
45 * @return the data path destination port.
46 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080047 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080048 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 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080055 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080056 public void setDstPort(SwitchPort dstPort) {
57 this.dstPort = dstPort;
58 }
59
60 /**
61 * Get the data path flow entries.
62 *
63 * @return the data path flow entries.
64 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080065 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080066 public ArrayList<FlowEntry> flowEntries() { return flowEntries; }
67
68 /**
69 * Set the data path flow entries.
70 *
71 * @param flowEntries the data path flow entries to set.
72 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080073 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080074 public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
75 this.flowEntries = flowEntries;
76 }
77
78 /**
79 * Convert the data path to a string.
80 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080081 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080082 * [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 -080083 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080084 * @return the data path as a string.
85 */
86 @Override
87 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080088 String ret = "[src=" + this.srcPort.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080089
90 for (FlowEntry fe : flowEntries) {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080091 ret += " flowEntry=" + fe.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080092 }
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080093 ret += " dst=" + this.dstPort.toString() + "]";
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080094
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080095 return ret;
96 }
97}