2 * Copyright 2014 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onosproject.openflow.controller;
18 import org.projectfloodlight.openflow.protocol.OFMessage;
21 * Abstraction of an OpenFlow controller. Serves as a one stop
22 * shop for obtaining OpenFlow devices and (un)register listeners
25 public interface OpenFlowController {
28 * Returns all switches known to this OF controller.
29 * @return Iterable of dpid elements
31 Iterable<OpenFlowSwitch> getSwitches();
34 * Returns all master switches known to this OF controller.
35 * @return Iterable of dpid elements
37 Iterable<OpenFlowSwitch> getMasterSwitches();
40 * Returns all equal switches known to this OF controller.
41 * @return Iterable of dpid elements
43 Iterable<OpenFlowSwitch> getEqualSwitches();
47 * Returns the actual switch for the given Dpid.
48 * @param dpid the switch to fetch
49 * @return the interface to this switch
51 OpenFlowSwitch getSwitch(Dpid dpid);
54 * Returns the actual master switch for the given Dpid, if one exists.
55 * @param dpid the switch to fetch
56 * @return the interface to this switch
58 OpenFlowSwitch getMasterSwitch(Dpid dpid);
61 * Returns the actual equal switch for the given Dpid, if one exists.
62 * @param dpid the switch to fetch
63 * @return the interface to this switch
65 OpenFlowSwitch getEqualSwitch(Dpid dpid);
68 * Register a listener for meta events that occur to OF
70 * @param listener the listener to notify
72 void addListener(OpenFlowSwitchListener listener);
75 * Unregister a listener.
77 * @param listener the listener to unregister
79 void removeListener(OpenFlowSwitchListener listener);
82 * Register a listener for packet events.
83 * @param priority the importance of this listener, lower values are more important
84 * @param listener the listener to notify
86 void addPacketListener(int priority, PacketListener listener);
89 * Unregister a listener.
91 * @param listener the listener to unregister
93 void removePacketListener(PacketListener listener);
96 * Register a listener for OF msg events.
98 * @param listener the listener to notify
100 void addEventListener(OpenFlowEventListener listener);
103 * Unregister a listener.
105 * @param listener the listener to unregister
107 void removeEventListener(OpenFlowEventListener listener);
110 * Send a message to a particular switch.
111 * @param dpid the switch to send to.
112 * @param msg the message to send
114 void write(Dpid dpid, OFMessage msg);
117 * Process a message and notify the appropriate listeners.
119 * @param dpid the dpid the message arrived on
120 * @param msg the message to process.
122 void processPacket(Dpid dpid, OFMessage msg);
125 * Sets the role for a given switch.
126 * @param role the desired role
127 * @param dpid the switch to set the role for.
129 void setRole(Dpid dpid, RoleState role);