blob: 2ac0e02530cf6db4626cfe6de1d3805aac1e7da9 [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 /**
104 * fetch the manufacturer description.
105 * @return the description
106 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700107 String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700108
109 /**
110 * fetch the datapath description.
111 * @return the description
112 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700113 String datapathDescription();
tom7ef8ff92014-09-17 13:08:06 -0700114
115 /**
116 * fetch the hardware description.
117 * @return the description
118 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700119 String hardwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700120
121 /**
122 * fetch the software description.
123 * @return the description
124 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700125 String softwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700126
127 /**
128 * fetch the serial number.
129 * @return the serial
130 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700131 String serialNumber();
tom7ef8ff92014-09-17 13:08:06 -0700132
133 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700134 * Checks if the switch is still connected.
135 *
136 * @return whether the switch is still connected
137 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700138 boolean isConnected();
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700139
140 /**
tom7ef8ff92014-09-17 13:08:06 -0700141 * Disconnects the switch by closing the TCP connection. Results in a call
142 * to the channel handler's channelDisconnected method for cleanup
143 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700144 void disconnectSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700145
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700146 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700147 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700148 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700149 * @param requested the role requested by the controller
150 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700151 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700152 void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700153
154 /**
Marc De Leenheerb9311372015-07-09 11:36:49 -0700155 * Returns the switch device type.
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700156 *
Marc De Leenheerb9311372015-07-09 11:36:49 -0700157 * @return device type
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700158 */
Marc De Leenheerb9311372015-07-09 11:36:49 -0700159 Device.Type deviceType();
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700160
Ray Milkeye53f1712015-01-16 09:17:16 -0800161 /**
162 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800163 *
164 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800165 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700166 String channelId();
tom7ef8ff92014-09-17 13:08:06 -0700167}