2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.openflow;
18 import java.util.List;
20 import org.jboss.netty.channel.Channel;
21 import org.onosproject.net.Device;
22 import org.onosproject.net.driver.DriverData;
23 import org.onosproject.net.driver.DriverHandler;
24 import org.onosproject.openflow.controller.Dpid;
25 import org.onosproject.openflow.controller.RoleState;
26 import org.onosproject.openflow.controller.driver.OpenFlowAgent;
27 import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
28 import org.onosproject.openflow.controller.driver.RoleHandler;
29 import org.onosproject.openflow.controller.driver.SwitchStateException;
30 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
31 import org.projectfloodlight.openflow.protocol.OFErrorMsg;
32 import org.projectfloodlight.openflow.protocol.OFFactories;
33 import org.projectfloodlight.openflow.protocol.OFFactory;
34 import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
35 import org.projectfloodlight.openflow.protocol.OFMessage;
36 import org.projectfloodlight.openflow.protocol.OFPortDesc;
37 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
38 import org.projectfloodlight.openflow.protocol.OFVersion;
41 * Testing adapter for the OpenFlow switch driver class.
43 public class OpenflowSwitchDriverAdapter implements OpenFlowSwitchDriver {
45 public void setAgent(OpenFlowAgent agent) {
50 public void setRoleHandler(RoleHandler roleHandler) {
55 public void reassertRole() {
60 public boolean handleRoleError(OFErrorMsg error) {
65 public void handleNiciraRole(OFMessage m) throws SwitchStateException {
70 public void handleRole(OFMessage m) throws SwitchStateException {
75 public boolean connectSwitch() {
80 public boolean activateMasterSwitch() {
85 public boolean activateEqualSwitch() {
90 public void transitionToEqualSwitch() {
95 public void transitionToMasterSwitch() {
100 public void removeConnectedSwitch() {
105 public void setPortDescReply(OFPortDescStatsReply portDescReply) {
110 public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
115 public void setFeaturesReply(OFFeaturesReply featuresReply) {
120 public void setSwitchDescription(OFDescStatsReply desc) {
125 public int getNextTransactionId() {
130 public void setOFVersion(OFVersion ofV) {
135 public void setTableFull(boolean full) {
140 public void setChannel(Channel channel) {
145 public void setConnected(boolean connected) {
150 public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) {
155 public Boolean supportNxRole() {
160 public void startDriverHandshake() {
165 public boolean isDriverHandshakeComplete() {
170 public void processDriverHandshakeMessage(OFMessage m) {
175 public void sendRoleRequest(OFMessage message) {
180 public void sendHandshakeMessage(OFMessage message) {
185 public DriverHandler handler() {
190 public void setHandler(DriverHandler handler) {
195 public DriverData data() {
200 public void setData(DriverData data) {
205 public void sendMsg(OFMessage msg) {
210 public void sendMsg(List<OFMessage> msgs) {
215 public void handleMessage(OFMessage fromSwitch) {
220 public void setRole(RoleState role) {
225 public RoleState getRole() {
230 public List<OFPortDesc> getPorts() {
235 public OFFactory factory() {
236 // return what-ever triggers requestPending = true
237 return OFFactories.getFactory(OFVersion.OF_10);
241 public String getStringId() {
246 public long getId() {
251 public String manufacturerDescription() {
256 public String datapathDescription() {
261 public String hardwareDescription() {
266 public String softwareDescription() {
271 public String serialNumber() {
276 public boolean isConnected() {
281 public void disconnectSwitch() {
286 public void returnRoleReply(RoleState requested, RoleState response) {
291 public Device.Type deviceType() {
292 return Device.Type.SWITCH;
296 public String channelId() {