use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setTableFeatures.
private MultipartReplyTableFeaturesCase setTableFeatures(final ByteBuf input) {
MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
List<TableFeatures> features = new ArrayList<>();
while (input.readableBytes() > 0) {
TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
final int length = input.readUnsignedShort();
featuresBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataMatch);
featuresBuilder.setMetadataMatch(metadataMatch);
byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataWrite);
featuresBuilder.setMetadataWrite(metadataWrite);
featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
featuresBuilder.setMaxEntries(input.readUnsignedInt());
featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
features.add(featuresBuilder.build());
}
builder.setTableFeatures(features);
caseBuilder.setMultipartReplyTableFeatures(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class PortStatusMessageFactoryTest method test.
/**
* Testing {@link PortStatusMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer(// reason
"01 " + // padding
"00 00 00 00 00 00 00 " + // port no
"00 01 02 03 " + // padding in ofp_port1
"00 00 00 00 " + // mac address
"08 00 27 00 B0 EB " + // padding in ofp_port2
"00 00 " + // port name, String "s1-eth1"
"73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port config
"00 00 00 41 " + // port state
"00 00 00 05 " + // current features
"00 00 00 81 " + // advertised features
"00 00 00 A1 " + // supported features
"00 00 00 B1 " + // peer features
"00 00 00 81 " + // curr speed
"00 00 00 81 " + // max speed
"00 00 00 80");
PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), builtByFactory.getHwAddr());
Assert.assertEquals("Wrong name", "s1-eth1", builtByFactory.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, true, true, false, false, true, false, false, false, false, false, false), builtByFactory.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, true, true, true, false, true, false, false, false, false, false, false), builtByFactory.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultipartReplyPortDescTest method testMultipartReplyPortDesc.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyPortDesc() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0D 00 00 00 00 00 00 " + // first port desc
"00 01 02 03 00 00 00 00 " + // portNo, padding
"08 00 27 00 B0 EB 00 00 " + // mac address, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
"00 00 00 65 " + // port config
"00 00 00 07 " + // port state
"00 00 00 81 " + // current features
"00 00 FF FF " + // advertised features
"00 00 C1 89 " + // supported features
"00 00 C5 8D " + // peer features
"00 00 00 81 " + // curr speed
"00 00 00 80 " + // second port desc
"00 00 00 01 00 00 00 00 " + // portNo, padding
"08 00 27 00 B0 EB 00 00 " + // mac address, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
"00 00 00 00 " + // port config
"00 00 00 00 " + // port state
"00 00 00 00 " + // current features
"00 00 00 00 " + // advertised features
"00 00 00 00 " + // supported features
"00 00 00 00 " + // peer features
"00 00 00 05 " + // curr speed
"00 00 00 06");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());
Ports port = message.getPorts().get(0);
Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());
Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, false, false, true, false, false, false, true, true, true), port.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());
port = message.getPorts().get(1);
Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());
Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultipartReplyPortDescTest method testEmptyMultipartReplyPortDesc.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testEmptyMultipartReplyPortDesc() {
ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
Assert.assertEquals("Wrong table features size", 0, message.getPorts().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0C 00 00 00 00 00 00 " + // length, tableId, padding
"00 B0 01 00 00 00 00 00 " + //
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // name
"00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
"00 00 00 00 00 00 00 01 " + // metadata write
"00 00 00 00 00 00 00 02 " + // config
"00 00 00 00 " + // max entries
"00 00 00 2A " + //
"00 00 00 04 00 00 00 00 " + //
"00 01 00 04 00 00 00 00 " + //
"00 02 00 08 01 02 03 04 " + //
"00 03 00 07 05 06 07 00 " + //
"00 04 00 04 00 00 00 00 " + //
"00 05 00 04 00 00 00 00 " + //
"00 06 00 04 00 00 00 00 " + //
"00 07 00 04 00 00 00 00 " + //
"00 08 00 04 00 00 00 00 " + //
"00 0A 00 04 00 00 00 00 " + //
"00 0C 00 04 00 00 00 00 " + //
"00 0D 00 04 00 00 00 00 " + //
"00 0E 00 04 00 00 00 00 " + "00 0F 00 04 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, feature.getTableFeatureProperties().get(0).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, feature.getTableFeatureProperties().get(1).getType());
TableFeatureProperties property = feature.getTableFeatureProperties().get(2);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, property.getType());
List<NextTableIds> tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 4, tableIds.size());
Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue());
property = feature.getTableFeatureProperties().get(3);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, property.getType());
tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 3, tableIds.size());
Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, feature.getTableFeatureProperties().get(4).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, feature.getTableFeatureProperties().get(5).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, feature.getTableFeatureProperties().get(6).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, feature.getTableFeatureProperties().get(7).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, feature.getTableFeatureProperties().get(8).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, feature.getTableFeatureProperties().get(9).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, feature.getTableFeatureProperties().get(10).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, feature.getTableFeatureProperties().get(11).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, feature.getTableFeatureProperties().get(12).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, feature.getTableFeatureProperties().get(13).getType());
}
Aggregations