blob: 3e153d7cdf7c5333d123b65e96a52de296b8602f [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;
tom7ef8ff92014-09-17 13:08:06 -070017
18import org.projectfloodlight.openflow.protocol.OFMessage;
19
Marc De Leenheer8aba62f2017-04-25 14:33:37 -070020import java.util.concurrent.CompletableFuture;
21
tom7ef8ff92014-09-17 13:08:06 -070022/**
23 * Abstraction of an OpenFlow controller. Serves as a one stop
24 * shop for obtaining OpenFlow devices and (un)register listeners
25 * on OpenFlow events
26 */
27public interface OpenFlowController {
28
29 /**
30 * Returns all switches known to this OF controller.
31 * @return Iterable of dpid elements
32 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070033 Iterable<OpenFlowSwitch> getSwitches();
tom7ef8ff92014-09-17 13:08:06 -070034
35 /**
36 * Returns all master switches known to this OF controller.
37 * @return Iterable of dpid elements
38 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070039 Iterable<OpenFlowSwitch> getMasterSwitches();
tom7ef8ff92014-09-17 13:08:06 -070040
41 /**
42 * Returns all equal switches known to this OF controller.
43 * @return Iterable of dpid elements
44 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070045 Iterable<OpenFlowSwitch> getEqualSwitches();
tom7ef8ff92014-09-17 13:08:06 -070046
47
48 /**
49 * Returns the actual switch for the given Dpid.
50 * @param dpid the switch to fetch
51 * @return the interface to this switch
52 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070053 OpenFlowSwitch getSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070054
55 /**
56 * Returns the actual master switch for the given Dpid, if one exists.
57 * @param dpid the switch to fetch
58 * @return the interface to this switch
59 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070060 OpenFlowSwitch getMasterSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070061
62 /**
63 * Returns the actual equal switch for the given Dpid, if one exists.
64 * @param dpid the switch to fetch
65 * @return the interface to this switch
66 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070067 OpenFlowSwitch getEqualSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070068
69 /**
70 * Register a listener for meta events that occur to OF
71 * devices.
72 * @param listener the listener to notify
73 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070074 void addListener(OpenFlowSwitchListener listener);
tom7ef8ff92014-09-17 13:08:06 -070075
76 /**
77 * Unregister a listener.
78 *
79 * @param listener the listener to unregister
80 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070081 void removeListener(OpenFlowSwitchListener listener);
tom7ef8ff92014-09-17 13:08:06 -070082
83 /**
Jian Lia78cdb22016-04-21 13:03:58 -070084 * Register a listener for all OF msg types.
85 *
86 * @param listener the listener to notify
87 */
88 void addMessageListener(OpenFlowMessageListener listener);
89
90 /**
91 * Unregister a listener for all OF msg types.
92 *
93 * @param listener the listener to notify
94 */
95 void removeMessageListener(OpenFlowMessageListener listener);
96
97 /**
tom7ef8ff92014-09-17 13:08:06 -070098 * Register a listener for packet events.
99 * @param priority the importance of this listener, lower values are more important
100 * @param listener the listener to notify
101 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700102 void addPacketListener(int priority, PacketListener listener);
tom7ef8ff92014-09-17 13:08:06 -0700103
104 /**
105 * Unregister a listener.
106 *
107 * @param listener the listener to unregister
108 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700109 void removePacketListener(PacketListener listener);
tom7ef8ff92014-09-17 13:08:06 -0700110
111 /**
alshabibeec3a062014-09-17 18:01:26 -0700112 * Register a listener for OF msg events.
113 *
114 * @param listener the listener to notify
115 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700116 void addEventListener(OpenFlowEventListener listener);
alshabibeec3a062014-09-17 18:01:26 -0700117
118 /**
119 * Unregister a listener.
120 *
121 * @param listener the listener to unregister
122 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700123 void removeEventListener(OpenFlowEventListener listener);
alshabibeec3a062014-09-17 18:01:26 -0700124
125 /**
tom7ef8ff92014-09-17 13:08:06 -0700126 * Send a message to a particular switch.
127 * @param dpid the switch to send to.
128 * @param msg the message to send
129 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700130 void write(Dpid dpid, OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -0700131
132 /**
Marc De Leenheer8aba62f2017-04-25 14:33:37 -0700133 * Send a message to a particular switch and return the future response.
134 *
135 * @param dpid the switch to send to
136 * @param msg the message to send
137 * @return future for response message
138 */
139 CompletableFuture<OFMessage> writeResponse(Dpid dpid, OFMessage msg);
140
141 /**
tom7ef8ff92014-09-17 13:08:06 -0700142 * Process a message and notify the appropriate listeners.
143 *
144 * @param dpid the dpid the message arrived on
145 * @param msg the message to process.
146 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700147 void processPacket(Dpid dpid, OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -0700148
149 /**
150 * Sets the role for a given switch.
151 * @param role the desired role
152 * @param dpid the switch to set the role for.
153 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700154 void setRole(Dpid dpid, RoleState role);
Anton Chigrinbf14b372019-01-14 17:29:56 +0200155
156 /**
157 * Remove OpenFlow classifier listener from runtime store of classifiers listener.
158 *
159 * @param listener the OpenFlow classifier to remove
160 */
161 void removeClassifierListener(OpenFlowClassifierListener listener);
162
163 /**
164 * Add OpenFlow classifier listener to runtime store of classifiers listener.
165 *
166 * @param listener the OpenFlow classifier listener
167 */
168 void addClassifierListener(OpenFlowClassifierListener listener);
tom7ef8ff92014-09-17 13:08:06 -0700169}