Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 16 | package org.onlab.onos.openflow.controller.driver; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.List; |
| 19 | |
| 20 | import org.jboss.netty.channel.Channel; |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 21 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 22 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
| 23 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
| 24 | import org.projectfloodlight.openflow.protocol.OFFeaturesReply; |
| 25 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 26 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
| 27 | import 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 | */ |
| 34 | public 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 Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 74 | * Handle OF 1.x (where x > 0) role messages. |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 75 | * @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 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 190 | * Writes the message to the output stream |
| 191 | * in a driver specific manner. |
| 192 | * |
| 193 | * @param msg the message to write |
| 194 | */ |
| 195 | public void write(OFMessage msg); |
| 196 | |
| 197 | /** |
| 198 | * Writes to the OFMessage list to the output stream |
| 199 | * in a driver specific manner. |
| 200 | * |
| 201 | * @param msgs the messages to be written |
| 202 | */ |
| 203 | public void write(List<OFMessage> msgs); |
| 204 | |
| 205 | } |