Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.networkgraph; |
| 2 | |
| 3 | import java.net.InetAddress; |
| 4 | |
| 5 | import net.floodlightcontroller.util.MACAddress; |
| 6 | |
| 7 | /** |
| 8 | * The northbound interface to the topology network graph. This interface |
| 9 | * is presented to the rest of ONOS. It is currently read-only, as we want |
| 10 | * only the discovery modules to be allowed to modify the topology. |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 11 | */ |
| 12 | public interface NetworkGraph { |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 13 | /** |
| 14 | * Get the switch for a given switch DPID. |
| 15 | * |
| 16 | * @param dpid the switch dpid. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 17 | * @return the switch if found, otherwise null. |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 18 | */ |
| 19 | public Switch getSwitch(Long dpid); |
Yuta HIGUCHI | c6174df | 2014-02-10 20:44:38 -0800 | [diff] [blame] | 20 | |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 21 | /** |
| 22 | * Get all switches in the network. |
| 23 | * |
| 24 | * @return all switches in the network. |
| 25 | */ |
| 26 | public Iterable<Switch> getSwitches(); |
Yuta HIGUCHI | c6174df | 2014-02-10 20:44:38 -0800 | [diff] [blame] | 27 | |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 28 | /** |
| 29 | * Get the port on a switch. |
| 30 | * |
| 31 | * @param dpid the switch DPID. |
| 32 | * @param number the switch port number. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 33 | * @return the switch port if found, otherwise null. |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 34 | */ |
| 35 | public Port getPort(Long dpid, Long number); |
| 36 | |
| 37 | /** |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 38 | * Get the outgoing link for a switch and a port. |
| 39 | * |
| 40 | * @param dpid the switch DPID. |
| 41 | * @param number the switch port number. |
| 42 | * @return the outgoing link if found, otherwise null. |
| 43 | */ |
| 44 | public Link getLink(Long dpid, Long number); |
| 45 | |
| 46 | /** |
| 47 | * Get the outgoing link from a switch and a port to another switch and |
| 48 | * a port. |
| 49 | * |
| 50 | * @param srcDpid the source switch DPID. |
| 51 | * @param srcNumber the source switch port number. |
| 52 | * @param dstDpid the destination switch DPID. |
| 53 | * @param dstNumber the destination switch port number. |
| 54 | * @return the outgoing link if found, otherwise null. |
| 55 | */ |
| 56 | public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid, |
| 57 | Long dstNumber); |
| 58 | |
| 59 | /** |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 60 | * Get all links in the network. |
| 61 | * |
| 62 | * TODO: Not clear if this method is needed. Remove if not used. |
| 63 | * |
| 64 | * @return all links in the network. |
| 65 | */ |
| 66 | public Iterable<Link> getLinks(); |
| 67 | |
| 68 | /** |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 69 | * Get the network devices for a given IP address. |
| 70 | * |
| 71 | * @param ipAddress the IP address to use. |
| 72 | * @return the network devices for the IP address. |
| 73 | */ |
| 74 | public Iterable<Device> getDevicesByIp(InetAddress ipAddress); |
| 75 | |
| 76 | /** |
| 77 | * Get the network device for a given MAC address. |
| 78 | * |
| 79 | * @param address the MAC address to use. |
| 80 | * @return the network device for the MAC address if found, otherwise null. |
| 81 | */ |
| 82 | public Device getDeviceByMac(MACAddress address); |
Jonathan Hart | 26f291b | 2014-02-18 16:57:24 -0800 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Acquire a read lock on the entire topology. The topology will not |
| 86 | * change while readers have the lock. Must be released using |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 87 | * {@link releaseReadLock()}. This method will block until a read lock is |
Jonathan Hart | 26f291b | 2014-02-18 16:57:24 -0800 | [diff] [blame] | 88 | * available. |
| 89 | */ |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 90 | public void acquireReadLock(); |
Jonathan Hart | 26f291b | 2014-02-18 16:57:24 -0800 | [diff] [blame] | 91 | |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 92 | /** |
| 93 | * Release the read lock on the topology. |
| 94 | */ |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 95 | public void releaseReadLock(); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 96 | } |