Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 1 | /* |
Jian Li | c7efc1d | 2018-08-23 16:37:34 +0900 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 3 | * |
| 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 |
| 7 | * |
| 8 | * 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. |
| 15 | */ |
Jian Li | c7efc1d | 2018-08-23 16:37:34 +0900 | [diff] [blame] | 16 | package org.onosproject.simplefabric.api; |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.IpAddress; |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onlab.packet.VlanId; |
| 21 | import org.onosproject.core.ApplicationId; |
| 22 | import org.onosproject.event.ListenerService; |
| 23 | import org.onosproject.net.intf.Interface; |
| 24 | import org.onosproject.net.ConnectPoint; |
| 25 | import org.onosproject.net.Host; |
| 26 | |
| 27 | import java.io.OutputStream; |
| 28 | import java.util.Set; |
| 29 | import java.util.Collection; |
| 30 | |
| 31 | /** |
| 32 | * Provides information about the routing configuration. |
| 33 | */ |
| 34 | public interface SimpleFabricService |
| 35 | extends ListenerService<SimpleFabricEvent, SimpleFabricListener> { |
| 36 | |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 37 | /** |
| 38 | * Gets appId. |
| 39 | * |
| 40 | * @return appId of simple fabric app |
| 41 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 42 | ApplicationId appId(); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 43 | |
| 44 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 45 | * Gets all the fabric networks. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 46 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 47 | * @return all the fabric networks |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 48 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 49 | Collection<FabricNetwork> fabricNetworks(); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 50 | |
| 51 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 52 | * Retrieves the entire set of fabricSubnets configuration. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 53 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 54 | * @return all the fabricSubnets |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 55 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 56 | Set<FabricSubnet> defaultFabricSubnets(); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Retrieves the entire set of static routes to outer networks. |
| 60 | * |
| 61 | * @return the set of static routes to outer networks. |
| 62 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 63 | Set<FabricRoute> fabricRoutes(); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 64 | |
| 65 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 66 | * Evaluates whether a MAC is of virtual gateway MAC addresses. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 67 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 68 | * @param mac the MAC address to evaluate |
| 69 | * @return true if the mac is of any virtual gateway MAC address of fabricSubnets |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 70 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 71 | boolean isVirtualGatewayMac(MacAddress mac); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 72 | |
| 73 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 74 | * Evaluates whether an interface belongs to fabric network or not. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 75 | * |
| 76 | * @param intf the interface to evaluate |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 77 | * @return true if the interface belongs to fabric network, otherwise false |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 78 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 79 | boolean isFabricNetworkInterface(Interface intf); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 80 | |
| 81 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 82 | * Finds virtual gateway MAC address for local subnet virtual gateway IP. |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 83 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 84 | * @param ip the IP to check for virtual gateway IP |
| 85 | * @return MAC address of virtual gateway |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 86 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 87 | MacAddress vMacForIp(IpAddress ip); |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 88 | |
| 89 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 90 | * Finds the L2 fabric network with given port and vlanId. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 91 | * |
| 92 | * @param port the port to be matched |
| 93 | * @param vlanId the vlanId to be matched |
| 94 | * @return the L2 Network for specific port and vlanId or null |
| 95 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 96 | FabricNetwork fabricNetwork(ConnectPoint port, VlanId vlanId); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 97 | |
| 98 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 99 | * Finds the fabric network by its name. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 100 | * |
| 101 | * @param name the name to be matched |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 102 | * @return the fabric network |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 103 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 104 | FabricNetwork fabricNetwork(String name); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 105 | |
| 106 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 107 | * Finds the FabricSubnet which contains the given IP address. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 108 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 109 | * @param ipAddress the IP address to be matched |
| 110 | * @return the FabricSubnet |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 111 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 112 | FabricSubnet fabricSubnet(IpAddress ipAddress); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 113 | |
| 114 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 115 | * Finds the FabricRoute which contains the given IP address. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 116 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 117 | * @param ipAddress the IP address to be matched |
| 118 | * @return the FabricRoute |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 119 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 120 | FabricRoute fabricRoute(IpAddress ipAddress); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 121 | |
| 122 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 123 | * Finds the network interface which associated with the host. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 124 | * |
| 125 | * @param host the host |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 126 | * @return the interface associated with the host |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 127 | */ |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 128 | Interface hostInterface(Host host); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 129 | |
| 130 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 131 | * Sends neighbour query (ARP or NDP) to find host location. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 132 | * |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 133 | * @param ip the IP address to resolve |
| 134 | * @return true if request MAC packets are emitted, false otherwise |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 135 | */ |
| 136 | boolean requestMac(IpAddress ip); |
| 137 | |
| 138 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 139 | * Sends dump event to all SimpleFabricListeners to dump info on the subject. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 140 | * |
| 141 | * @param subject the subject to dump |
| 142 | * @param out the output stream to dump |
| 143 | */ |
| 144 | void dumpToStream(String subject, OutputStream out); |
| 145 | |
| 146 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 147 | * Triggers to send refresh notification to all sub modules. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 148 | */ |
| 149 | void triggerRefresh(); |
| 150 | |
| 151 | /** |
Jian Li | e2d8751 | 2018-08-23 17:33:05 +0900 | [diff] [blame] | 152 | * Triggers to send flush notification to all sub modules. |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 153 | */ |
| 154 | void triggerFlush(); |
Lee Yongjae | 7c27bb4 | 2017-11-17 12:00:45 +0900 | [diff] [blame] | 155 | } |