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