Search in sources :

Example 6 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 testDesc.

/**
 * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization.
 */
@Test
public void testDesc() {
    ByteBuf bb = BufferHelper.buildBuffer("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(statsFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
    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());
    Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
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 7 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 setDesc.

private static MultipartReplyDescCase setDesc(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 8 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 serializeDescBody.

private void serializeDescBody(final MultipartReplyBody body, final 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 9 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 MsgGeneratorTestUtils method makeMultipartDescReply.

public static MultipartReplyMessageBuilder makeMultipartDescReply(final long xid, final String value, final boolean hasNext) {
    final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc(value).build();
    final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(descValue).build();
    MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder().setMultipartReplyBody(replyBody).setXid(xid).setFlags(new MultipartRequestFlags(hasNext)).setType(MultipartType.OFPMPDESC);
    return messageBuilder;
}
Also used : 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) MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc) MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) 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