Search in sources :

Example 6 with PortFeaturesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10 in project openflowplugin by opendaylight.

the class OF10PortStatusMessageFactoryTest method test.

/**
 * Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 " + "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 15 00 00 00 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
    PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
    Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());
    Assert.assertEquals("Wrong builtByFactory - hw-addr", new MacAddress("01:01:05:01:04:02"), builtByFactory.getHwAddr());
    Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName());
    Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true), builtByFactory.getConfigV10());
    Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, false, true, false), builtByFactory.getStateV10());
    Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true, false, false, false, false, false), builtByFactory.getCurrentFeaturesV10());
    Assert.assertEquals("Wrong builtByFactory - advertised", new PortFeaturesV10(false, false, true, true, false, false, false, false, false, false, true, false), builtByFactory.getAdvertisedFeaturesV10());
    Assert.assertEquals("Wrong builtByFactory - supbuiltByFactoryed", new PortFeaturesV10(true, true, false, false, false, false, false, true, false, true, false, false), builtByFactory.getSupportedFeaturesV10());
    Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), builtByFactory.getPeerFeaturesV10());
}
Also used : 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) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 7 with PortFeaturesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10 in project openflowplugin by opendaylight.

the class PortTranslatorUtilTest method testTranslatePortFeaturesV10.

/**
 * Test  method for
 * {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn
 * .opendaylight.openflow.common.types.rev130731.PortFeaturesV10)}.
 */
@Test
public void testTranslatePortFeaturesV10() {
    for (int i = 0; i < pfV10Bls.length; i++) {
        pfV10Bls[i] = true;
        final PortFeaturesV10 apfV10 = getPortFeaturesV10();
        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf = PortTranslatorUtil.translatePortFeatures(apfV10);
        assertEqualsPortFeaturesV10(apfV10, npf);
        pfV10Bls[i] = false;
    }
}
Also used : PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) Test(org.junit.Test)

Example 8 with PortFeaturesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10 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 9 with PortFeaturesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10 in project openflowplugin by opendaylight.

the class OF10PortStatusMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setReason(PortReason.forValue(1));
    builder.setPortNo(1L);
    builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
    builder.setName("Port name");
    builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
    builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
    builder.setCurrentFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setAdvertisedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setSupportedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setPeerFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    PortStatusMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64);
    Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(7);
    Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort());
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) 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) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 10 with PortFeaturesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10 in project openflowplugin by opendaylight.

the class PortConvertorTest method testtoPortModInputwithAllParameters.

/**
 * test of {@link PortConvertor#convert(Port, VersionConvertorData)} }.
 */
@Test
public void testtoPortModInputwithAllParameters() {
    PortBuilder portBld = new PortBuilder();
    portBld.setAdvertisedFeatures(features);
    portBld.setConfiguration(config);
    portBld.setPortNumber(new PortNumberUni(42L));
    portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
    VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
    final PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
    PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
    PortModInputBuilder portModInputBld = new PortModInputBuilder();
    portModInputBld.setConfig(config31);
    portModInputBld.setMask(configMask31);
    portModInputBld.setPortNo(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(42L));
    portModInputBld.setHwAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
    portModInputBld.setAdvertise(portf31);
    portModInputBld.setConfigV10(portConfV10);
    portModInputBld.setMaskV10(portConfMaskV10);
    portModInputBld.setAdvertiseV10(new PortFeaturesV10(null, null, null, null, null, null, null, true, null, null, null, null));
    portModInputBld.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    Assert.assertEquals(portModInputBld.build(), portOut);
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) Test(org.junit.Test)

Aggregations

PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)10 Test (org.junit.Test)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)8 ByteBuf (io.netty.buffer.ByteBuf)5 PortStateV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10)5 PortModInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput)3 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)2 PortModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder)2 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)2 ArrayList (java.util.ArrayList)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)1 PortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder)1 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)1 CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)1 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)1