use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method setTable.
private static MultipartReplyTableCase setTable(ByteBuf input) {
final MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
List<TableStats> tableStatsList = new ArrayList<>();
// TODO - replace ">= TABLE_STATS_LENGTH" with "> 0" after fix in OVS switch
while (input.readableBytes() >= TABLE_STATS_LENGTH) {
TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
tableStatsBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_TABLE_HEADER);
tableStatsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
long wildcards = input.readUnsignedInt();
tableStatsBuilder.setWildcards(OF10MatchDeserializer.createWildcards(wildcards));
tableStatsBuilder.setNwSrcMask(OF10MatchDeserializer.decodeNwSrcMask(wildcards));
tableStatsBuilder.setNwDstMask(OF10MatchDeserializer.decodeNwDstMask(wildcards));
tableStatsBuilder.setMaxEntries(input.readUnsignedInt());
tableStatsBuilder.setActiveCount(input.readUnsignedInt());
byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(lookupCount);
tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount));
byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(matchedCount);
tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount));
tableStatsList.add(tableStatsBuilder.build());
}
input.skipBytes(input.readableBytes());
builder.setTableStats(tableStatsList);
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, true));
builder.setNwSrcMask((short) 24);
builder.setNwDstMask((short) 16);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test2.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test2() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
builder.setNwSrcMask((short) 0);
builder.setNwDstMask((short) 0);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.
the class WildcardsTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Wildcards property = new WildcardsBuilder().setWildcardSetfield(new WildcardSetfieldBuilder().setSetFieldMatch(ImmutableList.<SetFieldMatch>builder().add(new SetFieldMatchBuilder().setMatchType(ArpOp.class).setHasMask(false).build()).build()).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method toTableProperties.
private static List<TableFeatureProperties> toTableProperties(final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
if (tableProperties == null) {
return Collections.emptyList();
}
List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property : sortedTableProperties) {
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property.getTableFeaturePropType();
setTableFeatureProperty(propType);
if (propType instanceof Instructions) {
setTableFeatureProperty((Instructions) propType, propBuilder);
} else if (propType instanceof InstructionsMiss) {
setTableFeatureProperty((InstructionsMiss) propType, propBuilder);
} else if (propType instanceof NextTable) {
setTableFeatureProperty((NextTable) propType, propBuilder);
} else if (propType instanceof NextTableMiss) {
setTableFeatureProperty((NextTableMiss) propType, propBuilder);
} else if (propType instanceof WriteActions) {
setTableFeatureProperty((WriteActions) propType, propBuilder);
} else if (propType instanceof WriteActionsMiss) {
setTableFeatureProperty((WriteActionsMiss) propType, propBuilder);
} else if (propType instanceof ApplyActions) {
setTableFeatureProperty((ApplyActions) propType, propBuilder);
} else if (propType instanceof ApplyActionsMiss) {
setTableFeatureProperty((ApplyActionsMiss) propType, propBuilder);
} else if (propType instanceof Match) {
setTableFeatureProperty((Match) propType, propBuilder);
} else if (propType instanceof Wildcards) {
setTableFeatureProperty((Wildcards) propType, propBuilder);
} else if (propType instanceof WriteSetfield) {
setTableFeatureProperty((WriteSetfield) propType, propBuilder);
} else if (propType instanceof WriteSetfieldMiss) {
setTableFeatureProperty((WriteSetfieldMiss) propType, propBuilder);
} else if (propType instanceof ApplySetfield) {
setTableFeatureProperty((ApplySetfield) propType, propBuilder);
} else if (propType instanceof ApplySetfieldMiss) {
setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
}
// Experimenter and Experimenter miss Table features are unhandled
ofTablePropertiesList.add(propBuilder.build());
}
return ofTablePropertiesList;
}
Aggregations