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);
}
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());
}
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();
}
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();
}
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();
}
Aggregations