blob: 2647fed3c076339f2151ed4e4d115943df842bb1 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 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 */
tom9c94c5b2014-09-17 13:14:42 -070016package org.onlab.onos.openflow.controller.driver;
tom7ef8ff92014-09-17 13:08:06 -070017
18import java.util.List;
19
20import org.jboss.netty.channel.Channel;
tom9c94c5b2014-09-17 13:14:42 -070021import org.onlab.onos.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;
26import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
27import org.projectfloodlight.openflow.protocol.OFVersion;
28
29/**
30 * Represents the driver side of an OpenFlow switch.
31 * This interface should never be exposed to consumers.
32 *
33 */
34public interface OpenFlowSwitchDriver extends OpenFlowSwitch {
35
36 /**
37 * Sets the OpenFlow agent to be used. This method
38 * can only be called once.
39 * @param agent the agent to set.
40 */
41 public void setAgent(OpenFlowAgent agent);
42
43 /**
44 * Sets the Role handler object.
45 * This method can only be called once.
46 * @param roleHandler the roleHandler class
47 */
48 public void setRoleHandler(RoleHandler roleHandler);
49
50 /**
51 * Reasserts this controllers role to the switch.
52 * Useful in cases where the switch no longer agrees
53 * that this controller has the role it claims.
54 */
55 public void reassertRole();
56
57 /**
58 * Handle the situation where the role request triggers an error.
59 * @param error the error to handle.
60 * @return true if handled, false if not.
61 */
62 public boolean handleRoleError(OFErrorMsg error);
63
64 /**
65 * If this driver know of Nicira style role messages, these should
66 * be handled here.
67 * @param m the role message to handle.
68 * @throws SwitchStateException if the message received was
69 * not a nicira role or was malformed.
70 */
71 public void handleNiciraRole(OFMessage m) throws SwitchStateException;
72
73 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070074 * Handle OF 1.x (where x > 0) role messages.
tom7ef8ff92014-09-17 13:08:06 -070075 * @param m the role message to handle
76 * @throws SwitchStateException if the message received was
77 * not a nicira role or was malformed.
78 */
79 public void handleRole(OFMessage m) throws SwitchStateException;
80
81 /**
82 * Starts the driver specific handshake process.
83 */
84 public void startDriverHandshake();
85
86 /**
87 * Checks whether the driver specific handshake is complete.
88 * @return true is finished, false if not.
89 */
90 public boolean isDriverHandshakeComplete();
91
92 /**
93 * Process a message during the driver specific handshake.
94 * @param m the message to process.
95 */
96 public void processDriverHandshakeMessage(OFMessage m);
97
98 /**
99 * Announce to the OpenFlow agent that this switch has connected.
100 * @return true if successful, false if duplicate switch.
101 */
102 public boolean connectSwitch();
103
104 /**
105 * Activate this MASTER switch-controller relationship in the OF agent.
106 * @return true is successful, false is switch has not
107 * connected or is unknown to the system.
108 */
109 public boolean activateMasterSwitch();
110
111 /**
112 * Activate this EQUAL switch-controller relationship in the OF agent.
113 * @return true is successful, false is switch has not
114 * connected or is unknown to the system.
115 */
116 public boolean activateEqualSwitch();
117
118 /**
119 * Transition this switch-controller relationship to an EQUAL state.
120 */
121 public void transitionToEqualSwitch();
122
123 /**
124 * Transition this switch-controller relationship to an Master state.
125 */
126 public void transitionToMasterSwitch();
127
128 /**
129 * Remove this switch from the openflow agent.
130 */
131 public void removeConnectedSwitch();
132
133 /**
134 * Sets the ports on this switch.
135 * @param portDescReply the port set and descriptions
136 */
137 public void setPortDescReply(OFPortDescStatsReply portDescReply);
138
139 /**
140 * Sets the features reply for this switch.
141 * @param featuresReply the features to set.
142 */
143 public void setFeaturesReply(OFFeaturesReply featuresReply);
144
145 /**
146 * Sets the switch description.
147 * @param desc the descriptions
148 */
149 public void setSwitchDescription(OFDescStatsReply desc);
150
151 /**
152 * Gets the next transaction id to use.
153 * @return the xid
154 */
155 public int getNextTransactionId();
156
157
158 /**
159 * Does this switch support Nicira Role messages.
160 * @return true if supports, false otherwise.
161 */
162 public Boolean supportNxRole();
163
164 /**
165 * Sets the OF version for this switch.
166 * @param ofV the version to set.
167 */
168 public void setOFVersion(OFVersion ofV);
169
170 /**
171 * Sets this switch has having a full flowtable.
172 * @param full true if full, false otherswise.
173 */
174 public void setTableFull(boolean full);
175
176 /**
177 * Sets the associated Netty channel for this switch.
178 * @param channel the Netty channel
179 */
180 public void setChannel(Channel channel);
181
182 /**
183 * Sets whether the switch is connected.
184 *
185 * @param connected whether the switch is connected
186 */
187 public void setConnected(boolean connected);
188
189 /**
190 * Checks if the switch is still connected.
191 *
192 * @return whether the switch is still connected
193 */
194 public boolean isConnected();
195
196 /**
197 * Writes the message to the output stream
198 * in a driver specific manner.
199 *
200 * @param msg the message to write
201 */
202 public void write(OFMessage msg);
203
204 /**
205 * Writes to the OFMessage list to the output stream
206 * in a driver specific manner.
207 *
208 * @param msgs the messages to be written
209 */
210 public void write(List<OFMessage> msgs);
211
212}