blob: f8fefd3b5c815752b728e6a459409bedbaf26222 [file] [log] [blame]
Ray Milkey7f9e0202015-11-04 17:14:09 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Ray Milkey7f9e0202015-11-04 17:14:09 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.openflow;
17
Ray Milkey7f9e0202015-11-04 17:14:09 -080018import org.onosproject.net.Device;
19import org.onosproject.net.driver.DriverData;
20import org.onosproject.net.driver.DriverHandler;
21import org.onosproject.openflow.controller.Dpid;
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -070022import org.onosproject.openflow.controller.OpenFlowSession;
Ray Milkey7f9e0202015-11-04 17:14:09 -080023import org.onosproject.openflow.controller.RoleState;
24import org.onosproject.openflow.controller.driver.OpenFlowAgent;
25import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
26import org.onosproject.openflow.controller.driver.RoleHandler;
27import org.onosproject.openflow.controller.driver.SwitchStateException;
28import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
29import org.projectfloodlight.openflow.protocol.OFErrorMsg;
30import org.projectfloodlight.openflow.protocol.OFFactories;
31import org.projectfloodlight.openflow.protocol.OFFactory;
32import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
33import org.projectfloodlight.openflow.protocol.OFMessage;
Jordi Ortizaa8de492016-12-01 00:21:36 +010034import org.projectfloodlight.openflow.protocol.OFMeterFeatures;
Jordi Ortiz91477b82016-11-29 15:22:50 +010035import org.projectfloodlight.openflow.protocol.OFMeterFeaturesStatsReply;
Ray Milkey7f9e0202015-11-04 17:14:09 -080036import org.projectfloodlight.openflow.protocol.OFPortDesc;
37import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
38import org.projectfloodlight.openflow.protocol.OFVersion;
39
Jian Lia78cdb22016-04-21 13:03:58 -070040import java.util.List;
pier7f292e72019-07-16 15:52:50 +020041import java.util.Set;
Jian Lia78cdb22016-04-21 13:03:58 -070042
Ray Milkey7f9e0202015-11-04 17:14:09 -080043/**
44 * Testing adapter for the OpenFlow switch driver class.
45 */
46public class OpenflowSwitchDriverAdapter implements OpenFlowSwitchDriver {
Ray Milkeyca20bb52015-11-10 13:59:16 -080047
48 RoleState role = RoleState.MASTER;
pier7f292e72019-07-16 15:52:50 +020049 // state of the connection
50 private Set<Dpid> connected;
51 private Dpid myDpid;
52 private boolean complete;
53
54 public OpenflowSwitchDriverAdapter() {
55 }
56
57 public OpenflowSwitchDriverAdapter(Set<Dpid> connected, Dpid myDpid, boolean complete) {
58 this.connected = connected;
59 this.myDpid = myDpid;
60 this.complete = complete;
61 }
Ray Milkeyca20bb52015-11-10 13:59:16 -080062
Ray Milkey7f9e0202015-11-04 17:14:09 -080063 @Override
64 public void setAgent(OpenFlowAgent agent) {
65
66 }
67
68 @Override
69 public void setRoleHandler(RoleHandler roleHandler) {
70
71 }
72
73 @Override
74 public void reassertRole() {
75
76 }
77
78 @Override
79 public boolean handleRoleError(OFErrorMsg error) {
80 return false;
81 }
82
83 @Override
84 public void handleNiciraRole(OFMessage m) throws SwitchStateException {
85
86 }
87
88 @Override
89 public void handleRole(OFMessage m) throws SwitchStateException {
90
91 }
92
93 @Override
94 public boolean connectSwitch() {
pier7f292e72019-07-16 15:52:50 +020095 return !connected.contains(myDpid);
Ray Milkey7f9e0202015-11-04 17:14:09 -080096 }
97
98 @Override
99 public boolean activateMasterSwitch() {
100 return false;
101 }
102
103 @Override
104 public boolean activateEqualSwitch() {
105 return false;
106 }
107
108 @Override
109 public void transitionToEqualSwitch() {
110
111 }
112
113 @Override
114 public void transitionToMasterSwitch() {
115
116 }
117
118 @Override
119 public void removeConnectedSwitch() {
120
121 }
122
123 @Override
124 public void setPortDescReply(OFPortDescStatsReply portDescReply) {
125
126 }
127
128 @Override
129 public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
130
131 }
132
133 @Override
134 public void setFeaturesReply(OFFeaturesReply featuresReply) {
135
136 }
137
138 @Override
Jordi Ortiz91477b82016-11-29 15:22:50 +0100139 public void setMeterFeaturesReply(OFMeterFeaturesStatsReply meterFeaturesReply) {
140
141 }
142
143 @Override
Ray Milkey7f9e0202015-11-04 17:14:09 -0800144 public void setSwitchDescription(OFDescStatsReply desc) {
145
146 }
147
148 @Override
149 public int getNextTransactionId() {
150 return 0;
151 }
152
153 @Override
154 public void setOFVersion(OFVersion ofV) {
155
156 }
157
158 @Override
159 public void setTableFull(boolean full) {
160
161 }
162
163 @Override
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700164 public void setChannel(OpenFlowSession channel) {
Ray Milkey7f9e0202015-11-04 17:14:09 -0800165
166 }
167
168 @Override
169 public void setConnected(boolean connected) {
170
171 }
172
173 @Override
174 public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) {
175
176 }
177
178 @Override
179 public Boolean supportNxRole() {
180 return true;
181 }
182
183 @Override
184 public void startDriverHandshake() {
185
186 }
187
188 @Override
189 public boolean isDriverHandshakeComplete() {
pier7f292e72019-07-16 15:52:50 +0200190 return complete;
Ray Milkey7f9e0202015-11-04 17:14:09 -0800191 }
192
193 @Override
194 public void processDriverHandshakeMessage(OFMessage m) {
pier7f292e72019-07-16 15:52:50 +0200195 complete = true;
Ray Milkey7f9e0202015-11-04 17:14:09 -0800196 }
197
198 @Override
199 public void sendRoleRequest(OFMessage message) {
200
201 }
202
203 @Override
204 public void sendHandshakeMessage(OFMessage message) {
205
206 }
207
208 @Override
209 public DriverHandler handler() {
210 return null;
211 }
212
213 @Override
214 public void setHandler(DriverHandler handler) {
215
216 }
217
218 @Override
219 public DriverData data() {
220 return null;
221 }
222
223 @Override
224 public void setData(DriverData data) {
225
226 }
227
228 @Override
229 public void sendMsg(OFMessage msg) {
230
231 }
232
233 @Override
234 public void sendMsg(List<OFMessage> msgs) {
235
236 }
237
238 @Override
239 public void handleMessage(OFMessage fromSwitch) {
240
241 }
242
243 @Override
244 public void setRole(RoleState role) {
Ray Milkeyca20bb52015-11-10 13:59:16 -0800245 this.role = role;
Ray Milkey7f9e0202015-11-04 17:14:09 -0800246 }
247
248 @Override
249 public RoleState getRole() {
Ray Milkeyca20bb52015-11-10 13:59:16 -0800250 return role;
Ray Milkey7f9e0202015-11-04 17:14:09 -0800251 }
252
253 @Override
254 public List<OFPortDesc> getPorts() {
255 return null;
256 }
257
258 @Override
Jordi Ortizaa8de492016-12-01 00:21:36 +0100259 public OFMeterFeatures getMeterFeatures() {
260 return null;
261 }
262
263 @Override
Ray Milkey7f9e0202015-11-04 17:14:09 -0800264 public OFFactory factory() {
265 // return what-ever triggers requestPending = true
266 return OFFactories.getFactory(OFVersion.OF_10);
267 }
268
269 @Override
270 public String getStringId() {
271 return "100";
272 }
273
274 @Override
275 public long getId() {
276 return 0;
277 }
278
279 @Override
280 public String manufacturerDescription() {
281 return null;
282 }
283
284 @Override
285 public String datapathDescription() {
286 return null;
287 }
288
289 @Override
290 public String hardwareDescription() {
291 return null;
292 }
293
294 @Override
295 public String softwareDescription() {
296 return null;
297 }
298
299 @Override
300 public String serialNumber() {
301 return null;
302 }
303
304 @Override
305 public boolean isConnected() {
306 return false;
307 }
308
309 @Override
310 public void disconnectSwitch() {
311
312 }
313
314 @Override
315 public void returnRoleReply(RoleState requested, RoleState response) {
316
317 }
318
319 @Override
320 public Device.Type deviceType() {
321 return Device.Type.SWITCH;
322 }
323
324 @Override
325 public String channelId() {
326 return null;
327 }
Ray Milkey7f9e0202015-11-04 17:14:09 -0800328}