blob: 1194e1825c851481b34dc6b37b145de6444b1e5c [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2 * Copyright 2011, Big Switch Networks, Inc.
3 * Originally created by David Erickson, Stanford University
Ray Milkey269ffb92014-04-03 14:43:30 -07004 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08005 * 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
18package net.floodlightcontroller.core;
19
20import java.util.List;
21import java.util.Map;
22
23import net.floodlightcontroller.core.module.IFloodlightService;
Pavlin Radoslavov695f8952014-07-23 16:57:01 -070024import net.onrc.onos.api.registry.ILocalSwitchMastershipListener;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070025import net.onrc.onos.core.packet.Ethernet;
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -070026import net.onrc.onos.core.util.OnosInstanceId;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080027
28import org.openflow.protocol.OFMessage;
29import org.openflow.protocol.OFType;
30import 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 */
38public interface IFloodlightProviderService extends IFloodlightService {
39
40 /**
41 * A value stored in the floodlight context containing a parsed packet
Ray Milkey269ffb92014-04-03 14:43:30 -070042 * representation of the payload of a packet-in message.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080043 */
Ray Milkey269ffb92014-04-03 14:43:30 -070044 public static final String CONTEXT_PI_PAYLOAD =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080045 "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 Milkey269ffb92014-04-03 14:43:30 -070051 public static enum Role {
52 EQUAL, MASTER, SLAVE
53 }
54
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080055 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070056 * A FloodlightContextStore object that can be used to retrieve the
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080057 * packet-in payload
58 */
Ray Milkey269ffb92014-04-03 14:43:30 -070059 public static final FloodlightContextStore<Ethernet> bcStore =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080060 new FloodlightContextStore<Ethernet>();
61
62 /**
63 * Adds an OpenFlow message listener
Ray Milkey269ffb92014-04-03 14:43:30 -070064 *
65 * @param type The OFType the component wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080066 * @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 Milkey269ffb92014-04-03 14:43:30 -070072 *
73 * @param type The OFType the component no long wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080074 * @param listener The component that no longer wants to receive the message
75 */
76 public void removeOFMessageListener(OFType type, IOFMessageListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -070077
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080078 /**
79 * Return a non-modifiable list of all current listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070080 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080081 * @return listeners
82 */
83 public Map<OFType, List<IOFMessageListener>> getListeners();
84
85 /**
Pavlin Radoslavov695f8952014-07-23 16:57:01 -070086 * 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 Krishnaswamy345ee992012-12-13 20:29:48 -0800104 * 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 Milkey269ffb92014-04-03 14:43:30 -0700106 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800107 * @return the set of actively connected switches
108 */
109 public Map<Long, IOFSwitch> getSwitches();
Ray Milkey269ffb92014-04-03 14:43:30 -0700110
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800111 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800112 * Get the current mapping of controller IDs to their IP addresses
Ray Milkey269ffb92014-04-03 14:43:30 -0700113 * Returns a copy of the current mapping.
114 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800115 * @see IHAListener
116 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700117 public Map<String, String> getControllerNodeIPs();
118
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800119 /**
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -0700120 * Gets the unique ID used to identify this ONOS instance in the cluster.
121 *
122 * @return ONOS Instance ID.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800123 */
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -0700124 public OnosInstanceId getOnosInstanceId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700125
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800126 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800127 * Add a switch listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700128 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800129 * @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 Milkey269ffb92014-04-03 14:43:30 -0700135 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800136 * @param listener The The module that no longer wants to listen for events
137 */
138 public void removeOFSwitchListener(IOFSwitchListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -0700139
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800140 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800141 * Terminate the process
142 */
143 public void terminate();
144
145 /**
146 * Re-injects an OFMessage back into the packet processing chain
Ray Milkey269ffb92014-04-03 14:43:30 -0700147 *
148 * @param sw The switch to use for the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800149 * @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 Milkey269ffb92014-04-03 14:43:30 -0700156 *
157 * @param sw The switch to use for the message
158 * @param msg the message to inject
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800159 * @param bContext a floodlight context to use if required
160 * @return True if successfully re-injected, false otherwise
161 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700162 public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
163 FloodlightContext bContext);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800164
165 /**
166 * Process written messages through the message listeners for the controller
Ray Milkey269ffb92014-04-03 14:43:30 -0700167 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800168 * @param sw The switch being written to
Ray Milkey269ffb92014-04-03 14:43:30 -0700169 * @param m the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800170 * @param bc any accompanying context object
171 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700172 public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
173 FloodlightContext bc);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800174
175 /**
176 * Gets the BasicFactory
Ray Milkey269ffb92014-04-03 14:43:30 -0700177 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800178 * @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 Milkey269ffb92014-04-03 14:43:30 -0700186
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 Krishnaswamy345ee992012-12-13 20:29:48 -0800208
209}