Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson, Stanford University |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 4 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package net.floodlightcontroller.core; |
| 19 | |
| 20 | import java.util.List; |
| 21 | import java.util.Map; |
| 22 | |
| 23 | import net.floodlightcontroller.core.module.IFloodlightService; |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 24 | import net.onrc.onos.api.registry.ILocalSwitchMastershipListener; |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 25 | import net.onrc.onos.core.packet.Ethernet; |
Pavlin Radoslavov | 53b208a | 2014-07-28 13:16:11 -0700 | [diff] [blame] | 26 | import net.onrc.onos.core.util.OnosInstanceId; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 27 | |
| 28 | import org.openflow.protocol.OFMessage; |
| 29 | import org.openflow.protocol.OFType; |
| 30 | import org.openflow.protocol.factory.BasicFactory; |
| 31 | |
| 32 | /** |
| 33 | * The interface exposed by the core bundle that allows you to interact |
| 34 | * with connected switches. |
| 35 | * |
| 36 | * @author David Erickson (daviderickson@cs.stanford.edu) |
| 37 | */ |
| 38 | public interface IFloodlightProviderService extends IFloodlightService { |
| 39 | |
| 40 | /** |
| 41 | * A value stored in the floodlight context containing a parsed packet |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 42 | * representation of the payload of a packet-in message. |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 43 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 44 | public static final String CONTEXT_PI_PAYLOAD = |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 45 | "net.floodlightcontroller.core.IFloodlightProvider.piPayload"; |
| 46 | |
| 47 | /** |
| 48 | * The role of the controller as used by the OF 1.2 and OVS failover and |
| 49 | * load-balancing mechanism. |
| 50 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 51 | public static enum Role { |
| 52 | EQUAL, MASTER, SLAVE |
| 53 | } |
| 54 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 55 | /** |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 56 | * A FloodlightContextStore object that can be used to retrieve the |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 57 | * packet-in payload |
| 58 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 59 | public static final FloodlightContextStore<Ethernet> bcStore = |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 60 | new FloodlightContextStore<Ethernet>(); |
| 61 | |
| 62 | /** |
| 63 | * Adds an OpenFlow message listener |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 64 | * |
| 65 | * @param type The OFType the component wants to listen for |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 66 | * @param listener The component that wants to listen for the message |
| 67 | */ |
| 68 | public void addOFMessageListener(OFType type, IOFMessageListener listener); |
| 69 | |
| 70 | /** |
| 71 | * Removes an OpenFlow message listener |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 72 | * |
| 73 | * @param type The OFType the component no long wants to listen for |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 74 | * @param listener The component that no longer wants to receive the message |
| 75 | */ |
| 76 | public void removeOFMessageListener(OFType type, IOFMessageListener listener); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 77 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 78 | /** |
| 79 | * Return a non-modifiable list of all current listeners |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 80 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 81 | * @return listeners |
| 82 | */ |
| 83 | public Map<OFType, List<IOFMessageListener>> getListeners(); |
| 84 | |
| 85 | /** |
Pavlin Radoslavov | 695f895 | 2014-07-23 16:57:01 -0700 | [diff] [blame] | 86 | * Adds a switch mastership listener for controller role changes for |
| 87 | * local switches. |
| 88 | * |
| 89 | * @param listener the listener to add. |
| 90 | */ |
| 91 | public void addLocalSwitchMastershipListener( |
| 92 | ILocalSwitchMastershipListener listener); |
| 93 | |
| 94 | /** |
| 95 | * Removes a switch mastership listener for controller role changes for |
| 96 | * local switches. |
| 97 | * |
| 98 | * @param listener the listener to remove. |
| 99 | */ |
| 100 | public void removeLocalSwitchMastershipListener( |
| 101 | ILocalSwitchMastershipListener listener); |
| 102 | |
| 103 | /** |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 104 | * Returns an unmodifiable map of all actively connected OpenFlow switches. This doesn't |
| 105 | * contain switches that are connected but the controller's in the slave role. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 106 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 107 | * @return the set of actively connected switches |
| 108 | */ |
| 109 | public Map<Long, IOFSwitch> getSwitches(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 110 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 111 | /** |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 112 | * Get the current mapping of controller IDs to their IP addresses |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 113 | * Returns a copy of the current mapping. |
| 114 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 115 | * @see IHAListener |
| 116 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 117 | public Map<String, String> getControllerNodeIPs(); |
| 118 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 119 | /** |
Pavlin Radoslavov | 53b208a | 2014-07-28 13:16:11 -0700 | [diff] [blame] | 120 | * Gets the unique ID used to identify this ONOS instance in the cluster. |
| 121 | * |
| 122 | * @return ONOS Instance ID. |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 123 | */ |
Pavlin Radoslavov | 53b208a | 2014-07-28 13:16:11 -0700 | [diff] [blame] | 124 | public OnosInstanceId getOnosInstanceId(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 125 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 126 | /** |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 127 | * Add a switch listener |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 128 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 129 | * @param listener The module that wants to listen for events |
| 130 | */ |
| 131 | public void addOFSwitchListener(IOFSwitchListener listener); |
| 132 | |
| 133 | /** |
| 134 | * Remove a switch listener |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 135 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 136 | * @param listener The The module that no longer wants to listen for events |
| 137 | */ |
| 138 | public void removeOFSwitchListener(IOFSwitchListener listener); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 139 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 140 | /** |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 141 | * Terminate the process |
| 142 | */ |
| 143 | public void terminate(); |
| 144 | |
| 145 | /** |
| 146 | * Re-injects an OFMessage back into the packet processing chain |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 147 | * |
| 148 | * @param sw The switch to use for the message |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 149 | * @param msg the message to inject |
| 150 | * @return True if successfully re-injected, false otherwise |
| 151 | */ |
| 152 | public boolean injectOfMessage(IOFSwitch sw, OFMessage msg); |
| 153 | |
| 154 | /** |
| 155 | * Re-injects an OFMessage back into the packet processing chain |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 156 | * |
| 157 | * @param sw The switch to use for the message |
| 158 | * @param msg the message to inject |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 159 | * @param bContext a floodlight context to use if required |
| 160 | * @return True if successfully re-injected, false otherwise |
| 161 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 162 | public boolean injectOfMessage(IOFSwitch sw, OFMessage msg, |
| 163 | FloodlightContext bContext); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Process written messages through the message listeners for the controller |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 167 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 168 | * @param sw The switch being written to |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 169 | * @param m the message |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 170 | * @param bc any accompanying context object |
| 171 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 172 | public void handleOutgoingMessage(IOFSwitch sw, OFMessage m, |
| 173 | FloodlightContext bc); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * Gets the BasicFactory |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 177 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 178 | * @return an OpenFlow message factory |
| 179 | */ |
| 180 | public BasicFactory getOFMessageFactory(); |
| 181 | |
| 182 | /** |
| 183 | * Run the main I/O loop of the Controller. |
| 184 | */ |
| 185 | public void run(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Return the controller start time in milliseconds |
| 189 | * |
| 190 | * @return |
| 191 | */ |
| 192 | public long getSystemStartTime(); |
| 193 | |
| 194 | /** |
| 195 | * Configure controller to always clear the flow table on the switch, |
| 196 | * when it connects to controller. This will be true for first time switch |
| 197 | * reconnect, as well as a switch re-attaching to Controller after HA |
| 198 | * switch over to ACTIVE role |
| 199 | */ |
| 200 | public void setAlwaysClearFlowsOnSwAdd(boolean value); |
| 201 | |
| 202 | /** |
| 203 | * Publish updates to Controller updates queue |
| 204 | * |
| 205 | * @param IUpdate |
| 206 | */ |
| 207 | public void publishUpdate(IUpdate update); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 208 | |
| 209 | } |