blob: c48291fcc67b1d99a6481ad3dba7219e36f67288 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
tom9c94c5b2014-09-17 13:14:42 -070016package org.onlab.onos.openflow.controller;
tom7ef8ff92014-09-17 13:08:06 -070017
18import org.projectfloodlight.openflow.protocol.OFMessage;
19
20/**
21 * Abstraction of an OpenFlow controller. Serves as a one stop
22 * shop for obtaining OpenFlow devices and (un)register listeners
23 * on OpenFlow events
24 */
25public interface OpenFlowController {
26
27 /**
28 * Returns all switches known to this OF controller.
29 * @return Iterable of dpid elements
30 */
31 public Iterable<OpenFlowSwitch> getSwitches();
32
33 /**
34 * Returns all master switches known to this OF controller.
35 * @return Iterable of dpid elements
36 */
37 public Iterable<OpenFlowSwitch> getMasterSwitches();
38
39 /**
40 * Returns all equal switches known to this OF controller.
41 * @return Iterable of dpid elements
42 */
43 public Iterable<OpenFlowSwitch> getEqualSwitches();
44
45
46 /**
47 * Returns the actual switch for the given Dpid.
48 * @param dpid the switch to fetch
49 * @return the interface to this switch
50 */
51 public OpenFlowSwitch getSwitch(Dpid dpid);
52
53 /**
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
57 */
58 public OpenFlowSwitch getMasterSwitch(Dpid dpid);
59
60 /**
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
64 */
65 public OpenFlowSwitch getEqualSwitch(Dpid dpid);
66
67 /**
68 * Register a listener for meta events that occur to OF
69 * devices.
70 * @param listener the listener to notify
71 */
72 public void addListener(OpenFlowSwitchListener listener);
73
74 /**
75 * Unregister a listener.
76 *
77 * @param listener the listener to unregister
78 */
79 public void removeListener(OpenFlowSwitchListener listener);
80
81 /**
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
85 */
86 public void addPacketListener(int priority, PacketListener listener);
87
88 /**
89 * Unregister a listener.
90 *
91 * @param listener the listener to unregister
92 */
93 public void removePacketListener(PacketListener listener);
94
95 /**
alshabibeec3a062014-09-17 18:01:26 -070096 * Register a listener for OF msg events.
97 *
98 * @param listener the listener to notify
99 */
100 public void addEventListener(OpenFlowEventListener listener);
101
102 /**
103 * Unregister a listener.
104 *
105 * @param listener the listener to unregister
106 */
107 public void removeEventListener(OpenFlowEventListener listener);
108
109 /**
tom7ef8ff92014-09-17 13:08:06 -0700110 * Send a message to a particular switch.
111 * @param dpid the switch to send to.
112 * @param msg the message to send
113 */
114 public void write(Dpid dpid, OFMessage msg);
115
116 /**
117 * Process a message and notify the appropriate listeners.
118 *
119 * @param dpid the dpid the message arrived on
120 * @param msg the message to process.
121 */
122 public void processPacket(Dpid dpid, OFMessage msg);
123
124 /**
125 * Sets the role for a given switch.
126 * @param role the desired role
127 * @param dpid the switch to set the role for.
128 */
129 public void setRole(Dpid dpid, RoleState role);
130}