blob: ad29a947fbed2a3af94e24259fe58701f7c5e778 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright 2011,2012, Big Switch Networks, Inc.
3* Originally created by David Erickson, Stanford University
4*
5* Licensed under the Apache License, Version 2.0 (the "License"); you may
6* not use this file except in compliance with the License. You may obtain
7* a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14* License for the specific language governing permissions and limitations
15* under the License.
16**/
17
18package net.floodlightcontroller.devicemanager;
19
20import java.util.Collection;
21import java.util.EnumSet;
22import java.util.Iterator;
23
24import net.floodlightcontroller.core.FloodlightContextStore;
25import net.floodlightcontroller.core.module.IFloodlightService;
26
27/**
28 * Device manager allows interacting with devices on the network. Note
29 * that under normal circumstances, {@link Device} objects should be retrieved
30 * from the {@link FloodlightContext} rather than from {@link IDeviceManager}.
31 */
32public interface IDeviceService extends IFloodlightService {
33 /**
34 * Fields used in devices for indexes and querying
35 * @see IDeviceService#addIndex
36 */
37 enum DeviceField {
38 MAC, IPV4, VLAN, SWITCH, PORT
39 }
40
41 /**
42 * The source device for the current packet-in, if applicable.
43 */
44 public static final String CONTEXT_SRC_DEVICE =
45 "net.floodlightcontroller.devicemanager.srcDevice";
46
47 /**
48 * The destination device for the current packet-in, if applicable.
49 */
50 public static final String CONTEXT_DST_DEVICE =
51 "net.floodlightcontroller.devicemanager.dstDevice";
52
53 /**
54 * A FloodlightContextStore object that can be used to interact with the
55 * FloodlightContext information created by BVS manager.
56 */
57 public static final FloodlightContextStore<IDevice> fcStore =
58 new FloodlightContextStore<IDevice>();
59
60 /**
61 * Get the device with the given device key.
62 *
63 * @param deviceKey the key to search for
64 * @return the device associated with the key, or null if no such device
65 * @see IDevice#getDeviceKey()
66 */
67 public IDevice getDevice(Long deviceKey);
68
69 /**
70 * Search for a device exactly matching the provided device fields. This
71 * is the same lookup process that is used for packet_in processing and
72 * device learning. Thus, findDevice() can be used to match flow entries
73 * from switches to devices.
74 * Only the key fields as defined by the {@link IEntityClassifierService} will
75 * be important in this search. All key fields MUST be supplied.
76 *
77 *{@link queryDevices()} might be more appropriate!
78 *
79 * @param macAddress The MAC address
80 * @param vlan the VLAN. Null means no VLAN and is valid even if VLAN is a
81 * key field.
82 * @param ipv4Address the ipv4 address
83 * @param switchDPID the switch DPID
84 * @param switchPort the switch port
85 * @return an {@link IDevice} or null if no device is found.
86 * @see IDeviceManager#setEntityClassifier(IEntityClassifierService)
87 * @throws IllegalArgumentException if not all key fields of the
88 * current {@link IEntityClassifierService} are specified.
89 */
90 public IDevice findDevice(long macAddress, Short vlan,
91 Integer ipv4Address, Long switchDPID,
92 Integer switchPort)
93 throws IllegalArgumentException;
94
95 /**
96 * Get a destination device using entity fields that corresponds with
97 * the given source device. The source device is important since
98 * there could be ambiguity in the destination device without the
99 * attachment point information.
100 *
101 * @param source the source device. The returned destination will be
102 * in the same entity class as the source.
103 * @param macAddress The MAC address for the destination
104 * @param vlan the VLAN if available
105 * @param ipv4Address The IP address if available.
106 * @return an {@link IDevice} or null if no device is found.
107 * @see IDeviceService#findDevice(long, Short, Integer, Long,
108 * Integer)
109 * @throws IllegalArgumentException if not all key fields of the
110 * source's {@link IEntityClass} are specified.
111 */
112 public IDevice findDestDevice(IDevice source,
113 long macAddress, Short vlan,
114 Integer ipv4Address)
115 throws IllegalArgumentException;
116
117 /**
118 * Get an unmodifiable collection view over all devices currently known.
119 * @return the collection of all devices
120 */
121 public Collection<? extends IDevice> getAllDevices();
122
123 /**
124 * Create an index over a set of fields. This allows efficient lookup
125 * of devices when querying using the indexed set of specified fields.
126 * The index must be registered before any device learning takes place,
127 * or it may be incomplete. It's OK if this is called multiple times with
128 * the same fields; only one index will be created for each unique set of
129 * fields.
130 *
131 * @param perClass set to true if the index should be maintained for each
132 * entity class separately.
133 * @param keyFields the set of fields on which to index
134 */
135 public void addIndex(boolean perClass,
136 EnumSet<DeviceField> keyFields);
137
138 /**
139 * Find devices that match the provided query. Any fields that are
140 * null will not be included in the query. If there is an index for
141 * the query, then it will be performed efficiently using the index.
142 * Otherwise, there will be a full scan of the device list.
143 *
144 * @param macAddress The MAC address
145 * @param vlan the VLAN
146 * @param ipv4Address the ipv4 address
147 * @param switchDPID the switch DPID
148 * @param switchPort the switch port
149 * @return an iterator over a set of devices matching the query
150 * @see IDeviceService#queryClassDevices(IEntityClass, Long,
151 * Short, Integer, Long, Integer)
152 */
153 public Iterator<? extends IDevice> queryDevices(Long macAddress,
154 Short vlan,
155 Integer ipv4Address,
156 Long switchDPID,
157 Integer switchPort);
158
159 /**
160 * Find devices that match the provided query. Only the index for
161 * the class of the specified reference device will be searched.
162 * Any fields that are null will not be included in the query. If
163 * there is an index for the query, then it will be performed
164 * efficiently using the index. Otherwise, there will be a full scan
165 * of the device list.
166 *
167 * @param reference The reference device to refer to when finding
168 * entity classes.
169 * @param macAddress The MAC address
170 * @param vlan the VLAN
171 * @param ipv4Address the ipv4 address
172 * @param switchDPID the switch DPID
173 * @param switchPort the switch port
174 * @return an iterator over a set of devices matching the query
175 * @see IDeviceService#queryClassDevices(Long,
176 * Short, Integer, Long, Integer)
177 */
178 public Iterator<? extends IDevice> queryClassDevices(IDevice reference,
179 Long macAddress,
180 Short vlan,
181 Integer ipv4Address,
182 Long switchDPID,
183 Integer switchPort);
184
185 /**
186 * Adds a listener to listen for IDeviceManagerServices notifications
187 *
188 * @param listener The listener that wants the notifications
189 */
190 public void addListener(IDeviceListener listener);
191
192 /**
193 * Specify points in the network where attachment points are not to
194 * be learned.
195 * @param sw
196 * @param port
197 */
198 public void addSuppressAPs(long swId, short port);
199
200 public void removeSuppressAPs(long swId, short port);
201
202}