blob: ad6cdb859ac7982421c0b79f10d12f0c7ccc417a [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 -08007import net.floodlightcontroller.util.serializers.DataPathSerializer;
8
9import org.codehaus.jackson.annotate.JsonProperty;
10import org.codehaus.jackson.map.annotate.JsonSerialize;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080011
12/**
13 * The class representing the Data Path.
14 */
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080015@JsonSerialize(using=DataPathSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080016public class DataPath {
17 private SwitchPort srcPort; // The source port
18 private SwitchPort dstPort; // The destination port
19 private ArrayList<FlowEntry> flowEntries; // The Flow Entries
20
21 /**
22 * Default constructor.
23 */
24 public DataPath() {
25 }
26
27 /**
28 * Get the data path source port.
29 *
30 * @return the data path source port.
31 */
32 public SwitchPort srcPort() { return srcPort; }
33
34 /**
35 * Set the data path source port.
36 *
37 * @param srcPort the data path source port to set.
38 */
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 */
48 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 */
55 public void setDstPort(SwitchPort dstPort) {
56 this.dstPort = dstPort;
57 }
58
59 /**
60 * Get the data path flow entries.
61 *
62 * @return the data path flow entries.
63 */
64 public ArrayList<FlowEntry> flowEntries() { return flowEntries; }
65
66 /**
67 * Set the data path flow entries.
68 *
69 * @param flowEntries the data path flow entries to set.
70 */
71 public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
72 this.flowEntries = flowEntries;
73 }
74
75 /**
76 * Convert the data path to a string.
77 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080078 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080079 * [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 -080080 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080081 * @return the data path as a string.
82 */
83 @Override
84 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080085 String ret = "[src=" + this.srcPort.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080086
87 for (FlowEntry fe : flowEntries) {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080088 ret += " flowEntry=" + fe.toString();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080089 }
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080090 ret += " dst=" + this.dstPort.toString() + "]";
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080091
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080092 return ret;
93 }
94}