Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
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; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 17 | |
| 18 | import 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 | */ |
| 25 | public interface OpenFlowController { |
| 26 | |
| 27 | /** |
| 28 | * Returns all switches known to this OF controller. |
| 29 | * @return Iterable of dpid elements |
| 30 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 31 | Iterable<OpenFlowSwitch> getSwitches(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Returns all master switches known to this OF controller. |
| 35 | * @return Iterable of dpid elements |
| 36 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 37 | Iterable<OpenFlowSwitch> getMasterSwitches(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Returns all equal switches known to this OF controller. |
| 41 | * @return Iterable of dpid elements |
| 42 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 43 | Iterable<OpenFlowSwitch> getEqualSwitches(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 44 | |
| 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 SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 51 | OpenFlowSwitch getSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 52 | |
| 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 SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 58 | OpenFlowSwitch getMasterSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 59 | |
| 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 SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 65 | OpenFlowSwitch getEqualSwitch(Dpid dpid); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Register a listener for meta events that occur to OF |
| 69 | * devices. |
| 70 | * @param listener the listener to notify |
| 71 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 72 | void addListener(OpenFlowSwitchListener listener); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Unregister a listener. |
| 76 | * |
| 77 | * @param listener the listener to unregister |
| 78 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 79 | void removeListener(OpenFlowSwitchListener listener); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Register a listener for packet events. |
| 83 | * @param priority the importance of this listener, lower values are more important |
| 84 | * @param listener the listener to notify |
| 85 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 86 | void addPacketListener(int priority, PacketListener listener); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Unregister a listener. |
| 90 | * |
| 91 | * @param listener the listener to unregister |
| 92 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 93 | void removePacketListener(PacketListener listener); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 96 | * Register a listener for OF msg events. |
| 97 | * |
| 98 | * @param listener the listener to notify |
| 99 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 100 | void addEventListener(OpenFlowEventListener listener); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Unregister a listener. |
| 104 | * |
| 105 | * @param listener the listener to unregister |
| 106 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 107 | void removeEventListener(OpenFlowEventListener listener); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 110 | * Send a message to a particular switch. |
| 111 | * @param dpid the switch to send to. |
| 112 | * @param msg the message to send |
| 113 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 114 | void write(Dpid dpid, OFMessage msg); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Process a message and notify the appropriate listeners. |
| 118 | * |
| 119 | * @param dpid the dpid the message arrived on |
| 120 | * @param msg the message to process. |
| 121 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 122 | void processPacket(Dpid dpid, OFMessage msg); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Sets the role for a given switch. |
| 126 | * @param role the desired role |
| 127 | * @param dpid the switch to set the role for. |
| 128 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 129 | void setRole(Dpid dpid, RoleState role); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 130 | } |