Search in sources :

Example 6 with ConnectionContext

use of org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext in project openflowplugin by opendaylight.

the class DeviceContextImplTest method prepareConnectionContext.

private ConnectionContext prepareConnectionContext() {
    final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
    final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
    when(mockedFeaturesReply.getAuxiliaryId()).thenReturn(DUMMY_AUXILIARY_ID);
    when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
    return mockedConnectionContext;
}
Also used : FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)

Example 7 with ConnectionContext

use of org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext in project openflowplugin by opendaylight.

the class OpenflowProtocolListenerInitialImpl method onHelloMessage.

@Override
public void onHelloMessage(final HelloMessage hello) {
    LOG.debug("processing HELLO.xid: {} from device {}", hello.getXid(), connectionContext.getConnectionAdapter().getRemoteAddress());
    final ConnectionContext.CONNECTION_STATE connectionState = connectionContext.getConnectionState();
    if (connectionState == null || ConnectionContext.CONNECTION_STATE.HANDSHAKING.equals(connectionState)) {
        synchronized (connectionContext) {
            if (connectionContext.getConnectionState() == null) {
                // got here before connection ready notification
                connectionContext.changeStateToHandshaking();
            }
            if (checkState(ConnectionContext.CONNECTION_STATE.HANDSHAKING)) {
                final HandshakeStepWrapper handshakeStepWrapper = new HandshakeStepWrapper(hello, handshakeContext.getHandshakeManager(), connectionContext.getConnectionAdapter());
                // use up netty thread
                handshakeStepWrapper.run();
            } else {
                LOG.debug("already out of handshake phase but still received hello message from device {}", connectionContext.getConnectionAdapter().getRemoteAddress());
            }
        }
    } else {
        // TODO: consider disconnecting of bad behaving device
        LOG.warn("Hello message received outside handshake phase:{} ", hello);
        LOG.debug("already touched by onConnectionReady event from device {} (or finished handshake)", connectionContext.getConnectionAdapter().getRemoteAddress());
    }
}
Also used : ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) HandshakeStepWrapper(org.opendaylight.openflowplugin.impl.connection.HandshakeStepWrapper)

Example 8 with ConnectionContext

use of org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorTest method prepareMocks.

private MultipartReplyMessage prepareMocks(DeviceContext mockedDeviceContext, MultipartReplyBody multipartReplyBody, final MultipartType multipartType) {
    ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
    FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
    when(mockedFeaturesReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mockedFeaturesReply.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    DeviceInfo deviceInfo = mock(DeviceInfo.class);
    when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(deviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    when(mockedDeviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
    when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
    MultipartReplyMessage multipartReplyMessage = mock(MultipartReplyMessage.class);
    when(multipartReplyMessage.getType()).thenReturn(multipartType);
    when(multipartReplyMessage.getFlags()).thenReturn(new MultipartRequestFlags(true));
    when(multipartReplyMessage.getXid()).thenReturn(DUMMY_XID);
    when(multipartReplyMessage.getMultipartReplyBody()).thenReturn(multipartReplyBody);
    return multipartReplyMessage;
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)

Aggregations

ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)8 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)4 Nullable (javax.annotation.Nullable)2 DeviceState (org.opendaylight.openflowplugin.api.openflow.device.DeviceState)2 Function (com.google.common.base.Function)1 Preconditions (com.google.common.base.Preconditions)1 AsyncFunction (com.google.common.util.concurrent.AsyncFunction)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Test (org.junit.Test)1 ConnectionReadyListener (org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener)1