blob: 77a2a13f0aa80f22951d90ece419875d7203d1b7 [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.api.intent;
2
Sho SHIMIZU54739912014-07-21 18:55:39 -07003import net.onrc.onos.core.matchaction.match.PacketMatch;
4import net.onrc.onos.core.util.SwitchPort;
5
Toshio Koidea03915e2014-07-01 18:39:52 -07006import java.util.Collection;
7import java.util.Collections;
8import java.util.HashSet;
Toshio Koidea03915e2014-07-01 18:39:52 -07009import java.util.Set;
10
Toshio Koidea03915e2014-07-01 18:39:52 -070011/**
12 * A packet layer Intent for a connectivity from a set of ports to a set of
13 * ports.
14 * <p>
15 * TODO: Design methods to support the ReactiveForwarding and the SDN-IP. <br>
16 * NOTE: Should this class support modifier methods? Should this object a
17 * read-only object?
18 */
19public class PacketConnectivityIntent extends Intent {
20 protected Set<SwitchPort> srcSwitchPorts;
21 protected PacketMatch match;
22 protected Set<SwitchPort> dstSwitchPorts;
23 protected boolean canSetupOpticalFlow;
24 protected int idleTimeoutValue;
25 protected int hardTimeoutValue;
26
27 /**
28 * Creates a connectivity intent for the packet layer.
29 * <p>
30 * When the "canSetupOpticalFlow" option is true, this intent will compute
31 * the packet/optical converged path, decompose it to the OpticalPathFlow
32 * and the PacketPathFlow objects, and execute the operations to add them
33 * considering the dependency between the packet and optical layers.
34 *
35 * @param id ID for this new Intent object.
36 * @param srcSwitchPorts The set of source switch ports.
37 * @param match Traffic specifier for this object.
38 * @param dstSwitchPorts The set of destination switch ports.
39 * @param canSetupOpticalFlow The flag whether this intent can create
40 * optical flows if needed.
41 */
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -070042 public PacketConnectivityIntent(IntentId id,
Toshio Koidea03915e2014-07-01 18:39:52 -070043 Collection<SwitchPort> srcSwitchPorts, PacketMatch match,
44 Collection<SwitchPort> dstSwitchPorts, boolean canSetupOpticalFlow) {
45 super(id);
46 this.srcSwitchPorts = new HashSet<SwitchPort>(srcSwitchPorts);
47 this.match = match;
48 this.dstSwitchPorts = new HashSet<SwitchPort>(dstSwitchPorts);
49 this.canSetupOpticalFlow = canSetupOpticalFlow;
50 this.idleTimeoutValue = 0;
51 this.hardTimeoutValue = 0;
52
53 // TODO: check consistency between these parameters.
54 }
55
56 /**
57 * Gets the set of source switch ports.
58 *
59 * @return the set of source switch ports.
60 */
61 public Collection<SwitchPort> getSrcSwitchPorts() {
62 return Collections.unmodifiableCollection(srcSwitchPorts);
63 }
64
65 /**
66 * Gets the traffic specifier.
67 *
68 * @return The traffic specifier.
69 */
70 public PacketMatch getMatch() {
71 return match;
72 }
73
74 /**
75 * Gets the set of destination switch ports.
76 *
77 * @return the set of destination switch ports.
78 */
79 public Collection<SwitchPort> getDstSwitchPorts() {
80 return Collections.unmodifiableCollection(dstSwitchPorts);
81 }
82
83 /**
84 * Adds the specified port to the set of source ports.
85 *
86 * @param port SwitchPort object to be added
87 */
88 public void addSrcSwitchPort(SwitchPort port) {
89 // TODO implement it.
90 }
91
92 /**
93 * Adds the specified port to the set of destination ports.
94 *
95 * @param port SwitchPort object to be added
96 */
97 public void addDstSwitchPort(SwitchPort port) {
98 // TODO implement it.
99 }
100
101 /**
102 * Removes the specified port from the set of source ports.
103 *
104 * @param port SwitchPort object to be removed
105 */
106 public void removeSrcSwitchPort(SwitchPort port) {
107 // TODO implement it.
108 }
109
110 /**
111 * Removes the specified port from the set of destination ports.
112 *
113 * @param port SwitchPort object to be removed
114 */
115 public void removeDstSwitchPort(SwitchPort port) {
116 // TODO implement it.
117 }
118
119 /**
120 * Sets idle-timeout value.
121 *
122 * @param timeout Idle-timeout value (seconds)
123 */
124 public void setIdleTimeout(int timeout) {
125 idleTimeoutValue = timeout;
126 }
127
128 /**
129 * Sets hard-timeout value.
130 *
131 * @param timeout Hard-timeout value (seconds)
132 */
133 public void setHardTimeout(int timeout) {
134 hardTimeoutValue = timeout;
135 }
136
137 /**
138 * Gets idle-timeout value.
139 *
140 * @return Idle-timeout value (seconds)
141 */
142 public int getIdleTimeout() {
143 return idleTimeoutValue;
144 }
145
146 /**
147 * Gets hard-timeout value.
148 *
149 * @return Hard-timeout value (seconds)
150 */
151 public int getHardTimeout() {
152 return hardTimeoutValue;
153 }
154
155 /**
156 * Returns whether this intent can create optical flows if needed.
157 *
158 * @return whether this intent can create optical flows.
159 */
160 public boolean canSetupOpticalFlow() {
161 return canSetupOpticalFlow;
162 }
Toshio Koidea03915e2014-07-01 18:39:52 -0700163}