use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase in project openflowplugin by opendaylight.
the class MultipartRequestInputFactory method serializeTableFeaturesBody.
private void serializeTableFeaturesBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) {
if (multipartRequestBody != null) {
MultipartRequestTableFeaturesCase tableFeaturesCase = (MultipartRequestTableFeaturesCase) multipartRequestBody;
MultipartRequestTableFeatures tableFeatures = tableFeaturesCase.getMultipartRequestTableFeatures();
if (tableFeatures.getTableFeatures() != null) {
for (TableFeatures currTableFeature : tableFeatures.getTableFeatures()) {
final int tableFeatureLengthIndex = output.writerIndex();
output.writeShort(EncodeConstants.EMPTY_LENGTH);
output.writeByte(currTableFeature.getTableId());
output.writeZero(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY);
final byte[] nameBytes = currTableFeature.getName().getBytes(StandardCharsets.UTF_8);
output.writeBytes(nameBytes);
output.writeZero(32 - nameBytes.length);
output.writeLong(currTableFeature.getMetadataMatch().longValue());
output.writeLong(currTableFeature.getMetadataWrite().longValue());
output.writeInt(createTableConfigBitmask(currTableFeature.getConfig()));
output.writeInt(currTableFeature.getMaxEntries().intValue());
writeTableFeatureProperties(output, currTableFeature.getTableFeatureProperties());
output.setShort(tableFeatureLengthIndex, output.writerIndex() - tableFeatureLengthIndex);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase in project openflowplugin by opendaylight.
the class MultipartRequestTableFeaturesInputMessageFactoryTest method createTableFeatures.
public MultipartRequestTableFeaturesCase createTableFeatures() {
MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();
builder.setTableFeatures(createTableFeaturesList());
caseBuilder.setMultipartRequestTableFeatures(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMakeMultipartRequestInputTableFeatures.
@Test
public void testMakeMultipartRequestInputTableFeatures() throws Exception {
final MultipartType mpType = MultipartType.OFPMPTABLEFEATURES;
final MultipartRequestInput mpRqInput = (MultipartRequestInput) MultipartRequestInputFactory.makeMultipartRequest(xid, ofVersion, mpType, false);
checkHeader(mpRqInput, mpType);
final MultipartRequestBody mpRqBody = mpRqInput.getMultipartRequestBody();
Assert.assertTrue(mpRqBody instanceof MultipartRequestTableFeaturesCase);
MultipartRequestTableFeatures mpRq = ((MultipartRequestTableFeaturesCase) mpRqBody).getMultipartRequestTableFeatures();
Assert.assertNotNull(mpRq);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method setTableFeatures.
private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) {
MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder();
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_REQUEST_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(new BigInteger(1, metadataMatch));
byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataWrite);
featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite));
featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
featuresBuilder.setMaxEntries(input.readUnsignedInt());
featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH));
features.add(featuresBuilder.build());
}
tableFeaturesBuilder.setTableFeatures(features);
caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build());
return caseBuilder.build();
}
Aggregations