blob: 199bf06eac2c84fd34e61a219a66051e912a8a8b [file] [log] [blame]
Jonathan Harteb8c9472015-08-05 07:43:13 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Jonathan Harteb8c9472015-08-05 07:43:13 -07003 *
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 */
16
Ray Milkeyfacf2862017-08-03 11:58:29 -070017package org.onosproject.net.intf;
Jonathan Harteb8c9472015-08-05 07:43:13 -070018
Ray Milkeyfacf2862017-08-03 11:58:29 -070019import java.util.Set;
20
Charles Chan971d7ba2018-05-01 11:50:20 -070021import com.google.common.collect.ImmutableSet;
Charles Chan84645922018-05-01 16:21:50 -070022import org.apache.commons.lang.NotImplementedException;
Jonathan Harteb8c9472015-08-05 07:43:13 -070023import org.onlab.packet.IpAddress;
24import org.onlab.packet.VlanId;
Jonathan Hart4b5c6dc2015-10-13 14:27:48 -070025import org.onosproject.event.ListenerService;
Jonathan Harteb8c9472015-08-05 07:43:13 -070026import org.onosproject.net.ConnectPoint;
27
Jonathan Harteb8c9472015-08-05 07:43:13 -070028/**
29 * Service for interacting with interfaces.
30 */
Ray Milkeyfacf2862017-08-03 11:58:29 -070031
Jonathan Hart4b5c6dc2015-10-13 14:27:48 -070032public interface InterfaceService
33 extends ListenerService<InterfaceEvent, InterfaceListener> {
Jonathan Harteb8c9472015-08-05 07:43:13 -070034
35 /**
36 * Returns the set of all interfaces in the system.
37 *
38 * @return set of interfaces
39 */
40 Set<Interface> getInterfaces();
41
42 /**
Jonathan Hart43d232e2016-02-03 15:34:10 -080043 * Returns the interface with the given name.
44 *
45 * @param connectPoint connect point of the interface
46 * @param name name of the interface
47 * @return interface if it exists, otherwise null
48 */
49 Interface getInterfaceByName(ConnectPoint connectPoint, String name);
50
51 /**
Jonathan Harteb8c9472015-08-05 07:43:13 -070052 * Returns the set of interfaces configured on the given port.
53 *
54 * @param port connect point
55 * @return set of interfaces
56 */
57 Set<Interface> getInterfacesByPort(ConnectPoint port);
58
59 /**
60 * Returns the set of interfaces with the given IP address.
61 *
62 * @param ip IP address
63 * @return set of interfaces
64 */
65 Set<Interface> getInterfacesByIp(IpAddress ip);
66
67 /**
68 * Returns the set of interfaces in the given VLAN.
69 *
70 * @param vlan VLAN ID of the interfaces
71 * @return set of interfaces
72 */
73 Set<Interface> getInterfacesByVlan(VlanId vlan);
74
75 /**
76 * Returns an interface that has an address that is in the same subnet as
77 * the given IP address.
78 *
79 * @param ip IP address to find matching subnet interface for
80 * @return interface
81 */
82 Interface getMatchingInterface(IpAddress ip);
Charles Chanb3b09cd2017-03-14 12:53:46 -070083
84 /**
85 * Returns all interfaces that have an address that is in the same
86 * subnet as the given IP address.
87 *
88 * @param ip IP address to find matching subnet interface for
89 * @return a set of interfaces
90 */
91 Set<Interface> getMatchingInterfaces(IpAddress ip);
Charles Chan971d7ba2018-05-01 11:50:20 -070092
93 /**
94 * Returns untagged VLAN configured on given connect point.
95 * <p>
96 * Only returns the first match if there are multiple untagged VLAN configured
97 * on the connect point.
98 *
99 * @param connectPoint connect point
100 * @return untagged VLAN or null if not configured
101 */
102 default VlanId getUntaggedVlanId(ConnectPoint connectPoint) {
103 return null;
104 }
105
106 /**
107 * Returns tagged VLAN configured on given connect point.
108 * <p>
109 * Returns all matches if there are multiple tagged VLAN configured
110 * on the connect point.
111 *
112 * @param connectPoint connect point
113 * @return tagged VLAN or empty set if not configured
114 */
115 default Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) {
116 return ImmutableSet.of();
117 }
118
119 /**
120 * Returns native VLAN configured on given connect point.
121 * <p>
122 * Only returns the first match if there are multiple native VLAN configured
123 * on the connect point.
124 *
125 * @param connectPoint connect point
126 * @return native VLAN or null if not configured
127 */
128 default VlanId getNativeVlanId(ConnectPoint connectPoint) {
129 return null;
130 }
Saurav Das9a554292018-04-27 18:42:30 -0700131
132 /**
133 * Returns true if given connectPoint has an IP address or vlan configured
134 * on any of its interfaces.
135 *
136 * @param connectPoint the port on a device
137 * @return true if connectpoint has a configured interface
138 */
Charles Chan84645922018-05-01 16:21:50 -0700139 default boolean isConfigured(ConnectPoint connectPoint) {
140 throw new NotImplementedException("isConfigured is not implemented");
141 }
Jonathan Harteb8c9472015-08-05 07:43:13 -0700142}