Search in sources :

Example 1 with SourcePorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.body()) {
        final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> sourcePortsBuilder.setValue((Uint16) dataContainerChild.body()));
        sourcePorts.add(sourcePortsBuilder.build());
    }
    return sourcePorts;
}
Also used : SourcePortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder) ArrayList(java.util.ArrayList) Uint16(org.opendaylight.yangtools.yang.common.Uint16) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) SourcePorts(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.rev200120.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(Uint16.valueOf(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length))));
        end = op.getEndOfList();
        ports.add(builder.build());
    }
    return ports;
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand) SourcePortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.rev200120.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.rev200120.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts)2 SourcePortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder)2 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand)1 Uint16 (org.opendaylight.yangtools.yang.common.Uint16)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1