use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class AbstractSrSubobjectParser method parseSrSubobject.
protected static SrSubobject parseSrSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
final SidType sidType = SidType.forValue(sidTypeByte);
final BitArray bitSet = BitArray.valueOf(buffer.readByte());
final boolean f = bitSet.get(F_FLAG_POSITION);
final boolean s = bitSet.get(S_FLAG_POSITION);
final boolean c = bitSet.get(C_FLAG_POSITION);
final boolean m = bitSet.get(M_FLAG_POSITION);
if (f && s) {
throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
}
Long tmp = null;
if (!s) {
if (m) {
tmp = buffer.readUnsignedInt() >>> MPLS_LABEL_OFFSET;
} else {
tmp = buffer.readUnsignedInt();
}
}
final Long sid = tmp;
final Nai nai;
if (sidType != null && !f) {
nai = parseNai(sidType, buffer);
} else {
nai = null;
}
return new SrSubobjectImpl(m, c, sidType, sid, nai);
}
Aggregations