Search in sources :

Example 1 with SourcePorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createSourcePorts.

private static List<SourcePorts> createSourcePorts(final UnkeyedListNode sourcePortsData) {
    final List<SourcePorts> sourcePorts = new ArrayList<>();
    for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) {
        final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            sourcePortsBuilder.setValue((Integer) valueNode.get().getValue());
        }
        sourcePorts.add(sourcePortsBuilder.build());
    }
    return sourcePorts;
}
Also used : Set(java.util.Set) SourcePortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) SourcePorts(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts)

Example 2 with SourcePorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts in project bgpcep by opendaylight.

the class FSSourcePortHandler method parseSourcePort.

private static List<SourcePorts> parseSourcePort(final ByteBuf nlri) {
    final List<SourcePorts> ports = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final SourcePortsBuilder builder = new SourcePortsBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        final short length = AbstractOperandParser.parseLength(b);
        builder.setValue(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length)));
        end = op.isEndOfList();
        ports.add(builder.build());
    }
    return ports;
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand) SourcePortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder) ArrayList(java.util.ArrayList) SourcePorts(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts)

Aggregations

ArrayList (java.util.ArrayList)2 SourcePorts (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts)2 SourcePortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder)2 Set (java.util.Set)1 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1