Search in sources :

Example 11 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class HandshakeManagerImpl method postHandshake.

/**
 * after handshake set features, register to session.
 *
 * @param proposedVersion proposed openflow version
 * @param xid             transaction id
 */
protected void postHandshake(final Short proposedVersion, final Long xid) {
    // set version
    version = proposedVersion;
    LOG.debug("version set: {}", proposedVersion);
    // request features
    GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
    featuresBuilder.setVersion(version).setXid(xid);
    LOG.debug("sending feature request for version={} and xid={}", version, xid);
    Future<RpcResult<GetFeaturesOutput>> featuresFuture = connectionAdapter.getFeatures(featuresBuilder.build());
    Futures.addCallback(JdkFutureAdapters.listenInPoolThread(featuresFuture), new FutureCallback<RpcResult<GetFeaturesOutput>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<GetFeaturesOutput> rpcFeatures) {
            LOG.trace("features are back");
            if (rpcFeatures.isSuccessful()) {
                GetFeaturesOutput featureOutput = rpcFeatures.getResult();
                LOG.debug("obtained features: datapathId={}", featureOutput.getDatapathId());
                LOG.debug("obtained features: auxiliaryId={}", featureOutput.getAuxiliaryId());
                LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}", version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId());
                handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion);
            } else {
                // handshake failed
                LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress());
                for (RpcError rpcError : rpcFeatures.getErrors()) {
                    LOG.debug("handshake - features failure [{}]: i:{} | m:{} | s:{}", xid, rpcError.getInfo(), rpcError.getMessage(), rpcError.getSeverity(), rpcError.getCause());
                }
                handshakeListener.onHandshakeFailure();
            }
            LOG.debug("postHandshake DONE");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("getting feature failed seriously [{}, addr:{}]: {}", xid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
        }
    }, MoreExecutors.directExecutor());
    LOG.debug("future features [{}] hooked ..", xid);
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 12 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class BuildSwitchCapabilitiesOF10 method build.

@Override
public SwitchFeatures build(GetFeaturesOutput features) {
    SwitchFeaturesBuilder builderSwFeatures = new SwitchFeaturesBuilder();
    builderSwFeatures.setMaxBuffers(features.getBuffers());
    builderSwFeatures.setMaxTables(features.getTables());
    List<Class<? extends FeatureCapability>> capabilities = new ArrayList<>();
    if (features.getCapabilitiesV10().isOFPCARPMATCHIP()) {
        capabilities.add(FlowFeatureCapabilityArpMatchIp.class);
    }
    if (features.getCapabilitiesV10().isOFPCFLOWSTATS()) {
        capabilities.add(FlowFeatureCapabilityFlowStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCIPREASM()) {
        capabilities.add(FlowFeatureCapabilityIpReasm.class);
    }
    if (features.getCapabilitiesV10().isOFPCPORTSTATS()) {
        capabilities.add(FlowFeatureCapabilityPortStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCQUEUESTATS()) {
        capabilities.add(FlowFeatureCapabilityQueueStats.class);
    }
    if (features.getCapabilitiesV10().isOFPCRESERVED()) {
        capabilities.add(FlowFeatureCapabilityReserved.class);
    }
    if (features.getCapabilitiesV10().isOFPCSTP()) {
        capabilities.add(FlowFeatureCapabilityStp.class);
    }
    if (features.getCapabilitiesV10().isOFPCTABLESTATS()) {
        capabilities.add(FlowFeatureCapabilityTableStats.class);
    }
    builderSwFeatures.setCapabilities(capabilities);
    return builderSwFeatures.build();
}
Also used : FeatureCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability) ArrayList(java.util.ArrayList) SwitchFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder)

Example 13 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactory method serialize.

@Override
public void serialize(final GetFeaturesOutput message, final ByteBuf outBuffer) {
    ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
    outBuffer.writeLong(message.getDatapathId().longValue());
    outBuffer.writeInt(message.getBuffers().intValue());
    outBuffer.writeByte(message.getTables().intValue());
    outBuffer.writeZero(PADDING);
    outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10()));
    outBuffer.writeInt(createActionsV10(message.getActionsV10()));
    for (PhyPort port : message.getPhyPort()) {
        outBuffer.writeShort(port.getPortNo().intValue());
        outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr()));
        writeName(port.getName(), outBuffer);
        writePortConfig(port.getConfigV10(), outBuffer);
        writePortState(port.getStateV10(), outBuffer);
        writePortFeature(port.getCurrentFeaturesV10(), outBuffer);
        writePortFeature(port.getAdvertisedFeaturesV10(), outBuffer);
        writePortFeature(port.getSupportedFeaturesV10(), outBuffer);
        writePortFeature(port.getPeerFeaturesV10(), outBuffer);
    }
    ByteBufUtils.updateOFHeaderLength(outBuffer);
}
Also used : PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)

Example 14 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method test.

/**
 * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 FF 00 00 0F FF " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 00 00 02 00 " + "00 00 0F FF 00 00 00 00 00 00 03 0C 00 00 08 88");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
    Assert.assertEquals("Wrong n-buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
    Assert.assertEquals("Wrong n-tables", 0x01, builtByFactory.getTables().shortValue());
    Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, true, true, true, true, true, true), builtByFactory.getCapabilitiesV10());
    Assert.assertEquals("Wrong actions", new ActionTypeV10(true, true, true, true, true, true, true, true, true, true, true, true, false), builtByFactory.getActionsV10());
    PhyPort port = builtByFactory.getPhyPort().get(0);
    Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue());
    Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr());
    Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName());
    Assert.assertEquals("Wrong port - config", new PortConfigV10(true, true, true, true, true, true, true), port.getConfigV10());
    Assert.assertEquals("Wrong port - state", new PortStateV10(false, false, false, false, true, false, true, false), port.getStateV10());
    Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(true, true, true, true, true, true, true, true, true, true, true, true), port.getCurrentFeaturesV10());
    Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeaturesV10());
    Assert.assertEquals("Wrong port - supported", new PortFeaturesV10(true, true, false, false, false, false, false, true, false, true, false, false), port.getSupportedFeaturesV10());
    Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), port.getPeerFeaturesV10());
}
Also used : ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortStateV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort) ByteBuf(io.netty.buffer.ByteBuf) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 15 with GetFeaturesOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method testWithNoPortsSet.

/**
 * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithNoPortsSet() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 00 00 00 00 00");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(false, false, false, false, false, false, false, false), builtByFactory.getCapabilitiesV10());
    Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false, false, false, false, false, false, false), builtByFactory.getActionsV10());
    Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
}
Also used : ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) ByteBuf(io.netty.buffer.ByteBuf) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Test(org.junit.Test)

Aggregations

GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)12 Test (org.junit.Test)10 ByteBuf (io.netty.buffer.ByteBuf)7 GetFeaturesOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder)6 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)5 ArrayList (java.util.ArrayList)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)3 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)3 CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)3 GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 BigInteger (java.math.BigInteger)2 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 FeatureCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability)2 SwitchFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder)2 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)2 PortStateV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10)2 GetFeaturesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder)2 HelloInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput)2