use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput 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.PortModInput 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.
the class PortModInputMessageFactoryTest method test.
@Test
public void test() throws Exception {
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 09 00 00 00 00 08 00 27 00 " + "b0 eb 00 00 00 00 00 24 00 00 00 41 00 00 01 10 00 00 00 00");
PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
// Test Message
Assert.assertEquals("Wrong port", new PortNumber(9L), deserializedMessage.getPortNo());
Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress());
Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig());
Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask());
Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false), deserializedMessage.getAdvertise());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.
the class SalPortServiceImpl method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final UpdatePortInput input) throws ServiceException {
final Optional<PortModInput> ofPortModInput = convertorExecutor.convert(getPortFromInput(input), data);
final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput.orElse(PortConvertor.defaultResult(getVersion()))).setXid(xid.getValue());
return mdInput.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput 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);
}
Aggregations