Search in sources :

Example 1 with MultipartReplyPortDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.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();
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) ArrayList(java.util.ArrayList) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder)

Example 2 with MultipartReplyPortDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.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);
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder) MultipartReplyPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder) Test(org.junit.Test)

Example 3 with MultipartReplyPortDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.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();
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder) MultipartReplyPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder) ArrayList(java.util.ArrayList) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder)

Example 4 with MultipartReplyPortDescBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.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());
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder) MultipartReplyPortDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase) MultipartReplyPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Aggregations

MultipartReplyPortDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder)3 MultipartReplyPortDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports)2 PortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)1 MultipartReplyPortDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder)1 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports)1 PortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)1 MultipartReplyPortDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc)1