use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesDeserializerTest method writeValues.
private void writeValues(ByteBuf buffer, int propertyType) {
buffer.clear();
final int replyIndex = buffer.readerIndex();
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeByte(TABLE_ID);
buffer.writeZero(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
buffer.writeZero(MAX_TABLE_NAME_LENGTH);
buffer.writeLong(METADATA_MATCH);
buffer.writeLong(METADATA_WRITE);
buffer.writeInt(TABLE_CONFIG);
buffer.writeInt(MAX_ENTRIES);
final int propIndex = buffer.writerIndex();
buffer.writeShort(propertyType);
final int propLengthIndex = buffer.writerIndex();
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
TableFeaturesPropType propType = TableFeaturesPropType.forValue(propertyType);
switch(propType) {
case OFPTFPTINSTRUCTIONS:
case OFPTFPTINSTRUCTIONSMISS:
int instructionStartIndex = buffer.writerIndex();
buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
int instructionLengthIndex = buffer.writerIndex();
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.setShort(instructionLengthIndex, buffer.writerIndex() - instructionStartIndex);
break;
case OFPTFPTNEXTTABLES:
case OFPTFPTNEXTTABLESMISS:
buffer.writeByte(1);
buffer.writeByte(2);
break;
case OFPTFPTWRITEACTIONS:
case OFPTFPTWRITEACTIONSMISS:
buffer.writeShort(InstructionConstants.WRITE_ACTIONS_TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTAPPLYACTIONS:
case OFPTFPTAPPLYACTIONSMISS:
buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTMATCH:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ARP_OP << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTWILDCARDS:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ARP_SHA << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTWRITESETFIELD:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ARP_SPA << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTWRITESETFIELDMISS:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ARP_THA << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTAPPLYSETFIELD:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ARP_TPA << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
case OFPTFPTAPPLYSETFIELDMISS:
buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
buffer.writeByte(OxmMatchConstants.ETH_TYPE << 1);
buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
break;
default:
break;
}
int propLength = buffer.writerIndex() - propIndex;
buffer.setShort(propLengthIndex, buffer.writerIndex() - propIndex);
int paddingRemainder = propLength % EncodeConstants.PADDING;
int result = 0;
if (paddingRemainder != 0) {
result = EncodeConstants.PADDING - paddingRemainder;
}
buffer.writeZero(result);
buffer.setShort(replyIndex, buffer.writerIndex() - replyIndex);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method createTableFeaturesProperties.
private List<TableFeatureProperties> createTableFeaturesProperties(final ByteBuf input, final int length) {
List<TableFeatureProperties> properties = new ArrayList<>();
int tableFeaturesLength = length;
while (tableFeaturesLength > 0) {
int propStartIndex = input.readerIndex();
TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
builder.setType(type);
int propertyLength = input.readUnsignedShort();
int paddingRemainder = propertyLength % EncodeConstants.PADDING;
tableFeaturesLength -= propertyLength;
if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS) || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Instruction> instructions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
insBuilder.setInstruction(instructions);
builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES) || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
propertyLength -= COMMON_PROPERTY_LENGTH;
NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
List<NextTableIds> ids = new ArrayList<>();
while (propertyLength > 0) {
NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
nextTableIdsBuilder.setTableId(input.readUnsignedByte());
ids.add(nextTableIdsBuilder.build());
propertyLength--;
}
tableBuilder.setNextTableIds(ids);
builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
actionBuilder.setAction(actions);
builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH) || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<MatchEntry> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
oxmBuilder.setMatchEntry(entries);
builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
long expId = input.readUnsignedInt();
input.readerIndex(propStartIndex);
OFDeserializer<TableFeatureProperties> propDeserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
TableFeatureProperties expProp = propDeserializer.deserialize(input);
properties.add(expProp);
continue;
}
if (paddingRemainder != 0) {
input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder;
}
properties.add(builder.build());
}
return properties;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method setSetFieldTableFeatureProperty.
private static void setSetFieldTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFields) {
List<MatchEntry> matchEntriesList = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch currMatch : setFields) {
Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> currMatchType = currMatch.getMatchType();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField> ofTableFeatureClass = SAL_TO_OF_TABLE_FEATURES.get(currMatchType);
setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.isHasMask());
matchEntriesList.add(matchEntryBuilder.build());
}
OxmRelatedTableFeaturePropertyBuilder propBuilder = new OxmRelatedTableFeaturePropertyBuilder();
propBuilder.setMatchEntry(matchEntriesList);
builder.setType(type);
builder.addAugmentation(OxmRelatedTableFeatureProperty.class, propBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertor method toTableProperties.
private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
if (ofTablePropertiesList == null) {
return new TablePropertiesBuilder().setTableFeatureProperties(Collections.emptyList()).build();
}
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
int index = 0;
for (TableFeatureProperties property : ofTablePropertiesList) {
TableFeaturesPropType propType = property.getType();
ActionExecutor actionExecutor = TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.get(propType);
if (actionExecutor != null) {
actionExecutor.execute(property, propBuilder);
} else {
LOG.error("Unsupported table feature property : " + propType);
}
propBuilder.setOrder(index);
salTablePropertiesList.add(propBuilder.build());
index += 1;
}
return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build();
}
Aggregations