tom | 9c94c5b | 2014-09-17 13:14:42 -0700 | [diff] [blame] | 1 | package org.onlab.onos.openflow.controller; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 2 | |
| 3 | import 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 | */ |
| 10 | public 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 | /** |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 81 | * Register a listener for OF msg events. |
| 82 | * |
| 83 | * @param listener the listener to notify |
| 84 | */ |
| 85 | public void addEventListener(OpenFlowEventListener listener); |
| 86 | |
| 87 | /** |
| 88 | * Unregister a listener. |
| 89 | * |
| 90 | * @param listener the listener to unregister |
| 91 | */ |
| 92 | public void removeEventListener(OpenFlowEventListener listener); |
| 93 | |
| 94 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 95 | * Send a message to a particular switch. |
| 96 | * @param dpid the switch to send to. |
| 97 | * @param msg the message to send |
| 98 | */ |
| 99 | public void write(Dpid dpid, OFMessage msg); |
| 100 | |
| 101 | /** |
| 102 | * Process a message and notify the appropriate listeners. |
| 103 | * |
| 104 | * @param dpid the dpid the message arrived on |
| 105 | * @param msg the message to process. |
| 106 | */ |
| 107 | public void processPacket(Dpid dpid, OFMessage msg); |
| 108 | |
| 109 | /** |
| 110 | * Sets the role for a given switch. |
| 111 | * @param role the desired role |
| 112 | * @param dpid the switch to set the role for. |
| 113 | */ |
| 114 | public void setRole(Dpid dpid, RoleState role); |
| 115 | } |