blob: ab80eee789857a0cb7bece1430a3950c95116050 [file] [log] [blame]
tom7ef8ff92014-09-17 13:08:06 -07001package org.onlab.onos.of.controller;
2
3import org.projectfloodlight.openflow.protocol.OFMessage;
4
5/**
6 * Abstraction of an OpenFlow controller. Serves as a one stop
7 * shop for obtaining OpenFlow devices and (un)register listeners
8 * on OpenFlow events
9 */
10public interface OpenFlowController {
11
12 /**
13 * Returns all switches known to this OF controller.
14 * @return Iterable of dpid elements
15 */
16 public Iterable<OpenFlowSwitch> getSwitches();
17
18 /**
19 * Returns all master switches known to this OF controller.
20 * @return Iterable of dpid elements
21 */
22 public Iterable<OpenFlowSwitch> getMasterSwitches();
23
24 /**
25 * Returns all equal switches known to this OF controller.
26 * @return Iterable of dpid elements
27 */
28 public Iterable<OpenFlowSwitch> getEqualSwitches();
29
30
31 /**
32 * Returns the actual switch for the given Dpid.
33 * @param dpid the switch to fetch
34 * @return the interface to this switch
35 */
36 public OpenFlowSwitch getSwitch(Dpid dpid);
37
38 /**
39 * Returns the actual master switch for the given Dpid, if one exists.
40 * @param dpid the switch to fetch
41 * @return the interface to this switch
42 */
43 public OpenFlowSwitch getMasterSwitch(Dpid dpid);
44
45 /**
46 * Returns the actual equal switch for the given Dpid, if one exists.
47 * @param dpid the switch to fetch
48 * @return the interface to this switch
49 */
50 public OpenFlowSwitch getEqualSwitch(Dpid dpid);
51
52 /**
53 * Register a listener for meta events that occur to OF
54 * devices.
55 * @param listener the listener to notify
56 */
57 public void addListener(OpenFlowSwitchListener listener);
58
59 /**
60 * Unregister a listener.
61 *
62 * @param listener the listener to unregister
63 */
64 public void removeListener(OpenFlowSwitchListener listener);
65
66 /**
67 * Register a listener for packet events.
68 * @param priority the importance of this listener, lower values are more important
69 * @param listener the listener to notify
70 */
71 public void addPacketListener(int priority, PacketListener listener);
72
73 /**
74 * Unregister a listener.
75 *
76 * @param listener the listener to unregister
77 */
78 public void removePacketListener(PacketListener listener);
79
80 /**
81 * Send a message to a particular switch.
82 * @param dpid the switch to send to.
83 * @param msg the message to send
84 */
85 public void write(Dpid dpid, OFMessage msg);
86
87 /**
88 * Process a message and notify the appropriate listeners.
89 *
90 * @param dpid the dpid the message arrived on
91 * @param msg the message to process.
92 */
93 public void processPacket(Dpid dpid, OFMessage msg);
94
95 /**
96 * Sets the role for a given switch.
97 * @param role the desired role
98 * @param dpid the switch to set the role for.
99 */
100 public void setRole(Dpid dpid, RoleState role);
101}