00f3d89b89f68980fbf3f6d9aee40cb4a54882fc
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / connection / ConnectionAdapterImpl.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9
10 package org.opendaylight.openflowjava.protocol.impl.core.connection;
11
12 import com.google.common.base.Preconditions;
13 import com.google.common.cache.Cache;
14 import com.google.common.cache.CacheBuilder;
15 import com.google.common.cache.RemovalCause;
16 import com.google.common.cache.RemovalListener;
17 import com.google.common.cache.RemovalNotification;
18 import com.google.common.util.concurrent.ListenableFuture;
19 import com.google.common.util.concurrent.SettableFuture;
20 import io.netty.channel.Channel;
21 import io.netty.channel.ChannelFuture;
22 import io.netty.util.concurrent.GenericFutureListener;
23 import java.net.InetSocketAddress;
24 import java.util.concurrent.Future;
25 import java.util.concurrent.RejectedExecutionException;
26 import java.util.concurrent.TimeUnit;
27 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
28 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
29 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
30 import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector;
31 import org.opendaylight.openflowjava.protocol.impl.core.PipelineHandlers;
32 import org.opendaylight.openflowjava.statistics.CounterEventTypes;
33 import org.opendaylight.openflowjava.statistics.StatisticsCounters;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
73 import org.opendaylight.yangtools.yang.binding.DataObject;
74 import org.opendaylight.yangtools.yang.binding.Notification;
75 import org.opendaylight.yangtools.yang.common.RpcResult;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
78
79 /**
80  * Handles messages (notifications + rpcs) and connections
81  * @author mirehak
82  * @author michal.polkorab
83  */
84 public class ConnectionAdapterImpl implements ConnectionFacade {
85     /** after this time, RPC future response objects will be thrown away (in minutes) */
86     public static final int RPC_RESPONSE_EXPIRATION = 1;
87
88     /**
89      * Default depth of write queue, e.g. we allow these many messages
90      * to be queued up before blocking producers.
91      */
92     public static final int DEFAULT_QUEUE_DEPTH = 1024;
93
94     private static final Logger LOG = LoggerFactory
95             .getLogger(ConnectionAdapterImpl.class);
96     private static final Exception QUEUE_FULL_EXCEPTION =
97             new RejectedExecutionException("Output queue is full");
98
99     private static final RemovalListener<RpcResponseKey, ResponseExpectedRpcListener<?>> REMOVAL_LISTENER =
100             new RemovalListener<RpcResponseKey, ResponseExpectedRpcListener<?>>() {
101         @Override
102         public void onRemoval(
103                 final RemovalNotification<RpcResponseKey, ResponseExpectedRpcListener<?>> notification) {
104             if (! notification.getCause().equals(RemovalCause.EXPLICIT)) {
105                 notification.getValue().discard();
106             }
107         }
108     };
109
110     /** expiring cache for future rpcResponses */
111     private Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> responseCache;
112
113     private final ChannelOutboundQueue output;
114     private final Channel channel;
115
116     private ConnectionReadyListener connectionReadyListener;
117     private OpenflowProtocolListener messageListener;
118     private SystemNotificationsListener systemListener;
119     private OutboundQueueManager<?> outputManager;
120     private boolean disconnectOccured = false;
121     private final StatisticsCounters statisticsCounters;
122     private OFVersionDetector versionDetector;
123     private final InetSocketAddress address;
124
125     private final boolean useBarrier;
126
127     /**
128      * default ctor
129      * @param channel the channel to be set - used for communication
130      * @param address client address (used only in case of UDP communication,
131      *  as there is no need to store address over tcp (stable channel))
132      */
133     public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address, final boolean useBarrier) {
134         this.channel = Preconditions.checkNotNull(channel);
135         this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address);
136         this.address = address;
137
138         responseCache = CacheBuilder.newBuilder()
139                 .concurrencyLevel(1)
140                 .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES)
141                 .removalListener(REMOVAL_LISTENER).build();
142
143         this.useBarrier = useBarrier;
144         channel.pipeline().addLast(output);
145         statisticsCounters = StatisticsCounters.getInstance();
146
147         LOG.debug("ConnectionAdapter created");
148     }
149
150     @Override
151     public Future<RpcResult<BarrierOutput>> barrier(final BarrierInput input) {
152         return sendToSwitchExpectRpcResultFuture(
153                 input, BarrierOutput.class, "barrier-input sending failed");
154     }
155
156     @Override
157     public Future<RpcResult<EchoOutput>> echo(final EchoInput input) {
158         return sendToSwitchExpectRpcResultFuture(
159                 input, EchoOutput.class, "echo-input sending failed");
160     }
161
162     @Override
163     public Future<RpcResult<Void>> echoReply(final EchoReplyInput input) {
164         return sendToSwitchFuture(input, "echo-reply sending failed");
165     }
166
167     @Override
168     public Future<RpcResult<Void>> experimenter(final ExperimenterInput input) {
169         return sendToSwitchFuture(input, "experimenter sending failed");
170     }
171
172     @Override
173     public Future<RpcResult<Void>> flowMod(final FlowModInput input) {
174         statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_ENTERED);
175         return sendToSwitchFuture(input, "flow-mod sending failed");
176     }
177
178     @Override
179     public Future<RpcResult<GetConfigOutput>> getConfig(final GetConfigInput input) {
180         return sendToSwitchExpectRpcResultFuture(
181                 input, GetConfigOutput.class, "get-config-input sending failed");
182     }
183
184     @Override
185     public Future<RpcResult<GetFeaturesOutput>> getFeatures(
186             final GetFeaturesInput input) {
187         return sendToSwitchExpectRpcResultFuture(
188                 input, GetFeaturesOutput.class, "get-features-input sending failed");
189     }
190
191     @Override
192     public Future<RpcResult<GetQueueConfigOutput>> getQueueConfig(
193             final GetQueueConfigInput input) {
194         return sendToSwitchExpectRpcResultFuture(
195                 input, GetQueueConfigOutput.class, "get-queue-config-input sending failed");
196     }
197
198     @Override
199     public Future<RpcResult<Void>> groupMod(final GroupModInput input) {
200         return sendToSwitchFuture(input, "group-mod-input sending failed");
201     }
202
203     @Override
204     public Future<RpcResult<Void>> hello(final HelloInput input) {
205         return sendToSwitchFuture(input, "hello-input sending failed");
206     }
207
208     @Override
209     public Future<RpcResult<Void>> meterMod(final MeterModInput input) {
210         return sendToSwitchFuture(input, "meter-mod-input sending failed");
211     }
212
213     @Override
214     public Future<RpcResult<Void>> packetOut(final PacketOutInput input) {
215         return sendToSwitchFuture(input, "packet-out-input sending failed");
216     }
217
218     @Override
219     public Future<RpcResult<Void>> multipartRequest(final MultipartRequestInput input) {
220         return sendToSwitchFuture(input, "multi-part-request sending failed");
221     }
222
223     @Override
224     public Future<RpcResult<Void>> portMod(final PortModInput input) {
225         return sendToSwitchFuture(input, "port-mod-input sending failed");
226     }
227
228     @Override
229     public Future<RpcResult<RoleRequestOutput>> roleRequest(
230             final RoleRequestInput input) {
231         return sendToSwitchExpectRpcResultFuture(
232                 input, RoleRequestOutput.class, "role-request-config-input sending failed");
233     }
234
235     @Override
236     public Future<RpcResult<Void>> setConfig(final SetConfigInput input) {
237         return sendToSwitchFuture(input, "set-config-input sending failed");
238     }
239
240     @Override
241     public Future<RpcResult<Void>> tableMod(final TableModInput input) {
242         return sendToSwitchFuture(input, "table-mod-input sending failed");
243     }
244
245     @Override
246     public Future<RpcResult<GetAsyncOutput>> getAsync(final GetAsyncInput input) {
247         return sendToSwitchExpectRpcResultFuture(
248                 input, GetAsyncOutput.class, "get-async-input sending failed");
249     }
250
251     @Override
252     public Future<RpcResult<Void>> setAsync(final SetAsyncInput input) {
253         return sendToSwitchFuture(input, "set-async-input sending failed");
254     }
255
256     @Override
257     public Future<Boolean> disconnect() {
258         final ChannelFuture disconnectResult = channel.disconnect();
259         responseCache.invalidateAll();
260         disconnectOccured = true;
261
262         return handleTransportChannelFuture(disconnectResult);
263     }
264
265     @Override
266     public boolean isAlive() {
267         return channel.isOpen();
268     }
269
270     @Override
271     public void setMessageListener(final OpenflowProtocolListener messageListener) {
272         this.messageListener = messageListener;
273     }
274
275     @Override
276     public void consume(final DataObject message) {
277         LOG.debug("ConsumeIntern msg on {}", channel);
278         if (disconnectOccured ) {
279             return;
280         }
281         if (message instanceof Notification) {
282
283             // System events
284             if (message instanceof DisconnectEvent) {
285                 systemListener.onDisconnectEvent((DisconnectEvent) message);
286                 responseCache.invalidateAll();
287                 disconnectOccured = true;
288             } else if (message instanceof SwitchIdleEvent) {
289                 systemListener.onSwitchIdleEvent((SwitchIdleEvent) message);
290                 // OpenFlow messages
291             } else if (message instanceof EchoRequestMessage) {
292                 if (outputManager != null) {
293                     outputManager.onEchoRequest((EchoRequestMessage) message);
294                 } else {
295                     messageListener.onEchoRequestMessage((EchoRequestMessage) message);
296                 }
297                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
298             } else if (message instanceof ErrorMessage) {
299                 // Send only unmatched errors
300                 if (outputManager == null || !outputManager.onMessage((OfHeader) message)) {
301                     messageListener.onErrorMessage((ErrorMessage) message);
302                 }
303                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
304             } else if (message instanceof ExperimenterMessage) {
305                 if (outputManager != null) {
306                     outputManager.onMessage((OfHeader) message);
307                 }
308                 messageListener.onExperimenterMessage((ExperimenterMessage) message);
309                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
310             } else if (message instanceof FlowRemovedMessage) {
311                 messageListener.onFlowRemovedMessage((FlowRemovedMessage) message);
312                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
313             } else if (message instanceof HelloMessage) {
314                 LOG.info("Hello received / branch");
315                 messageListener.onHelloMessage((HelloMessage) message);
316                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
317             } else if (message instanceof MultipartReplyMessage) {
318                 if (outputManager != null) {
319                     outputManager.onMessage((OfHeader) message);
320                 }
321                 messageListener.onMultipartReplyMessage((MultipartReplyMessage) message);
322                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
323             } else if (message instanceof PacketInMessage) {
324                 messageListener.onPacketInMessage((PacketInMessage) message);
325                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
326             } else if (message instanceof PortStatusMessage) {
327                 messageListener.onPortStatusMessage((PortStatusMessage) message);
328                 statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
329             } else {
330                 LOG.warn("message listening not supported for type: {}", message.getClass());
331             }
332         } else if (message instanceof OfHeader) {
333             LOG.debug("OFheader msg received");
334
335             if (outputManager == null || !outputManager.onMessage((OfHeader) message)) {
336                 final RpcResponseKey key = createRpcResponseKey((OfHeader) message);
337                 final ResponseExpectedRpcListener<?> listener = findRpcResponse(key);
338                 if (listener != null) {
339                     LOG.debug("corresponding rpcFuture found");
340                     listener.completed((OfHeader)message);
341                     statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS);
342                     LOG.debug("after setting rpcFuture");
343                     responseCache.invalidate(key);
344                 } else {
345                     LOG.warn("received unexpected rpc response: {}", key);
346                 }
347             }
348         } else {
349             LOG.warn("message listening not supported for type: {}", message.getClass());
350         }
351     }
352
353     private <T> ListenableFuture<RpcResult<T>> enqueueMessage(final AbstractRpcListener<T> promise) {
354         LOG.debug("Submitting promise {}", promise);
355
356         if (!output.enqueue(promise)) {
357             LOG.debug("Message queue is full, rejecting execution");
358             promise.failedRpc(QUEUE_FULL_EXCEPTION);
359         } else {
360             LOG.debug("Promise enqueued successfully");
361         }
362
363         return promise.getResult();
364     }
365
366     /**
367      * sends given message to switch, sending result will be reported via return value
368      * @param input message to send
369      * @param failureInfo describes, what type of message caused failure by sending
370      * @return future object, <ul>
371      *  <li>if send successful, {@link RpcResult} without errors and successful
372      *  status will be returned, </li>
373      *  <li>else {@link RpcResult} will contain errors and failed status</li>
374      *  </ul>
375      */
376     private ListenableFuture<RpcResult<Void>> sendToSwitchFuture(
377             final DataObject input, final String failureInfo) {
378         statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA);
379         return enqueueMessage(new SimpleRpcListener(input, failureInfo));
380     }
381
382     /**
383      * sends given message to switch, sending result or switch response will be reported via return value
384      * @param input message to send
385      * @param responseClazz type of response
386      * @param failureInfo describes, what type of message caused failure by sending
387      * @return future object, <ul>
388      *  <li>if send fails, {@link RpcResult} will contain errors and failed status </li>
389      *  <li>else {@link RpcResult} will be stored in responseCache and wait for particular timeout
390      *  ({@link ConnectionAdapterImpl#RPC_RESPONSE_EXPIRATION}),
391      *  <ul><li>either switch will manage to answer
392      *  and then corresponding response message will be set into returned future</li>
393      *  <li>or response in cache will expire and returned future will be cancelled</li></ul>
394      *  </li>
395      *  </ul>
396      */
397     private <IN extends OfHeader, OUT extends OfHeader> ListenableFuture<RpcResult<OUT>> sendToSwitchExpectRpcResultFuture(
398             final IN input, final Class<OUT> responseClazz, final String failureInfo) {
399         final RpcResponseKey key = new RpcResponseKey(input.getXid(), responseClazz.getName());
400         final ResponseExpectedRpcListener<OUT> listener =
401                 new ResponseExpectedRpcListener<>(input, failureInfo, responseCache, key);
402         statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA);
403         return enqueueMessage(listener);
404     }
405
406     /**
407      * @param resultFuture
408      * @param failureInfo
409      * @param errorSeverity
410      * @param message
411      * @return
412      */
413     private static SettableFuture<Boolean> handleTransportChannelFuture(
414             final ChannelFuture resultFuture) {
415
416         final SettableFuture<Boolean> transportResult = SettableFuture.create();
417
418         resultFuture.addListener(new GenericFutureListener<io.netty.util.concurrent.Future<? super Void>>() {
419
420             @Override
421             public void operationComplete(
422                     final io.netty.util.concurrent.Future<? super Void> future)
423                     throws Exception {
424                 transportResult.set(future.isSuccess());
425                 if (!future.isSuccess()) {
426                     transportResult.setException(future.cause());
427                 }
428             }
429         });
430         return transportResult;
431     }
432
433     /**
434      * @param message
435      * @return
436      */
437     private static RpcResponseKey createRpcResponseKey(final OfHeader message) {
438         return new RpcResponseKey(message.getXid(), message.getImplementedInterface().getName());
439     }
440
441     /**
442      * @return
443      */
444     private ResponseExpectedRpcListener<?> findRpcResponse(final RpcResponseKey key) {
445         return responseCache.getIfPresent(key);
446     }
447
448     @Override
449     public void setSystemListener(final SystemNotificationsListener systemListener) {
450         this.systemListener = systemListener;
451     }
452
453     @Override
454     public void checkListeners() {
455         final StringBuilder buffer =  new StringBuilder();
456         if (systemListener == null) {
457             buffer.append("SystemListener ");
458         }
459         if (messageListener == null) {
460             buffer.append("MessageListener ");
461         }
462         if (connectionReadyListener == null) {
463             buffer.append("ConnectionReadyListener ");
464         }
465
466         Preconditions.checkState(buffer.length() == 0, "Missing listeners: %s", buffer.toString());
467     }
468
469     @Override
470     public void fireConnectionReadyNotification() {
471         versionDetector = (OFVersionDetector) channel.pipeline().get(PipelineHandlers.OF_VERSION_DETECTOR.name());
472         Preconditions.checkState(versionDetector != null);
473
474         new Thread(new Runnable() {
475             @Override
476             public void run() {
477                 connectionReadyListener.onConnectionReady();
478             }
479         }).start();
480     }
481
482     @Override
483     public void setConnectionReadyListener(
484             final ConnectionReadyListener connectionReadyListener) {
485         this.connectionReadyListener = connectionReadyListener;
486     }
487
488     @Override
489     public InetSocketAddress getRemoteAddress() {
490         return (InetSocketAddress) channel.remoteAddress();
491     }
492
493     /**
494      * Used only for testing purposes
495      * @param cache
496      */
497     public void setResponseCache(final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache) {
498         this.responseCache = cache;
499     }
500
501         @Override
502     public boolean isAutoRead() {
503         return channel.config().isAutoRead();
504     }
505
506         @Override
507     public void setAutoRead(final boolean autoRead) {
508         channel.config().setAutoRead(autoRead);
509     }
510
511     @Override
512     public <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(
513             final T handler, final int maxQueueDepth, final long maxBarrierNanos) {
514         Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager);
515
516         if (useBarrier) {
517
518         }
519
520         final OutboundQueueManager<T> ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos);
521         outputManager = ret;
522         channel.pipeline().addLast(outputManager);
523
524         return new OutboundQueueHandlerRegistrationImpl<T>(handler) {
525             @Override
526             protected void removeRegistration() {
527                 outputManager.close();
528                 channel.pipeline().remove(outputManager);
529                 outputManager = null;
530             }
531         };
532     }
533
534     Channel getChannel() {
535         return channel;
536     }
537
538     @Override
539     public void setPacketInFiltering(final boolean enabled) {
540         versionDetector.setFilterPacketIns(enabled);
541         LOG.debug("PacketIn filtering {}abled", enabled ? "en" : "dis");
542     }
543 }