Search in sources :

Example 11 with Wildcards

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();
}
Also used : MultipartReplyTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) TableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats) MultipartReplyTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder)

Example 12 with Wildcards

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());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 13 with Wildcards

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());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 14 with Wildcards

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);
    });
}
Also used : SetFieldMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder) WildcardSetfieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder) Wildcards(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards) WildcardsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder) SetFieldMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch) Test(org.junit.Test)

Example 15 with Wildcards

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;
}
Also used : TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) WriteSetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss) ApplyActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match) ApplySetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) WriteActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions) WriteActionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) TableFeaturePropType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) NextTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable) InstructionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions) ApplySetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield) NextTableMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss) WriteSetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield) Wildcards(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards)

Aggregations

Test (org.junit.Test)13 ByteBuf (io.netty.buffer.ByteBuf)11 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)10 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)8 ArrayList (java.util.ArrayList)6 BigInteger (java.math.BigInteger)5 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)4 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)4 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 ApplySetfield (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)2 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)2 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)2 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)2 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)2 Wildcards (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards)2