use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.
the class FeaturesReplyMessageFactoryTest method test.
/**
* Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 00 00 00 01 02 03");
GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities());
Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.
the class FeaturesReplyMessageFactoryTest method testCapabilities.
/**
* Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
* (capabilities set).
*/
@Test
public void testCapabilities() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 01 6F 00 01 02 03");
GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong capabilities", new Capabilities(true, true, true, true, true, true, true), builtByFactory.getCapabilities());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.
the class FeaturesReplyMessageFactory method deserialize.
@Override
public GetFeaturesOutput deserialize(ByteBuf rawMessage) {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(datapathId);
builder.setDatapathId(new BigInteger(1, datapathId));
builder.setBuffers(rawMessage.readUnsignedInt());
builder.setTables(rawMessage.readUnsignedByte());
builder.setAuxiliaryId(rawMessage.readUnsignedByte());
rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
builder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
builder.setReserved(rawMessage.readUnsignedInt());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.
the class MockPlugin method getSwitchFeatures.
protected void getSwitchFeatures() {
GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
featuresBuilder.setVersion((short) 4);
featuresBuilder.setXid(3L);
GetFeaturesInput featuresInput = featuresBuilder.build();
try {
LOGGER.debug("Requesting features ");
RpcResult<GetFeaturesOutput> rpcResult = adapter.getFeatures(featuresInput).get(2500, TimeUnit.MILLISECONDS);
if (rpcResult.isSuccessful()) {
byte[] byteArray = rpcResult.getResult().getDatapathId().toByteArray();
LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray));
} else {
RpcError rpcError = rpcResult.getErrors().iterator().next();
LOGGER.warn("rpcResult failed", rpcError.getCause());
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setDatapathId(BigInteger.valueOf(1L));
builder.setBuffers(1L);
builder.setTables((short) 1);
builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true));
builder.setPhyPort(createPorts());
GetFeaturesOutput message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(3);
Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), createCapabilities(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
PhyPort port = message.getPhyPort().get(0);
Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
byte[] address = new byte[6];
serializedBuffer.readBytes(address);
Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
byte[] name = new byte[16];
serializedBuffer.readBytes(name);
Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
Aggregations