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