Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.openflow.controller.Dpid; |
| 19 | import org.onosproject.openflow.controller.OpenFlowSwitch; |
| 20 | import org.onosproject.openflow.controller.RoleState; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 21 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 22 | |
Jian Li | a78cdb2 | 2016-04-21 13:03:58 -0700 | [diff] [blame] | 23 | import java.util.List; |
| 24 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Responsible for keeping track of the current set of switches |
| 27 | * connected to the system. As well as whether they are in Master |
| 28 | * role or not. |
| 29 | * |
| 30 | */ |
| 31 | public interface OpenFlowAgent { |
| 32 | |
| 33 | /** |
| 34 | * Add a switch that has just connected to the system. |
| 35 | * @param dpid the dpid to add |
| 36 | * @param sw the actual switch object. |
| 37 | * @return true if added, false otherwise. |
| 38 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 39 | boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Checks if the activation for this switch is valid. |
| 43 | * @param dpid the dpid to check |
| 44 | * @return true if valid, false otherwise |
| 45 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 46 | boolean validActivation(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Called when a switch is activated, with this controller's role as MASTER. |
| 50 | * @param dpid the dpid to add. |
| 51 | * @param sw the actual switch |
| 52 | * @return true if added, false otherwise. |
| 53 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 54 | boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Called when a switch is activated, with this controller's role as EQUAL. |
| 58 | * @param dpid the dpid to add. |
| 59 | * @param sw the actual switch |
| 60 | * @return true if added, false otherwise. |
| 61 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 62 | boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * Called when this controller's role for a switch transitions from equal |
| 66 | * to master. For 1.0 switches, we internally refer to the role 'slave' as |
| 67 | * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'. |
Frank Wang | d8ab096 | 2017-08-11 11:09:30 +0800 | [diff] [blame^] | 68 | * @param dpid the dpid to transition. |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 69 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 70 | void transitionToMasterSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Called when this controller's role for a switch transitions to equal. |
| 74 | * For 1.0 switches, we internally refer to the role 'slave' as |
| 75 | * 'equal'. |
Frank Wang | d8ab096 | 2017-08-11 11:09:30 +0800 | [diff] [blame^] | 76 | * @param dpid the dpid to transition. |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 77 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 78 | void transitionToEqualSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Clear all state in controller switch maps for a switch that has |
| 82 | * disconnected from the local controller. Also release control for |
| 83 | * that switch from the global repository. Notify switch listeners. |
| 84 | * @param dpid the dpid to remove. |
| 85 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 86 | void removeConnectedSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
Jian Li | a78cdb2 | 2016-04-21 13:03:58 -0700 | [diff] [blame] | 89 | * Notify OpenFlow message listeners on all outgoing message event. |
| 90 | * |
| 91 | * @param dpid the dpid the message sent to |
| 92 | * @param m the collection of messages to sent out |
| 93 | */ |
| 94 | void processDownstreamMessage(Dpid dpid, List<OFMessage> m); |
| 95 | |
| 96 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 97 | * Process a message coming from a switch. |
| 98 | * |
| 99 | * @param dpid the dpid the message came on. |
| 100 | * @param m the message to process |
| 101 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 102 | void processMessage(Dpid dpid, OFMessage m); |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Notifies the controller that role assertion has failed. |
| 106 | * |
| 107 | * @param dpid the switch that failed role assertion |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 108 | * @param requested the role controller requested |
| 109 | * @param response role reply from the switch |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 110 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 111 | void returnRoleReply(Dpid dpid, RoleState requested, RoleState response); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 112 | } |