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.
34 * Calling {@link #sendMsg(OFMessage)} does NOT guarantee the messages to be
35 * transmitted on the wire in order, especially during role transition.
36 * The messages may be reordered at the switch side.
38 * Calling {@link #sendMsg(List)} guarantee the messages inside the list
39 * to be transmitted on the wire in order.
41 * @param msg the message to write
43 void sendMsg(OFMessage msg);
46 * Writes the OFMessage list to the driver.
48 * @param msgs the messages to be written
50 void sendMsg(List<OFMessage> msgs);
53 * Handle a message from the switch.
54 * @param fromSwitch the message to handle
56 void handleMessage(OFMessage fromSwitch);
59 * Sets the role for this switch.
60 * @param role the role to set.
62 void setRole(RoleState role);
65 * Fetch the role for this switch.
71 * Fetches the ports of this switch.
72 * @return unmodifiable list of the ports.
74 List<OFPortDesc> getPorts();
77 * Provides the factory for this OF version.
78 * @return OF version specific factory.
83 * Gets a string version of the ID for this switch.
85 * @return string version of the ID
90 * Gets the datapathId of the switch.
92 * @return the switch dpid in long format
97 * fetch the manufacturer description.
98 * @return the description
100 String manufacturerDescription();
103 * fetch the datapath description.
104 * @return the description
106 String datapathDescription();
109 * fetch the hardware description.
110 * @return the description
112 String hardwareDescription();
115 * fetch the software description.
116 * @return the description
118 String softwareDescription();
121 * fetch the serial number.
124 String serialNumber();
127 * Checks if the switch is still connected.
129 * @return whether the switch is still connected
131 boolean isConnected();
134 * Disconnects the switch by closing the TCP connection. Results in a call
135 * to the channel handler's channelDisconnected method for cleanup
137 void disconnectSwitch();
140 * Notifies the controller that the device has responded to a set-role request.
142 * @param requested the role requested by the controller
143 * @param response the role set at the device
145 void returnRoleReply(RoleState requested, RoleState response);
148 * Returns the switch device type.
150 * @return device type
152 Device.Type deviceType();
155 * Identifies the channel used to communicate with the switch.
157 * @return string representation of the connection to the device