blob: 893d70e852650a171409ea16d8bca0e729a6c092 [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
3import java.util.Collection;
4import java.util.Collections;
5import java.util.HashSet;
6import java.util.Set;
7
8import org.onlab.onos.net.ConnectPoint;
9import org.onlab.onos.net.flow.TrafficSelector;
10
11// TODO: consider if this intent should be sub-class of Connectivity intent
12/**
13 * A packet layer Intent for a connectivity from a set of ports to a set of
14 * ports.
15 * <p>
16 * TODO: Design methods to support the ReactiveForwarding and the SDN-IP. <br>
17 * NOTE: Should this class support modifier methods? Should this object a
18 * read-only object?
19 */
20public class PacketConnectivityIntent extends AbstractIntent {
21 protected Set<ConnectPoint> srcConnectPoints;
22 protected TrafficSelector selector;
23 protected Set<ConnectPoint> dstConnectPoints;
24 protected boolean canSetupOpticalFlow;
25 protected int idleTimeoutValue;
26 protected int hardTimeoutValue;
27
28 /**
29 * Creates a connectivity intent for the packet layer.
30 * <p>
31 * When the "canSetupOpticalFlow" option is true, this intent will compute
32 * the packet/optical converged path, decompose it to the OpticalPathFlow
33 * and the PacketPathFlow objects, and execute the operations to add them
34 * considering the dependency between the packet and optical layers.
35 *
36 * @param id ID for this new Intent object.
37 * @param srcConnectPoints The set of source switch ports.
38 * @param match Traffic specifier for this object.
39 * @param dstConnectPoints The set of destination switch ports.
40 * @param canSetupOpticalFlow The flag whether this intent can create
41 * optical flows if needed.
42 */
43 public PacketConnectivityIntent(IntentId id,
44 Collection<ConnectPoint> srcConnectPoints, TrafficSelector match,
45 Collection<ConnectPoint> dstConnectPoints, boolean canSetupOpticalFlow) {
46 super(id);
47 this.srcConnectPoints = new HashSet<ConnectPoint>(srcConnectPoints);
48 this.selector = match;
49 this.dstConnectPoints = new HashSet<ConnectPoint>(dstConnectPoints);
50 this.canSetupOpticalFlow = canSetupOpticalFlow;
51 this.idleTimeoutValue = 0;
52 this.hardTimeoutValue = 0;
53
54 // TODO: check consistency between these parameters.
55 }
56
57 /**
58 * Constructor for serializer.
59 */
60 protected PacketConnectivityIntent() {
61 super();
62 this.srcConnectPoints = null;
63 this.selector = null;
64 this.dstConnectPoints = null;
65 this.canSetupOpticalFlow = false;
66 this.idleTimeoutValue = 0;
67 this.hardTimeoutValue = 0;
68 }
69
70 /**
71 * Gets the set of source switch ports.
72 *
73 * @return the set of source switch ports.
74 */
75 public Collection<ConnectPoint> getSrcConnectPoints() {
76 return Collections.unmodifiableCollection(srcConnectPoints);
77 }
78
79 /**
80 * Gets the traffic specifier.
81 *
82 * @return The traffic specifier.
83 */
84 public TrafficSelector getMatch() {
85 return selector;
86 }
87
88 /**
89 * Gets the set of destination switch ports.
90 *
91 * @return the set of destination switch ports.
92 */
93 public Collection<ConnectPoint> getDstConnectPoints() {
94 return Collections.unmodifiableCollection(dstConnectPoints);
95 }
96
97 /**
98 * Adds the specified port to the set of source ports.
99 *
100 * @param port ConnectPoint object to be added
101 */
102 public void addSrcConnectPoint(ConnectPoint port) {
103 // TODO implement it.
104 }
105
106 /**
107 * Adds the specified port to the set of destination ports.
108 *
109 * @param port ConnectPoint object to be added
110 */
111 public void addDstConnectPoint(ConnectPoint port) {
112 // TODO implement it.
113 }
114
115 /**
116 * Removes the specified port from the set of source ports.
117 *
118 * @param port ConnectPoint object to be removed
119 */
120 public void removeSrcConnectPoint(ConnectPoint port) {
121 // TODO implement it.
122 }
123
124 /**
125 * Removes the specified port from the set of destination ports.
126 *
127 * @param port ConnectPoint object to be removed
128 */
129 public void removeDstConnectPoint(ConnectPoint port) {
130 // TODO implement it.
131 }
132
133 /**
134 * Sets idle-timeout value.
135 *
136 * @param timeout Idle-timeout value (seconds)
137 */
138 public void setIdleTimeout(int timeout) {
139 idleTimeoutValue = timeout;
140 }
141
142 /**
143 * Sets hard-timeout value.
144 *
145 * @param timeout Hard-timeout value (seconds)
146 */
147 public void setHardTimeout(int timeout) {
148 hardTimeoutValue = timeout;
149 }
150
151 /**
152 * Gets idle-timeout value.
153 *
154 * @return Idle-timeout value (seconds)
155 */
156 public int getIdleTimeout() {
157 return idleTimeoutValue;
158 }
159
160 /**
161 * Gets hard-timeout value.
162 *
163 * @return Hard-timeout value (seconds)
164 */
165 public int getHardTimeout() {
166 return hardTimeoutValue;
167 }
168
169 /**
170 * Returns whether this intent can create optical flows if needed.
171 *
172 * @return whether this intent can create optical flows.
173 */
174 public boolean canSetupOpticalFlow() {
175 return canSetupOpticalFlow;
176 }
177}