Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 19 | package org.onlab.onos.openflow.controller; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 20 | |
| 21 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 22 | |
| 23 | /** |
| 24 | * Abstraction of an OpenFlow controller. Serves as a one stop |
| 25 | * shop for obtaining OpenFlow devices and (un)register listeners |
| 26 | * on OpenFlow events |
| 27 | */ |
| 28 | public interface OpenFlowController { |
| 29 | |
| 30 | /** |
| 31 | * Returns all switches known to this OF controller. |
| 32 | * @return Iterable of dpid elements |
| 33 | */ |
| 34 | public Iterable<OpenFlowSwitch> getSwitches(); |
| 35 | |
| 36 | /** |
| 37 | * Returns all master switches known to this OF controller. |
| 38 | * @return Iterable of dpid elements |
| 39 | */ |
| 40 | public Iterable<OpenFlowSwitch> getMasterSwitches(); |
| 41 | |
| 42 | /** |
| 43 | * Returns all equal switches known to this OF controller. |
| 44 | * @return Iterable of dpid elements |
| 45 | */ |
| 46 | public Iterable<OpenFlowSwitch> getEqualSwitches(); |
| 47 | |
| 48 | |
| 49 | /** |
| 50 | * Returns the actual switch for the given Dpid. |
| 51 | * @param dpid the switch to fetch |
| 52 | * @return the interface to this switch |
| 53 | */ |
| 54 | public OpenFlowSwitch getSwitch(Dpid dpid); |
| 55 | |
| 56 | /** |
| 57 | * Returns the actual master switch for the given Dpid, if one exists. |
| 58 | * @param dpid the switch to fetch |
| 59 | * @return the interface to this switch |
| 60 | */ |
| 61 | public OpenFlowSwitch getMasterSwitch(Dpid dpid); |
| 62 | |
| 63 | /** |
| 64 | * Returns the actual equal switch for the given Dpid, if one exists. |
| 65 | * @param dpid the switch to fetch |
| 66 | * @return the interface to this switch |
| 67 | */ |
| 68 | public OpenFlowSwitch getEqualSwitch(Dpid dpid); |
| 69 | |
| 70 | /** |
| 71 | * Register a listener for meta events that occur to OF |
| 72 | * devices. |
| 73 | * @param listener the listener to notify |
| 74 | */ |
| 75 | public void addListener(OpenFlowSwitchListener listener); |
| 76 | |
| 77 | /** |
| 78 | * Unregister a listener. |
| 79 | * |
| 80 | * @param listener the listener to unregister |
| 81 | */ |
| 82 | public void removeListener(OpenFlowSwitchListener listener); |
| 83 | |
| 84 | /** |
| 85 | * Register a listener for packet events. |
| 86 | * @param priority the importance of this listener, lower values are more important |
| 87 | * @param listener the listener to notify |
| 88 | */ |
| 89 | public void addPacketListener(int priority, PacketListener listener); |
| 90 | |
| 91 | /** |
| 92 | * Unregister a listener. |
| 93 | * |
| 94 | * @param listener the listener to unregister |
| 95 | */ |
| 96 | public void removePacketListener(PacketListener listener); |
| 97 | |
| 98 | /** |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 99 | * Register a listener for OF msg events. |
| 100 | * |
| 101 | * @param listener the listener to notify |
| 102 | */ |
| 103 | public void addEventListener(OpenFlowEventListener listener); |
| 104 | |
| 105 | /** |
| 106 | * Unregister a listener. |
| 107 | * |
| 108 | * @param listener the listener to unregister |
| 109 | */ |
| 110 | public void removeEventListener(OpenFlowEventListener listener); |
| 111 | |
| 112 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 113 | * Send a message to a particular switch. |
| 114 | * @param dpid the switch to send to. |
| 115 | * @param msg the message to send |
| 116 | */ |
| 117 | public void write(Dpid dpid, OFMessage msg); |
| 118 | |
| 119 | /** |
| 120 | * Process a message and notify the appropriate listeners. |
| 121 | * |
| 122 | * @param dpid the dpid the message arrived on |
| 123 | * @param msg the message to process. |
| 124 | */ |
| 125 | public void processPacket(Dpid dpid, OFMessage msg); |
| 126 | |
| 127 | /** |
| 128 | * Sets the role for a given switch. |
| 129 | * @param role the desired role |
| 130 | * @param dpid the switch to set the role for. |
| 131 | */ |
| 132 | public void setRole(Dpid dpid, RoleState role); |
| 133 | } |