blob: e6e1f826acf143ead08969fedf3ca4451f4b2785 [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;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080026
27import org.openflow.protocol.OFMessage;
28import org.openflow.protocol.OFType;
29import 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 */
37public interface IFloodlightProviderService extends IFloodlightService {
38
39 /**
40 * A value stored in the floodlight context containing a parsed packet
Ray Milkey269ffb92014-04-03 14:43:30 -070041 * representation of the payload of a packet-in message.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080042 */
Ray Milkey269ffb92014-04-03 14:43:30 -070043 public static final String CONTEXT_PI_PAYLOAD =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080044 "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 Milkey269ffb92014-04-03 14:43:30 -070050 public static enum Role {
51 EQUAL, MASTER, SLAVE
52 }
53
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080054 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070055 * A FloodlightContextStore object that can be used to retrieve the
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080056 * packet-in payload
57 */
Ray Milkey269ffb92014-04-03 14:43:30 -070058 public static final FloodlightContextStore<Ethernet> bcStore =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080059 new FloodlightContextStore<Ethernet>();
60
61 /**
62 * Adds an OpenFlow message listener
Ray Milkey269ffb92014-04-03 14:43:30 -070063 *
64 * @param type The OFType the component wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080065 * @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 Milkey269ffb92014-04-03 14:43:30 -070071 *
72 * @param type The OFType the component no long wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080073 * @param listener The component that no longer wants to receive the message
74 */
75 public void removeOFMessageListener(OFType type, IOFMessageListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -070076
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080077 /**
78 * Return a non-modifiable list of all current listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070079 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080080 * @return listeners
81 */
82 public Map<OFType, List<IOFMessageListener>> getListeners();
83
84 /**
Pavlin Radoslavov695f8952014-07-23 16:57:01 -070085 * 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 Krishnaswamy345ee992012-12-13 20:29:48 -0800103 * 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 Milkey269ffb92014-04-03 14:43:30 -0700105 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800106 * @return the set of actively connected switches
107 */
108 public Map<Long, IOFSwitch> getSwitches();
Ray Milkey269ffb92014-04-03 14:43:30 -0700109
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800110 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800111 * Get the current mapping of controller IDs to their IP addresses
Ray Milkey269ffb92014-04-03 14:43:30 -0700112 * Returns a copy of the current mapping.
113 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800114 * @see IHAListener
115 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700116 public Map<String, String> getControllerNodeIPs();
117
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800118 /**
119 * Gets the ID of the controller
120 */
121 public String getControllerId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700122
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800123 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800124 * Add a switch listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700125 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800126 * @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 Milkey269ffb92014-04-03 14:43:30 -0700132 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800133 * @param listener The The module that no longer wants to listen for events
134 */
135 public void removeOFSwitchListener(IOFSwitchListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -0700136
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800137 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800138 * Terminate the process
139 */
140 public void terminate();
141
142 /**
143 * Re-injects an OFMessage back into the packet processing chain
Ray Milkey269ffb92014-04-03 14:43:30 -0700144 *
145 * @param sw The switch to use for the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800146 * @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 Milkey269ffb92014-04-03 14:43:30 -0700153 *
154 * @param sw The switch to use for the message
155 * @param msg the message to inject
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800156 * @param bContext a floodlight context to use if required
157 * @return True if successfully re-injected, false otherwise
158 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700159 public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
160 FloodlightContext bContext);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800161
162 /**
163 * Process written messages through the message listeners for the controller
Ray Milkey269ffb92014-04-03 14:43:30 -0700164 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800165 * @param sw The switch being written to
Ray Milkey269ffb92014-04-03 14:43:30 -0700166 * @param m the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800167 * @param bc any accompanying context object
168 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700169 public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
170 FloodlightContext bc);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800171
172 /**
173 * Gets the BasicFactory
Ray Milkey269ffb92014-04-03 14:43:30 -0700174 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800175 * @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 Milkey269ffb92014-04-03 14:43:30 -0700183
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 Krishnaswamy345ee992012-12-13 20:29:48 -0800205
206}