blob: b3c2091762a9b4881cc77cb7fd42409e4faabbd9 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
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
20/**
21 * Abstraction of an OpenFlow controller. Serves as a one stop
22 * shop for obtaining OpenFlow devices and (un)register listeners
23 * on OpenFlow events
24 */
25public interface OpenFlowController {
26
27 /**
28 * Returns all switches known to this OF controller.
29 * @return Iterable of dpid elements
30 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070031 Iterable<OpenFlowSwitch> getSwitches();
tom7ef8ff92014-09-17 13:08:06 -070032
33 /**
34 * Returns all master switches known to this OF controller.
35 * @return Iterable of dpid elements
36 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070037 Iterable<OpenFlowSwitch> getMasterSwitches();
tom7ef8ff92014-09-17 13:08:06 -070038
39 /**
40 * Returns all equal switches known to this OF controller.
41 * @return Iterable of dpid elements
42 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070043 Iterable<OpenFlowSwitch> getEqualSwitches();
tom7ef8ff92014-09-17 13:08:06 -070044
45
46 /**
47 * Returns the actual switch for the given Dpid.
48 * @param dpid the switch to fetch
49 * @return the interface to this switch
50 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070051 OpenFlowSwitch getSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070052
53 /**
54 * Returns the actual master switch for the given Dpid, if one exists.
55 * @param dpid the switch to fetch
56 * @return the interface to this switch
57 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070058 OpenFlowSwitch getMasterSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070059
60 /**
61 * Returns the actual equal switch for the given Dpid, if one exists.
62 * @param dpid the switch to fetch
63 * @return the interface to this switch
64 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070065 OpenFlowSwitch getEqualSwitch(Dpid dpid);
tom7ef8ff92014-09-17 13:08:06 -070066
67 /**
Jian Li28247b52016-01-07 17:24:15 -080068 * If this set to be true, all incoming events are monitored.
69 * Other wise, only stats related incoming events are monitored
70 * @param monitor monitoring flag
71 */
72 void monitorAllEvents(boolean monitor);
73
74 /**
tom7ef8ff92014-09-17 13:08:06 -070075 * Register a listener for meta events that occur to OF
76 * devices.
77 * @param listener the listener to notify
78 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070079 void addListener(OpenFlowSwitchListener listener);
tom7ef8ff92014-09-17 13:08:06 -070080
81 /**
82 * Unregister a listener.
83 *
84 * @param listener the listener to unregister
85 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070086 void removeListener(OpenFlowSwitchListener listener);
tom7ef8ff92014-09-17 13:08:06 -070087
88 /**
89 * Register a listener for packet events.
90 * @param priority the importance of this listener, lower values are more important
91 * @param listener the listener to notify
92 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070093 void addPacketListener(int priority, PacketListener listener);
tom7ef8ff92014-09-17 13:08:06 -070094
95 /**
96 * Unregister a listener.
97 *
98 * @param listener the listener to unregister
99 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700100 void removePacketListener(PacketListener listener);
tom7ef8ff92014-09-17 13:08:06 -0700101
102 /**
alshabibeec3a062014-09-17 18:01:26 -0700103 * Register a listener for OF msg events.
104 *
105 * @param listener the listener to notify
106 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700107 void addEventListener(OpenFlowEventListener listener);
alshabibeec3a062014-09-17 18:01:26 -0700108
109 /**
110 * Unregister a listener.
111 *
112 * @param listener the listener to unregister
113 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700114 void removeEventListener(OpenFlowEventListener listener);
alshabibeec3a062014-09-17 18:01:26 -0700115
116 /**
tom7ef8ff92014-09-17 13:08:06 -0700117 * Send a message to a particular switch.
118 * @param dpid the switch to send to.
119 * @param msg the message to send
120 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700121 void write(Dpid dpid, OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -0700122
123 /**
124 * Process a message and notify the appropriate listeners.
125 *
126 * @param dpid the dpid the message arrived on
127 * @param msg the message to process.
128 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700129 void processPacket(Dpid dpid, OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -0700130
131 /**
132 * Sets the role for a given switch.
133 * @param role the desired role
134 * @param dpid the switch to set the role for.
135 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700136 void setRole(Dpid dpid, RoleState role);
tom7ef8ff92014-09-17 13:08:06 -0700137}