@Test public void testOnHelloCoreMessage() { Mockito.doNothing().when(connectionHandler).sendGetFeaturesOuputToCore((short) EncodeConstants.OF13_VERSION_ID, 0, connectionAdapter); Pair<Protocol, ProtocolVersions> supportedProtocol = new Pair<Protocol, ProtocolVersions>(Protocol.OPENFLOW, ProtocolVersions.parse(Protocol.OPENFLOW, EncodeConstants.OF13_VERSION_ID)); Mockito.stub(connectionHandler.getSupportedProtocol()).toReturn(supportedProtocol); Set<ConnectionAdapter> connections = new HashSet<ConnectionAdapter>(); connections.add(connectionAdapter); Mockito.stub(registry.getConnectionAdapters()).toReturn(connections); List<Pair<Protocol, ProtocolVersions>> requestedProtocols = new ArrayList<>(); requestedProtocols.add(supportedProtocol); HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(supportedProtocol); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(0); connectionHandler.onHelloCoreMessage(requestedProtocols, 0); Mockito.verify(coreConnector).SendData(msg.toByteRepresentation()); Mockito.verify(connectionHandler).sendGetFeaturesOuputToCore((short) EncodeConstants.OF13_VERSION_ID, 0, connectionAdapter); }
@Override public void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId) { for (Pair<Protocol, ProtocolVersions> requested : requestedProtocols) { if (getSupportedProtocol() != null) { if (requested.getValue0().getValue() == getSupportedProtocol().getValue0().getValue() && requested.getValue1().getValue() == getSupportedProtocol().getValue1().getValue()) { HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(getSupportedProtocol()); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(moduleId); coreConnector.SendData(msg.toByteRepresentation()); for (ConnectionAdapter conn : connectionRegistry.getConnectionAdapters()) { sendGetFeaturesOuputToCore((short) getSupportedProtocol().getValue1().getValue(), moduleId, conn); } } } } }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { @Override public void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId) { for (Pair<Protocol, ProtocolVersions> requested : requestedProtocols) { if (getSupportedProtocol() != null) { if (requested.getValue0().getValue() == getSupportedProtocol().getValue0().getValue() && requested.getValue1().getValue() == getSupportedProtocol().getValue1().getValue()) { HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(getSupportedProtocol()); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(moduleId); coreConnector.SendData(msg.toByteRepresentation()); for (ConnectionAdapter conn : connectionRegistry.getConnectionAdapters()) { sendGetFeaturesOuputToCore((short) getSupportedProtocol().getValue1().getValue(), moduleId, conn); } } } } } }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { @Override public void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId) { for (Pair<Protocol, ProtocolVersions> requested : requestedProtocols) { if (getSupportedProtocol() != null) { if (requested.getValue0().getValue() == getSupportedProtocol().getValue0().getValue() && requested.getValue1().getValue() == getSupportedProtocol().getValue1().getValue()) { HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(getSupportedProtocol()); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(moduleId); coreConnector.SendData(msg.toByteRepresentation()); for (ConnectionAdapter conn : connectionRegistry.getConnectionAdapters()) { sendGetFeaturesOuputToCore((short) getSupportedProtocol().getValue1().getValue(), moduleId, conn); } } } } } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { @Override public void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId) { for (Pair<Protocol, ProtocolVersions> requested : requestedProtocols) { if (getSupportedProtocol() != null) { if (requested.getValue0().getValue() == getSupportedProtocol().getValue0().getValue() && requested.getValue1().getValue() == getSupportedProtocol().getValue1().getValue()) { HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(getSupportedProtocol()); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(moduleId); coreConnector.SendData(msg.toByteRepresentation()); for (ConnectionAdapter conn : connectionRegistry.getConnectionAdapters()) { sendGetFeaturesOuputToCore((short) getSupportedProtocol().getValue1().getValue(), moduleId, conn); } } } } } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); void setSwitchFeaturesUtil(SwitchFeaturesUtil featureUtil); void init(); ShimRelay createShimRelay(); ConnectionAdaptersRegistry createConnectionAdaptersRegistry(); @Override boolean accept(InetAddress arg0); @Override void onSwitchConnected(ConnectionAdapter connectionAdapter); void handshake(ConnectionAdapter connectionAdapter); @Override void onSwitchHelloMessage(long xid, Short version, ConnectionAdapter connectionAdapter); NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter); static InstanceIdentifier<Node> identifierFromDatapathId(final BigInteger datapathId); static NodeKey nodeKeyFromDatapathId(final BigInteger datapathId); static NodeId nodeIdFromDatapathId(final BigInteger datapathId); byte getMaxOFSupportedProtocol(); List<Byte> getSupportedOFProtocols(); int getNumberOfSwitches(); Pair<Protocol, ProtocolVersions> getSupportedProtocol(); void setSupportedProtocol(byte version); @Override void onOpenFlowCoreMessage(Long datapathId, ByteBuf msg, int moduleId); @Override void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId); void collectGetFeaturesOuput(Future<RpcResult<GetFeaturesOutput>> switchReply,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesOuputToCore(final Short proposedVersion, final int moduleId,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesToSwitch(final Short proposedVersion, final Long xid,
            final ConnectionAdapter connectionAdapter); @Override void onSwitchDisconnected(ConnectionAdapter connectionAdapter); GetFeaturesOutput getFeaturesFromRegistry(ConnectionAdapter conn); }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { @Override public void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId) { for (Pair<Protocol, ProtocolVersions> requested : requestedProtocols) { if (getSupportedProtocol() != null) { if (requested.getValue0().getValue() == getSupportedProtocol().getValue0().getValue() && requested.getValue1().getValue() == getSupportedProtocol().getValue1().getValue()) { HelloMessage msg = new HelloMessage(); msg.getSupportedProtocols().add(getSupportedProtocol()); msg.getHeader().setPayloadLength((short) 2); msg.getHeader().setModuleId(moduleId); coreConnector.SendData(msg.toByteRepresentation()); for (ConnectionAdapter conn : connectionRegistry.getConnectionAdapters()) { sendGetFeaturesOuputToCore((short) getSupportedProtocol().getValue1().getValue(), moduleId, conn); } } } } } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); void setSwitchFeaturesUtil(SwitchFeaturesUtil featureUtil); void init(); ShimRelay createShimRelay(); ConnectionAdaptersRegistry createConnectionAdaptersRegistry(); @Override boolean accept(InetAddress arg0); @Override void onSwitchConnected(ConnectionAdapter connectionAdapter); void handshake(ConnectionAdapter connectionAdapter); @Override void onSwitchHelloMessage(long xid, Short version, ConnectionAdapter connectionAdapter); NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter); static InstanceIdentifier<Node> identifierFromDatapathId(final BigInteger datapathId); static NodeKey nodeKeyFromDatapathId(final BigInteger datapathId); static NodeId nodeIdFromDatapathId(final BigInteger datapathId); byte getMaxOFSupportedProtocol(); List<Byte> getSupportedOFProtocols(); int getNumberOfSwitches(); Pair<Protocol, ProtocolVersions> getSupportedProtocol(); void setSupportedProtocol(byte version); @Override void onOpenFlowCoreMessage(Long datapathId, ByteBuf msg, int moduleId); @Override void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId); void collectGetFeaturesOuput(Future<RpcResult<GetFeaturesOutput>> switchReply,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesOuputToCore(final Short proposedVersion, final int moduleId,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesToSwitch(final Short proposedVersion, final Long xid,
            final ConnectionAdapter connectionAdapter); @Override void onSwitchDisconnected(ConnectionAdapter connectionAdapter); GetFeaturesOutput getFeaturesFromRegistry(ConnectionAdapter conn); static final Long DEFAULT_XID; }