Search in sources :

Example 1 with MultipartReplyDescCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method serializeDescBody.

private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
    MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
    write256String(desc.getMfrDesc(), outBuffer);
    write256String(desc.getHwDesc(), outBuffer);
    write256String(desc.getSwDesc(), outBuffer);
    write32String(desc.getSerialNum(), outBuffer);
    write256String(desc.getDpDesc(), outBuffer);
}
Also used : MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc)

Example 2 with MultipartReplyDescCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyDescBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyDescBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
    String mfrDesc = "Manufacturer description";
    byte[] mfrDescBytes = new byte[256];
    mfrDescBytes = mfrDesc.getBytes();
    bb.writeBytes(mfrDescBytes);
    bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
    String hwDesc = "Hardware description";
    byte[] hwDescBytes = new byte[256];
    hwDescBytes = hwDesc.getBytes();
    bb.writeBytes(hwDescBytes);
    bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
    String swDesc = "Software description";
    byte[] swDescBytes = new byte[256];
    swDescBytes = swDesc.getBytes();
    bb.writeBytes(swDescBytes);
    bb.writeZero(DESC_STR_LEN - swDescBytes.length);
    String serialNum = "SN0123456789";
    byte[] serialNumBytes = new byte[32];
    serialNumBytes = serialNum.getBytes();
    bb.writeBytes(serialNumBytes);
    bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
    String dpDesc = "switch3 in room 3120";
    byte[] dpDescBytes = new byte[256];
    dpDescBytes = dpDesc.getBytes();
    bb.writeBytes(dpDescBytes);
    bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
    Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
    Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
    Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
    Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
    Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc) Test(org.junit.Test)

Example 3 with MultipartReplyDescCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setDesc.

private static MultipartReplyDescCase setDesc(final ByteBuf input) {
    final MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
    byte[] mfrDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(mfrDescBytes);
    String mfrDesc = new String(mfrDescBytes, StandardCharsets.UTF_8);
    descBuilder.setMfrDesc(mfrDesc.trim());
    byte[] hwDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(hwDescBytes);
    String hwDesc = new String(hwDescBytes, StandardCharsets.UTF_8);
    descBuilder.setHwDesc(hwDesc.trim());
    byte[] swDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(swDescBytes);
    String swDesc = new String(swDescBytes, StandardCharsets.UTF_8);
    descBuilder.setSwDesc(swDesc.trim());
    byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];
    input.readBytes(serialNumBytes);
    String serialNum = new String(serialNumBytes, StandardCharsets.UTF_8);
    descBuilder.setSerialNum(serialNum.trim());
    byte[] dpDescBytes = new byte[DESC_STR_LEN];
    input.readBytes(dpDescBytes);
    String dpDesc = new String(dpDescBytes, StandardCharsets.UTF_8);
    descBuilder.setDpDesc(dpDesc.trim());
    caseBuilder.setMultipartReplyDesc(descBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Example 4 with MultipartReplyDescCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method decodeDescBody.

private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
    final MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    byte[] mfrDesc = new byte[256];
    output.readBytes(mfrDesc);
    desc.setMfrDesc(new String(mfrDesc).trim());
    byte[] hwDesc = new byte[256];
    output.readBytes(hwDesc);
    desc.setHwDesc(new String(hwDesc).trim());
    byte[] swDesc = new byte[256];
    output.readBytes(swDesc);
    desc.setSwDesc(new String(swDesc).trim());
    byte[] serialNumber = new byte[32];
    output.readBytes(serialNumber);
    desc.setSerialNum(new String(serialNumber).trim());
    byte[] dpDesc = new byte[256];
    output.readBytes(dpDesc);
    desc.setDpDesc(new String(dpDesc).trim());
    descCase.setMultipartReplyDesc(desc.build());
    return descCase.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Example 5 with MultipartReplyDescCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method decodeDescBody.

private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
    final MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    byte[] mfrDesc = new byte[256];
    output.readBytes(mfrDesc);
    desc.setMfrDesc(new String(mfrDesc).trim());
    byte[] hwDesc = new byte[256];
    output.readBytes(hwDesc);
    desc.setHwDesc(new String(hwDesc).trim());
    byte[] swDesc = new byte[256];
    output.readBytes(swDesc);
    desc.setSwDesc(new String(swDesc).trim());
    byte[] serialNumber = new byte[32];
    output.readBytes(serialNumber);
    desc.setSerialNum(new String(serialNumber).trim());
    byte[] dpDesc = new byte[256];
    output.readBytes(dpDesc);
    desc.setDpDesc(new String(dpDesc).trim());
    descCase.setMultipartReplyDesc(desc.build());
    return descCase.build();
}
Also used : MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Aggregations

MultipartReplyDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase)5 MultipartReplyDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder)5 MultipartReplyDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc)5 MultipartReplyDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1