2 * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.openflowplugin.api.openflow.connection;
11 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
12 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
13 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
15 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
21 * Each OpenFlow session is tracked by a Connection Context. These attach to a particular Device Context in such a way,
22 * that there is at most one primary session associated with a Device Context.
25 public interface ConnectionContext {
28 * @param handshakeContext corresponding handshake context used upon this connection
30 void setHandshakeContext(HandshakeContext handshakeContext);
33 * distinguished connection states
35 enum CONNECTION_STATE {
37 * initial phase of talking to switch
41 * standard phase - interacting with switch
45 * connection is idle, waiting for echo reply from switch
49 * talking to switch is over - resting in pieces
59 void setNodeId(NodeId nodeId);
62 * Method returns identifier of device whic connection represents this context.
64 * @return {@link org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId}
69 * @return the connectionAdapter
71 ConnectionAdapter getConnectionAdapter();
74 * Returns reference to OFJava outbound queue provider. Outbound queue is used for outbound messages processing.
78 OutboundQueue getOutboundQueueProvider();
81 * Method sets reference to OFJava outbound queue provider.
83 void setOutboundQueueProvider(OutboundQueueProvider outboundQueueProvider);
86 * Method returns current connection state.
88 * @return {@link ConnectionContext.CONNECTION_STATE}
90 CONNECTION_STATE getConnectionState();
93 * @param featuresReply as received from device during handshake
95 void setFeatures(FeaturesReply featuresReply);
98 * @return featureReply as received from device during handshake
100 FeaturesReply getFeatures();
103 * Method sets handler for handling closing connections.
105 * @param deviceDisconnectedHandler
107 void setDeviceDisconnectedHandler(DeviceDisconnectedHandler deviceDisconnectedHandler);
109 void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration);
112 * actively drop associated connection
114 * @param propagate true if event need to be propagated to higher contexts (device, stats, rpc..)
115 * or false if invoked from higher context
116 * @see ConnectionAdapter#disconnect()
118 void closeConnection(boolean propagate);
121 * cleanup context upon connection closed event (by device)
123 void onConnectionClosed();
126 * change internal state to {@link ConnectionContext.CONNECTION_STATE#HANDSHAKING}
128 void changeStateToHandshaking();
131 * change internal state to {@link ConnectionContext.CONNECTION_STATE#TIMEOUTING}
133 void changeStateToTimeouting();
136 * change internal state to {@link ConnectionContext.CONNECTION_STATE#WORKING}
138 void changeStateToWorking();
141 * Create and return basic device info
144 DeviceInfo getDeviceInfo();
147 * This method creates a basic device information. Should be called after nodeId and features are set in connection context
149 void handshakeSuccessful();