Search in sources :

Example 1 with SidLabelIndex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.

the class SrLinkAttributesParser method parseAdjacencySegmentIdentifier.

public static SrAdjIds parseAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
    final Flags adjFlags;
    final Weight weight;
    final SidLabelIndex sidValue;
    if (buffer.isReadable()) {
        final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
        adjFlags = parseFlags(flags, protocolId);
        weight = new Weight(buffer.readUnsignedByte());
        buffer.skipBytes(RESERVED);
        sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
    } else {
        adjFlags = null;
        weight = null;
        sidValue = null;
    }
    return new SrAdjIdsBuilder().setFlags(adjFlags).setSidLabelIndex(sidValue).setWeight(weight).build();
}
Also used : SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex) SrAdjIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrAdjIdsBuilder) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags) BitArray(org.opendaylight.protocol.util.BitArray) Weight(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)

Example 2 with SidLabelIndex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.

the class SrLinkAttributesParser method serializeAdjFlags.

private static BitArray serializeAdjFlags(final Flags flags, final SidLabelIndex sidLabelIndex) {
    final BitArray bitFlags = new BitArray(FLAGS_BITS_SIZE);
    if (flags instanceof OspfAdjFlagsCase) {
        final OspfAdjFlagsCase ospfFlags = (OspfAdjFlagsCase) flags;
        bitFlags.set(BACKUP_OSPF, ospfFlags.isBackup());
        bitFlags.set(SET_OSPF, ospfFlags.isSet());
        SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_OSPF, LOCAL_OSPF);
    } else if (flags instanceof IsisAdjFlagsCase) {
        final IsisAdjFlagsCase isisFlags = (IsisAdjFlagsCase) flags;
        bitFlags.set(ADDRESS_FAMILY_FLAG, isisFlags.isAddressFamily());
        bitFlags.set(BACKUP_ISIS, isisFlags.isBackup());
        bitFlags.set(SET_ISIS, isisFlags.isSet());
        SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_ISIS, LOCAL_ISIS);
    } else if (flags == null) {
        SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_EPE, LOCAL_EPE);
    }
    return bitFlags;
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) IsisAdjFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.flags.IsisAdjFlagsCase) OspfAdjFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.flags.OspfAdjFlagsCase)

Example 3 with SidLabelIndex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.

the class SrLinkAttributesParser method parseEpeAdjacencySegmentIdentifier.

public static EpeAdjSidTlv parseEpeAdjacencySegmentIdentifier(final ByteBuf buffer) {
    final Weight weight;
    final SidLabelIndex sidValue;
    if (buffer.isReadable()) {
        buffer.skipBytes(FLAGS_BYTE_SIZE);
        weight = new Weight(buffer.readUnsignedByte());
        buffer.skipBytes(RESERVED);
        sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
    } else {
        weight = null;
        sidValue = null;
    }
    return new EpeAdjSidTlv() {

        @Override
        public Class<? extends DataContainer> getImplementedInterface() {
            return EpeAdjSidTlv.class;
        }

        @Override
        public Weight getWeight() {
            return weight;
        }

        @Override
        public SidLabelIndex getSidLabelIndex() {
            return sidValue;
        }
    };
}
Also used : EpeAdjSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.EpeAdjSidTlv) SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex) Weight(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)

Example 4 with SidLabelIndex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.

the class SrPrefixAttributesParser method serializePrefixFlags.

private static BitArray serializePrefixFlags(final Flags flags, final SidLabelIndex sidLabelIndex) {
    final BitArray bitFlags = new BitArray(FLAGS_SIZE);
    SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE, LOCAL);
    if (flags instanceof OspfPrefixFlagsCase) {
        final OspfPrefixFlagsCase ospfFlags = (OspfPrefixFlagsCase) flags;
        bitFlags.set(NO_PHP_OSPF, ospfFlags.isNoPhp());
        bitFlags.set(MAPPING_SERVER, ospfFlags.isMappingServer());
        bitFlags.set(EXPLICIT_NULL, ospfFlags.isExplicitNull());
    } else if (flags instanceof IsisPrefixFlagsCase) {
        final IsisPrefixFlagsCase isisFlags = (IsisPrefixFlagsCase) flags;
        bitFlags.set(RE_ADVERTISEMENT, isisFlags.isReadvertisement());
        bitFlags.set(NODE_SID, isisFlags.isNodeSid());
        bitFlags.set(NO_PHP, isisFlags.isNoPhp());
        bitFlags.set(EXPLICIT_NULL, isisFlags.isExplicitNull());
    }
    return bitFlags;
}
Also used : IsisPrefixFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.prefix.sid.tlv.flags.IsisPrefixFlagsCase) OspfPrefixFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.prefix.sid.tlv.flags.OspfPrefixFlagsCase) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)3 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)2 SidLabelIndex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex)2 SrAdjIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrAdjIdsBuilder)1 EpeAdjSidTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.EpeAdjSidTlv)1 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags)1 IsisAdjFlagsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.flags.IsisAdjFlagsCase)1 OspfAdjFlagsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.flags.OspfAdjFlagsCase)1 IsisPrefixFlagsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.prefix.sid.tlv.flags.IsisPrefixFlagsCase)1 OspfPrefixFlagsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.prefix.sid.tlv.flags.OspfPrefixFlagsCase)1