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 |
| 4 | * |
| 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; |
| 24 | import net.floodlightcontroller.packet.Ethernet; |
| 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 |
| 40 | * representation of the payload of a packet-in message. |
| 41 | */ |
| 42 | public static final String CONTEXT_PI_PAYLOAD = |
| 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 | */ |
| 49 | public static enum Role { EQUAL, MASTER, SLAVE }; |
| 50 | |
| 51 | /** |
| 52 | * A FloodlightContextStore object that can be used to retrieve the |
| 53 | * packet-in payload |
| 54 | */ |
| 55 | public static final FloodlightContextStore<Ethernet> bcStore = |
| 56 | new FloodlightContextStore<Ethernet>(); |
| 57 | |
| 58 | /** |
| 59 | * Adds an OpenFlow message listener |
| 60 | * @param type The OFType the component wants to listen for |
| 61 | * @param listener The component that wants to listen for the message |
| 62 | */ |
| 63 | public void addOFMessageListener(OFType type, IOFMessageListener listener); |
| 64 | |
| 65 | /** |
| 66 | * Removes an OpenFlow message listener |
| 67 | * @param type The OFType the component no long wants to listen for |
| 68 | * @param listener The component that no longer wants to receive the message |
| 69 | */ |
| 70 | public void removeOFMessageListener(OFType type, IOFMessageListener listener); |
| 71 | |
| 72 | /** |
| 73 | * Return a non-modifiable list of all current listeners |
| 74 | * @return listeners |
| 75 | */ |
| 76 | public Map<OFType, List<IOFMessageListener>> getListeners(); |
| 77 | |
| 78 | /** |
| 79 | * Returns an unmodifiable map of all actively connected OpenFlow switches. This doesn't |
| 80 | * contain switches that are connected but the controller's in the slave role. |
| 81 | * @return the set of actively connected switches |
| 82 | */ |
| 83 | public Map<Long, IOFSwitch> getSwitches(); |
| 84 | |
| 85 | /** |
| 86 | * Get the current role of the controller |
| 87 | */ |
| 88 | public Role getRole(); |
| 89 | |
| 90 | /** |
| 91 | * Get the current mapping of controller IDs to their IP addresses |
| 92 | * Returns a copy of the current mapping. |
| 93 | * @see IHAListener |
| 94 | */ |
| 95 | public Map<String,String> getControllerNodeIPs(); |
| 96 | |
| 97 | /** |
| 98 | * Gets the ID of the controller |
| 99 | */ |
| 100 | public String getControllerId(); |
| 101 | |
| 102 | /** |
| 103 | * Set the role of the controller |
| 104 | */ |
| 105 | public void setRole(Role role); |
| 106 | |
| 107 | /** |
| 108 | * Add a switch listener |
| 109 | * @param listener The module that wants to listen for events |
| 110 | */ |
| 111 | public void addOFSwitchListener(IOFSwitchListener listener); |
| 112 | |
| 113 | /** |
| 114 | * Remove a switch listener |
| 115 | * @param listener The The module that no longer wants to listen for events |
| 116 | */ |
| 117 | public void removeOFSwitchListener(IOFSwitchListener listener); |
| 118 | |
| 119 | /** |
| 120 | * Adds a listener for HA role events |
| 121 | * @param listener The module that wants to listen for events |
| 122 | */ |
| 123 | public void addHAListener(IHAListener listener); |
| 124 | |
| 125 | /** |
| 126 | * Removes a listener for HA role events |
| 127 | * @param listener The module that no longer wants to listen for events |
| 128 | */ |
| 129 | public void removeHAListener(IHAListener listener); |
| 130 | |
| 131 | /** |
| 132 | * Terminate the process |
| 133 | */ |
| 134 | public void terminate(); |
| 135 | |
| 136 | /** |
| 137 | * Re-injects an OFMessage back into the packet processing chain |
| 138 | * @param sw The switch to use for the message |
| 139 | * @param msg the message to inject |
| 140 | * @return True if successfully re-injected, false otherwise |
| 141 | */ |
| 142 | public boolean injectOfMessage(IOFSwitch sw, OFMessage msg); |
| 143 | |
| 144 | /** |
| 145 | * Re-injects an OFMessage back into the packet processing chain |
| 146 | * @param sw The switch to use for the message |
| 147 | * @param msg the message to inject |
| 148 | * @param bContext a floodlight context to use if required |
| 149 | * @return True if successfully re-injected, false otherwise |
| 150 | */ |
| 151 | public boolean injectOfMessage(IOFSwitch sw, OFMessage msg, |
| 152 | FloodlightContext bContext); |
| 153 | |
| 154 | /** |
| 155 | * Process written messages through the message listeners for the controller |
| 156 | * @param sw The switch being written to |
| 157 | * @param m the message |
| 158 | * @param bc any accompanying context object |
| 159 | */ |
| 160 | public void handleOutgoingMessage(IOFSwitch sw, OFMessage m, |
| 161 | FloodlightContext bc); |
| 162 | |
| 163 | /** |
| 164 | * Gets the BasicFactory |
| 165 | * @return an OpenFlow message factory |
| 166 | */ |
| 167 | public BasicFactory getOFMessageFactory(); |
| 168 | |
| 169 | /** |
| 170 | * Run the main I/O loop of the Controller. |
| 171 | */ |
| 172 | public void run(); |
| 173 | |
| 174 | /** |
| 175 | * Add an info provider of a particular type |
| 176 | * @param type |
| 177 | * @param provider |
| 178 | */ |
| 179 | public void addInfoProvider(String type, IInfoProvider provider); |
| 180 | |
| 181 | /** |
| 182 | * Remove an info provider of a particular type |
| 183 | * @param type |
| 184 | * @param provider |
| 185 | */ |
| 186 | public void removeInfoProvider(String type, IInfoProvider provider); |
| 187 | |
| 188 | /** |
| 189 | * Return information of a particular type (for rest services) |
| 190 | * @param type |
| 191 | * @return |
| 192 | */ |
| 193 | public Map<String, Object> getControllerInfo(String type); |
| 194 | |
| 195 | |
| 196 | /** |
| 197 | * Return the controller start time in milliseconds |
| 198 | * @return |
| 199 | */ |
| 200 | public long getSystemStartTime(); |
| 201 | |
| 202 | /** |
| 203 | * Configure controller to always clear the flow table on the switch, |
| 204 | * when it connects to controller. This will be true for first time switch |
| 205 | * reconnect, as well as a switch re-attaching to Controller after HA |
| 206 | * switch over to ACTIVE role |
| 207 | */ |
| 208 | public void setAlwaysClearFlowsOnSwAdd(boolean value); |
| 209 | |
| 210 | } |