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