blob: 4447b7539e64b105b366928b1b3eef01f29da11c [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07002 * Copyright 2011, Big Switch Networks, Inc.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08003 * 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;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070022import java.util.Set;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080023
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070024import net.floodlightcontroller.core.internal.Controller.Counters;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025import net.floodlightcontroller.core.module.IFloodlightService;
Saurav Dasfc5e3eb2014-09-25 19:05:21 -070026import net.onrc.onos.core.configmanager.INetworkConfigService;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070027import net.onrc.onos.core.packet.Ethernet;
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -070028import net.onrc.onos.core.util.OnosInstanceId;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080029
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070030import org.projectfloodlight.openflow.protocol.OFControllerRole;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070031import org.projectfloodlight.openflow.protocol.OFType;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080032
33/**
34 * The interface exposed by the core bundle that allows you to interact
35 * with connected switches.
36 *
37 * @author David Erickson (daviderickson@cs.stanford.edu)
38 */
39public interface IFloodlightProviderService extends IFloodlightService {
40
41 /**
42 * A value stored in the floodlight context containing a parsed packet
Ray Milkey269ffb92014-04-03 14:43:30 -070043 * representation of the payload of a packet-in message.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080044 */
Ray Milkey269ffb92014-04-03 14:43:30 -070045 public static final String CONTEXT_PI_PAYLOAD =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080046 "net.floodlightcontroller.core.IFloodlightProvider.piPayload";
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070047 public static final String CONTEXT_PI_INPORT =
48 "net.floodlightcontroller.core.IFloodlightProvider.piInPort";;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080049 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070050 * The role of the controller as it pertains to a particular switch.
51 * Note that this definition of the role enum is different from the
52 * OF1.3 definition. It is maintained here to be backward compatible to
53 * earlier versions of the controller code. This enum is translated
54 * to the OF1.3 enum, before role messages are sent to the switch.
55 * See sendRoleRequestMessage method in OFSwitchImpl
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080056 */
Ray Milkey269ffb92014-04-03 14:43:30 -070057 public static enum Role {
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070058 EQUAL(OFControllerRole.ROLE_EQUAL),
59 MASTER(OFControllerRole.ROLE_MASTER),
60 SLAVE(OFControllerRole.ROLE_SLAVE);
61
62 private final int nxRole;
63
64 private Role(OFControllerRole nxRole) {
65 this.nxRole = nxRole.ordinal();
66 }
67 /*
68 private static Map<Integer,Role> nxRoleToEnum
69 = new HashMap<Integer,Role>();
70 static {
71 for(Role r: Role.values())
72 nxRoleToEnum.put(r.toNxRole(), r);
73 }
74 public int toNxRole() {
75 return nxRole;
76 }
77 // Return the enum representing the given nxRole or null if no
78 // such role exists
79 public static Role fromNxRole(int nxRole) {
80 return nxRoleToEnum.get(nxRole);
81 }*/
Ray Milkey269ffb92014-04-03 14:43:30 -070082 }
83
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080084 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070085 * A FloodlightContextStore object that can be used to retrieve the
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080086 * packet-in payload
87 */
Ray Milkey269ffb92014-04-03 14:43:30 -070088 public static final FloodlightContextStore<Ethernet> bcStore =
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080089 new FloodlightContextStore<Ethernet>();
90
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070091
92 //************************
93 // Controller related
94 //************************
95
96 /**
97 * Get the current mapping of controller IDs to their IP addresses
98 * Returns a copy of the current mapping.
99 *
100 * @see IHAListener
101 */
102 public Map<String, String> getControllerNodeIPs();
103
104 /**
105 * Return the controller start time in milliseconds
106 *
107 * @return
108 */
109 public long getSystemStartTime();
110
111 /**
112 * Run the main I/O loop of the Controller.
113 */
114 public void run();
115
116// /**
117// * Terminate the process
118// */
119// public void terminate();
120
121 //************************
122 // OF Message Listener related
123 //************************
124
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800125 /**
126 * Adds an OpenFlow message listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700127 *
128 * @param type The OFType the component wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800129 * @param listener The component that wants to listen for the message
130 */
131 public void addOFMessageListener(OFType type, IOFMessageListener listener);
132
133 /**
134 * Removes an OpenFlow message listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700135 *
136 * @param type The OFType the component no long wants to listen for
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800137 * @param listener The component that no longer wants to receive the message
138 */
139 public void removeOFMessageListener(OFType type, IOFMessageListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -0700140
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800141 /**
142 * Return a non-modifiable list of all current listeners
Ray Milkey269ffb92014-04-03 14:43:30 -0700143 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800144 * @return listeners
145 */
146 public Map<OFType, List<IOFMessageListener>> getListeners();
147
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700148 //************************
149 // Switch & SwitchListener related
150 //************************
Pavlin Radoslavov695f8952014-07-23 16:57:01 -0700151
152 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800153 * Returns an unmodifiable map of all actively connected OpenFlow switches. This doesn't
154 * contain switches that are connected but the controller's in the slave role.
Ray Milkey269ffb92014-04-03 14:43:30 -0700155 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800156 * @return the set of actively connected switches
157 */
158 public Map<Long, IOFSwitch> getSwitches();
Ray Milkey269ffb92014-04-03 14:43:30 -0700159
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800160 /**
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700161 * Configure controller to always clear the flow table on the switch,
162 * when it connects to controller. This will be true for first time switch
163 * reconnect, as well as a switch re-attaching to Controller after HA
164 * switch over to ACTIVE role
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800165 */
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700166 public void setAlwaysClearFlowsOnSwAdd(boolean value);
Ray Milkey269ffb92014-04-03 14:43:30 -0700167
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800168 /**
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -0700169 * Gets the unique ID used to identify this ONOS instance in the cluster.
170 *
171 * @return ONOS Instance ID.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800172 */
Pavlin Radoslavov53b208a2014-07-28 13:16:11 -0700173 public OnosInstanceId getOnosInstanceId();
Ray Milkey269ffb92014-04-03 14:43:30 -0700174
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800175 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800176 * Add a switch listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700177 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800178 * @param listener The module that wants to listen for events
179 */
180 public void addOFSwitchListener(IOFSwitchListener listener);
181
182 /**
183 * Remove a switch listener
Ray Milkey269ffb92014-04-03 14:43:30 -0700184 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800185 * @param listener The The module that no longer wants to listen for events
186 */
187 public void removeOFSwitchListener(IOFSwitchListener listener);
Ray Milkey269ffb92014-04-03 14:43:30 -0700188
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700189
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700190 Set<Long> getAllSwitchDpids();
191
192 IOFSwitch getSwitch(long dpid);
193
194 /**
195 * Record a switch event in in-memory debug-event
196 *
197 * @param switchDPID
198 * @param reason Reason for this event
199 * @param flushNow see debug-event flushing in IDebugEventService
200 */
201 public void addSwitchEvent(long switchDPID, String reason, boolean flushNow);
202
203 Set<Long> getAllMasterSwitchDpids();
204
205 Set<Long> getAllEqualSwitchDpids();
206
207 IOFSwitch getMasterSwitch(long dpid);
208
209 IOFSwitch getEqualSwitch(long dpid);
210
211 void setAlwaysClearFlowsOnSwActivate(boolean value);
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700212
213 //************************
214 // Utility methods
215 //************************
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800216
217 /**
Ray Milkey269ffb92014-04-03 14:43:30 -0700218 * Publish updates to Controller updates queue
219 *
220 * @param IUpdate
221 */
222 public void publishUpdate(IUpdate update);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800223
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700224// /**
225// * Re-injects an OFMessage back into the packet processing chain
226// *
227// * @param sw The switch to use for the message
228// * @param msg the message to inject
229// * @return True if successfully re-injected, false otherwise
230// */
231// public boolean injectOfMessage(IOFSwitch sw, OFMessage msg);
232//
233// /**
234// * Re-injects an OFMessage back into the packet processing chain
235// *
236// * @param sw The switch to use for the message
237// * @param msg the message to inject
238// * @param bContext a floodlight context to use if required
239// * @return True if successfully re-injected, false otherwise
240// */
241// public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
242// FloodlightContext bContext);
243//
244// /**
245// * Process written messages through the message listeners for the controller
246// *
247// * @param sw The switch being written to
248// * @param m the message
249// * @param bc any accompanying context object
250// */
251// public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
252// FloodlightContext bc);
253
254
255 /**
256 * Return the default set of counters
257 * @return
258 */
259 public Counters getCounters();
260
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700261
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700262
263 Map<String, Long> getMemory();
264
265 Long getUptime();
266
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700267
Saurav Dasfc5e3eb2014-09-25 19:05:21 -0700268 public INetworkConfigService getNetworkConfigService();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800269}