blob: 4451b194dbea77ecb7bd50ae5b23c1162b94c012 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.openflow.controller.driver;
tom7ef8ff92014-09-17 13:08:06 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.openflow.controller.Dpid;
Anton Chigrinbf14b372019-01-14 17:29:56 +020019import org.onosproject.openflow.controller.OpenFlowClassifierListener;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.openflow.controller.OpenFlowSwitch;
21import org.onosproject.openflow.controller.RoleState;
tom7ef8ff92014-09-17 13:08:06 -070022import org.projectfloodlight.openflow.protocol.OFMessage;
23
Jian Lia78cdb22016-04-21 13:03:58 -070024import java.util.List;
25
tom7ef8ff92014-09-17 13:08:06 -070026/**
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 */
32public 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 SHIMIZU3310a342015-05-13 12:14:05 -070040 boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw);
tom7ef8ff92014-09-17 13:08:06 -070041
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 SHIMIZU3310a342015-05-13 12:14:05 -070047 boolean validActivation(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070048
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 SHIMIZU3310a342015-05-13 12:14:05 -070055 boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw);
tom7ef8ff92014-09-17 13:08:06 -070056
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 SHIMIZU3310a342015-05-13 12:14:05 -070063 boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw);
tom7ef8ff92014-09-17 13:08:06 -070064
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 Wangd8ab0962017-08-11 11:09:30 +080069 * @param dpid the dpid to transition.
tom7ef8ff92014-09-17 13:08:06 -070070 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070071 void transitionToMasterSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070072
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 Wangd8ab0962017-08-11 11:09:30 +080077 * @param dpid the dpid to transition.
tom7ef8ff92014-09-17 13:08:06 -070078 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070079 void transitionToEqualSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070080
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 SHIMIZU3310a342015-05-13 12:14:05 -070087 void removeConnectedSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070088
89 /**
Jian Lia78cdb22016-04-21 13:03:58 -070090 * 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 /**
tom7ef8ff92014-09-17 13:08:06 -070098 * 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 SHIMIZU3310a342015-05-13 12:14:05 -0700103 void processMessage(Dpid dpid, OFMessage m);
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700104
105 /**
106 * Notifies the controller that role assertion has failed.
107 *
108 * @param dpid the switch that failed role assertion
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800109 * @param requested the role controller requested
110 * @param response role reply from the switch
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700111 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700112 void returnRoleReply(Dpid dpid, RoleState requested, RoleState response);
Anton Chigrinbf14b372019-01-14 17:29:56 +0200113
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);
tom7ef8ff92014-09-17 13:08:06 -0700127}