blob: 095944e7051eccbdbc55123b977d7bcdf2b9847e [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.driver;
tom7ef8ff92014-09-17 13:08:06 -070017
alshabibb452fd72015-04-22 20:46:20 -070018import org.onosproject.net.driver.HandlerBehaviour;
19import org.onosproject.openflow.controller.Dpid;
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -070020import org.onosproject.openflow.controller.OpenFlowSession;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.openflow.controller.OpenFlowSwitch;
tom7ef8ff92014-09-17 13:08:06 -070022import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
23import org.projectfloodlight.openflow.protocol.OFErrorMsg;
24import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
25import org.projectfloodlight.openflow.protocol.OFMessage;
Jordi Ortiz91477b82016-11-29 15:22:50 +010026import org.projectfloodlight.openflow.protocol.OFMeterFeaturesStatsReply;
tom7ef8ff92014-09-17 13:08:06 -070027import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
28import org.projectfloodlight.openflow.protocol.OFVersion;
29
alshabibb452fd72015-04-22 20:46:20 -070030import java.util.List;
31
tom7ef8ff92014-09-17 13:08:06 -070032/**
33 * Represents the driver side of an OpenFlow switch.
34 * This interface should never be exposed to consumers.
35 *
36 */
alshabibb452fd72015-04-22 20:46:20 -070037public interface OpenFlowSwitchDriver extends OpenFlowSwitch, HandlerBehaviour {
tom7ef8ff92014-09-17 13:08:06 -070038
39 /**
40 * Sets the OpenFlow agent to be used. This method
41 * can only be called once.
42 * @param agent the agent to set.
43 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070044 void setAgent(OpenFlowAgent agent);
tom7ef8ff92014-09-17 13:08:06 -070045
46 /**
47 * Sets the Role handler object.
48 * This method can only be called once.
49 * @param roleHandler the roleHandler class
50 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070051 void setRoleHandler(RoleHandler roleHandler);
tom7ef8ff92014-09-17 13:08:06 -070052
53 /**
54 * Reasserts this controllers role to the switch.
55 * Useful in cases where the switch no longer agrees
56 * that this controller has the role it claims.
57 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070058 void reassertRole();
tom7ef8ff92014-09-17 13:08:06 -070059
60 /**
61 * Handle the situation where the role request triggers an error.
62 * @param error the error to handle.
63 * @return true if handled, false if not.
64 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070065 boolean handleRoleError(OFErrorMsg error);
tom7ef8ff92014-09-17 13:08:06 -070066
67 /**
68 * If this driver know of Nicira style role messages, these should
69 * be handled here.
70 * @param m the role message to handle.
71 * @throws SwitchStateException if the message received was
72 * not a nicira role or was malformed.
73 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070074 void handleNiciraRole(OFMessage m) throws SwitchStateException;
tom7ef8ff92014-09-17 13:08:06 -070075
76 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070077 * Handle OF 1.x (where x > 0) role messages.
tom7ef8ff92014-09-17 13:08:06 -070078 * @param m the role message to handle
79 * @throws SwitchStateException if the message received was
80 * not a nicira role or was malformed.
81 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070082 void handleRole(OFMessage m) throws SwitchStateException;
tom7ef8ff92014-09-17 13:08:06 -070083
84 /**
tom7ef8ff92014-09-17 13:08:06 -070085 * Announce to the OpenFlow agent that this switch has connected.
86 * @return true if successful, false if duplicate switch.
87 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070088 boolean connectSwitch();
tom7ef8ff92014-09-17 13:08:06 -070089
90 /**
91 * Activate this MASTER switch-controller relationship in the OF agent.
92 * @return true is successful, false is switch has not
93 * connected or is unknown to the system.
94 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070095 boolean activateMasterSwitch();
tom7ef8ff92014-09-17 13:08:06 -070096
97 /**
98 * Activate this EQUAL switch-controller relationship in the OF agent.
99 * @return true is successful, false is switch has not
100 * connected or is unknown to the system.
101 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700102 boolean activateEqualSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700103
104 /**
105 * Transition this switch-controller relationship to an EQUAL state.
106 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700107 void transitionToEqualSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700108
109 /**
110 * Transition this switch-controller relationship to an Master state.
111 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700112 void transitionToMasterSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700113
114 /**
115 * Remove this switch from the openflow agent.
116 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700117 void removeConnectedSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700118
119 /**
120 * Sets the ports on this switch.
121 * @param portDescReply the port set and descriptions
122 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700123 void setPortDescReply(OFPortDescStatsReply portDescReply);
tom7ef8ff92014-09-17 13:08:06 -0700124
125 /**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700126 * Sets the ports on this switch.
127 * @param portDescReplies list of port set and descriptions
128 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700129 void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700130
131 /**
tom7ef8ff92014-09-17 13:08:06 -0700132 * Sets the features reply for this switch.
133 * @param featuresReply the features to set.
134 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700135 void setFeaturesReply(OFFeaturesReply featuresReply);
tom7ef8ff92014-09-17 13:08:06 -0700136
137 /**
Jordi Ortiz91477b82016-11-29 15:22:50 +0100138 * Sets the meter features reply for this switch.
139 * @param meterFeaturesReply the meter features to set.
140 */
141 void setMeterFeaturesReply(OFMeterFeaturesStatsReply meterFeaturesReply);
142
143 /**
tom7ef8ff92014-09-17 13:08:06 -0700144 * Sets the switch description.
145 * @param desc the descriptions
146 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700147 void setSwitchDescription(OFDescStatsReply desc);
tom7ef8ff92014-09-17 13:08:06 -0700148
149 /**
150 * Gets the next transaction id to use.
151 * @return the xid
152 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700153 int getNextTransactionId();
tom7ef8ff92014-09-17 13:08:06 -0700154
155
156 /**
tom7ef8ff92014-09-17 13:08:06 -0700157 * Sets the OF version for this switch.
158 * @param ofV the version to set.
159 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700160 void setOFVersion(OFVersion ofV);
tom7ef8ff92014-09-17 13:08:06 -0700161
162 /**
163 * Sets this switch has having a full flowtable.
164 * @param full true if full, false otherswise.
165 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700166 void setTableFull(boolean full);
tom7ef8ff92014-09-17 13:08:06 -0700167
168 /**
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700169 * Sets the associated OpenFlow session for this switch.
170 *
171 * @param session the OpenFlow session
tom7ef8ff92014-09-17 13:08:06 -0700172 */
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700173 void setChannel(OpenFlowSession session);
tom7ef8ff92014-09-17 13:08:06 -0700174
175 /**
176 * Sets whether the switch is connected.
177 *
178 * @param connected whether the switch is connected
179 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700180 void setConnected(boolean connected);
tom7ef8ff92014-09-17 13:08:06 -0700181
182 /**
alshabibb452fd72015-04-22 20:46:20 -0700183 * Initialises the behaviour.
184 * @param dpid a dpid
185 * @param desc a switch description
186 * @param ofv OpenFlow version
tom7ef8ff92014-09-17 13:08:06 -0700187 */
alshabibb452fd72015-04-22 20:46:20 -0700188 void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv);
tom7ef8ff92014-09-17 13:08:06 -0700189
190 /**
alshabibb452fd72015-04-22 20:46:20 -0700191 * Does this switch support Nicira Role messages.
Yuta HIGUCHI2341e602017-03-08 20:10:08 -0800192 * <p>
193 * Only relevant if this Device is OpenFlow 1.0.
194 *
alshabibb452fd72015-04-22 20:46:20 -0700195 * @return true if supports, false otherwise.
tom7ef8ff92014-09-17 13:08:06 -0700196 */
alshabibb452fd72015-04-22 20:46:20 -0700197 Boolean supportNxRole();
198
199
200 /**
201 * Starts the driver specific handshake process.
202 */
203 void startDriverHandshake();
204
205 /**
206 * Checks whether the driver specific handshake is complete.
207 * @return true is finished, false if not.
208 */
209 boolean isDriverHandshakeComplete();
210
211 /**
212 * Process a message during the driver specific handshake.
213 * @param m the message to process.
214 */
215 void processDriverHandshakeMessage(OFMessage m);
216
217 /**
218 * Sends only role request messages.
219 *
220 * @param message a role request message.
221 */
222 void sendRoleRequest(OFMessage message);
tom7ef8ff92014-09-17 13:08:06 -0700223
alshabiba2df7b2a2015-05-06 13:57:10 -0700224 /**
225 * Allows the handshaker behaviour to send messages during the
226 * handshake phase only.
227 *
228 * @param message an OpenFlow message
229 */
230 void sendHandshakeMessage(OFMessage message);
Yuta HIGUCHI6ee6b8c2017-05-09 14:44:30 -0700231
tom7ef8ff92014-09-17 13:08:06 -0700232}