blob: b6ec57442a7138e2e47ea451454d8dbbfc470e47 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.openflow.controller;
tom7ef8ff92014-09-17 13:08:06 -070017
Marc De Leenheerb9311372015-07-09 11:36:49 -070018import org.onosproject.net.Device;
tom7ef8ff92014-09-17 13:08:06 -070019import org.projectfloodlight.openflow.protocol.OFFactory;
20import org.projectfloodlight.openflow.protocol.OFMessage;
21import org.projectfloodlight.openflow.protocol.OFPortDesc;
alshabibb452fd72015-04-22 20:46:20 -070022
23import java.util.List;
tom7ef8ff92014-09-17 13:08:06 -070024
25/**
26 * Represents to provider facing side of a switch.
27 */
28public interface OpenFlowSwitch {
29
30 /**
31 * Writes the message to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080032 * <p>
33 * Note: Messages may be silently dropped/lost due to IOExceptions or
34 * role. If this is a concern, then a caller should use barriers.
35 * </p>
Charles Chan5b7ec342015-10-18 20:55:41 -070036 *
tom7ef8ff92014-09-17 13:08:06 -070037 * @param msg the message to write
38 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070039 void sendMsg(OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -070040
41 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080042 * Writes the OFMessage list to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080043 * <p>
44 * Note: Messages may be silently dropped/lost due to IOExceptions or
45 * role. If this is a concern, then a caller should use barriers.
46 * </p>
tom7ef8ff92014-09-17 13:08:06 -070047 *
48 * @param msgs the messages to be written
49 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070050 void sendMsg(List<OFMessage> msgs);
tom7ef8ff92014-09-17 13:08:06 -070051
52 /**
53 * Handle a message from the switch.
54 * @param fromSwitch the message to handle
55 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070056 void handleMessage(OFMessage fromSwitch);
tom7ef8ff92014-09-17 13:08:06 -070057
58 /**
59 * Sets the role for this switch.
60 * @param role the role to set.
61 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070062 void setRole(RoleState role);
tom7ef8ff92014-09-17 13:08:06 -070063
64 /**
65 * Fetch the role for this switch.
66 * @return the role.
67 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070068 RoleState getRole();
tom7ef8ff92014-09-17 13:08:06 -070069
70 /**
71 * Fetches the ports of this switch.
72 * @return unmodifiable list of the ports.
73 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070074 List<OFPortDesc> getPorts();
tom7ef8ff92014-09-17 13:08:06 -070075
76 /**
77 * Provides the factory for this OF version.
78 * @return OF version specific factory.
79 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070080 OFFactory factory();
tom7ef8ff92014-09-17 13:08:06 -070081
82 /**
83 * Gets a string version of the ID for this switch.
84 *
85 * @return string version of the ID
86 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070087 String getStringId();
tom7ef8ff92014-09-17 13:08:06 -070088
89 /**
90 * Gets the datapathId of the switch.
91 *
92 * @return the switch dpid in long format
93 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070094 long getId();
tom7ef8ff92014-09-17 13:08:06 -070095
96 /**
97 * fetch the manufacturer description.
98 * @return the description
99 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700100 String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700101
102 /**
103 * fetch the datapath description.
104 * @return the description
105 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700106 String datapathDescription();
tom7ef8ff92014-09-17 13:08:06 -0700107
108 /**
109 * fetch the hardware description.
110 * @return the description
111 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700112 String hardwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700113
114 /**
115 * fetch the software description.
116 * @return the description
117 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700118 String softwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700119
120 /**
121 * fetch the serial number.
122 * @return the serial
123 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700124 String serialNumber();
tom7ef8ff92014-09-17 13:08:06 -0700125
126 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700127 * Checks if the switch is still connected.
128 *
129 * @return whether the switch is still connected
130 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700131 boolean isConnected();
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700132
133 /**
tom7ef8ff92014-09-17 13:08:06 -0700134 * Disconnects the switch by closing the TCP connection. Results in a call
135 * to the channel handler's channelDisconnected method for cleanup
136 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700137 void disconnectSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700138
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700139 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700140 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700141 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700142 * @param requested the role requested by the controller
143 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700144 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700145 void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700146
147 /**
Marc De Leenheerb9311372015-07-09 11:36:49 -0700148 * Returns the switch device type.
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700149 *
Marc De Leenheerb9311372015-07-09 11:36:49 -0700150 * @return device type
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700151 */
Marc De Leenheerb9311372015-07-09 11:36:49 -0700152 Device.Type deviceType();
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700153
Ray Milkeye53f1712015-01-16 09:17:16 -0800154 /**
155 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800156 *
157 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800158 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700159 String channelId();
tom7ef8ff92014-09-17 13:08:06 -0700160}