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;
}
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());
}
}
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;
}
Aggregations