Merge "Add SwitchCertificate attributes in TLS failure notification"
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / connection / ConnectionAdapter.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 package org.opendaylight.openflowjava.protocol.api.connection;
9
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.concurrent.ExecutorService;
15 import java.util.concurrent.Future;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.AlienMessageListener;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
20
21 /**
22  * Manages a switch connection.
23  *
24  * @author mirehak
25  * @author michal.polkorab
26  */
27 public interface ConnectionAdapter extends OpenflowProtocolService {
28
29     /**
30      * Disconnect corresponding switch.
31      *
32      * @return future set to true, when disconnect completed
33      */
34     Future<Boolean> disconnect();
35
36     /**
37      * Determines if the connection to the switch is alive.
38      *
39      * @return true, if connection to switch is alive
40      */
41     boolean isAlive();
42
43     /**
44      * Returns the address of the connected switch.
45      *
46      * @return address of the remote end - address of a switch if connected
47      */
48     InetSocketAddress getRemoteAddress();
49
50     /**
51      * Sets the protocol message listener.
52      *
53      * @param messageListener here will be pushed all messages from switch
54      */
55     void setMessageListener(OpenflowProtocolListener messageListener);
56
57     /**
58      * Sets the system message listener.
59      *
60      * @param systemListener here will be pushed all system messages from library
61      */
62     void setSystemListener(SystemNotificationsListener systemListener);
63
64     /**
65      * Set handler for alien messages received from device.
66      *
67      * @param alienMessageListener here will be pushed all alien messages from switch
68      */
69     void setAlienMessageListener(AlienMessageListener alienMessageListener);
70
71     /**
72      * Throws exception if any of required listeners is missing.
73      */
74     void checkListeners();
75
76     /**
77      * Notify listener about connection ready-to-use event.
78      */
79     void fireConnectionReadyNotification();
80
81     /**
82      * Notify listener about switch certificate information.
83      * @param switchcertificate X509Certificate of switch
84      */
85     void onSwitchCertificateIdentified(X509Certificate switchcertificate);
86
87     /**
88      * Set listener for connection became ready-to-use event.
89      *
90      * @param connectionReadyListener listens to connection ready event
91      */
92     void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener);
93
94     /**
95      * Sets option for automatic channel reading - if set to false, incoming messages won't be read.
96      *
97      * @param autoRead target value to be switched to
98      */
99     void setAutoRead(boolean autoRead);
100
101     /**
102      * Determines if the channel is configured to auto-read.
103      *
104      * @return true, if channel is configured to auto-read
105      */
106     boolean isAutoRead();
107
108     /**
109      * Registers a new bypass outbound queue.
110      *
111      * @param <T> handler type
112      * @param handler queue handler
113      * @param maxQueueDepth max amount of not confirmed messaged in queue (i.e. edge for barrier message)
114      * @param maxBarrierNanos regular base for barrier message
115      * @return An {@link OutboundQueueHandlerRegistration}
116      */
117     @Beta
118     <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(T handler,
119         int maxQueueDepth, long maxBarrierNanos);
120
121     /**
122      * Set filtering of PacketIn messages. By default these messages are not filtered.
123      * @param enabled True if PacketIn messages should be filtered, false if they should be reported.
124      */
125     @Beta
126     void setPacketInFiltering(boolean enabled);
127
128     /**
129      * Set datapathId for the dpn.
130      * @param datapathId of the dpn
131      */
132     void setDatapathId(BigInteger datapathId);
133
134     /**
135      * Sets executorService.
136      * @param executorService for all dpns
137      */
138     void setExecutorService(ExecutorService executorService);
139 }