blob: 00adb78813ab6117f7c91be0684073b29a045604 [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;
Jonathan Harteb8c9472015-08-05 07:43:13 -070022import org.onlab.packet.IpAddress;
23import org.onlab.packet.VlanId;
Jonathan Hart4b5c6dc2015-10-13 14:27:48 -070024import org.onosproject.event.ListenerService;
Jonathan Harteb8c9472015-08-05 07:43:13 -070025import org.onosproject.net.ConnectPoint;
26
Jonathan Harteb8c9472015-08-05 07:43:13 -070027/**
28 * Service for interacting with interfaces.
29 */
Ray Milkeyfacf2862017-08-03 11:58:29 -070030
Jonathan Hart4b5c6dc2015-10-13 14:27:48 -070031public interface InterfaceService
32 extends ListenerService<InterfaceEvent, InterfaceListener> {
Jonathan Harteb8c9472015-08-05 07:43:13 -070033
34 /**
35 * Returns the set of all interfaces in the system.
36 *
37 * @return set of interfaces
38 */
39 Set<Interface> getInterfaces();
40
41 /**
Jonathan Hart43d232e2016-02-03 15:34:10 -080042 * Returns the interface with the given name.
43 *
44 * @param connectPoint connect point of the interface
45 * @param name name of the interface
46 * @return interface if it exists, otherwise null
47 */
48 Interface getInterfaceByName(ConnectPoint connectPoint, String name);
49
50 /**
Jonathan Harteb8c9472015-08-05 07:43:13 -070051 * Returns the set of interfaces configured on the given port.
52 *
53 * @param port connect point
54 * @return set of interfaces
55 */
56 Set<Interface> getInterfacesByPort(ConnectPoint port);
57
58 /**
59 * Returns the set of interfaces with the given IP address.
60 *
61 * @param ip IP address
62 * @return set of interfaces
63 */
64 Set<Interface> getInterfacesByIp(IpAddress ip);
65
66 /**
67 * Returns the set of interfaces in the given VLAN.
68 *
69 * @param vlan VLAN ID of the interfaces
70 * @return set of interfaces
71 */
72 Set<Interface> getInterfacesByVlan(VlanId vlan);
73
74 /**
75 * Returns an interface that has an address that is in the same subnet as
76 * the given IP address.
77 *
78 * @param ip IP address to find matching subnet interface for
79 * @return interface
80 */
81 Interface getMatchingInterface(IpAddress ip);
Charles Chanb3b09cd2017-03-14 12:53:46 -070082
83 /**
84 * Returns all interfaces that have an address that is in the same
85 * subnet as the given IP address.
86 *
87 * @param ip IP address to find matching subnet interface for
88 * @return a set of interfaces
89 */
90 Set<Interface> getMatchingInterfaces(IpAddress ip);
Charles Chan971d7ba2018-05-01 11:50:20 -070091
92 /**
93 * Returns untagged VLAN configured on given connect point.
94 * <p>
95 * Only returns the first match if there are multiple untagged VLAN configured
96 * on the connect point.
97 *
98 * @param connectPoint connect point
99 * @return untagged VLAN or null if not configured
100 */
101 default VlanId getUntaggedVlanId(ConnectPoint connectPoint) {
102 return null;
103 }
104
105 /**
106 * Returns tagged VLAN configured on given connect point.
107 * <p>
108 * Returns all matches if there are multiple tagged VLAN configured
109 * on the connect point.
110 *
111 * @param connectPoint connect point
112 * @return tagged VLAN or empty set if not configured
113 */
114 default Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) {
115 return ImmutableSet.of();
116 }
117
118 /**
119 * Returns native VLAN configured on given connect point.
120 * <p>
121 * Only returns the first match if there are multiple native VLAN configured
122 * on the connect point.
123 *
124 * @param connectPoint connect point
125 * @return native VLAN or null if not configured
126 */
127 default VlanId getNativeVlanId(ConnectPoint connectPoint) {
128 return null;
129 }
Jonathan Harteb8c9472015-08-05 07:43:13 -0700130}