blob: 878223648167d3ca38b308cb0abb2e431a9d9a9e [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present 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;
Jordi Ortizaa8de492016-12-01 00:21:36 +010021import org.projectfloodlight.openflow.protocol.OFMeterFeatures;
tom7ef8ff92014-09-17 13:08:06 -070022import org.projectfloodlight.openflow.protocol.OFPortDesc;
alshabibb452fd72015-04-22 20:46:20 -070023
24import java.util.List;
tom7ef8ff92014-09-17 13:08:06 -070025
26/**
27 * Represents to provider facing side of a switch.
28 */
29public interface OpenFlowSwitch {
30
31 /**
32 * Writes the message to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080033 * <p>
34 * Note: Messages may be silently dropped/lost due to IOExceptions or
35 * role. If this is a concern, then a caller should use barriers.
36 * </p>
Charles Chan5b7ec342015-10-18 20:55:41 -070037 *
tom7ef8ff92014-09-17 13:08:06 -070038 * @param msg the message to write
39 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070040 void sendMsg(OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -070041
42 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080043 * Writes the OFMessage list to the driver.
Brian O'Connore755caa2015-11-16 16:43:09 -080044 * <p>
45 * Note: Messages may be silently dropped/lost due to IOExceptions or
46 * role. If this is a concern, then a caller should use barriers.
47 * </p>
tom7ef8ff92014-09-17 13:08:06 -070048 *
49 * @param msgs the messages to be written
50 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070051 void sendMsg(List<OFMessage> msgs);
tom7ef8ff92014-09-17 13:08:06 -070052
53 /**
54 * Handle a message from the switch.
55 * @param fromSwitch the message to handle
56 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070057 void handleMessage(OFMessage fromSwitch);
tom7ef8ff92014-09-17 13:08:06 -070058
59 /**
60 * Sets the role for this switch.
61 * @param role the role to set.
62 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070063 void setRole(RoleState role);
tom7ef8ff92014-09-17 13:08:06 -070064
65 /**
66 * Fetch the role for this switch.
67 * @return the role.
68 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070069 RoleState getRole();
tom7ef8ff92014-09-17 13:08:06 -070070
71 /**
72 * Fetches the ports of this switch.
73 * @return unmodifiable list of the ports.
74 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070075 List<OFPortDesc> getPorts();
tom7ef8ff92014-09-17 13:08:06 -070076
77 /**
Jordi Ortizaa8de492016-12-01 00:21:36 +010078 * Fetches the meter features of this switch.
79 * @return unmodifiable meter features
80 */
81 OFMeterFeatures getMeterFeatures();
82
83 /**
tom7ef8ff92014-09-17 13:08:06 -070084 * Provides the factory for this OF version.
85 * @return OF version specific factory.
86 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070087 OFFactory factory();
tom7ef8ff92014-09-17 13:08:06 -070088
89 /**
90 * Gets a string version of the ID for this switch.
91 *
92 * @return string version of the ID
93 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070094 String getStringId();
tom7ef8ff92014-09-17 13:08:06 -070095
96 /**
97 * Gets the datapathId of the switch.
98 *
99 * @return the switch dpid in long format
100 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700101 long getId();
tom7ef8ff92014-09-17 13:08:06 -0700102
103 /**
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700104 * Gets the datapathId of the switch.
105 *
106 * @return the switch dpid
107 */
108 default Dpid getDpid() {
109 return new Dpid(getId());
110 }
111
112 /**
tom7ef8ff92014-09-17 13:08:06 -0700113 * fetch the manufacturer description.
114 * @return the description
115 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700116 String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700117
118 /**
119 * fetch the datapath description.
120 * @return the description
121 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700122 String datapathDescription();
tom7ef8ff92014-09-17 13:08:06 -0700123
124 /**
125 * fetch the hardware description.
126 * @return the description
127 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700128 String hardwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700129
130 /**
131 * fetch the software description.
132 * @return the description
133 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700134 String softwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700135
136 /**
137 * fetch the serial number.
138 * @return the serial
139 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700140 String serialNumber();
tom7ef8ff92014-09-17 13:08:06 -0700141
142 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700143 * Checks if the switch is still connected.
144 *
145 * @return whether the switch is still connected
146 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700147 boolean isConnected();
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700148
149 /**
tom7ef8ff92014-09-17 13:08:06 -0700150 * Disconnects the switch by closing the TCP connection. Results in a call
151 * to the channel handler's channelDisconnected method for cleanup
152 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700153 void disconnectSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700154
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700155 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700156 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700157 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700158 * @param requested the role requested by the controller
159 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700160 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700161 void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700162
163 /**
Marc De Leenheerb9311372015-07-09 11:36:49 -0700164 * Returns the switch device type.
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700165 *
Marc De Leenheerb9311372015-07-09 11:36:49 -0700166 * @return device type
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700167 */
Marc De Leenheerb9311372015-07-09 11:36:49 -0700168 Device.Type deviceType();
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700169
Ray Milkeye53f1712015-01-16 09:17:16 -0800170 /**
171 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800172 *
173 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800174 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700175 String channelId();
tom7ef8ff92014-09-17 13:08:06 -0700176}