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 | |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 18 | import org.onlab.onos.openflow.controller.Dpid; |
| 19 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 20 | import org.onlab.onos.openflow.controller.RoleState; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 21 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 22 | |
| 23 | /** |
| 24 | * Responsible for keeping track of the current set of switches |
| 25 | * connected to the system. As well as whether they are in Master |
| 26 | * role or not. |
| 27 | * |
| 28 | */ |
| 29 | public interface OpenFlowAgent { |
| 30 | |
| 31 | /** |
| 32 | * Add a switch that has just connected to the system. |
| 33 | * @param dpid the dpid to add |
| 34 | * @param sw the actual switch object. |
| 35 | * @return true if added, false otherwise. |
| 36 | */ |
| 37 | public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw); |
| 38 | |
| 39 | /** |
| 40 | * Checks if the activation for this switch is valid. |
| 41 | * @param dpid the dpid to check |
| 42 | * @return true if valid, false otherwise |
| 43 | */ |
| 44 | public boolean validActivation(Dpid dpid); |
| 45 | |
| 46 | /** |
| 47 | * Called when a switch is activated, with this controller's role as MASTER. |
| 48 | * @param dpid the dpid to add. |
| 49 | * @param sw the actual switch |
| 50 | * @return true if added, false otherwise. |
| 51 | */ |
| 52 | public boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw); |
| 53 | |
| 54 | /** |
| 55 | * Called when a switch is activated, with this controller's role as EQUAL. |
| 56 | * @param dpid the dpid to add. |
| 57 | * @param sw the actual switch |
| 58 | * @return true if added, false otherwise. |
| 59 | */ |
| 60 | public boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw); |
| 61 | |
| 62 | /** |
| 63 | * Called when this controller's role for a switch transitions from equal |
| 64 | * to master. For 1.0 switches, we internally refer to the role 'slave' as |
| 65 | * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'. |
| 66 | * @param dpid the dpid to transistion. |
| 67 | */ |
| 68 | public void transitionToMasterSwitch(Dpid dpid); |
| 69 | |
| 70 | /** |
| 71 | * Called when this controller's role for a switch transitions to equal. |
| 72 | * For 1.0 switches, we internally refer to the role 'slave' as |
| 73 | * 'equal'. |
| 74 | * @param dpid the dpid to transistion. |
| 75 | */ |
| 76 | public void transitionToEqualSwitch(Dpid dpid); |
| 77 | |
| 78 | /** |
| 79 | * Clear all state in controller switch maps for a switch that has |
| 80 | * disconnected from the local controller. Also release control for |
| 81 | * that switch from the global repository. Notify switch listeners. |
| 82 | * @param dpid the dpid to remove. |
| 83 | */ |
| 84 | public void removeConnectedSwitch(Dpid dpid); |
| 85 | |
| 86 | /** |
| 87 | * Process a message coming from a switch. |
| 88 | * |
| 89 | * @param dpid the dpid the message came on. |
| 90 | * @param m the message to process |
| 91 | */ |
| 92 | public void processMessage(Dpid dpid, OFMessage m); |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * Notifies the controller that role assertion has failed. |
| 96 | * |
| 97 | * @param dpid the switch that failed role assertion |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 98 | * @param requested the role controller requested |
| 99 | * @param response role reply from the switch |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 100 | */ |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 101 | public void returnRoleReply(Dpid dpid, RoleState requested, RoleState response); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 102 | } |