use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.
the class OF10PortModInputMessageFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("19 e9 08 00 27 00 b0 eb " + "00 00 00 15 00 00 00 62 00 00 02 8c 00 00 00 00 ");
PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV10(deserializedMessage);
Assert.assertEquals("Wrong port", new PortNumber(6633L), deserializedMessage.getPortNo());
Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress());
Assert.assertEquals("Wrong config", new PortConfigV10(true, false, false, true, false, false, true), deserializedMessage.getConfigV10());
Assert.assertEquals("Wrong mask", new PortConfigV10(false, true, true, false, false, true, false), deserializedMessage.getMaskV10());
Assert.assertEquals("Wrong advertise", new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false), deserializedMessage.getAdvertiseV10());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput 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.PortModInput in project openflowplugin by opendaylight.
the class BundleAddMessageConverter method convertBundlePortCase.
private BundlePortModCase convertBundlePortCase(final BundleInnerMessage messageCase, final VersionDatapathIdConvertorData data) throws ConversionException {
Optional<PortModInput> portModInput = Optional.empty();
final Class<?> clazz = messageCase.getImplementedInterface();
if (clazz.equals(BundleUpdatePortCase.class)) {
portModInput = CONVERTER_EXECUTOR.convert(new PortBuilder(((BundleUpdatePortCase) messageCase).getUpdatePortCaseData().getPort().getPort().get(0)).build(), data);
}
if (portModInput.isPresent()) {
return new BundlePortModCaseBuilder().setPortModCaseData(new PortModCaseDataBuilder(portModInput.get()).setXid(xid).build()).build();
} else {
throw new ConversionException("BundlePortCase conversion unsuccessful.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput 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.PortModInput 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);
}
Aggregations