Search in sources :

Example 26 with Flowspec

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

the class AbstractFlowspecL3vpnNlriParser method stringNlri.

@Override
public String stringNlri(final DataContainerNode<?> flowspec) {
    final StringBuilder buffer = new StringBuilder();
    final RouteDistinguisher rd = extractRouteDistinguisher(flowspec, RD_NID);
    if (rd != null) {
        buffer.append("[l3vpn with route-distinguisher ").append(rd.getValue()).append("] ");
    }
    buffer.append(super.stringNlri(flowspec));
    return buffer.toString();
}
Also used : RouteDistinguisherUtil.extractRouteDistinguisher(org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher)

Example 27 with Flowspec

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

the class AbstractFlowspecNlriParser method encodeFlow.

@VisibleForTesting
final String encodeFlow(final Flowspec flow) {
    final StringBuilder buffer = new StringBuilder();
    final FlowspecType value = flow.getFlowspecType();
    if (value instanceof PortCase) {
        buffer.append("where port ");
        buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((PortCase) value).getPorts()));
    } else if (value instanceof DestinationPortCase) {
        buffer.append("where destination port ");
        buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((DestinationPortCase) value).getDestinationPorts()));
    } else if (value instanceof SourcePortCase) {
        buffer.append("where source port ");
        buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((SourcePortCase) value).getSourcePorts()));
    } else if (value instanceof IcmpTypeCase) {
        buffer.append("where ICMP type ");
        buffer.append(NumericOneByteOperandParser.INSTANCE.toString(((IcmpTypeCase) value).getTypes()));
    } else if (value instanceof IcmpCodeCase) {
        buffer.append("where ICMP code ");
        buffer.append(NumericOneByteOperandParser.INSTANCE.toString(((IcmpCodeCase) value).getCodes()));
    } else if (value instanceof TcpFlagsCase) {
        buffer.append(stringTcpFlags(((TcpFlagsCase) value).getTcpFlags()));
    } else if (value instanceof PacketLengthCase) {
        buffer.append("where packet length ");
        buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((PacketLengthCase) value).getPacketLengths()));
    } else if (value instanceof DscpCase) {
        buffer.append(stringDscp(((DscpCase) value).getDscps()));
    } else if (value instanceof FragmentCase) {
        buffer.append(stringFragment(((FragmentCase) value).getFragments()));
    } else {
        stringSpecificFSNlriType(value, buffer);
    }
    return buffer.toString();
}
Also used : TcpFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.TcpFlagsCase) FragmentCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.FragmentCase) IcmpTypeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.IcmpTypeCase) FlowspecType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.FlowspecType) PacketLengthCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PacketLengthCase) DscpCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCase) PortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.PortCase) SourcePortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.SourcePortCase) DestinationPortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DestinationPortCase) DestinationPortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DestinationPortCase) SourcePortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.SourcePortCase) IcmpCodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.IcmpCodeCase) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 28 with Flowspec

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

the class AbstractFlowspecL3vpnNlriParser method stringNlri.

@Override
public String stringNlri(final DataContainerNode flowspec) {
    final StringBuilder buffer = new StringBuilder();
    final RouteDistinguisher rd = extractRouteDistinguisher(flowspec, RD_NID);
    if (rd != null) {
        buffer.append("[l3vpn with route-distinguisher ").append(rd.stringValue()).append("] ");
    }
    buffer.append(super.stringNlri(flowspec));
    return buffer.toString();
}
Also used : RouteDistinguisherUtil.extractRouteDistinguisher(org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher)

Example 29 with Flowspec

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

the class AbstractFlowspecL3vpnNlriParser method readRouteDistinguisher.

/**
 * For flowspec-l3vpn, there is a route distinguisher field at the beginning of NLRI (8 bytes).
 */
private static RouteDistinguisher readRouteDistinguisher(final ByteBuf nlri) {
    final RouteDistinguisher rd = RouteDistinguisherUtil.parseRouteDistinguisher(nlri);
    LOG.trace("Route Distinguisher read from NLRI: {}", rd);
    return rd;
}
Also used : RouteDistinguisherUtil.extractRouteDistinguisher(org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher)

Example 30 with Flowspec

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

the class AbstractFlowspecL3vpnNlriParser method parseL3vpnNlriFlowspecList.

protected final List<Flowspec> parseL3vpnNlriFlowspecList(final ByteBuf nlri) {
    if (!nlri.isReadable()) {
        return null;
    }
    final List<Flowspec> fss = new ArrayList<>();
    while (nlri.isReadable()) {
        final FlowspecBuilder builder = new FlowspecBuilder();
        builder.setFlowspecType(flowspecTypeRegistry.parseFlowspecType(nlri));
        fss.add(builder.build());
    }
    return fss;
}
Also used : FlowspecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.FlowspecBuilder) ArrayList(java.util.ArrayList) Flowspec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.Flowspec)

Aggregations

Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.Flowspec)59 ArrayList (java.util.ArrayList)55 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.FlowspecBuilder)53 Test (org.junit.Test)51 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)34 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)34 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)24 ByteBuf (io.netty.buffer.ByteBuf)16 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)16 RouteDistinguisher (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher)15 FlowspecType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.FlowspecType)13 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder)9 RouteDistinguisherUtil.extractRouteDistinguisher (org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher)8 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)8 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)8 AttributesReachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder)8 AttributesUnreachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder)8 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)8 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder)8 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)8