Search in sources :

Example 1 with Dscps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createDscpsLengths.

private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) {
    final List<Dscps> dscpsLengths = new ArrayList<>();
    for (final UnkeyedListEntryNode node : dscpLengthsData.body()) {
        final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> dscpsLengthsBuilder.setValue(new Dscp((Uint8) dataContainerChild.body())));
        dscpsLengths.add(dscpsLengthsBuilder.build());
    }
    return dscpsLengths;
}
Also used : Dscps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps) DscpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) Dscp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp)

Example 2 with Dscps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method stringDscp.

private static String stringDscp(final List<Dscps> dscps) {
    final StringBuilder buffer = new StringBuilder("where DSCP ");
    boolean isFirst = true;
    for (final Dscps item : dscps) {
        buffer.append(NumericOneByteOperandParser.INSTANCE.toString(item.getOp(), isFirst));
        buffer.append(item.getValue().getValue());
        buffer.append(' ');
        if (isFirst) {
            isFirst = false;
        }
    }
    return buffer.toString();
}
Also used : Dscps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps)

Example 3 with Dscps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project openflowplugin by opendaylight.

the class MatchResponseConvertorTest method testFromOFMatchV10ToSALMatch.

/**
 * Test method for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testFromOFMatchV10ToSALMatch() {
    int[] vids = { // Match untagged frame.
    DL_VLAN_NONE, // Match packet with VLAN tag and VID equals the specified value.
    1, 20, 4095 };
    short[] dscps = { 0, 1, 20, 40, 62, 63 };
    FlowWildcardsV10Builder wcBuilder = new FlowWildcardsV10Builder();
    for (int vid : vids) {
        for (short dscp : dscps) {
            short tos = (short) (dscp << 2);
            MatchV10Builder builder = new MatchV10Builder();
            builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).setDlVlanPcp(VLAN_PCP).setDlType(ETHTYPE_IPV4).setInPort(IN_PORT.intValue()).setNwSrc(IPV4_SRC).setNwDst(IPV4_DST).setNwTos(tos);
            wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).setTpDst(true);
            if (vid == DL_VLAN_NONE) {
                wcBuilder.setDlVlanPcp(true);
            }
            FlowWildcardsV10 wc = wcBuilder.build();
            MatchV10 ofMatch = builder.setWildcards(wc).build();
            final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
            data.setDatapathId(DPID);
            Match match = convert(ofMatch, data).build();
            checkDefaultV10(match, wc, vid);
            IpMatch ipMatch = match.getIpMatch();
            assertEquals(null, ipMatch.getIpProtocol());
            assertEquals(dscp, ipMatch.getIpDscp().getValue().shortValue());
            assertEquals(null, ipMatch.getIpEcn());
            // Set all wildcard bits.
            wc = wcBuilder.setAll(true).build();
            ofMatch = builder.setWildcards(wc).build();
            match = convert(ofMatch, data).build();
            checkDefaultV10(match, wc, vid);
            assertEquals(null, match.getIpMatch());
        }
    }
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) VlanMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Test(org.junit.Test)

Example 4 with Dscps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.

the class FSDscpHandler method parseDscps.

private static List<Dscps> parseDscps(final ByteBuf nlri) {
    final List<Dscps> dscps = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final DscpsBuilder builder = new DscpsBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        // RFC does not specify operator
        final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        builder.setValue(new Dscp(ByteBufUtils.readUint8(nlri)));
        end = op.getEndOfList();
        dscps.add(builder.build());
    }
    return dscps;
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand) Dscps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps) DscpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder) ArrayList(java.util.ArrayList) Dscp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp)

Example 5 with Dscps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps in project bgpcep by opendaylight.

the class FSDscpHandler method serializeDscps.

private static void serializeDscps(final List<Dscps> dscps, final ByteBuf nlriByteBuf) {
    for (final Iterator<Dscps> it = dscps.iterator(); it.hasNext(); ) {
        final Dscps dscp = it.next();
        NumericOneByteOperandParser.INSTANCE.serialize(dscp.getOp(), 1, !it.hasNext(), nlriByteBuf);
        ByteBufUtils.write(nlriByteBuf, dscp.getValue().getValue());
    }
}
Also used : Dscps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps)

Aggregations

Dscps (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps)4 ArrayList (java.util.ArrayList)2 Dscp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp)2 DscpsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder)2 Test (org.junit.Test)1 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)1 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)1 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)1 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)1 VlanMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch)1 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)1 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)1 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)1 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)1 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1