blob: 1066c8b2dd13146732dacf118e265afc89f8b98e [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;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070024import net.onrc.onos.core.packet.Ethernet;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025
26import org.openflow.protocol.OFMessage;
27import org.openflow.protocol.OFType;
28import 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 */
36public interface IFloodlightProviderService extends IFloodlightService {
37
38 /**
39 * A value stored in the floodlight context containing a parsed packet
Ray Milkey269ffb92014-04-03 14:43:30 -070040 * representation of the payload of a packet-in message.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080041 */
Ray Milkey269ffb92014-04-03 14:43:30 -070042 public static final String CONTEXT_PI_PAYLOAD =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080043 "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 Milkey269ffb92014-04-03 14:43:30 -070049 public static enum Role {
50 EQUAL, MASTER, SLAVE
51 }
52
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080053 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070054 * A FloodlightContextStore object that can be used to retrieve the
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080055 * packet-in payload
56 */
Ray Milkey269ffb92014-04-03 14:43:30 -070057 public static final FloodlightContextStore<Ethernet> bcStore =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080058 new FloodlightContextStore<Ethernet>();
59
60 /**
61 * Adds an OpenFlow message listener
Ray Milkey269ffb92014-04-03 14:43:30 -070062 *
63 * @param type The OFType the component wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080064 * @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 Milkey269ffb92014-04-03 14:43:30 -070070 *
71 * @param type The OFType the component no long wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080072 * @param listener The component that no longer wants to receive the message
73 */
74 public void removeOFMessageListener(OFType type, IOFMessageListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -070075
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080076 /**
77 * Return a non-modifiable list of all current listeners
Ray Milkey269ffb92014-04-03 14:43:30 -070078 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080079 * @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 Milkey269ffb92014-04-03 14:43:30 -070086 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080087 * @return the set of actively connected switches
88 */
89 public Map<Long, IOFSwitch> getSwitches();
Ray Milkey269ffb92014-04-03 14:43:30 -070090
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080091 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080092 * Get the current mapping of controller IDs to their IP addresses
Ray Milkey269ffb92014-04-03 14:43:30 -070093 * Returns a copy of the current mapping.
94 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080095 * @see IHAListener
96 */
Ray Milkey269ffb92014-04-03 14:43:30 -070097 public Map<String, String> getControllerNodeIPs();
98
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080099 /**
100 * Gets the ID of the controller
101 */
102 public String getControllerId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700103
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800104 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800105 * Add a switch listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700106 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800107 * @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 Milkey269ffb92014-04-03 14:43:30 -0700113 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800114 * @param listener The The module that no longer wants to listen for events
115 */
116 public void removeOFSwitchListener(IOFSwitchListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -0700117
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800118 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800119 * Terminate the process
120 */
121 public void terminate();
122
123 /**
124 * Re-injects an OFMessage back into the packet processing chain
Ray Milkey269ffb92014-04-03 14:43:30 -0700125 *
126 * @param sw The switch to use for the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800127 * @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 Milkey269ffb92014-04-03 14:43:30 -0700134 *
135 * @param sw The switch to use for the message
136 * @param msg the message to inject
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800137 * @param bContext a floodlight context to use if required
138 * @return True if successfully re-injected, false otherwise
139 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700140 public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
141 FloodlightContext bContext);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800142
143 /**
144 * Process written messages through the message listeners for the controller
Ray Milkey269ffb92014-04-03 14:43:30 -0700145 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800146 * @param sw The switch being written to
Ray Milkey269ffb92014-04-03 14:43:30 -0700147 * @param m the message
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800148 * @param bc any accompanying context object
149 */
Ray Milkey269ffb92014-04-03 14:43:30 -0700150 public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
151 FloodlightContext bc);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800152
153 /**
154 * Gets the BasicFactory
Ray Milkey269ffb92014-04-03 14:43:30 -0700155 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800156 * @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 Milkey269ffb92014-04-03 14:43:30 -0700164
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 Krishnaswamy345ee992012-12-13 20:29:48 -0800186
187}