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