Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 19 | package org.onlab.onos.openflow.controller.driver; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 20 | |
| 21 | import java.util.List; |
| 22 | |
| 23 | import org.jboss.netty.channel.Channel; |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 24 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 25 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
| 26 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
| 27 | import org.projectfloodlight.openflow.protocol.OFFeaturesReply; |
| 28 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 29 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
| 30 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 31 | |
| 32 | /** |
| 33 | * Represents the driver side of an OpenFlow switch. |
| 34 | * This interface should never be exposed to consumers. |
| 35 | * |
| 36 | */ |
| 37 | public interface OpenFlowSwitchDriver extends OpenFlowSwitch { |
| 38 | |
| 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 | */ |
| 44 | public void setAgent(OpenFlowAgent agent); |
| 45 | |
| 46 | /** |
| 47 | * Sets the Role handler object. |
| 48 | * This method can only be called once. |
| 49 | * @param roleHandler the roleHandler class |
| 50 | */ |
| 51 | public void setRoleHandler(RoleHandler roleHandler); |
| 52 | |
| 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 | */ |
| 58 | public void reassertRole(); |
| 59 | |
| 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 | */ |
| 65 | public boolean handleRoleError(OFErrorMsg error); |
| 66 | |
| 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 | */ |
| 74 | public void handleNiciraRole(OFMessage m) throws SwitchStateException; |
| 75 | |
| 76 | /** |
| 77 | * Handle OF 1.x (where x > 0) role messages. |
| 78 | * @param m the role message to handle |
| 79 | * @throws SwitchStateException if the message received was |
| 80 | * not a nicira role or was malformed. |
| 81 | */ |
| 82 | public void handleRole(OFMessage m) throws SwitchStateException; |
| 83 | |
| 84 | /** |
| 85 | * Starts the driver specific handshake process. |
| 86 | */ |
| 87 | public void startDriverHandshake(); |
| 88 | |
| 89 | /** |
| 90 | * Checks whether the driver specific handshake is complete. |
| 91 | * @return true is finished, false if not. |
| 92 | */ |
| 93 | public boolean isDriverHandshakeComplete(); |
| 94 | |
| 95 | /** |
| 96 | * Process a message during the driver specific handshake. |
| 97 | * @param m the message to process. |
| 98 | */ |
| 99 | public void processDriverHandshakeMessage(OFMessage m); |
| 100 | |
| 101 | /** |
| 102 | * Announce to the OpenFlow agent that this switch has connected. |
| 103 | * @return true if successful, false if duplicate switch. |
| 104 | */ |
| 105 | public boolean connectSwitch(); |
| 106 | |
| 107 | /** |
| 108 | * Activate this MASTER switch-controller relationship in the OF agent. |
| 109 | * @return true is successful, false is switch has not |
| 110 | * connected or is unknown to the system. |
| 111 | */ |
| 112 | public boolean activateMasterSwitch(); |
| 113 | |
| 114 | /** |
| 115 | * Activate this EQUAL switch-controller relationship in the OF agent. |
| 116 | * @return true is successful, false is switch has not |
| 117 | * connected or is unknown to the system. |
| 118 | */ |
| 119 | public boolean activateEqualSwitch(); |
| 120 | |
| 121 | /** |
| 122 | * Transition this switch-controller relationship to an EQUAL state. |
| 123 | */ |
| 124 | public void transitionToEqualSwitch(); |
| 125 | |
| 126 | /** |
| 127 | * Transition this switch-controller relationship to an Master state. |
| 128 | */ |
| 129 | public void transitionToMasterSwitch(); |
| 130 | |
| 131 | /** |
| 132 | * Remove this switch from the openflow agent. |
| 133 | */ |
| 134 | public void removeConnectedSwitch(); |
| 135 | |
| 136 | /** |
| 137 | * Sets the ports on this switch. |
| 138 | * @param portDescReply the port set and descriptions |
| 139 | */ |
| 140 | public void setPortDescReply(OFPortDescStatsReply portDescReply); |
| 141 | |
| 142 | /** |
| 143 | * Sets the features reply for this switch. |
| 144 | * @param featuresReply the features to set. |
| 145 | */ |
| 146 | public void setFeaturesReply(OFFeaturesReply featuresReply); |
| 147 | |
| 148 | /** |
| 149 | * Sets the switch description. |
| 150 | * @param desc the descriptions |
| 151 | */ |
| 152 | public void setSwitchDescription(OFDescStatsReply desc); |
| 153 | |
| 154 | /** |
| 155 | * Gets the next transaction id to use. |
| 156 | * @return the xid |
| 157 | */ |
| 158 | public int getNextTransactionId(); |
| 159 | |
| 160 | |
| 161 | /** |
| 162 | * Does this switch support Nicira Role messages. |
| 163 | * @return true if supports, false otherwise. |
| 164 | */ |
| 165 | public Boolean supportNxRole(); |
| 166 | |
| 167 | /** |
| 168 | * Sets the OF version for this switch. |
| 169 | * @param ofV the version to set. |
| 170 | */ |
| 171 | public void setOFVersion(OFVersion ofV); |
| 172 | |
| 173 | /** |
| 174 | * Sets this switch has having a full flowtable. |
| 175 | * @param full true if full, false otherswise. |
| 176 | */ |
| 177 | public void setTableFull(boolean full); |
| 178 | |
| 179 | /** |
| 180 | * Sets the associated Netty channel for this switch. |
| 181 | * @param channel the Netty channel |
| 182 | */ |
| 183 | public void setChannel(Channel channel); |
| 184 | |
| 185 | /** |
| 186 | * Sets whether the switch is connected. |
| 187 | * |
| 188 | * @param connected whether the switch is connected |
| 189 | */ |
| 190 | public void setConnected(boolean connected); |
| 191 | |
| 192 | /** |
| 193 | * Checks if the switch is still connected. |
| 194 | * |
| 195 | * @return whether the switch is still connected |
| 196 | */ |
| 197 | public boolean isConnected(); |
| 198 | |
| 199 | /** |
| 200 | * Writes the message to the output stream |
| 201 | * in a driver specific manner. |
| 202 | * |
| 203 | * @param msg the message to write |
| 204 | */ |
| 205 | public void write(OFMessage msg); |
| 206 | |
| 207 | /** |
| 208 | * Writes to the OFMessage list to the output stream |
| 209 | * in a driver specific manner. |
| 210 | * |
| 211 | * @param msgs the messages to be written |
| 212 | */ |
| 213 | public void write(List<OFMessage> msgs); |
| 214 | |
| 215 | } |