2 * Copyright 2014-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.controller;
18 import org.onosproject.net.Device;
19 import org.projectfloodlight.openflow.protocol.OFFactory;
20 import org.projectfloodlight.openflow.protocol.OFMessage;
21 import org.projectfloodlight.openflow.protocol.OFPortDesc;
23 import java.util.List;
26 * Represents to provider facing side of a switch.
28 public interface OpenFlowSwitch {
31 * Writes the message to the driver.
33 * @param msg the message to write
35 void sendMsg(OFMessage msg);
38 * Writes the OFMessage list to the driver.
40 * @param msgs the messages to be written
42 void sendMsg(List<OFMessage> msgs);
45 * Handle a message from the switch.
46 * @param fromSwitch the message to handle
48 void handleMessage(OFMessage fromSwitch);
51 * Sets the role for this switch.
52 * @param role the role to set.
54 void setRole(RoleState role);
57 * Fetch the role for this switch.
63 * Fetches the ports of this switch.
64 * @return unmodifiable list of the ports.
66 List<OFPortDesc> getPorts();
69 * Provides the factory for this OF version.
70 * @return OF version specific factory.
75 * Gets a string version of the ID for this switch.
77 * @return string version of the ID
82 * Gets the datapathId of the switch.
84 * @return the switch dpid in long format
89 * fetch the manufacturer description.
90 * @return the description
92 String manufacturerDescription();
95 * fetch the datapath description.
96 * @return the description
98 String datapathDescription();
101 * fetch the hardware description.
102 * @return the description
104 String hardwareDescription();
107 * fetch the software description.
108 * @return the description
110 String softwareDescription();
113 * fetch the serial number.
116 String serialNumber();
119 * Checks if the switch is still connected.
121 * @return whether the switch is still connected
123 boolean isConnected();
126 * Disconnects the switch by closing the TCP connection. Results in a call
127 * to the channel handler's channelDisconnected method for cleanup
129 void disconnectSwitch();
132 * Notifies the controller that the device has responded to a set-role request.
134 * @param requested the role requested by the controller
135 * @param response the role set at the device
137 void returnRoleReply(RoleState requested, RoleState response);
140 * Returns the switch device type.
142 * @return device type
144 Device.Type deviceType();
147 * Identifies the channel used to communicate with the switch.
149 * @return string representation of the connection to the device