blob: f3e32abe4fb45253a1b7ad479bb358b328961146 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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;
Laszlo Pappedadbe22017-12-14 20:05:49 +000020import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
tom7ef8ff92014-09-17 13:08:06 -070021import org.projectfloodlight.openflow.protocol.OFMessage;
Jordi Ortizaa8de492016-12-01 00:21:36 +010022import org.projectfloodlight.openflow.protocol.OFMeterFeatures;
tom7ef8ff92014-09-17 13:08:06 -070023import org.projectfloodlight.openflow.protocol.OFPortDesc;
alshabibb452fd72015-04-22 20:46:20 -070024
25import java.util.List;
tom7ef8ff92014-09-17 13:08:06 -070026
27/**
28 * Represents to provider facing side of a switch.
29 */
30public interface OpenFlowSwitch {
31
32 /**
33 * Writes the message to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080034 * <p>
35 * Note: Messages may be silently dropped/lost due to IOExceptions or
36 * role. If this is a concern, then a caller should use barriers.
37 * </p>
Charles Chan5b7ec342015-10-18 20:55:41 -070038 *
tom7ef8ff92014-09-17 13:08:06 -070039 * @param msg the message to write
40 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070041 void sendMsg(OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -070042
43 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080044 * Writes the OFMessage list to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080045 * <p>
46 * Note: Messages may be silently dropped/lost due to IOExceptions or
47 * role. If this is a concern, then a caller should use barriers.
48 * </p>
tom7ef8ff92014-09-17 13:08:06 -070049 *
50 * @param msgs the messages to be written
51 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070052 void sendMsg(List<OFMessage> msgs);
tom7ef8ff92014-09-17 13:08:06 -070053
54 /**
55 * Handle a message from the switch.
56 * @param fromSwitch the message to handle
57 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070058 void handleMessage(OFMessage fromSwitch);
tom7ef8ff92014-09-17 13:08:06 -070059
60 /**
61 * Sets the role for this switch.
62 * @param role the role to set.
63 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070064 void setRole(RoleState role);
tom7ef8ff92014-09-17 13:08:06 -070065
66 /**
67 * Fetch the role for this switch.
68 * @return the role.
69 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070070 RoleState getRole();
tom7ef8ff92014-09-17 13:08:06 -070071
72 /**
73 * Fetches the ports of this switch.
74 * @return unmodifiable list of the ports.
75 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070076 List<OFPortDesc> getPorts();
tom7ef8ff92014-09-17 13:08:06 -070077
78 /**
Jordi Ortizaa8de492016-12-01 00:21:36 +010079 * Fetches the meter features of this switch.
80 * @return unmodifiable meter features
81 */
82 OFMeterFeatures getMeterFeatures();
83
84 /**
Laszlo Pappedadbe22017-12-14 20:05:49 +000085 * Fetches the features of this switch.
86 * @return unmodifiable features
87 */
88 default OFFeaturesReply features() {
89 return null;
90 }
91
92 /**
tom7ef8ff92014-09-17 13:08:06 -070093 * Provides the factory for this OF version.
94 * @return OF version specific factory.
95 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070096 OFFactory factory();
tom7ef8ff92014-09-17 13:08:06 -070097
98 /**
99 * Gets a string version of the ID for this switch.
100 *
101 * @return string version of the ID
102 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700103 String getStringId();
tom7ef8ff92014-09-17 13:08:06 -0700104
105 /**
106 * Gets the datapathId of the switch.
107 *
108 * @return the switch dpid in long format
109 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700110 long getId();
tom7ef8ff92014-09-17 13:08:06 -0700111
112 /**
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700113 * Gets the datapathId of the switch.
114 *
115 * @return the switch dpid
116 */
117 default Dpid getDpid() {
118 return new Dpid(getId());
119 }
120
121 /**
tom7ef8ff92014-09-17 13:08:06 -0700122 * fetch the manufacturer description.
123 * @return the description
124 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700125 String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700126
127 /**
128 * fetch the datapath description.
129 * @return the description
130 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700131 String datapathDescription();
tom7ef8ff92014-09-17 13:08:06 -0700132
133 /**
134 * fetch the hardware description.
135 * @return the description
136 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700137 String hardwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700138
139 /**
140 * fetch the software description.
141 * @return the description
142 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700143 String softwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700144
145 /**
146 * fetch the serial number.
147 * @return the serial
148 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700149 String serialNumber();
tom7ef8ff92014-09-17 13:08:06 -0700150
151 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700152 * Checks if the switch is still connected.
153 *
154 * @return whether the switch is still connected
155 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700156 boolean isConnected();
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700157
158 /**
tom7ef8ff92014-09-17 13:08:06 -0700159 * Disconnects the switch by closing the TCP connection. Results in a call
160 * to the channel handler's channelDisconnected method for cleanup
161 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700162 void disconnectSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700163
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700164 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700165 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700166 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700167 * @param requested the role requested by the controller
168 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700169 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700170 void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700171
172 /**
Marc De Leenheerb9311372015-07-09 11:36:49 -0700173 * Returns the switch device type.
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700174 *
Marc De Leenheerb9311372015-07-09 11:36:49 -0700175 * @return device type
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700176 */
Marc De Leenheerb9311372015-07-09 11:36:49 -0700177 Device.Type deviceType();
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700178
Ray Milkeye53f1712015-01-16 09:17:16 -0800179 /**
180 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800181 *
182 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800183 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700184 String channelId();
tom7ef8ff92014-09-17 13:08:06 -0700185}