blob: 4a49488c33555c5ff11fe71ac481df4e74a4a342 [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
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
18package net.floodlightcontroller.core;
19
20import java.util.List;
21import java.util.Map;
22
23import net.floodlightcontroller.core.module.IFloodlightService;
Jonathan Hart96892d12014-03-26 20:21:29 -070024import net.onrc.onos.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
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 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080086 * Get the current mapping of controller IDs to their IP addresses
87 * Returns a copy of the current mapping.
88 * @see IHAListener
89 */
90 public Map<String,String> getControllerNodeIPs();
91
92 /**
93 * Gets the ID of the controller
94 */
95 public String getControllerId();
96
97 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080098 * Add a switch listener
99 * @param listener The module that wants to listen for events
100 */
101 public void addOFSwitchListener(IOFSwitchListener listener);
102
103 /**
104 * Remove a switch listener
105 * @param listener The The module that no longer wants to listen for events
106 */
107 public void removeOFSwitchListener(IOFSwitchListener listener);
108
109 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800110 * Terminate the process
111 */
112 public void terminate();
113
114 /**
115 * Re-injects an OFMessage back into the packet processing chain
116 * @param sw The switch to use for the message
117 * @param msg the message to inject
118 * @return True if successfully re-injected, false otherwise
119 */
120 public boolean injectOfMessage(IOFSwitch sw, OFMessage msg);
121
122 /**
123 * Re-injects an OFMessage back into the packet processing chain
124 * @param sw The switch to use for the message
125 * @param msg the message to inject
126 * @param bContext a floodlight context to use if required
127 * @return True if successfully re-injected, false otherwise
128 */
129 public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
130 FloodlightContext bContext);
131
132 /**
133 * Process written messages through the message listeners for the controller
134 * @param sw The switch being written to
135 * @param m the message
136 * @param bc any accompanying context object
137 */
138 public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
139 FloodlightContext bc);
140
141 /**
142 * Gets the BasicFactory
143 * @return an OpenFlow message factory
144 */
145 public BasicFactory getOFMessageFactory();
146
147 /**
148 * Run the main I/O loop of the Controller.
149 */
150 public void run();
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800151
152 /**
153 * Return the controller start time in milliseconds
154 * @return
155 */
156 public long getSystemStartTime();
157
158 /**
159 * Configure controller to always clear the flow table on the switch,
160 * when it connects to controller. This will be true for first time switch
161 * reconnect, as well as a switch re-attaching to Controller after HA
162 * switch over to ACTIVE role
163 */
164 public void setAlwaysClearFlowsOnSwAdd(boolean value);
Pankaj Berdedc73bb12013-08-14 13:46:38 -0700165
166 /**
167 * Publish updates to Controller updates queue
168 * @param IUpdate
169 */
170 public void publishUpdate(IUpdate update);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800171
172}