use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final SubobjectBuilder builder = new SubobjectBuilder();
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
buffer.skipBytes(RESERVED);
ubuilder.setRouterId(buffer.readUnsignedInt());
ubuilder.setInterfaceId(buffer.readUnsignedInt());
builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
return builder.build();
}
use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validate.
@Override
public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcrpt message cannot be empty.");
}
final List<Reports> reports = Lists.newArrayList();
while (!objects.isEmpty()) {
final Reports report = getValidReports(objects, errors);
if (report != null) {
reports.add(report);
}
}
return new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
}
use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class Stateful07StatefulCapabilityTlvParser method parseTlv.
@Override
public Stateful parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
if (buffer.readableBytes() < FLAGS_F_LENGTH / Byte.SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >= " + FLAGS_F_LENGTH / Byte.SIZE + ".");
}
final StatefulBuilder sb = new StatefulBuilder();
parseFlags(sb, buffer);
return sb.build();
}
use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class XROIpv4PrefixSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final SubobjectBuilder builder = new SubobjectBuilder();
builder.setMandatory(mandatory);
if (buffer.readableBytes() != CONTENT4_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
}
final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length)));
builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
buffer.skipBytes(PREFIX_F_LENGTH);
builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
return builder.build();
}
use of org.opendaylight.protocol.pcep.spi.PCEPDeserializerException in project bgpcep by opendaylight.
the class XROPathKey32SubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + CONTENT_LENGTH + ".");
}
final int pathKey = buffer.readUnsignedShort();
final byte[] pceId = ByteArray.readBytes(buffer, PCE_ID_F_LENGTH);
final SubobjectBuilder builder = new SubobjectBuilder();
final PathKeyBuilder pBuilder = new PathKeyBuilder();
pBuilder.setPceId(new PceId(pceId));
pBuilder.setPathKey(new PathKey(pathKey));
builder.setMandatory(mandatory);
builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
return builder.build();
}
Aggregations