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();
}
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();
}
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;
}
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));
}
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();
}
Aggregations