2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.openflowjava.protocol.api.connection;
10 import com.google.common.annotations.Beta;
11 import java.math.BigInteger;
12 import java.net.InetSocketAddress;
13 import java.security.cert.X509Certificate;
14 import java.util.List;
15 import java.util.concurrent.ExecutorService;
16 import java.util.concurrent.Future;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.opendaylight.openflowjava.protocol.api.extensibility.AlienMessageListener;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SslConnectionError;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;
27 * Manages a switch connection.
30 * @author michal.polkorab
32 public interface ConnectionAdapter extends OpenflowProtocolService {
34 interface SystemListener {
35 void onDisconnect(DisconnectEvent disconnect);
37 void onSwitchIdle(SwitchIdleEvent switchIdle);
39 void onSslConnectionError(SslConnectionError sslConnectionError);
43 * Disconnect corresponding switch.
45 * @return future set to true, when disconnect completed
47 Future<Boolean> disconnect();
50 * Determines if the connection to the switch is alive.
52 * @return true, if connection to switch is alive
57 * Returns the address of the connected switch.
59 * @return address of the remote end - address of a switch if connected
61 InetSocketAddress getRemoteAddress();
64 * Sets the protocol message listener.
66 * @param messageListener here will be pushed all messages from switch
68 void setMessageListener(OpenflowProtocolListener messageListener);
71 * Sets the system message listener.
73 * @param systemListener here will be pushed all system messages from library
75 void setSystemListener(SystemListener systemListener);
78 * Set handler for alien messages received from device.
80 * @param alienMessageListener here will be pushed all alien messages from switch
82 void setAlienMessageListener(AlienMessageListener alienMessageListener);
85 * Throws exception if any of required listeners is missing.
87 void checkListeners();
90 * Notify listener about connection ready-to-use event.
92 void fireConnectionReadyNotification();
95 * Notify listener about switch certificate information.
97 * @param certificateChain X509 certificate chain presented by the switch
99 void onSwitchCertificateIdentified(@Nullable List<X509Certificate> certificateChain);
102 * Set listener for connection became ready-to-use event.
104 * @param connectionReadyListener listens to connection ready event
106 void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener);
109 * Sets option for automatic channel reading - if set to false, incoming messages won't be read.
111 * @param autoRead target value to be switched to
113 void setAutoRead(boolean autoRead);
116 * Determines if the channel is configured to auto-read.
118 * @return true, if channel is configured to auto-read
120 boolean isAutoRead();
123 * Registers a new bypass outbound queue.
125 * @param <T> handler type
126 * @param handler queue handler
127 * @param maxQueueDepth max amount of not confirmed messaged in queue (i.e. edge for barrier message)
128 * @param maxBarrierNanos regular base for barrier message
129 * @return An {@link OutboundQueueHandlerRegistration}
132 <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(T handler,
133 int maxQueueDepth, long maxBarrierNanos);
136 * Set filtering of PacketIn messages. By default these messages are not filtered.
137 * @param enabled True if PacketIn messages should be filtered, false if they should be reported.
140 void setPacketInFiltering(boolean enabled);
143 * Set datapathId for the dpn.
144 * @param datapathId of the dpn
146 void setDatapathId(BigInteger datapathId);
149 * Sets executorService.
150 * @param executorService for all dpns
152 void setExecutorService(ExecutorService executorService);