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