use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder in project openflowplugin by opendaylight.
the class MultipartReplyPortDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
final List<Ports> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final PortsBuilder itemBuilder = new PortsBuilder();
itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
items.add(itemBuilder.setName(ByteBufUtils.decodeNullTerminatedString(message, EncodeConstants.MAX_PORT_NAME_LENGTH)).setConfiguration(readPortConfig(message)).setState(readPortState(message)).setCurrentFeature(readPortFeatures(message)).setAdvertisedFeatures(readPortFeatures(message)).setSupported(readPortFeatures(message)).setPeerFeatures(readPortFeatures(message)).setCurrentSpeed(message.readUnsignedInt()).setMaximumSpeed(message.readUnsignedInt()).build());
}
return builder.setPorts(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtilTest method translatePortDesc.
@Test
public void translatePortDesc() {
final MultipartReply multipartReply = buildReply(MultipartType.OFPMPPORTDESC, new MultipartReplyPortDescCaseBuilder().setMultipartReplyPortDesc(new MultipartReplyPortDescBuilder().setPorts(Collections.singletonList(new PortsBuilder().build())).build()).build());
dummyAssertReply(multipartReply);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setPortDesc.
private static MultipartReplyPortDescCase setPortDesc(final ByteBuf input) {
MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
List<Ports> portsList = new ArrayList<>();
while (input.readableBytes() > 0) {
PortsBuilder portsBuilder = new PortsBuilder();
portsBuilder.setPortNo(input.readUnsignedInt());
input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
portsBuilder.setHwAddr(ByteBufUtils.readIetfMacAddress(input));
input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
portsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, EncodeConstants.MAX_PORT_NAME_LENGTH));
portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));
portsBuilder.setState(createPortState(input.readUnsignedInt()));
portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setCurrSpeed(input.readUnsignedInt());
portsBuilder.setMaxSpeed(input.readUnsignedInt());
portsList.add(portsBuilder.build());
}
builder.setPorts(portsList);
caseBuilder.setMultipartReplyPortDesc(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testPortDescSerialize.
@Test
public void testPortDescSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(13));
MultipartReplyPortDescCaseBuilder portDescCase = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder portDesc = new MultipartReplyPortDescBuilder();
portDesc.setPorts(createPortList());
portDescCase.setMultipartReplyPortDesc(portDesc.build());
builder.setMultipartReplyBody(portDescCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTDESC.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyPortDescCase body = (MultipartReplyPortDescCase) message.getMultipartReplyBody();
MultipartReplyPortDesc messageOutput = body.getMultipartReplyPortDesc();
Ports port = messageOutput.getPorts().get(0);
Assert.assertEquals("Wrong PortNo", port.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
serializedBuffer.skipBytes(4);
byte[] address = new byte[6];
serializedBuffer.readBytes(address);
Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
serializedBuffer.skipBytes(2);
byte[] name = new byte[16];
serializedBuffer.readBytes(name);
Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
Assert.assertEquals("Wrong config", port.getConfig(), createPortConfig(serializedBuffer.readInt()));
Assert.assertEquals("Wrong state", port.getState(), createPortState(serializedBuffer.readInt()));
Assert.assertEquals("Wrong current", port.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong advertised", port.getAdvertisedFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong supported", port.getSupportedFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong peer", port.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong Current speed", port.getCurrSpeed().longValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong Max speed", port.getMaxSpeed().longValue(), serializedBuffer.readInt());
}
Aggregations