blob: b2dded63bce9aadc2d460e75f060dbc7359f598c [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 Radoslavovb6f53542013-03-01 16:02:14 -080022 srcPort = new SwitchPort();
23 dstPort = new SwitchPort();
Pavlin Radoslavovf83aa442013-02-26 14:09:01 -080024 flowEntries = new ArrayList<FlowEntry>();
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080025 }
26
27 /**
28 * Get the data path source port.
29 *
30 * @return the data path source port.
31 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080032 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080033 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 Radoslavov2013cbb2013-02-26 10:15:18 -080040 @JsonProperty("srcPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080041 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 Radoslavov2013cbb2013-02-26 10:15:18 -080050 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080051 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 Radoslavov2013cbb2013-02-26 10:15:18 -080058 @JsonProperty("dstPort")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080059 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 Radoslavov2013cbb2013-02-26 10:15:18 -080068 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080069 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 Radoslavov2013cbb2013-02-26 10:15:18 -080076 @JsonProperty("flowEntries")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080077 public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
78 this.flowEntries = flowEntries;
79 }
80
81 /**
82 * Convert the data path to a string.
83 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080084 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080085 * [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 -080086 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080087 * @return the data path as a string.
88 */
89 @Override
90 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080091 String ret = "[src=" + this.srcPort.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080092
93 for (FlowEntry fe : flowEntries) {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080094 ret += " flowEntry=" + fe.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080095 }
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080096 ret += " dst=" + this.dstPort.toString() + "]";
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080097
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080098 return ret;
99 }
100}