Search in sources :

Example 1 with PortModInputBuilder

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

the class PortConvertor method convert.

@Override
public PortModInput convert(Port source, VersionConvertorData data) {
    PortConfig config = maskPortConfigFields(source.getConfiguration());
    PortConfigV10 configV10 = maskPortConfigV10Fields(source.getConfiguration());
    PortModInputBuilder portModInputBuilder = new PortModInputBuilder();
    portModInputBuilder.setAdvertise(getPortFeatures(source.getAdvertisedFeatures()));
    portModInputBuilder.setPortNo(new PortNumber(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(data.getVersion()), source.getPortNumber())));
    portModInputBuilder.setConfig(config);
    portModInputBuilder.setMask(MoreObjects.firstNonNull(maskPortConfigFields(source.getMask()), new PortConfig(true, true, true, true)));
    portModInputBuilder.setHwAddress(new MacAddress(source.getHardwareAddress()));
    portModInputBuilder.setVersion(data.getVersion());
    portModInputBuilder.setConfigV10(configV10);
    portModInputBuilder.setMaskV10(MoreObjects.firstNonNull(maskPortConfigV10Fields(source.getMask()), new PortConfigV10(true, true, true, true, true, true, true)));
    portModInputBuilder.setAdvertiseV10(getPortFeaturesV10(source.getAdvertisedFeatures()));
    return portModInputBuilder.build();
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)

Example 2 with PortModInputBuilder

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

the class PortModInputMessageFactory method deserialize.

@Override
public PortModInput deserialize(final ByteBuf rawMessage) {
    PortModInputBuilder builder = new PortModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1);
    builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2);
    builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setMask(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setAdvertise(createPortFeatures(rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3);
    return builder.build();
}
Also used : PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 3 with PortModInputBuilder

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

the class OF10PortModInputMessageFactoryTest method testPortModInput.

/**
 * Testing of {@link OF10PortModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testPortModInput() throws Exception {
    PortModInputBuilder builder = new PortModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setPortNo(new PortNumber(6633L));
    builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
    builder.setConfigV10(new PortConfigV10(true, false, false, true, false, false, true));
    builder.setMaskV10(new PortConfigV10(false, true, true, false, false, true, false));
    builder.setAdvertiseV10(new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false));
    PortModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    portModFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 15, 32);
    Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedShort());
    byte[] address = new byte[6];
    out.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddress(), new MacAddress(ByteBufUtils.macAddressToString(address)));
    Assert.assertEquals("Wrong config", 21, out.readUnsignedInt());
    Assert.assertEquals("Wrong mask", 98, out.readUnsignedInt());
    Assert.assertEquals("Wrong advertise", 652, out.readUnsignedInt());
    out.skipBytes(4);
}
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) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) 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 4 with PortModInputBuilder

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

the class PortModInputMessageFactoryTest method testPortModInput.

/**
 * Testing of {@link PortModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testPortModInput() throws Exception {
    PortModInputBuilder builder = new PortModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPortNo(new PortNumber(9L));
    builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
    builder.setConfig(new PortConfig(true, false, true, false));
    builder.setMask(new PortConfig(false, true, false, true));
    builder.setAdvertise(new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false));
    final PortModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    // simulate parent message
    out.writeInt(1);
    out.writeZero(2);
    out.writeShort(3);
    portModFactory.serialize(message, out);
    // read parent message
    out.readInt();
    out.skipBytes(2);
    out.readShort();
    BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
    Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
    byte[] address = new byte[6];
    out.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue());
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
    Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));
    Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));
    Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);
}
Also used : PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) Test(org.junit.Test)

Example 5 with PortModInputBuilder

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

the class OF10PortModInputMessageFactory method deserialize.

@Override
public PortModInput deserialize(final ByteBuf rawMessage) {
    PortModInputBuilder builder = new PortModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort()));
    builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
    builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()));
    return builder.build();
}
Also used : PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Aggregations

PortModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder)7 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)5 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 PortModInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput)4 Test (org.junit.Test)3 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)3 ByteBuf (io.netty.buffer.ByteBuf)2 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)2 PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)2 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 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)1