Search in sources :

Example 91 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class SrLinkAttributesParser method parseLanAdjacencySegmentIdentifier.

public static SrLanAdjIds parseLanAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
    if (!buffer.isReadable()) {
        return new SrLanAdjIdsBuilder().build();
    }
    final SrLanAdjIdsBuilder srLanAdjIdBuilder = new SrLanAdjIdsBuilder();
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
    srLanAdjIdBuilder.setFlags(parseFlags(flags, protocolId));
    srLanAdjIdBuilder.setWeight(new Weight(buffer.readUnsignedByte()));
    buffer.skipBytes(RESERVED);
    switch(protocolId) {
        case IsisLevel1:
        case IsisLevel2:
            srLanAdjIdBuilder.setIsoSystemId(new IsoSystemIdentifier(ByteArray.readBytes(buffer, ISO_SYSTEM_ID_SIZE)));
            break;
        case Ospf:
        case OspfV3:
            srLanAdjIdBuilder.setNeighborId(Ipv4Util.addressForByteBuf(buffer));
            break;
        default:
            return null;
    }
    // length determines a type of next field, which is used for parsing
    srLanAdjIdBuilder.setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer));
    return srLanAdjIdBuilder.build();
}
Also used : SrLanAdjIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrLanAdjIdsBuilder) IsoSystemIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier) 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 92 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class SrNodeAttributesParser method parseSrCapabilities.

public static SrCapabilities parseSrCapabilities(final ByteBuf buffer, final ProtocolId protocol) {
    final SrCapabilitiesBuilder builder = new SrCapabilitiesBuilder();
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    setFlags(flags, protocol, builder);
    buffer.skipBytes(RESERVERED);
    builder.setRangeSize((long) buffer.readUnsignedMedium());
    builder.setSidLabelIndex(SidLabelIndexParser.parseSidSubTlv(buffer));
    return builder.build();
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) SrCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder)

Example 93 with BitArray

use of org.opendaylight.protocol.util.BitArray 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)

Example 94 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class SrPrefixAttributesParser method serializePrefixAttributes.

public static void serializePrefixAttributes(final Flags flags, final Algorithm algorithm, final SidLabelIndex sidLabelIndex, final ByteBuf buffer) {
    final BitArray bitFlags = serializePrefixFlags(flags, sidLabelIndex);
    bitFlags.toByteBuf(buffer);
    buffer.writeByte(algorithm.getIntValue());
    buffer.writeZero(RESERVED_PREFIX);
    buffer.writeBytes(SidLabelIndexParser.serializeSidValue(sidLabelIndex));
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray)

Example 95 with BitArray

use of org.opendaylight.protocol.util.BitArray in project bgpcep by opendaylight.

the class Ipv4EroParser method parseIpv4EroCase.

static Ipv4EroCase parseIpv4EroCase(final ByteBuf buffer) {
    final Ipv4EroCaseBuilder builder = new Ipv4EroCaseBuilder();
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
    builder.setLoose(flags.get(LOOSE));
    buffer.skipBytes(RESERVED_ERO);
    builder.setAddress(Ipv4Util.addressForByteBuf(buffer));
    return builder.build();
}
Also used : Ipv4EroCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.Ipv4EroCaseBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)100 ByteBuf (io.netty.buffer.ByteBuf)27 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)4 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCase)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)3 LabelType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType)3 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)3 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder)3 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)3 ArrayList (java.util.ArrayList)2 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)2 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)2 Nai (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.Nai)2 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)2 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring.Flags)2