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